I thought I understood how import worked...

Paul Rubin no.email at nospam.invalid
Tue Aug 7 11:53:10 EDT 2012


Roy Smith <roy at panix.com> writes:
>> In general, you should avoid non-idempotent code. 
> I don't understand your aversion to non-idempotent code as a general
> rule.  Most code is non-idempotent.  Surely you're not saying we
> should never write:
>>>> foo += 1
> or
>>>> my_list.pop()
> ???

I don't think "in general avoid" means the same thing as "never write".

One of the tenets of the functional-programming movement is that it is
in fact reasonable to write in a style that avoids "foo += 1" and
"my_list.pop()" most of the time, leading to cleaner, more reliable
code.

In Python it's not possible to get rid of ALL of the data mutation
without horrendous contortions, but it's pretty easy (and IMHO of
worthwhile benefit) to avoid quite a lot of it.  



More information about the Python-list mailing list