noob import question

bruno at modulix onurb at xiludom.gro
Fri May 19 10:28:08 EDT 2006


PA wrote:
> 
> On May 19, 2006, at 15:33, Diez B. Roggisch wrote:
> 
>> And it seems as if you have some JAVA-background, putting one class in
>> one
>> file called the same as the class. Don't do that, it's a stupid
>> restriction
>> in JAVA and should be avoided in PYTHON. 
> 
> Restrictive or not, what's so fundamentally devious in putting a class
> declaration in a separate file whose name is that of the declared class
> (class Queue -> Queue.py)?
> 
> Sounds like a handy way of organizing your code, no?
> 

Not in Python. Python classes tend to be smaller than Java classes.
Also, Python, while fully OO, is not anal-retentive about putting
everything in classes - functions are fine too. Would you advocate
putting each function in its own file ?-) And finally, with Python's
file<->module equivalence, grouping related classes and functions in a
same module greatly simplify imports.

wrt/ naming, having the module named after the class (your example)
leads to confusions like the one experimented by the OP. FWIW, Zope2
uses this convention, and I found this confusing too.


-- 
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