472,145 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

"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 5028
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 Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.