modules

Philip Swartzleonard starx at pacbell.net
Mon Apr 8 14:01:49 EDT 2002


Peter Hansen || Sun 07 Apr 2002 08:47:48p:

> Date: Sun, 07 Apr 2002 23:47:48 -0400
> Subject: Re: modules
> From: Peter Hansen <peter at engcorp.com>
> Newsgroups: comp.lang.python
> 
> 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?
> [ ... ] 
>
> 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.)

It may help to add this:

Some nice people have already set up modules that contain useful functions 
and classes organized into coherent sets. There are quite a few of these, 
and a great many make up the 'standard library' that comes with Python. 
The master guide to all this usefulness is the Python Library Referance*. 
Read over the table of contents here... each of these names that you see 
in typewriter font is a diferent module you can import into your program: 
sys, urllib, string, random, pickle, threading, socket, os, Tkinter, 
email.. each of these is a module, some .py file sitting somewhere in your 
Python folder just waiting to be evoked for some useful or sinister 
purpose. Sort of like magic :).

If these are the names you are thinking of when you ask 'what each one 
does', then this reference should be your first stop for information. It 
might not make sense, but if you can at least try to understand it you 
will be that much more prepared to ask a question here, and people will be 
more able (and more willing) to help you if you can pick out what you 
don't understand and ask more specific questions.

* http://www.python.org/doc/current/lib/lib.html - the contents, alhtough 
it's more like a subject index

http://www.python.org/doc/current/lib/modindex.html - index of module 
names, often easier to find something here if you only know it's name 
(though i usually just use find in the browser on the other page :)

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

Learining... moving from ignorance to understanding of a subject... is 
rarely easy. However, with work and ye shall be rewarded.

-- 
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com
"There's more than one answer to these questions-- pointing me in a 
crooked line" - (Closer to fine)



More information about the Python-list mailing list