Re: how to pickle unpicklable objects

2005-09-23 Thread Hans Georg Krauthaeuser
Guy Lateur schrieb:
> Hi all,
> 
> I've been writing an application containing a lot of settings which can be 
> changed by the user. I'm using wx.Config to read/write these settings (to 
> the windows registry). This means I can only store strings, ints and floats.
> 
> However, it would be very convenient if I could also store more general 
> objects. It seems to work for wx.Colour, but not for wx.Font. It raises a 
> "TypeError: can't pickle PySwigObject objects".

The object is wrapped by SWIG. So, python can not know anything about it
and the object can not be pickled.

As far as I see, there are two possibilities
- define __getstate__ and __setstate__ in the c/c++-source or the .i
file (used by swig). This is only possible if the source is available
- use copy_reg (http://docs.python.org/lib/module-copyreg.html) to
register a 'reduce' function (I never used that).

I use the first option in the .i-File for a wrapped c++-class like this:

%extend UMDMResult {
%insert("python") %{
def __getstate__(self):
return (self.v,self.u,self.l,self.unit,self.Z0,self.Eta0,self.t)
def __setstate__(self,tup):
self.this = _umddevice.new_UMDMResult(tup[0],tup[1],tup[2],tup[3])
self.thisown=1
(self.Z0,self.Eta0,self.t)=[i for i in tup[4:]]
%}
}

regards
Hans Georg Krauthaeuser
-- 
http://mail.python.org/mailman/listinfo/python-list


searching python/gui developper in germany

2005-10-11 Thread Hans Georg Krauthaeuser
Dear all,

for the measurements in our labs we have developed python scripts that
are pretty fine for our needs. Basically, we have classes and call the
appropriate methods from the command line (or by other scripts). So, we
don't have any GUI.

Now, an external customer want to use our software and -- as you can
imagine -- we want a pretty GUI.

So, we are looking for someone who can develop such a pretty GUI for us
(of course for money). OS is Windows (XP). We are not fixed to a special
toolkit -- it just should look nice and do the job.

Best would be someone from our region (Magdeburg, Germany).

If someone is interested: contact me by email, please.

Best regards
Hans Georg Krauthaeuser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching python/gui developper in germany

2005-10-12 Thread Hans Georg Krauthaeuser
malv schrieb:
> Hans Georg Krauthaeuser wrote:
> 
>>Dear all,
>>
>>for the measurements in our labs we have developed python scripts that
>>are pretty fine for our needs. Basically, we have classes and call the
>>appropriate methods from the command line (or by other scripts). So, we
>>don't have any GUI.
>>
>>Now, an external customer want to use our software and -- as you can
>>imagine -- we want a pretty GUI.
>>
>>So, we are looking for someone who can develop such a pretty GUI for us
>>(of course for money). OS is Windows (XP). We are not fixed to a special
>>toolkit -- it just should look nice and do the job.
>>
>>Best would be someone from our region (Magdeburg, Germany).
>>
>>If someone is interested: contact me by email, please.
>>
>>Best regards
>>Hans Georg Krauthaeuser
> 
> http://www.die-offenbachs.de/detlev/eric3.html
> If you run SuSE9.3 or SuSE 10.0, everything is there. Simply install
> eric or eric3.
> There is also a great gui design utility in the installation.
> You'll be going in no time.
> malv
> 
Sorry for the question, but... Is this a bot?

If not, just as a clearification: We are NOT looking for an IDE or an
GUI tool. I'm sure, I can build a GUI, with eric3 or an other tool. I
simply have not the time. So, we are looking for a person do do the job
for us.

regards
Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with cPickle for deserializing datetime.datetime instances

2005-10-14 Thread Hans Georg Krauthaeuser
Mingus Tsai schrieb:
> Hello- please help with unpickling problem:
> 
> I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows
> XPhome system.
> 
> My problem is with using cPickle to deserialize my pickled arrays of
> datetime.datetime instances.  The following is the code I have written:
> 
> import cPickle, datetime
> import Numeric
> 
> #the file below contains a serialized dict with arrays of datetime
> #objects.  When these three statements run, the IDLE crashes!
> 
> input1 = open('tsm2_outa','r')
> time1 = cPickle.load(input1)
> input1.close()
> 
> #the file below contains serialized dict with arrays of built-in objects
> #it unpickles without any problem, when I omit the above unpickling
> #operation.
> 
> input2 = open('tsm2_outb','rb')
> data1 = cPickle.load(input2)
> input2.close()
> 
> My guess is that I need to somehow tell the pickle.load command that it
> is loading datetime instances, but I have no idea how to do this.  Any
> help would be much appreciated.
> 
> Thanks,
> Ming
How did you wrote the pickle-file. If you used mode 2 you have to open
the file with mode "rb", as you did for the other pickle file.

Hans
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good python reference?

2005-11-11 Thread Hans Georg Krauthaeuser
derek schrieb:
> Hello! I'm new to the group and am looking for a decent reference for
> information about the history / evolution of the Python language and
> its features.  Typing, scoping, etc...  I'd appreciate any good links.
> Thanks!
> 
> - Derek
> 
Looking at the title of your mail I would answer

http://rgruet.free.fr/PQR24/PQR2.4.html

But history? Sorry

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


platform independent kbhit()

2005-01-17 Thread Hans Georg Krauthaeuser
Hey all,
this is probably a FAQ, but I didn't found the answer...
I use msvcrt.kbhit() to check for a user keyboard event on windows. But 
now, I would prefer to make the module independent from the platform 
used. I already know that I can use curses (on linux/unix) or Tkinter. 
Also, I  found this http://my.execpc.com/~geezer/software/kbhit.c C 
source that has a kbhit() and a getch() for linux/unix that I can SWIG 
to python.

Are there other (more simple, pure python, true platform independent) 
possibilities?

Best regards
Hans Georg Krauthaeuser
--
www.uni-magdeburg.de/krauthae
--
http://mail.python.org/mailman/listinfo/python-list


Re: Text To Speech with pyTTS

2005-02-28 Thread Hans Georg Krauthaeuser
Mike P. wrote:
Hi,
I was wondering if anyone has had any luck with the python text to speech
(pyTTS) module available on Sourceforge:
http://sourceforge.net/projects/uncassist
I have followed the tutorial for pyTTS at:
http://www.cs.unc.edu/~parente/tech/tr02.shtml
Using the first simple speech example:
import pyTTS
tts = pyTTS.Create()
tts.Speak("Hello World!")
I get the following error on the call to pyTTS.Create()
C:\Program Files\Python23\Lib\site-packages\pyTTS>python
ActivePython 2.3.2 Build 232 (ActiveState Corp.) based on
Python 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
import pyTTS
tts = pyTTS.Create()
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Program Files\Python23\Lib\site-packages\pyTTS\__init__.py", line
28, in Create
raise ValueError('"%s" not supported' % api)
ValueError: "SAPI" not supported
...
The TTSFast.py file is missing in the 2.3 distribution. I made a copy 
from the 2.4 dist and everything worked fine for me.

Hans Georg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Text To Speech with pyTTS

2005-03-04 Thread Hans Georg Krauthaeuser
Peter wrote:
I released a new version of the Windows installer for Python 2.3 that
includes the missing _TTSFast.pyd file.

Unfortunenately, the file TTSFast.py is missing, not _TTSFast.pyd.
Hans Georg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Tkinter Question

2005-04-13 Thread Hans Georg Krauthaeuser
Peter Otten schrieb:
> Pseud O'Nym wrote:
> 
> 
>>the following fragment doesn't cause any errors and results in buttons the
>>correct size for the images, but the buttons don't work, and the images
>>aren't displayed. If I add a text property, and remove the images, they
>>work fine, so the rest of my code's OK. I've searched this group and
>>Python.org to no avail.
>>
>>class App:
>>  def __init__(self, master):
>>frame = Frame(master)
>>frame.pack(side=LEFT, fill=Y)
>>image1 = PhotoImage(file='button_a.gif')
>>self.button = Button(frame, image=image1)
>>self.button.pack(side=TOP)
> 
> 
>   self.image = image1
> 
> 
>>Can anyone enlighten me?
> 
> 
> For reasons that are beyond me widgets do not increase the reference count
> of a PhotoImage. Therefore you have to put a reference to the image
> elsewhere, e. g. into the App instance, to prevent it from being
> garbage-collected when the image1 variable goes out of scope.
> 
> Peter
> 
Because I stumbled across the same 'feature' just recently, I think it's
good to give a reference...

>From http://tkinter.unpythonic.net/wiki/Images

"Something that seems to bite every new Tkinter programmer at least
once: you've loaded a PhotoImage, applied it to a Button, Label, or
other widget, and nothing shows up - because you referenced the image
only via a local variable, so it went out of scope and got deleted
before the widget ever appeared. The usual solution is to store a
reference to the image as an attribute of the widget that is to display it.

You might just call this a bug in Tkinter, but the reality isn't quite
that simple... Tk images are not first-class objects: when you apply one
to a widget, you do not in any sense "pass a reference to" the image.
Instead, you just pass a name, which Tk looks up in an internal table of
defined images (from which images can only be deleted manually). From
Tkinter, passing a PhotoImage as a parameter actually only sends the
str() of the image object to the Tcl side: this is just a string, the
randomly-generated name assigned when the object was created. "No
reference to the image itself" means "no reference counting" means "no
way for the Python side to be notified when the image is truly no longer
used". If Tkinter didn't delete images when no Python reference to them
existed, they would be unavoidable memory leaks.
..."

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


scipy.stats.itemfreq: overflow with add.reduce

2005-12-21 Thread Hans Georg Krauthaeuser
Hi All,

I was playing with scipy.stats.itemfreq when I observed the following 
overflow:

In [119]:for i in [254,255,256,257,258]:
.:l=[0]*i
.:print i, stats.itemfreq(l), l.count(0)
.:
254 [ [  0 254]] 254
255 [ [  0 255]] 255
256 [ [0 0]] 256
257 [ [0 1]] 257
258 [ [0 2]] 258

itemfreq is pretty small (in stats.py):

--
def itemfreq(a):
 """
Returns a 2D array of item frequencies.  Column 1 contains item values,
column 2 contains their respective counts.  Assumes a 1D array is passed.

Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies)
"""
 scores = _support.unique(a)
 scores = sort(scores)
 freq = zeros(len(scores))
 for i in range(len(scores)):
 freq[i] = add.reduce(equal(a,scores[i]))
 return array(_support.abut(scores, freq))
--

It seems that add.reduce is the source for the overflow:

In [116]:from scipy import *

In [117]:for i in [254,255,256,257,258]:
.:l=[0]*i
.:print i, add.reduce(equal(l,0))
.:
254 254
255 255
256 0
257 1
258 2

Is there any possibility to avoid the overflow?

BTW:
Python 2.3.5 (#2, Aug 30 2005, 15:50:26)
[GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] on linux2

scipy_version.scipy_version  --> '0.3.2'


Thanks and best regards
Hans Georg Krauthäuser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scipy.stats.itemfreq: overflow with add.reduce

2005-12-21 Thread Hans Georg Krauthaeuser
Hans Georg Krauthaeuser schrieb:
> Hi All,
> 
> I was playing with scipy.stats.itemfreq when I observed the following 
> overflow:
> 
> In [119]:for i in [254,255,256,257,258]:
>.:l=[0]*i
>.:print i, stats.itemfreq(l), l.count(0)
>.:
> 254 [ [  0 254]] 254
> 255 [ [  0 255]] 255
> 256 [ [0 0]] 256
> 257 [ [0 1]] 257
> 258 [ [0 2]] 258
> 
> itemfreq is pretty small (in stats.py):
> 
> --
> def itemfreq(a):
> """
> Returns a 2D array of item frequencies.  Column 1 contains item values,
> column 2 contains their respective counts.  Assumes a 1D array is passed.
> 
> Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies)
> """
> scores = _support.unique(a)
> scores = sort(scores)
> freq = zeros(len(scores))
> for i in range(len(scores)):
> freq[i] = add.reduce(equal(a,scores[i]))
> return array(_support.abut(scores, freq))
> --
> 
> It seems that add.reduce is the source for the overflow:
> 
> In [116]:from scipy import *
> 
> In [117]:for i in [254,255,256,257,258]:
>.:l=[0]*i
>.:print i, add.reduce(equal(l,0))
>.:
> 254 254
> 255 255
> 256 0
> 257 1
> 258 2
> 
> Is there any possibility to avoid the overflow?
> 
> BTW:
> Python 2.3.5 (#2, Aug 30 2005, 15:50:26)
> [GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] on linux2
> 
> scipy_version.scipy_version  --> '0.3.2'
> 
> 
> Thanks and best regards
> Hans Georg Krauthäuser
After some further investigation:

In [150]:add.reduce(array(equal([0]*256,0),typecode='l'))
Out[150]:256

In [151]:add.reduce(equal([0]*256,0))
Out[151]:0

The problem occurs with arrays with typecode 'b' (as returned by equal).

Workaround patch for itemfreq is obvious, but ... is it a bug or a feature?

regards
Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scipy.stats.itemfreq: overflow with add.reduce

2005-12-21 Thread Hans Georg Krauthaeuser
Hans Georg Krauthaeuser schrieb:
> Hans Georg Krauthaeuser schrieb:
> 
>> Hi All,
>>
>> I was playing with scipy.stats.itemfreq when I observed the following 
>> overflow:
>>
>> In [119]:for i in [254,255,256,257,258]:
>>.:l=[0]*i
>>.:print i, stats.itemfreq(l), l.count(0)
>>.:
>> 254 [ [  0 254]] 254
>> 255 [ [  0 255]] 255
>> 256 [ [0 0]] 256
>> 257 [ [0 1]] 257
>> 258 [ [0 2]] 258
>>
>> itemfreq is pretty small (in stats.py):
>>
>> --
>> def itemfreq(a):
>> """
>> Returns a 2D array of item frequencies.  Column 1 contains item values,
>> column 2 contains their respective counts.  Assumes a 1D array is passed.
>>
>> Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies)
>> """
>> scores = _support.unique(a)
>> scores = sort(scores)
>> freq = zeros(len(scores))
>> for i in range(len(scores)):
>> freq[i] = add.reduce(equal(a,scores[i]))
>> return array(_support.abut(scores, freq))
>> --
>>
>> It seems that add.reduce is the source for the overflow:
>>
>> In [116]:from scipy import *
>>
>> In [117]:for i in [254,255,256,257,258]:
>>.:l=[0]*i
>>.:print i, add.reduce(equal(l,0))
>>.:
>> 254 254
>> 255 255
>> 256 0
>> 257 1
>> 258 2
>>
>> Is there any possibility to avoid the overflow?
>>
>> BTW:
>> Python 2.3.5 (#2, Aug 30 2005, 15:50:26)
>> [GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] on linux2
>>
>> scipy_version.scipy_version  --> '0.3.2'
>>
>>
>> Thanks and best regards
>> Hans Georg Krauthäuser
> 
> After some further investigation:
> 
> In [150]:add.reduce(array(equal([0]*256,0),typecode='l'))
> Out[150]:256
> 
> In [151]:add.reduce(equal([0]*256,0))
> Out[151]:0
> 
> The problem occurs with arrays with typecode 'b' (as returned by equal).
> 
> Workaround patch for itemfreq is obvious, but ... is it a bug or a feature?
> 
> regards
> Hans Georg

I feel a bit lonely here, but, nevertheless a further remark:

The problem comes directly from the ufunc 'add' for typecode 'b'. In 
contrast to 'multiply' the typecode is not 'upcasted':

In [178]:array(array([1],'b')*2)
Out[178]:array([2],'i')

In [179]:array(array([1],'b')+array([1],'b'))
Out[179]:array([2],'b')

So, for a array a with typecode 'b' it follows that

a+a != a*2

At the moment, I don't have the time to try the new scipy_core. It would 
be nice to hear whether the problem is known or even already fixed!?

Regards
Hans Georg Krauthäuser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] no goto (WAS: Python code written in 1998...)

2006-01-20 Thread Hans Georg Krauthaeuser
Steven Bethard schrieb:
> Carl Cerecke wrote:
> 
>> Python has no goto.
> 
> 
> Not in the standard library.  You have to download the module:
> http://www.entrian.com/goto/
> 
> ;)
> 
> STeVe
This remerbers me to VATICAL, a famous programming language from the 80s.

http://www.uni-weimar.de/~mildenbe/spass/vatical/vatical.html

It's in German only and I'm not aware of a English translation.

Please be aware that content of that page is not political correct and
may offend your religious sensibilities.

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to save a running program and reload next time ?

2006-09-21 Thread Hans Georg Krauthaeuser
[EMAIL PROTECTED] wrote:
> 
> Can objects be saved and reloaded by "Pickle"  ?  I have tried but no
> success.
> 
Yes, that's the intended use of pickle/cPickle. There are examples in
the docs:

http://docs.python.org/lib/module-pickle.html

What have you tried and what didn't work?

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to save a running program and reload next time ?

2006-09-21 Thread Hans Georg Krauthaeuser
[EMAIL PROTECTED] wrote:
> Hans Georg Krauthaeuser wrote:
>> [EMAIL PROTECTED] wrote:
>>  
>>> Can objects be saved and reloaded by "Pickle"  ?  I have tried but no
>>> success.
>>>
>>> 
>> Yes, that's the intended use of pickle/cPickle. There are examples in
>> the docs:
>>
>> http://docs.python.org/lib/module-pickle.html
>>
>> What have you tried and what didn't work?
>>
>> Hans Georg
>>   
> My program is a genetic algorithm based program, so I thought I just
> need to save a generation object of the population and reload it later
> then my program could continue. But after I saved a generation object
> from within python using cPickle and reload it from another program, it
> said that some class object couldn't be found. Now I realized that a
> program cannot be suspended and reloaded by just simply dumping and
> loading using cPickle/Pickle.
> 
> I will try stackless python later.
> 
> Thanks a lot .
> 
> Regards,
> 
> xiaojf
> 
I use pickle to periodically save measured data for measurements that
take several days to finish. Actually, I save a class instance with the
data, the measurement methods and additional informations what method
was called and with what parameters. If the measurement crashes due to
some reasons, I recreate the class instance from the pickle file, call
the appropriate method with the saved parameters. Then, the method has
to look what data is already there and will continue to measure the rest.

I have no idea whether that will help you in your situation.

Anyway, I wish you all the best.

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RPy / R

2006-02-07 Thread Hans Georg Krauthaeuser
jason schrieb:
> Hello:
> 
> I installed the following:
> 
> python-2.4.2.msi
> pywin32-207.win32-py2.4.exe
> R-2.2.1-win32.exe
> rpy-0.4.6-R-2.0.0-to-2.2.1-py24.win32.exe
> 
> on a Windows XP (SP2) box.
> 
> When I try to run the following (source: 
> http://rpy.sourceforge.net/plotting-with-RPy.html) in IDLE
> 
from rpy import *
x = range(0, 10)
y = [ 2*i for i in x ]
r.plot_default(x, y)

Jason,

the example runs here without problems.

My configuration:

Python 2.3.5 (#2, Aug 30 2005, 15:50:26)
[GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] on linux2
Type "copyright", "credits" or "license()" for more information.

>>> r.version
{'status': '', 'major': '2', 'language': 'R', 'os': 'linux-gnu', 'svn
rev': '36812', 'system': 'i486, linux-gnu', 'month': '12', 'platform':
'i486-pc-linux-gnu', 'year': '2005', 'arch': 'i486', 'day': '20',
'minor': '2.1'}

Seems to be a problem with your installation...

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickling multiple dictionaries

2006-05-24 Thread Hans Georg Krauthaeuser
manstey wrote:
> Hi,
> 
> I am running a script that produces about 450,000 dictionaries. I tried
> putting them into a tuple and then pickling the tuple, but the tuple
> gets too big. Can I pickle dictionaries one after another into the same
> file and then read them out again?
> 
> Cheers,
> Matthew
> 
If you don't know, just try it:

In [1]:import pickle
In [2]:d1={'a':1}
In [3]:d2={'b':2}
In [4]:pfile=file('test.p','wb')
In [5]:pickle.dump(d1,pfile)
In [6]:pickle.dump(d2,pfile)
In [7]:pfile.close()
In [8]:del d1
In [9]:del d2
In [10]:pfile=file('test.p','rb')
In [11]:d1=pickle.load(pfile)
In [12]:d1
Out[12]:{'a': 1}
In [13]:d2=pickle.load(pfile)
In [14]:d2
Out[14]:{'b': 2}

If your data is *really* large, have a look to PyTables
(http://www.pytables.org/moin).

Regards,
Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FIR filtering

2006-03-15 Thread Hans Georg Krauthaeuser
LabWINC wrote:
> Hi all,
> i'm looking for a module to implement a digital FIR filter!
> Can anyone help me?
> 
> Thanks,
> 
> Vincent
> 
gnuradio?

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FIR filtering

2006-03-15 Thread Hans Georg Krauthaeuser
LabWINC wrote:
> What's gnuradio?
> 
http://www.gnu.org/software/gnuradio/

It's a c++ lib with a python wrapper.

BTW, thats the first hit in google ...

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FIR filtering

2006-03-15 Thread Hans Georg Krauthaeuser
LabWINC wrote:
> I can't understand how gnuradio can help me...
> I find scipy is the only way to implement a good FIR.

Well, then do it with scipy...
gnuradio has a module for FIR. I never used it. I just wanted to share
that information.

Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to determine if a line of python code is a continuation of the line above it

2006-04-09 Thread Hans Georg Krauthaeuser
Sandra-24 wrote:
> I'm not sure how complex this is, I've been brainstorming a little, and
> I've come up with:
> 
> If the previous line ended with a comma or a \ (before an optional
> comment)
> 
> That's easy to cover with a regex
> 
> But that doesn't cover everything, because this is legal:
> 
> l = [
>  1,
>  2,
>  3
>  ]
> 
> and with dictionaries and tuples as well.
> 
> Not sure how I would check for that programmatically yet.
> 
> Is there any others I'm missing?
> 
> Thanks,
> -Sandra
> 
Sandra,

in a similar situation I used 'inspect' and 'compile' like so:


import inspect

def func(*arg, **kwarg):
return get_cmd()

def get_cmd():
frame = inspect.currentframe()
outerframes = inspect.getouterframes(frame)
caller = outerframes[1][0]
ccframe = outerframes[2][0]
ccfname = outerframes[2][1]
ccmodule = inspect.getmodule(ccframe)
slines, start = inspect.getsourcelines(ccmodule)
clen = len(slines)
finfo = inspect.getframeinfo(ccframe, clen)
theindex = finfo[4]
lines = finfo[3]
theline = lines[theindex]
cmd = theline
for i in range(theindex-1, 0, -1):
line = lines[i]
try:
compile (cmd.lstrip(), '', 'exec')
except SyntaxError:
cmd = line + cmd
else:
break
return cmd

if __name__ == '__main__':
a=0
b="test"
c=42

cmd=func(a)
print cmd
cmd=func(a,
b,
c)
print cmd



output:
cmd=func(a)

cmd=func(a,
b,
c)

Regards
Hans Georg
-- 
http://mail.python.org/mailman/listinfo/python-list