Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Kent Johnson
Hans Dushanthakumar wrote: > Oops answered my own question. Dynamic importing is done using the > __import__ function: > > t = ["test1.py", "test2.py"] #Actually this list is filled in by a > Tkinter Listbox selection. > > for f in t: > testname = f[:-3] > test = __import__("%s"%(testname

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Orri Ganel
Hans Dushanthakumar wrote: >Oops answered my own question. Dynamic importing is done using the >__import__ function: > >t = ["test1.py", "test2.py"] #Actually this list is filled in by a >Tkinter Listbox selection. > >for f in t: >testname = f[:-3] >test = __import__("%s"%(testname)) >

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Orri Ganel
Hans Dushanthakumar wrote: >Thanks for your reply Kent. > >Is it possible to dynamically import a module? > >The foll snippet of code throws an error "ImportError: No module named >testname" > > >t = ["test1.py", "test2.py"] #Actually this list is filled in by a >Tkinter Listbox selection. > >for

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread John Fouhy
On 12/01/06, Hans Dushanthakumar <[EMAIL PROTECTED]> wrote: > Any other means of importing dynamically? There's an __import__ builtin. It's a function that takes a string and returns the module. eg: >>> sys = __import__('sys') >>> sys.platform 'win32' [actually, it does a bit more than just tha

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
= test.run_test() Cheers Hans -Original Message- From: Hans Dushanthakumar Sent: Thursday, 12 January 2006 2:28 p.m. Cc: Python Tutor Subject: RE: [Tutor] Returning multiple values from a script Thanks for your reply Kent. Is it possible to dynamically import a module? The foll s

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
Subject: Re: [Tutor] Returning multiple values from a script Hans Dushanthakumar wrote: > Yes I agree that it'd be cleaner to import the second script and call > it. > > The reason I'm keen to find a alternate method is that I have a whole > lot of scripts that were design

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Kent Johnson
ort the module you want to run >>> returnedvalue 5 Isn't Python wonderful! Kent > ... > > Cheers > Hans > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Kent Johnson > Sent: Thursday, 12 Jan

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
ginal Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Sent: Thursday, 12 January 2006 12:06 p.m. Cc: Python Tutor Subject: Re: [Tutor] Returning multiple values from a script Hans Dushanthakumar wrote: > Hi, >Can a script return multiple values to th

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Kent Johnson
Hans Dushanthakumar wrote: > Hi, >Can a script return multiple values to the os? Is there a reason why you have to call the second test.py using os.system()? I would write it to be imported and called. test.py -- def findR(): return 7, 'Hans' script1.py - import test res

[Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
Hi, Can a script return multiple values to the os? What I have in mind is something like the following: 1) Test.py --- import sys r = 7 sys.exit(r) # What I really want to do is something along the lines of sys.exit(r, "Hans") 2) Script1.py (This script executes script test.py and pri