Re: language-x-isms

2006-06-08 Thread Fredrik Lundh
Alan Kennedy wrote: > We still don't get anything that sheds light on how the code I posted > is deficient. who said that? > Why can't you just say "I made a mistake, I thought your code replaced > the builtin enumerate, but it doesnt"? I can read python code quite well, thank you. the point h

Re: language-x-isms

2006-06-08 Thread Gerard Flanagan
Alan Kennedy wrote: > [Alan Kennedy] > >> Your comment makes "using a user-defined enumerate [on cpython] is > >> slower than using the built-in version" makes no sense in relation to > >> the code I posted > > Fredrik Lundh wrote: > > try combining with the second sentence in my post. > > OK, so

Re: language-x-isms

2006-06-08 Thread Alan Kennedy
[Alan Kennedy] >> Your comment makes "using a user-defined enumerate [on cpython] is >> slower than using the built-in version" makes no sense in relation to >> the code I posted Fredrik Lundh wrote: > try combining with the second sentence in my post. OK, so putting "at least in CPython, using a

Re: language-x-isms

2006-06-08 Thread Alan Kennedy
[Steve Holden] > You are assuming a relatively recent release of CPython. If you look at > the stuff that the effbot distributes you will see that most of it > supports CPython all the way back to 1.5.2. Oh for cripes sake. The code I posted 1. works on all versions of cpython 2. works on all ve

Re: language-x-isms

2006-06-08 Thread Fredrik Lundh
Alan Kennedy wrote: > Your comment makes "using a user-defined enumerate [on cpython] is > slower than using the built-in version" makes no sense in relation to > the code I posted try combining with the second sentence in my post. -- http://mail.python.org/mailman/listinfo/python-list

Re: language-x-isms

2006-06-08 Thread Alan Kennedy
[Alan Kennedy] > On jython 2.1, I use something like this > #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > try: > enumerate > except NameError: > def enumerate(iterable): > results = [] ; ix = 0 > for item in iterable: > results.append( (ix, item) ) > ix = ix+1 > return res

Re: language-x-isms

2006-06-08 Thread Steve Holden
Alan Kennedy wrote: > [Alan Kennedy] > >>>On jython 2.1, I use something like this >>> >>>#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= >>>try: >>> enumerate >>>except NameError: >>> def enumerate(iterable): >>>results = [] ; ix = 0 >>>for item in iterable: >>> results.append( (ix, item

Re: language-x-isms

2006-06-08 Thread Fredrik Lundh
Alan Kennedy wrote: > Who's using a user-defined enumerate on cpython? anyone targeting older Python platforms. > On cpython, the reference to enumerate doesn't generate a NameError, > python Python 2.2.3 (#42, May 30 2003, 18:12:08) >>> enumerate Traceback (most recent call last): File ""

Re: language-x-isms

2006-06-08 Thread Alan Kennedy
[Alan Kennedy] >> On jython 2.1, I use something like this >> >> #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= >> try: >> enumerate >> except NameError: >> def enumerate(iterable): >> results = [] ; ix = 0 >> for item in iterable: >> results.append( (ix, item) ) >> ix = ix+1 >>

Re: language-x-isms

2006-06-08 Thread Fredrik Lundh
Alan Kennedy wrote: > On jython 2.1, I use something like this > > #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > try: > enumerate > except NameError: > def enumerate(iterable): > results = [] ; ix = 0 > for item in iterable: > results.append( (ix, item) ) > ix = ix+1 > r

Re: language-x-isms

2006-06-08 Thread Alan Kennedy
[Bryan] for example, i've noticed several java developers i know write python code like this: foo_list = [...] for i in range(len(foo_list)): print '%d %s' % (i, foo_list[i]) [Fredrik Lundh] >>> which is a perfectly valid way of doing things if you're targeti

Re: language-x-isms

2006-06-08 Thread bruno at modulix
Bryan wrote: > does anyone know if there is a collection somewhere of common python > mistakes or inefficiencies or unpythonic code that java developers make > when first starting out writing python code? Try googling for "python is not java" !-) -- bruno desthuilliers python -c "print '@'.joi

Re: language-x-isms

2006-06-08 Thread Fredrik Lundh
astyonax wrote: > But it's not the pythonic way. really? I'd say breaking stuff just because you can is remarkably unpythonic. -- http://mail.python.org/mailman/listinfo/python-list

Re: language-x-isms

2006-06-08 Thread Terry Reedy
"astyonax" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Fredrik Lundh wrote: >> Bryan wrote: >> >> > for example, i've noticed several java developers i know >> > write python code like >> > this: >> > >> > foo_list = [...] >> > for i in range(len(foo_list)): >> > print '%d

Re: language-x-isms

2006-06-08 Thread astyonax
Fredrik Lundh wrote: > Bryan wrote: > > > for example, i've noticed several java developers i know write python code > > like > > this: > > > > foo_list = [...] > > for i in range(len(foo_list)): > > print '%d %s' % (i, foo_list[i]) > > which is a perfectly valid way of doing things if you're

Re: language-x-isms

2006-06-07 Thread Fredrik Lundh
Bryan wrote: > for example, i've noticed several java developers i know write python code > like > this: > > foo_list = [...] > for i in range(len(foo_list)): > print '%d %s' % (i, foo_list[i]) which is a perfectly valid way of doing things if you're targeting older Python platforms as we

language-x-isms

2006-06-07 Thread Bryan
know write python code like this: foo_list = [...] for i in range(len(foo_list)): print '%d %s' % (i, foo_list[i]) of course, one way to do this would be to use enumerate: for i, foo in enumerate(foo_list): print '%d %s' % (i, foo) i'm guessing there is a lot