gary on 20 Feb 2014 07:12:36 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Python Syntax Question

=> I'm confused a little about importing modules in python.
=> In some cases, you add a statement like:
=> "import sys"
=> But in other cases, the syntax is:
=> "from sys import *"

   In the former case, you reference the module elements as,
whereas in the latter case you just reference foo. The latter is
probably slightly faster per reference, but you should only use it on
modules which are designed for it. Otherwise, it can overwrite your own
variables or replace names imported from other modules. To be explicit,
you are better off using:

"from sys import foo, bar"

where foo and bar are the particular items of interest. If you aren't sure
all the names you will want, just use the first style.

                                  Gary Duzan

p.s. PhillyPUG is an active Python Users Group if you are really
interested. The meetings are scheduled on Meetup.

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --