Why NOT only one class per file?
Thomas Krüger
newsgroups at nospam.nowire.org
Wed Apr 4 17:52:35 EDT 2007
Chris Lasher schrieb:
> why should we NOT be
> placing classes in their own separate files?
>
> Thoughts, comments, and insight much appreciated,
At first: if he really like it he can place every class in a single
file. But there are some reasons why Python "allows" you to place many
classes in one file:
- It's (a little bit) faster, no additional file system lookup is needed. ;)
- You can define a class in a class. Django, for example, uses this for
it's data models. If you do this you are forced to have multiple classes
in on file. Example:
http://www.djangoproject.com/documentation/tutorial02/#make-the-poll-app-modifiable-in-the-admin
See also:
http://mail.python.org/pipermail/python-list/2006-December/418363.html
Thomas
More information about the Python-list
mailing list