Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66616

Re: Import order question

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'read.': 0.03; 'classes,': 0.05; 'column': 0.07; 'definitions': 0.07; 'problem:': 0.07; 'funny,': 0.09; 'wrapper': 0.09; 'subject:question': 0.10; 'python': 0.11; 'java.': 0.16; 'modules,': 0.16; 'modules.': 0.16; 'pep8': 0.16; 'pythonic': 0.16; 'reason.': 0.16; 'task.': 0.16; 'wxpython': 0.16; 'code.': 0.18; 'do.': 0.18; 'packages.': 0.19; 'help.': 0.21; 'example': 0.22; 'separate': 0.22; 'header:User- Agent:1': 0.23; 'circular': 0.24; 'module,': 0.24; 'why.': 0.24; 'java': 0.24; 'header:In-Reply-To:1': 0.27; 'related': 0.29; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; 'idea,': 0.31; 'names.': 0.31; 'class': 0.32; 'probably': 0.32; 'ago': 0.33; 'guess': 0.33; 'sense': 0.34; 'problem': 0.35; 'classes': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'c++': 0.36; 'instances': 0.36; 'leads': 0.36; 'module.': 0.36; 'method': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'url:2004': 0.39; 'does': 0.39; 'bad': 0.39; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'around.': 0.60; 'tell': 0.60; 'lower': 0.61; 'from:charset:utf-8': 0.61; 'received:62': 0.63; "you've": 0.63; 'making': 0.63; 'different': 0.65; 'here': 0.66; 'article': 0.77; 'received:192.168.13': 0.84; 'received:62.179': 0.84; 'received:62.179.121': 0.84; 'received:upcmail.net': 0.84; 'habit': 0.91
X-SourceIP 89.134.227.148
Date Mon, 17 Feb 2014 19:14:48 +0100
From Nagy László Zsolt <gandalf@shopzeus.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Import order question
References <53020843.5010804@shopzeus.com> <851tz16fzt.fsf@benfinney.id.au>
In-Reply-To <851tz16fzt.fsf@benfinney.id.au>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7106.1392660896.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392660896 news.xs4all.nl 2850 [2001:888:2000:d::a6]:59729
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66616

Show key headers only | View raw


>> Here is the problem: these methods should create instances of Row,
>> Column and Navbar. But this leads to circular imports.
> It should not; Python is not Java.
>
> Use modules to group your class definitions conceptually. There is no
> need whatever to separate every class into a different module.
If there is a consensus, and it is really desireable to put all these 
related classes into the same module, then this is what I'm going to do.
>
>> This might be a bad idea, but then please tell me why it is bad, and
>> what would be the right code pattern for this task.
> Not only does it lead to the problem you've described, it makes the code
> needlessly difficult to read.
>
> Pyth is not Java
> <URL:http://dirtsimple.org/2004/12/python-is-not-java.html>.
This is funny, because I was working for wxPython for years and this 
article is making an example with wxPython. It is one of the best 
toolkits around. Some years ago I wondered why did they not follow PEP8 
and used lower case method names. Then I found out that these are C++ 
wrapper classes, many of them automatically generated from C++ code. So 
that is why.  But by that time I was using captialized method names for 
UI widgets everywhere, and I guess this is my bad habit now. Probably 
when it comes to UI widgets I do not think the Pythonic way for the same 
reason.

I never know when to put classes in different modules. I usually draw an 
UML diagram and group classes into packages. Wich makes sense because 
there can be sub-groups with subpackages. But I'm always confused with 
modules, I don't know why.

Thanks for the help.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Import order question Nagy László Zsolt <gandalf@shopzeus.com> - 2014-02-17 19:14 +0100

csiph-web