Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100523 > unrolled thread
| Started by | Carl Meyer <carl@oddbird.net> |
|---|---|
| First post | 2015-12-16 09:19 -0700 |
| Last post | 2015-12-16 09:19 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: does the order in which the modules are placed in a file matters ? Carl Meyer <carl@oddbird.net> - 2015-12-16 09:19 -0700
| From | Carl Meyer <carl@oddbird.net> |
|---|---|
| Date | 2015-12-16 09:19 -0700 |
| Subject | Re: does the order in which the modules are placed in a file matters ? |
| Message-ID | <mailman.19.1450284973.30845.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
Hi Ganesh, On 12/16/2015 09:09 AM, Ganesh Pal wrote: > Iam on python 2.7 and linux .I need to know if we need to place the > modules in a particular or it doesn't matter at all > > order while writing the program As you've probably already noticed, it usually doesn't matter to Python (though it can become relevant in certain unusual circular-import cases). Most people will have some opinion about what constitutes good style, though. Opinions tend to look something like these (though details will vary): 1. All imports at the top of the module. 2. Standard library imports, then third-party imports, then local imports. 3. Sometimes the above types of imports are grouped with intervening blank lines. 4. Sometimes imports are alphabetized within those groups. > For Example > > import os > import shlex > import subprocess > import time > import sys > import logging > import plaftform.cluster > from util import run > > > def main(): > """ ---MAIN--- """ > > if __name__ == '__main__': > main() > > In the above example : > > 1. Iam guessing may be the python modules like os , shlex etc come > first and later the user defined modules like import > plaftform.cluster .etc come latter > > Sorry if my question sounds dump , I was running pep8 and don't see > its bothered much about it AFAIK the pep8 module doesn't care about import order. If you'd like to enforce an import order in your project, you can look at isort. [1] Carl [1] https://pypi.python.org/pypi/isort
Back to top | Article view | comp.lang.python
csiph-web