Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79794 > unrolled thread
| Started by | "umatrp@gmail.com" <trsexgl@gmail.com> |
|---|---|
| First post | 2014-10-27 09:01 -0700 |
| Last post | 2014-10-30 10:41 -0700 |
| Articles | 8 on this page of 28 — 9 participants |
Back to article view | Back to comp.lang.python
A bug? "umatrp@gmail.com" <trsexgl@gmail.com> - 2014-10-27 09:01 -0700
Re: A bug? Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-27 17:17 +0100
Re: A bug? Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-27 10:26 -0600
Re: A bug? Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-28 00:36 +0000
Re: A bug? Rustom Mody <rustompmody@gmail.com> - 2014-10-27 18:12 -0700
Re: A bug? Chris Angelico <rosuav@gmail.com> - 2014-10-28 12:25 +1100
Re: A bug? Rustom Mody <rustompmody@gmail.com> - 2014-10-27 19:13 -0700
Re: A bug? Joshua Landau <joshua@landau.ws> - 2014-10-28 01:29 +0000
Re: A bug? Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-29 02:17 +0000
What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 20:22 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-28 23:16 -0500
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-28 23:23 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 21:40 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-28 23:59 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 22:15 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-29 00:39 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 23:11 -0700
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-29 01:18 -0500
Finding way around ABCs (was What for -- for? (was A bug?)) Rustom Mody <rustompmody@gmail.com> - 2014-10-30 10:01 -0700
Re: Finding way around ABCs (was What for -- for? (was A bug?)) Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-30 11:09 -0600
Re: Finding way around ABCs (was What for -- for? (was A bug?)) Rustom Mody <rustompmody@gmail.com> - 2014-10-30 10:16 -0700
Re: Finding way around ABCs (was What for -- for? (was A bug?)) Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-30 11:11 -0600
Re: What for -- for? (was A bug?) Ben Finney <ben+python@benfinney.id.au> - 2014-10-29 16:27 +1100
Re: What for -- for? (was A bug?) Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-29 00:42 -0500
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-28 22:57 -0700
Re: What for -- for? (was A bug?) Ben Finney <ben+python@benfinney.id.au> - 2014-10-29 17:02 +1100
Re: What for -- for? (was A bug?) Joshua Landau <joshua@landau.ws> - 2014-10-30 17:21 +0000
Re: What for -- for? (was A bug?) Rustom Mody <rustompmody@gmail.com> - 2014-10-30 10:41 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-30 10:16 -0700 |
| Subject | Re: Finding way around ABCs (was What for -- for? (was A bug?)) |
| Message-ID | <c7eaa34c-a747-4c7d-ae2e-66f083e4f620@googlegroups.com> |
| In reply to | #79958 |
On Thursday, October 30, 2014 10:40:42 PM UTC+5:30, Ian wrote: > On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody wrote: > > On Wednesday, October 29, 2014 11:49:27 AM UTC+5:30, Zachary Ware wrote: > >> On Wed, Oct 29, 2014 at 1:11 AM, Rustom Mody wrote: > >> > On Wednesday, October 29, 2014 11:10:06 AM UTC+5:30, Zachary Ware wrote: > >> >> Of course, that's 3 (progressively shorter) loops to get the names of > >> >> the ABCs of a class compared to 1 (fairly short in the first place) > >> >> loop for a map of relationships to all available ABCs, but optimizing > >> >> such a toy as this would just be an exercise in futility :) > >> > > >> > Not so. > >> > > >> > The charm of introspection is that the introspection > >> > itself can be introspected. > >> > For that to be convincing there needs to be a good combo > >> > of clarity and succinctness. In particular why not reduce > >> > the two functions to one? > >> > > >> > def get_abc_names(cls): > >> > return [abc.__name__ for abc in abcs if issubclass(cls,abc)] > >> > >> Well, it depends on what you actually want, the spec has been a bit fuzzy ;) > > > > Thanks for this much -- its helpful. > > Regarding ABCs -- is there a central documentation for them: > > > > "What exactly is a sequence or iterable or etc protocol?" > > > > This information seems to be strewn all over the place but systematically. > > Maybe the glossary? > > https://docs.python.org/3/glossary.html Ummm... I was looking for something more reference-ish, ie More prolix for ABCs And not containing random bits of unconnected data like - What is CPython - What is EAFP Maybe there's something in the bowels of the C(Python)-code?
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-10-30 11:11 -0600 |
| Subject | Re: Finding way around ABCs (was What for -- for? (was A bug?)) |
| Message-ID | <mailman.15327.1414689131.18130.python-list@python.org> |
| In reply to | #79957 |
On Thu, Oct 30, 2014 at 11:09 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote: > On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody <rustompmody@gmail.com> wrote: >> On Wednesday, October 29, 2014 11:49:27 AM UTC+5:30, Zachary Ware wrote: >>> On Wed, Oct 29, 2014 at 1:11 AM, Rustom Mody wrote: >>> > On Wednesday, October 29, 2014 11:10:06 AM UTC+5:30, Zachary Ware wrote: >>> >> Of course, that's 3 (progressively shorter) loops to get the names of >>> >> the ABCs of a class compared to 1 (fairly short in the first place) >>> >> loop for a map of relationships to all available ABCs, but optimizing >>> >> such a toy as this would just be an exercise in futility :) >>> > >>> > Not so. >>> > >>> > The charm of introspection is that the introspection >>> > itself can be introspected. >>> > For that to be convincing there needs to be a good combo >>> > of clarity and succinctness. In particular why not reduce >>> > the two functions to one? >>> > >>> > def get_abc_names(cls): >>> > return [abc.__name__ for abc in abcs if issubclass(cls,abc)] >>> >>> Well, it depends on what you actually want, the spec has been a bit fuzzy ;) >> >> Thanks for this much -- its helpful. >> Regarding ABCs -- is there a central documentation for them: >> >> "What exactly is a sequence or iterable or etc protocol?" >> >> This information seems to be strewn all over the place but systematically. > > Maybe the glossary? Also the documentation for the collections.abc and numbers modules: https://docs.python.org/3/library/collections.abc.html https://docs.python.org/3/library/numbers.html
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-10-29 16:27 +1100 |
| Subject | Re: What for -- for? (was A bug?) |
| Message-ID | <mailman.15284.1414560463.18130.python-list@python.org> |
| In reply to | #79873 |
Zachary Ware <zachary.ware+pylist@gmail.com> writes: > Of course, Gmail decided to wrap my long line for me. In case it's not > obvious, that should be a single line. Right, GMail is a poor choice for composing messages. You might get better results installing a proper mail client, and communicating via IMAP. -- \ “Pinky, are you pondering what I'm pondering?” “Wuh, I think | `\ so, Brain, but how will we get three pink flamingos into one | _o__) pair of Capri pants?” —_Pinky and The Brain_ | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
|---|---|
| Date | 2014-10-29 00:42 -0500 |
| Subject | Re: What for -- for? (was A bug?) |
| Message-ID | <mailman.15286.1414561397.18130.python-list@python.org> |
| In reply to | #79873 |
On Wed, Oct 29, 2014 at 12:27 AM, Ben Finney <ben+python@benfinney.id.au> wrote: > Zachary Ware <zachary.ware+pylist@gmail.com> writes: > >> Of course, Gmail decided to wrap my long line for me. In case it's not >> obvious, that should be a single line. > > Right, GMail is a poor choice for composing messages. You might get > better results installing a proper mail client, and communicating via > IMAP. Noted, but it works fine 99% of the time for me. I'm not really interested in trying to get a proper mail client set up on 5 different devices and 4 different platforms with settings shared between all just to avoid inconvenient line-wrapping (that I can avoid just by sticking to 80 column lines in the first place :). Although if you have a suggestion for that kind of setup, I'm all ears. -- Zach
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-28 22:57 -0700 |
| Subject | Re: What for -- for? (was A bug?) |
| Message-ID | <0397247b-2581-4732-b0a7-9a49ee8f99ed@googlegroups.com> |
| In reply to | #79887 |
On Wednesday, October 29, 2014 11:14:14 AM UTC+5:30, Zachary Ware wrote: > On Wed, Oct 29, 2014 at 12:27 AM, Ben Finney wrote: > > Zachary Ware writes: > > > >> Of course, Gmail decided to wrap my long line for me. In case it's not > >> obvious, that should be a single line. > > > > Right, GMail is a poor choice for composing messages. You might get > > better results installing a proper mail client, and communicating via > > IMAP. > > Noted, but it works fine 99% of the time for me. I'm not really > interested in trying to get a proper mail client set up on 5 different > devices and 4 different platforms with settings shared between all > just to avoid inconvenient line-wrapping (that I can avoid just by > sticking to 80 column lines in the first place :). I was going to say the same: gmail is fine if you remember to press RET
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-10-29 17:02 +1100 |
| Subject | Re: What for -- for? (was A bug?) |
| Message-ID | <mailman.15287.1414562574.18130.python-list@python.org> |
| In reply to | #79873 |
Zachary Ware <zachary.ware+pylist@gmail.com> writes: > […] just to avoid inconvenient line-wrapping (that I can avoid just by > sticking to 80 column lines in the first place :). That is a valid solution. If you have the discipline to stick to it, congratulations :-) -- \ “If you ever drop your keys into a river of molten lava, let | `\ 'em go, because, man, they're gone.” —Jack Handey | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua@landau.ws> |
|---|---|
| Date | 2014-10-30 17:21 +0000 |
| Subject | Re: What for -- for? (was A bug?) |
| Message-ID | <mailman.15328.1414689765.18130.python-list@python.org> |
| In reply to | #79873 |
On 29 October 2014 03:22, Rustom Mody <rustompmody@gmail.com> wrote:
> Yesterday I was trying to introduce python to some senior computer scientists.
>
> Tried showing a comprehension-based dir-walker vs a for-loop based one:
>
> def dw(p):
> if isfile(p):
> return [p]
> else:
> return [p] + [c for f in listdir(p) for c in dw(p+'/'+f)]
>
...
>
> Comment to me : "Well this is neat and compact, but it does not add
> anything fundamental (over usual index based for-loops)"
>
> I tried to say that 'for' over general sequences is quite different
> and significantly more powerful than C/Pascal for over indexes +
> explicit indexing.
If you really want to show the generality of iteration, I suggest you
start with iterators:
def walk(path):
yield path
if isdir(path):
for name in iterdir(path):
for file in walk(path + "/" + name):
yield file
This is fundementally inexpressable with indexes. It also lends itself
to expressing delegation (eg. "yield from walk(path + "/" + name)").
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-30 10:41 -0700 |
| Subject | Re: What for -- for? (was A bug?) |
| Message-ID | <ccf6f639-3537-45cb-ad0e-2a4ece231016@googlegroups.com> |
| In reply to | #79961 |
On Thursday, October 30, 2014 10:53:13 PM UTC+5:30, Joshua Landau wrote: > On 29 October 2014 03:22, Rustom Mody wrote: > > Yesterday I was trying to introduce python to some senior computer scientists. > > > > Tried showing a comprehension-based dir-walker vs a for-loop based one: > > > > def dw(p): > > if isfile(p): > > return [p] > > else: > > return [p] + [c for f in listdir(p) for c in dw(p+'/'+f)] > > > ... > > > > Comment to me : "Well this is neat and compact, but it does not add > > anything fundamental (over usual index based for-loops)" > > > > I tried to say that 'for' over general sequences is quite different > > and significantly more powerful than C/Pascal for over indexes + > > explicit indexing. > > If you really want to show the generality of iteration, I suggest you > start with iterators: > > def walk(path): > yield path > > if isdir(path): > for name in iterdir(path): > for file in walk(path + "/" + name): > yield file heh! That was my next version -- almost word-for-word [Not on that laptop now; will check later]
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web