modules

Peter Hansen peter at engcorp.com
Sun Apr 7 23:47:48 EDT 2002


distrex wrote:
> Jim Dennis wrote:
> > distrex wrote:
> > >I understand most of python. But I still don't get modules. I know
> > >they are just basicaly a function but i don't know how to use them
> > >effectively and what each one does.  [...]
> >
> >  Modules are things that you import into your namespace.  
[...snip rest of Jim's reply]
> 
> Don't take this the wrong way but I am a newbie and didn't understand
> 86% of what you just said. All I got was modules are classes functions
> and variables. and a few other things but that was to complicated for
> me (the newbie)

I can see how it might have been above the level you are at just yet,
so don't take this the wrong way: what are you going to do about it?

Have you read the Python tutorial yet?  It's on the web site.  Have
you read the documentation on modules?  Or is that where you got the
(wrong) impression they were "basically functions"?  If so, there may be
some improvements to be made since I don't believe the documentation
authors intended for the material to be incomprehensible to newbies.

If you've tried to learn what they are, but are still having a hard
time, maybe you could post some specific questions to test your 
understanding.  You ask "how to use them effectively", which is
a good one, but without more of an idea what you are trying to 
accomplish, it might be hard to provide a good answer.

Your question about "what each one does" is also strange to us.  
It almost sounds like you know there are dozens of standard modules
and were asking what each one does.  There is full documentation
on each module already, so that must not have been what you meant.
But in that case the question is bizarre. "Each one"?  What "each"
are you talking about?

And in case it helps any, here's a shorter answer than Jim's:

Modules are files which contain collections of functions, variables,
and classes.  They help organize your code so it doesn't all 
have to be in one large file, and they let you put code in 
libraries to make it easier to re-use, so you don't have to
copy-and-paste all the time to re-use other people's code.
(This is a somewhat simplified description but may be more 
useful to a newbie.)

Help us a little more, and we can help you a little more. :-)

-Peter



More information about the Python-list mailing list