How can I import python script into another python script?
Hi, I have a Script (Python) called 'functions'. I want to import this script into another Script (Python). import Include.Functions.requests says import of "Include.Functions.requests" is unauthorized Where am I wrong? Thanks, Ferhat __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
At Thursday 31/8/2006 18:11, Ferhat Ayaz wrote:
I have a Script (Python) called 'functions'. I want to import this script into another Script (Python).
import Include.Functions.requests
says
import of "Include.Functions.requests" is unauthorized
You don't import it; you can reference it as container.Include.Functions.whatever(args...) Gabriel Genellina Softlab SRL __________________________________________________ Pregunt�. Respond�. Descubr�. Todo lo que quer�as saber, y lo que ni imaginabas, est� en Yahoo! Respuestas (Beta). �Probalo ya! http://www.yahoo.com.ar/respuestas
Gabriel Genellina wrote:
At Thursday 31/8/2006 18:11, Ferhat Ayaz wrote:
I have a Script (Python) called 'functions'. I want to import this script into another Script (Python).
import Include.Functions.requests
says
import of "Include.Functions.requests" is unauthorized
You don't import it; you can reference it as container.Include.Functions.whatever(args...)
Or even do: Functions = container.Include.Functions and then reference: Functions.whatever() But do yourself a favour and extract the functions out of your Python script into a Python module. It will run faster and be easier to maintain and to debug.
Thanks, it's just a little function (3-5 lines) and uses the REQUEST object. It will lookup for request parameters, if not found, a default value will be returned. But your suggestion can make the code more readable. Greets, Ferhat --- Duncan Booth <duncan.booth@suttoncourtenay.org.uk> wrote:
Gabriel Genellina wrote:
At Thursday 31/8/2006 18:11, Ferhat Ayaz wrote:
I have a Script (Python) called 'functions'. I want to import this script into another Script (Python).
import Include.Functions.requests
says
import of "Include.Functions.requests" is unauthorized
You don't import it; you can reference it as container.Include.Functions.whatever(args...)
Or even do:
Functions = container.Include.Functions
and then reference:
Functions.whatever()
But do yourself a favour and extract the functions out of your Python script into a Python module. It will run faster and be easier to maintain and to debug.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
participants (3)
-
Duncan Booth -
Ferhat Ayaz -
Gabriel Genellina