Idiosyncratic python

Akira Li 4kir4.1i at gmail.com
Fri Sep 25 02:04:04 CEST 2015


Mark Lawrence <breamoreboy at yahoo.co.uk> writes:

> On 24/09/2015 07:02, 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?
>>
>
> My favourite was from a guy I worked with years ago.  In C but I'm
> sure you'll enjoy it.  In all functions, something like:-
>
> int flag = 0;
> if flag {
>     printf("\nthe string");
> }
> else{
>     printf("the string");
>     flag = 1;
> }
>
> At least I think I've got it correct, too lazy to check, sorry :)

It looks like a sys.stdout.softspace hack in Python 2:

  print line, # comma!



More information about the Python-list mailing list