En Fri, 11 Jul 2008 03:51:39 -0300, Uwe Schmitt
<[EMAIL PROTECTED]> escribi�:
On 1 Jul., 15:15, Mel <[EMAIL PROTECTED]> wrote:
rocksportrockerwrote:
> the following code does not work until I ommit the "a=0" statement.
> def test():
> exec "a=3" in locals()
> print a
>
Uwe Schmitt wrote:
>> Apparently, exec in locals() knows nothing about slots (because locals()
>> is the only dictionary in the universe where slots would be involved ? --
>> perhaps not, but close).
>>
>> Mel.
>
> Thanks for your answer. I wonder if this is a bug, or did I miss
> something in th
On 1 Jul., 15:15, Mel <[EMAIL PROTECTED]> wrote:
> rocksportrockerwrote:
>
> > Hi,
>
> > the following code does not work until I ommit the "a=0" statement.
>
> > def test():
> > exec "a=3" in locals()
> > print a
> > a=0
>
> > test()
>
> > print raises:
> > Unbound
rocksportrocker wrote:
>
> Hi,
>
> the following code does not work until I ommit the "a=0" statement.
>
>
>def test():
>exec "a=3" in locals()
>print a
>a=0
>
> test()
>
> print raises:
> UnboundLocalError: local variable 'a' referenced before
> assignme
On Mar 14, 2008, at 4:41 AM, [EMAIL PROTECTED] wrote:
> On Mar 14, 9:47 am, Justus Schwabedal <[EMAIL PROTECTED]>
> wrote:
> [snipped]
>> However when I do this:
>>
>> bash-3.2$ cat execBug2.py
>> #! /usr/bin/python
>> header="""
>> from scipy import randn
>> def f():
>> return randn()
>>
On Mar 14, 9:47 am, Justus Schwabedal <[EMAIL PROTECTED]>
wrote:
[snipped]
> However when I do this:
>
> bash-3.2$ cat execBug2.py
> #! /usr/bin/python
> header="""
> from scipy import randn
> def f():
> return randn()
> """
> def g():
> exec header
> return f()
> print "
On 23 srp, 09:19, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Sun, 22 Jul 2007 10:36:59 -0300, <[EMAIL PROTECTED]>
> escribió:
>
> >> Since the application is transforming
> >> its input, it could transform braces into indentation. Of course
> >> *Python*
> >> doesn't use braces, but the qu
En Sun, 22 Jul 2007 10:36:59 -0300, <[EMAIL PROTECTED]>
escribió:
>> Since the application is transforming
>> its input, it could transform braces into indentation. Of course
>> *Python*
>> doesn't use braces, but the question was how to write "pseudo-Python"
>> without using indentation to in
Steven D'Aprano wrote:
> On Sun, 22 Jul 2007 09:12:21 -0400, Steve Holden wrote:
>
>
>>> Steve Holden was playing silly games. You can't use { } for indentation.
>>> You have to use indentation.
>>>
>> I wasn't playing silly games at all, and I did prefix that part ofmy
>> answer with "I'm afrai
On Sun, 22 Jul 2007 09:12:21 -0400, Steve Holden wrote:
>> Steve Holden was playing silly games. You can't use { } for indentation.
>> You have to use indentation.
>>
> I wasn't playing silly games at all, and I did prefix that part ofmy
> answer with "I'm afraid I don't understand this questio
> I wasn't playing silly games at all, and I did prefix that part ofmy
> answer with "I'm afraid I don't understand this question". The OP is
> writing a program to "translate" a Python-like language that uses
> non-English keywords into Python. Since the application is transforming
> its input, it
Steven D'Aprano wrote:
> On Sun, 22 Jul 2007 03:23:30 -0700, vedrandekovic wrote:
>
>> Thanks for everything previously, but just to I ask about code
>> indentation,this with { and } doesn't
>> employed, here is my example how can I solve this about code
>> indentation:
>>
> n=90
> if n==9
On Sun, 22 Jul 2007 03:23:30 -0700, vedrandekovic wrote:
> Thanks for everything previously, but just to I ask about code
> indentation,this with { and } doesn't
> employed, here is my example how can I solve this about code
> indentation:
>
n=90
if n==90:
> {print "bok kjai ma'
On 21 srp, 22:31, Steve Holden <[EMAIL PROTECTED]> wrote:
> ...:::JA:::... wrote:
> > Hello,
>
> > After my program read and translate this code:
>
> > koristi os,sys;
> > ispisi 'bok kaj ima';
>
> > into the:
>
> > import os,sys;
> > print 'bok kaj ima';
>
> > and when it run this code with "exec"
On Sat, 21 Jul 2007 16:31:38 -0400, Steve Holden wrote:
> I'm afraid I don't understand this question. If you are talking about
> the indentation of the code, if you don't want indentation you will have
> to use braces - { and } - to indicate the nesting structure of your program.
Oh my, teasin
...:::JA:::... wrote:
> Hello,
>
> After my program read and translate this code:
>
> koristi os,sys;
> ispisi 'bok kaj ima';
>
> into the:
>
> import os,sys;
> print 'bok kaj ima';
>
> and when it run this code with "exec", I always get error like this, but I
> still dont't know what is a pro
Op 2005-12-16, Peter Otten schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>
>> I'm using PLY. The assign function is a dumbded down version
>> of a production function that will be called during the parsing
>> of a config file. Each time a line of the form:
>>
>> var = val
>>
>> is encounte
Peter Otten wrote:
>
> If you could provide a function with a different namespace when it's called,
> e. g
>
> f() in namespace
>
> would look up its globals in namespace, that might be an interesting concept
> but it's not how Python works.
>
> Peter
>
It does seem like an interesting concep
Antoon Pardon wrote:
> Op 2005-12-16, Larry Bates schreef <[EMAIL PROTECTED]>:
>> Antoon Pardon wrote:
>>> I have the following little piece of code:
>>>
>>> class Cfg:pass
>>> #config = Cfg()
>>>
>>> def assign():
>>> setattr(config, 'Start' , [13, 26, 29, 34])
>>>
>>> def foo():
>>> confi
Antoon Pardon wrote:
> And from the documentation
> from exec I get the impression you can use it so that a function
> will have temporarily a different reference to global namespace.
That impression confuses two things:
(1) A function object carries a global namespace with it. That namespace
Op 2005-12-16, Larry Bates schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> I have the following little piece of code:
>>
>> class Cfg:pass
>> #config = Cfg()
>>
>> def assign():
>> setattr(config, 'Start' , [13, 26, 29, 34])
>>
>> def foo():
>> config = Cfg()
>> dct = {'config':conf
Op 2005-12-16, Peter Otten schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>
>> I have the following little piece of code:
>>
>> class Cfg:pass
>> #config = Cfg()
>>
>> def assign():
>> setattr(config, 'Start' , [13, 26, 29, 34])
>>
>> def foo():
>> config = Cfg()
>> dct = {'config':co
Antoon Pardon wrote:
> I have the following little piece of code:
>
> class Cfg:pass
> #config = Cfg()
>
> def assign():
> setattr(config, 'Start' , [13, 26, 29, 34])
>
> def foo():
> config = Cfg()
> dct = {'config':config, 'assign':assign}
> exec "assign()" in dct
> print config.Start
Antoon Pardon wrote:
> I have the following little piece of code:
>
> class Cfg:pass
> #config = Cfg()
>
> def assign():
> setattr(config, 'Start' , [13, 26, 29, 34])
>
> def foo():
> config = Cfg()
> dct = {'config':config, 'assign':assign}
> exec "assign()" in dct
> print config.Sta
Antoon Pardon wrote:
> I have the following little piece of code:
>
> class Cfg:pass
> #config = Cfg()
>
> def assign():
> setattr(config, 'Start' , [13, 26, 29, 34])
>
> def foo():
> config = Cfg()
> dct = {'config':config, 'assign':assign}
> exec "assign()" in dct
> print config.Sta
Antoon Pardon wrote:
> I have the following little piece of code:
>
> class Cfg:pass
> #config = Cfg()
>
> def assign():
> setattr(config, 'Start' , [13, 26, 29, 34])
>
> def foo():
> config = Cfg()
> dct = {'config':config, 'assign':assign}
> exec "assign()" in dct
> print config.Star
26 matches
Mail list logo