Re: [Tutor] repr()

2005-06-07 Thread Bernard Lebel
Well, to make a long story short, this is because I use Python through another software, Softimage|XSI, and by design a string is required to pass logic to on-the-fly GUIs. Since XSI implements 3 other languages (ActivePerl, VBScript and JScript), I suppose this was designed that way with JScri

Re: [Tutor] repr()

2005-06-07 Thread jfouhy
Quoting Alan G <[EMAIL PROTECTED]>: > The other waybthat you can use repr() is by using the backtick > notation > > >>> print `s` > 'hello' > >>> It's worth noting that backticks are going out of fashion --- I think they are queued for deletion in Py3000. Better to get in the habit of just call

Re: [Tutor] repr()

2005-06-07 Thread Alan G
> The real question is, then, is there a way I can print the code of a > function as a string? Something like > > 'def myFunction: print "hello"' There is a module for doing black magic like that. I think it may be the one with the disassembler in it? Curious as to why you would ever want t

Re: [Tutor] repr()

2005-06-07 Thread Alan G
> Possibly I am missing something, but how do you use the repr() function? THere are several ways of using repr, the most common is at the >>> prompt. >>> x = 5 >>> x 5 >>> when I typed x at the >>> prompt Python called repr(x) to display the result. This can be slightly different to using print

Re: [Tutor] repr()

2005-06-07 Thread Danny Yoo
On Tue, 7 Jun 2005, Bernard Lebel wrote: > The real question is, then, is there a way I can print the code of a > function as a string? Something like > > 'def myFunction: print "hello"' Hi Bernard, Ah, ok. You can use 'inspect': http://www.python.org/doc/lib/inspect-source.html Fo

Re: [Tutor] repr()

2005-06-07 Thread Bernard Lebel
Ok thanks a lot. The real question is, then, is there a way I can print the code of a function as a string? Something like 'def myFunction: print "hello"' Thanks Bernard On 6/7/05, Max Noel <[EMAIL PROTECTED]> wrote: > > On Jun 7, 2005, at 20:42, Bernard Lebel wrote: > > > repr( myFunc

Re: [Tutor] repr()

2005-06-07 Thread Terry Carroll
On Tue, 7 Jun 2005, Bernard Lebel wrote: > repr( myFunc ) > '' > > > > s = repr( myFunc() ) > print s > > 'None' In the first example, your repr invocation is: repr(myFunc) i.e., you're asking for the repr of the function myFunc. In the second example, your repr invocation is: repr(my

Re: [Tutor] repr()

2005-06-07 Thread Danny Yoo
> Okay then I run > > s = repr( myFunc() ) > print s > > Wich returns > > 'None' Hi Bernard, Ok, what do you expect to see instead of 'None'? I ask this to make sure I understand the situation better. Best of wishes? ___ Tutor maillist - Tutor@py

Re: [Tutor] repr()

2005-06-07 Thread Max Noel
On Jun 7, 2005, at 20:42, Bernard Lebel wrote: > repr( myFunc ) > > Wich returns > > '' > > > Okay then I run > > s = repr( myFunc() ) > print s > > Wich returns > > 'None' That's perfectly normal. Your last assignment calls the function, then assigns to s the representation of the functi

[Tutor] repr()

2005-06-07 Thread Bernard Lebel
Hello, Possibly I am missing something, but how do you use the repr() function? I type this ultra-simple function: def myFunc(): print 'hello' Then run repr( myFunc ) Wich returns '' Okay then I run s = repr( myFunc() ) print s Wich returns 'None' Thanks Bernard __