Idiosyncratic python

jmp jeanmichel at sequans.com
Thu Sep 24 05:12:36 EDT 2015


On 09/24/2015 08:02 AM, Steven D'Aprano wrote:
> I was looking at an in-house code base today, and the author seems to have a
> rather idiosyncratic approach to Python. For example:
>
>
> for k, v in mydict.items():
>      del(k)
>      ...
>
>
> instead of the more obvious
>
> for v in mydict.values():
>      ...
>
>
>
> What are your favorite not-wrong-just-weird Python moments?

A lot of our in base weird python comes from heavily C-wired people:

The classic
for i in range(len(alist)):
   print alist[i]

with its twin brother

i=0
while i < len(alist):
   print alist[i]
   i += 1

And the even more annoying

result = Result()
getResult(result)

JM







More information about the Python-list mailing list