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


Groups > comp.lang.python > #75177 > unrolled thread

How to place several "import ...." lines in one .py file?

Started byfl <rxjwg98@gmail.com>
First post2014-07-24 13:25 -0700
Last post2014-07-24 14:45 -0600
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  How to place several "import ...." lines in one .py file? fl <rxjwg98@gmail.com> - 2014-07-24 13:25 -0700
    Re: How to place several "import ...." lines in one .py file? Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-24 14:45 -0600

#75177 — How to place several "import ...." lines in one .py file?

Fromfl <rxjwg98@gmail.com>
Date2014-07-24 13:25 -0700
SubjectHow to place several "import ...." lines in one .py file?
Message-ID<5061f92b-4626-4e64-aeb2-0ad68904eef0@googlegroups.com>
Hi,

I have seen several kinds of module import examples, but most of the programs are
small and less content. They only have one or two module import.

I'll use the following modules in a small project. I would like to know whether
it is appropriate to put all of them at the file header, like this:



import pandas as pd
import numpy as np
import sci
import matplotlib.pyplot as plt
from pandas import DataFrame




Because some modules are used only at the beginning or the end, does it recommend
to separate to place the import lines just before the associated function lines.




import pandas as pd

.
..
...
import numpy as np

.
...
.....
import sci
..
.....
...
import matplotlib.pyplot as plt
from pandas import DataFrame



Or, it recommends to have separate files for each main functionality, such as
input, process and output (plot etc.)?



Thanks,

[toc] | [next] | [standalone]


#75178

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-07-24 14:45 -0600
Message-ID<mailman.12299.1406234787.18130.python-list@python.org>
In reply to#75177
On Thu, Jul 24, 2014 at 2:25 PM, fl <rxjwg98@gmail.com> wrote:
> Hi,
>
> I have seen several kinds of module import examples, but most of the programs are
> small and less content. They only have one or two module import.
>
> I'll use the following modules in a small project. I would like to know whether
> it is appropriate to put all of them at the file header, like this:

http://legacy.python.org/dev/peps/pep-0008/#imports

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web