[Wolves] python question
Ron Wellsted
ron at wellsted.org.uk
Sat Feb 28 14:06:16 GMT 2004
On Saturday 28 February 2004 13:37, sparkes wrote:
> On Sat, 2004-02-28 at 13:25, Ron Wellsted wrote:
> > On Saturday 28 February 2004 12:52, sparkes wrote:
> > > i am sure I have seen this somewhere but I can't find the command to
> > > use.
> > >
> > > I want to run a string as a python command, but how do I do it?
> >
> > python -c "python commands"
> >
> > eg
> >
> > python -c "print dir()"
> >
> > will produce the expected output. The "print" is required if you want
> > output, otherwise you will get nothing.
>
> cheers Ron but I don't think I was clear on the question I have a python
> script that will want to run a string as a series of commands inline. I
> am sure I have seen this somewhere but can't for the life of me find it
> again.
Ah, I take it you mean self-modifying code. Try
s = 'dir()'
eval(s)
--
Ron Wellsted
http://www.wellsted.org.uk
ron at wellsted.org.uk
N 52.567623, W 2.137621
More information about the Wolves
mailing list