My python annoyances so far

James Stroud jstroud at mbi.ucla.edu
Thu Apr 26 20:20:44 EDT 2007


Steve Holden wrote:
> flifus at gmail.com wrote:
> 
>> Hi all. I'm learning python these days. I'm going to use this thread
>> to post, from time to time, my annoyances with python. I hope someone
>> will clarify things to me where I have misunderstood them.
>>
>> Annoyances:
>> 2. There are modules, there are functions, and there are classes-
>> methods! Wouldn't it have been easier had everything either been a
>> function or a class method?
>>
> Actually, it's really simple. When you get right down to it, 
> *everything* in *every* current implementation of Python is either a one 
> or a zero. Would you like us to make it all zeros?
> 
> Perhaps you should meditate on the idea to the concept of "sufficient 
> and necessary complexity" ...

Here is something on which to meditate: classes become functions when 
you get the quantum mechanics just so!

py> class add(object):
...   def __new__(self, a, b):
...     return a + b
...
py> c = add(3, 1)
py> c
4
py> type(c)
<type 'int'>
py> add
<class '__main__.add'>
py> def add(a, b):
...   return a + b
...
py> add(3, 1)
4



More information about the Python-list mailing list