Re: Python scoping

2011-06-21 Thread gervaz
On 21 Giu, 06:06, Ben Finney wrote: > Chris Angelico writes: > > On Tue, Jun 21, 2011 at 12:38 PM, Ben Finney > > wrote: > > > The *binding* is scoped. > > > And the binding follows the exact same rules as anything else would. > > It has scope and visibility. In terms of the OP, the binding IS

Re: Python scoping

2011-06-20 Thread Ben Finney
Chris Angelico writes: > On Tue, Jun 21, 2011 at 12:38 PM, Ben Finney > wrote: > > The *binding* is scoped. > > And the binding follows the exact same rules as anything else would. > It has scope and visibility. In terms of the OP, the binding IS like a > variable. Yes. So let's stop behaving

Re: Python scoping

2011-06-20 Thread Chris Angelico
On Tue, Jun 21, 2011 at 12:38 PM, Ben Finney wrote: > The *binding* is scoped. > And the binding follows the exact same rules as anything else would. It has scope and visibility. In terms of the OP, the binding IS like a variable. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Python scoping

2011-06-20 Thread Ben Finney
Chris Angelico writes: > On Tue, Jun 21, 2011 at 10:39 AM, Ben Finney > wrote: > > Instead, Python has objects, and references to those objects so you > > can get at them. The Python documentation, much to my frustration, > > calls these references “variables” even though that gives exactly >

Re: Python scoping

2011-06-20 Thread Steven D'Aprano
On Mon, 20 Jun 2011 15:35:35 -0700, gervaz wrote: > Hi all, can you explain me why this simple function works well (i.e. I > can call the print function using txt) in py > def test(value): > ... if value%5: txt = "hello" > ... else: txt = "test" > ... print(txt) > > while in oth

Re: Python scoping

2011-06-20 Thread Chris Angelico
On Tue, Jun 21, 2011 at 10:39 AM, Ben Finney wrote: > gervaz writes: > Python doesn't have variables the way C or many other languages have > them. > > Instead, Python has objects, and references to those objects so you can > get at them. The Python documentation, much to my frustration, calls >

Re: Python scoping

2011-06-20 Thread Ben Finney
gervaz writes: > Hi all, can you explain me why this simple function works well (i.e. I > can call the print function using txt) in py > > >>> def test(value): > ... if value%5: txt = "hello" > ... else: txt = "test" > ... print(txt) > > while in other languages like C the txt identif

Re: Python scoping

2011-06-20 Thread Chris Angelico
On Tue, Jun 21, 2011 at 8:35 AM, gervaz wrote: > Hi all, can you explain me why this simple function works well (i.e. I > can call the print function using txt) in py > def test(value): > ...     if value%5: txt = "hello" > ...     else: txt = "test" > ...     print(txt) It's as though you h