Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: does the order in which the modules are placed in a file matters ? Date: Thu, 17 Dec 2015 03:14:09 +1100 Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 8rc2pYyjaRUO33gMKTqlJAVvnruK8gcwrBgNWyJPOFGA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; 'subject:file': 0.07; 'cc:addr:python-list': 0.09; 'imported': 0.09; 'statements': 0.09; 'subject:modules': 0.09; 'subject:which': 0.09; 'python': 0.10; 'assume': 0.11; '2.7': 0.13; 'thu,': 0.15; 'afterwards.': 0.16; 'alphabetical': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'modules,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:matters': 0.16; 'subprocess': 0.16; 'wrote:': 0.16; 'library': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'first,': 0.20; 'am,': 0.23; 'dec': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; "doesn't": 0.26; 'example': 0.26; 'linux': 0.26; 'logging': 0.27; 'subject: ?': 0.27; 'message-id:@mail.gmail.com': 0.27; '(maybe': 0.29; 'convention': 0.30; 'up.': 0.32; 'generally': 0.32; 'maybe': 0.33; 'run': 0.33; 'common': 0.33; 'usually': 0.33; 'rule': 0.33; 'received:google.com': 0.35; 'but': 0.36; 'project': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'loaded': 0.36; 'modules': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; "won't": 0.38; 'received:209': 0.38; 'whatever': 0.39; 'subject:the': 0.39; 'some': 0.40; 'making': 0.62; 'matter': 0.63; 'chrisa': 0.84; 'difference.': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=KP+d0F5w8g2sLu8nv4GwN4ByPj7GjBC0TsTvkQHQQ1s=; b=u4AnutN2MMjx5PwWYIGvTUvDtOQ94gVi03rorh1WWpe5ig4BbaxgfjB3Wrf2xwx789 Qz6Lu5Dyiw+ye9ss2Vr+2kf1DKoAI88yrQy2/e4mz0p3D3CZrAMzg2tgeHPqf+sSbB5C kB+xphH8UnzUpEVguQhnLtngSn6oISTzC2zsQi1UNyuEUtKESsSyJoEj+XtOuTpxOxwo sBFl+mXCtNsjvyb1lF0PoR7Iqc++ju1sX+lWFgTF+yyToZOegoNkhIgVKGCejfnoUf/Z Lc9Gh2slNgMOQigYYttXWPyWMS1bkEZDlSuVpl8Y/kIAaj3ywZj7VGq77ReEYVEdxOkR 9jOg== X-Received: by 10.50.28.19 with SMTP id x19mr11414679igg.92.1450282449377; Wed, 16 Dec 2015 08:14:09 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100515 On Thu, Dec 17, 2015 at 3: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 > > For Example > > import os > import shlex > import subprocess > import time > import sys > import logging > import plaftform.cluster > from util import run The order of the import statements is the order the modules will get loaded up. As a general rule this won't matter; when it comes to standard library modules, you can generally assume that you can put them in any order without it making any difference. It's common to order them in some aesthetically-pleasing way (maybe alphabetical order, or maybe sort them by the length of the name - whatever you like). There is a broad convention that standard library modules get imported first, and modules that are part of the current project get imported afterwards. But even that doesn't usually matter very much. ChrisA