On vrijdag 13 juli 2018 13:44:21 CEST Mickael Barbo wrote:

> *I like working with " 1 file - 1 object " (Object could be class,
> function...).*
> It simplify visibility, debug etc... and it's easy for me to *don't pollute
> my brain* :-)

It only seems that way.  Debugging is actually much harder, as you jump from 
source file to source file, for the tiniest things.

My assumption is that you come from a php background, where you have single 
inheritance with autoload functionality. In php a lot is implicit, hidden and 
fragmented.

Python is a different animal. Imports are explicit. Sharing imports is a good 
thing. Bunding tiny classes (mixins, utilities) in one file is a good thing. 
Bundling related classes in a single file is a good thing.

When you really want to stick to one file per class, then you sacrifice 
performance. Where you could avoid an import for a related Django model, you 
now have to import the module and depending if you the need to avoid a 
circular import you either cause a runtime import or add extra startup time.

It's better to not adhere to such "one size fits all" rule systems but use your 
brain to construct your modules in a sensible way.

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11617338.cXBrDTWfSs%40fritzbook.
For more options, visit https://groups.google.com/d/optout.

Reply via email to