469,616 Members | 1,823 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,616 developers. It's quick & easy.

"constructor" or initialization function for module

Hi Everyone,

An extended module (.pyd) written in C have an init function that is
called when the module is imported. Does anyone know if there is a way
to provide an init function for a module written in python?

Thanks,
Geoffrey

Aug 19 '07 #1
2 4884
beginner wrote:
Hi Everyone,

An extended module (.pyd) written in C have an init function that is
called when the module is imported. Does anyone know if there is a way
to provide an init function for a module written in python?
The body of a Python module is executed the first time it is imported
(that's how the functions and classes get defined: class and def
statements are executable), so just put your initialization code inline.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Aug 19 '07 #2
On Aug 18, 8:25 pm, Steve Holden <st...@holdenweb.comwrote:
beginner wrote:
Hi Everyone,
An extended module (.pyd) written in C have an init function that is
called when the module is imported. Does anyone know if there is a way
to provide an init function for a module written in python?

The body of a Python module is executed the first time it is imported
(that's how the functions and classes get defined: class and def
statements are executable), so just put your initialization code inline.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
I see. That works.

Aug 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Pierre Senellart | last post: by
4 posts views Thread by Dan Stromberg | last post: by
8 posts views Thread by Asfand Yar Qazi | last post: by
1 post views Thread by Bart Simpson | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.