[CentralOH] 2016-05-13 道場 Scribbles 落書/惡文? caniuse dd cielo yield from uyuni gen limit websockets no assignment sicp uncle bob meld diff np hard bronowski ascent of man connections james burke first computer use notepad++ swift atom pycandy optimization pycharm

Joe Shaw joe at joeshaw.org
Sun May 15 07:38:53 EDT 2016


Hi,

Ah, right you are about creating these generator objects. The other issue
with using a list comprehension here is that unless you know it'll have at
least 10 elements you need to handle StopIteration too. So
itertools.islice() (or an old-fashioned for loop) is probably the way to
go.

Joe
On Sun, May 15, 2016 at 12:24 AM Andrew Kubera <andrewkubera at gmail.com>
wrote:

> Itertools has an islice function which could be used for this.
>
> from itertools import islice
> ...
> list(islice(foo(), 10))
>
>
> Without using islice, you wouldn't call foo (Joe's method would create a
> list of 10 generator objects), but next() with the generator created by
> calling foo:
>
> foo_gen = foo()
> [next(foo_gen) for _ in range(10)]
>
> - Andrew Kubera
>
> On May 14, 2016, at 6:39 PM, Joe Shaw <joe at joeshaw.org> wrote:
>
> Hi again,
>
> Or rather:
>
> [foo() for i in range(10)]
>
> Joe
> On Sat, May 14, 2016 at 6:38 PM Joe Shaw <joe at joeshaw.org> wrote:
>
>> Hi,
>>
>> Could you do this instead?
>>
>> list(foo() for i in range(10))
>>
>>
>> Joe
>>
>> On Sat, May 14, 2016 at 5:01 PM <jep200404 at columbus.rr.com> wrote:
>>
>>> caniuse.com
>>>
>>> more dd stuff
>>> http://www.techworm.net/2016/05/backup-partition-linux.html
>>>
>>> https://www.youtube.com/watch?v=DkI7LaJ7ncQ
>>> http://data.hdwallpapers.im/salt_flats_walking_on_clouds.jpg
>>>
>>> Playing with 'yield from'.
>>>
>>>     from itertools import count
>>>
>>>     def foo():
>>>         yield from range(3)
>>>         yield from ('hello', 'world')
>>>         yield from count()
>>>
>>>     list(x[0] for x in zip(foo(), range(10)))
>>>
>>>     # See PEP 380 https://www.python.org/dev/peps/pep-0380/
>>>
>>> By the way, that last line's way of limiting a generator to n values
>>> looks ugly. What's a Pythonic way of doing that?
>>>
>>> http://websocketstest.com
>>>
>>> WebSockets from the Wire Up
>>> http://pyvideo.org/video/3506/websockets-from-the-wire-up
>>>     https://tools.ietf.org/html/rfc6455
>>>     http://danielmiessler.com/study/tcpdump/
>>>     https://github.com/spang/websockets-from-the-wire-up
>>>     http://enterprisewebbook.com/ch8_websockets.html
>>>
>>> http://enterprisewebbook.com/ch8_websockets.html#upgrading_http_to_websocket
>>>     https://flask-socketio.readthedocs.org/en/latest/
>>>
>>> no assignment statements in first 259 pages of SICP
>>> then apologized for
>>>
>>> unclebob at cleancoder.com
>>> cleancoders.com
>>> blog.8thlight.com
>>> @unclebobmartin
>>>
>>> Privacy and the New Math
>>> http://www.linuxjournal.com/content/privacy-and-new-math
>>>
>>> What's the difference?
>>>
>>>     meld is beautiful
>>>     https://docs.python.org/3/library/difflib.html
>>>     https://github.com/bollwyvl/nbdiffstream
>>>
>>> What kind of person rhymes with Haskell?
>>>
>>> Make More Responsive Web Applications with SocketIO and gevent
>>>
>>> http://pyvideo.org/video/1798/make-more-responsive-web-applications-with-socket
>>> @Luke Sneeringer
>>> lukesn.me/py2013-socketio
>>>
>>> Node Schmode!
>>> "Pythonic Realtime Web"
>>> http://gpys.pretaweb.com
>>> Dylan Jay
>>> @djay75
>>> dylan at pretaweb.com
>>>
>>>     "Node and scaling in the Small vs Scaling in the Largs" - Alex Payne
>>>     http://al3x.net/2010/07/27/node.html
>>>     wp:Thomas Paine
>>>
>>> wp: prefix means Wikipedia
>>> To get good answers, consider following the advice in the links below.
>>> http://catb.org/~esr/faqs/smart-questions.html
>>>
>>> http://web.archive.org/web/20090627155454/www.greenend.org.uk/rjk/2000/06/14/quoting.html
>>>
>>> https://www.djangopackages.com/grids/g/websockets/
>>> https://websockets.readthedocs.io/en/stable/intro.html
>>>
>>> browserquest.mozilla.org
>>>
>>> first
>>>     list(zip(someiterable, range(n)))[0][0]
>>>     what's a better way of limiting someiterable to n items?
>>> fold
>>>
>>> There are NP hard problems, then there are just plain hard problems.
>>>
>>>     refactor using classes
>>>
>>>
>>> http://waitbutwhy.com/2015/11/the-cook-and-the-chef-musks-secret-sauce.html
>>>
>>>
>>> https://opensource.com/business/16/5/oscon-interview-donna-benjamin-leslie-hawthorn
>>>
>>> Bronowski
>>> Ascent of Man
>>> Connections
>>> James Burke
>>>
>>> how old were you when you first used a computer?
>>>
>>> 24-25
>>> 11
>>> 2
>>> 17-18
>>> ~12
>>> 28
>>>
>>> wp:Margarine
>>> wp:Napoleon III
>>>
>>> swift ios
>>>
>>> notepad++
>>> atom (saves in .py)
>>>
>>> lean team
>>>
>>> dealer.com
>>>
>>> python eye candy
>>> pycandy
>>>
>>> Premature optimization is the root of all evil.
>>>
>>> For the love of money is the root of all evil:
>>> which while some coveted after,
>>> they have erred from the faith,
>>> and pierced themselves through with many sorrows.
>>>
>>> pycharm
>>>
>>> Dragon Bridge (Da Nang)
>>> _______________________________________________
>>> CentralOH mailing list
>>> CentralOH at python.org
>>> https://mail.python.org/mailman/listinfo/centraloh
>>>
>> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
>
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20160515/23e79490/attachment-0001.html>


More information about the CentralOH mailing list