function causing core dump

Xaver Hinterhuber xaver_hinterhuber at web.de
Mon May 17 06:15:15 EDT 2004


Hi Peter,

I now have tried it.
My problem is now, that I get unicode encoding errors.
I am working on a german windoze machine.
Could you plz give me a tip what encoding I should use (iso8859-1 and utf-8
dont't work)?

-- 
with kind regards
Xaver Hinterhuber

"Xaver Hinterhuber" <xaver_hinterhuber at web.de> schrieb im Newsbeitrag
news:c7qger$mml$1 at online.de...
> Hi Peter,
>
> "Peter Otten" <__peter__ at web.de> schrieb im Newsbeitrag
> news:c7q1vs$oph$04$1 at news.t-online.com...
> > Xaver Hinterhuber wrote:
> >
> > > I don't show you codeString because it is a real string variable.
> >
> > You could show an _example_ codeString, though. That would have greatly
> > simplified the diagnosis.
>
> For clarification: The codeString contains up to 500 lines of code. It's a
> complete program to render a pdf page with
> reportlab. It's really a huge monster. But in future I'll try give an
> example with all variables declared.
> >
> > > And yes, its uncompiled.
> > > The user in my program enters a python program in this variable
without
> a
> > > def statement
> > > and then the code is executed and the result returned.
> > >
> > > Maybe you can help me to add a "def f():" to the codeString, take care
> of
> > > the
> > > indentation and then execute the code?
> > >
> > > I really don't know how to handle the indentation thing. A "def
> > > f():\n"+codeString is easy, but this doesn't solve
> > > this issue.
> >
> > Maybe you can get away with a simple expression:
> >
> > >>> from math import *
> > >>> codeString = "sin(0.5) + 23"
> > >>> eval(codeString)
> > 23.479425538604204
> >
> > If not, try
> >
> > >>> codeString2 = "a=0.5\nb=23\nreturn sin(a) + b"
> > >>> funcString = "def f():\n    " + "\n
".join(codeString2.split("\n"))
> > >>> funcString
> > 'def f():\n    a=0.5\n    b=23\n    return sin(a) + b'
> > >>> exec funcString
> > >>> f()
> > 23.479425538604204
> > >>>
>
> Thats a good idea. I'll try it as soon as possible.
>
> Thanx
>
>





More information about the Python-list mailing list