What are modules really for?

bruno modulix onurb at xiludom.gro
Thu Aug 11 10:01:41 EDT 2005


Magnus Lycka wrote:
> N.Davis wrote:
> 
>> Functions existing in a module? Surely if "everything is an object"
>> (OK thats Java-talk but supposedly Python will eventually follow this
>> too) 
> 
> 
> int too? ;)

Yes, int too.

>>> i = 42
>>> i.__class__
<type 'int'>
>>> i.__class__.__name__
'int'
>>> dir(i)
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__',
'__delattr__', '__div__', '__divmod__', '__doc__', '__float__',
'__floordiv__', '__getattribute__', '__getnewargs__', '__hash__',
'__hex__', '__init__', '__int__', '__invert__', '__long__',
'__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__',
'__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__',
'__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__',
'__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__',
'__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__',
'__rxor__', '__setattr__', '__str__', '__sub__', '__truediv__', '__xor__']
>>>


(snip)
> It seems to me that Java is designed
> to make is difficult for programmers to write bad code, while
> Python is designed to make it easy to write good code. 

+1 QOTW

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list