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
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
[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
[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
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
[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
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
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 ""
[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
>>
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
[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
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
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
"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
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
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
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
17 matches
Mail list logo