Re: [Tutor] module versus file

2006-06-08 Thread Kent Johnson
> From: Dave Kuhlman <[EMAIL PROTECTED]>
> 

> If you are importing a module from a directory other than your
> current directory, then the directory is effectively a package.
> In order to make a directory into a package, the directory must
> contain a file named __init__.py.  

That's not quite right. If the module is in a directory that is in sys.path, it 
is just a plain module, not a package. If the module is in a subdirectory of a 
directory in sys.path, then the subdirectory is a package and requires an 
__init__.py file to be recognized as a package. There is a good discussion of 
modules and packages in the tutorial:
http://docs.python.org/tut/node8.html

Kent


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] directory as package

2006-06-08 Thread Kermit Rose
 
Message: 4
Date: Wed, 7 Jun 2006 20:10:52 -0700
From: Dave Kuhlman <[EMAIL PROTECTED]>
Subject: Re: [Tutor] module versus file
To: tutor@python.org
 
Hello Dave.
 
 
>>
 
If you are importing a module from a directory other than your
current directory, then the directory is effectively a package.
In order to make a directory into a package, the directory must
contain a file named __init__.py.
 
The file __init__.py can be empty or can contain code.  It will be
evaluated the first time (and only the first time) an application
imports the package or something in it.
 
Dave
 
***
 
It must  be someother method that I used, because
 
there is no file named _init_.py is directory math\factoring
 
 
Is it that the convention must be different for a windows machine?
 
C:\Math\Factoring>dir *init*
 Volume in drive C has no label.
 Volume Serial Number is 4748-654D
 
 Directory of C:\Math\Factoring
 
File Not Found

 
Kermit<  [EMAIL PROTECTED]  >
 
 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] module versus file

2006-06-08 Thread Kent Johnson
Kermit Rose wrote:
> Are you saying that any .py file that I save in math\factoring
> can be imported?

Yes

>  You already have
> many modules installed as part of the standard library and any
> third-party add-ons you have installed.
>  
> **
>  
> Yes.   I'm impressed with the listing in built_in.
>  
> I assumed system modules were handled in a different way than user modules.

Many system modules are written in Python and handled the same way as 
user modules - they are found by searching sys.path. The actual files 
are in C:\Python24\Lib

Some system modules are written in C, they are still on sys.path but the 
modules are called .pyd.

Some system modules are built-in to Python and don't correspond to an 
actual file in the file system.
>  
> *
>  
>  
> If you are working with a module from the interpreter and you make
> changes to the module, you have to reload it with the command
>   >>> reload(factor30)
>  
> *
>  
> I will try the reload command next time I work with factor30. 
>  
> This won't work for local names (from factor30 import xx)! Just use the
> full name to access any elements of factor30, e.G. factor30.gcd. Read
>  
> **
>  
> In order to have the shorter name,
>  
> gcd 
>  
> instead of factor30.gcd,
>  
> I prepare by
>  
> typing 
>  
> from factor30 import gcd

If you do this, reload(factor30) will not get you a new copy of gcd 
because gcd is bound to the old function.
>  
>  
> Once someone said that modules and files are not the same thing.
>  
> This statement left me puzzled.  Why not?

Most modules do have corresponding files. The exceptions are the ones 
built-in to Python. In fact modules have a __file__ attribute that tells 
you where it came from; try typing
factor30.__file__

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] making a python program part of xhtml

2006-06-08 Thread Emily Fortuna
Hola everyone,
I'm working on creating a webpage in which a user can submit data into 
fields to be held in a database (there are other details, but this is 
the gist of the idea), and I need to use python.  I am unfamiliar with 
manipulating data and web apps as a whole (and new to python), so I have 
been encountering much unfamiliar terrain.  I _think_ I want to somehow 
embed the python into the page, but I'm really not sure how to do it.  
After googling I found some programs that generate xhtml from python, 
but I don't think that is what I want, or is it?  Your help is appreciated!
Emily

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] PyGTK on cygwin

2006-06-08 Thread Christopher Spears
Does PyGTK work well on cygwin?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] making a python program part of xhtml

2006-06-08 Thread Mike Hansen
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Emily Fortuna
> Sent: Thursday, June 08, 2006 7:20 AM
> To: tutor@python.org
> Subject: [Tutor] making a python program part of xhtml
> 
> Hola everyone,
> I'm working on creating a webpage in which a user can submit 
> data into 
> fields to be held in a database (there are other details, but this is 
> the gist of the idea), and I need to use python.  I am 
> unfamiliar with 
> manipulating data and web apps as a whole (and new to 
> python), so I have 
> been encountering much unfamiliar terrain.  I _think_ I want 
> to somehow 
> embed the python into the page, but I'm really not sure how 
> to do it.  
> After googling I found some programs that generate xhtml from python, 
> but I don't think that is what I want, or is it?  Your help 
> is appreciated!
> Emily
>

Although you can embed python in a web page to be run on a server, you
probably don't want to do that.(It can get pretty messy.)

What I'd suggest is creating a web page that calls a python program on the
server and processes form fields in the web page. The python program would
save the data in the database.

[web page] -> [python program on server] -> [database]

Look at the FORM tag in HTML/XHTML. Also look at the cgi module for Python.
I think there's some web topics on the Python web site that might point to
articles about doing simple cgi stuff in Python.

http://wiki.python.org/moin/CgiScripts

http://www.devshed.com/index2.php?option=content&task=view&id=198&pop=1&page
=0&hide_js=1

Is an article on cgi programming with Python.

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PyGTK on cygwin

2006-06-08 Thread Carlos Daniel Ruvalcaba Valenzuela
There is a PyGTK package for win32, don't know if it uses cygwin or
mingw but works pretty well on windows, it only needs the gtk runtime.

http://www.pcpm.ucl.ac.be/~gustin/win32_ports/

Altough I might been misunderstanding your question ;)

On 6/8/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
> Does PyGTK work well on cygwin?
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What is a widget?

2006-06-08 Thread Christopher Spears
I'm a bit embarassed to ask this...I am looking at a
tutorial for PyGTK+ that is discussing widgets.  What
are widgets?

-Chris
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What is a widget?

2006-06-08 Thread Bob Gailer




Christopher Spears wrote:

  I'm a bit embarassed to ask this...I am looking at a
tutorial for PyGTK+ that is discussing widgets.  What
are widgets?
  

http://en.wikipedia.org/wiki/Widget_(computing)
-- 
Bob Gailer
510-978-4454

Broadband Phone Service for local and long distance $19.95/mo plus 1 mo Free


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor