Jarek Zgoda wrote: > Chris Lasher napisał(a): > >> A friend of mine with a programming background in Java and Perl places >> each class in its own separate file in . I informed him that keeping >> all related classes together in a single file is more in the Python >> idiom than one file per class. He asked why, and frankly, his valid >> question has me flummoxed. >> >> I tried to rationalize this Python idiom by claiming a file--a single >> module--makes for a great container of code which is logically tied >> together, such as a class and its subclasses. He posited that >> directories (packages) can tie the files together just as well, and by >> having the classes as separate files, he can "diff" them to see how >> they differ, something he wouldn't be able to do with the code all in >> one file. > > I'd not try to rationalize it, it's just natural. The requirement to > have only one public class per module needs rationalization (other than > limitation of compiler), not the freedom to have as much of classes in > module as is needed by program's architecure. > The fact that your friend find being able to diff his classes valuable implies that he isn't taking much advantage of modularity anyway but instead using copy-and-paste techniques. Of course I may be doing him a disservice.
In Java *everything* has to be in a class, unlike in Python. The module seems a much more natural unit of storage to me, and to force us to put each class in its own module would seem unnatural. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list