Re: Reference or Value?

2009-02-24 Thread Tim Rowe
2009/2/24 Steven D'Aprano : > If you look at this Wikipedia page: > > http://en.wikipedia.org/wiki/Evaluation_strategy > > you should be able to count no fewer than thirteen different terms for > different evaluation strategies, and "call-by-value" itself is described as > a family of strategies.

Re: Reference or Value?

2009-02-24 Thread Steven D'Aprano
andrew cooke wrote: > Steven D'Aprano wrote: >> On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: >> >>> Steven D'Aprano wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: > as far as i understand things, the best model is: > > 1 - everything is an object >>

Re: Reference or Value?

2009-02-24 Thread andrew cooke
Gabriel Genellina wrote: > En Tue, 24 Feb 2009 06:44:01 -0200, andrew cooke > escribió: > >> Steven D'Aprano wrote: >>> On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: >>> Steven D'Aprano wrote: > On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: > >> as far as i und

Re: Reference or Value?

2009-02-24 Thread Gabriel Genellina
En Tue, 24 Feb 2009 06:44:01 -0200, andrew cooke escribió: Steven D'Aprano wrote: On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: Steven D'Aprano wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far as i understand things, the best model is: 1 - everything is a

Re: Reference or Value?

2009-02-24 Thread andrew cooke
Steven D'Aprano wrote: > On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: > >> Steven D'Aprano wrote: >>> On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: >>> as far as i understand things, the best model is: 1 - everything is an object 2 - everything is passed by

Re: Reference or Value?

2009-02-23 Thread Steven D'Aprano
On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: > Steven D'Aprano wrote: >> On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: >> >>> as far as i understand things, the best model is: >>> >>> 1 - everything is an object >>> 2 - everything is passed by reference >> >> Except that is wr

Re: Reference or Value?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 17:17:04 -0200, Brian Blais escribió: On Feb 23, 2009, at 3:03 , Gabriel Genellina wrote: En Mon, 23 Feb 2009 03:54:16 -0200, Denis Kasak escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far a

Re: Reference or Value?

2009-02-23 Thread Steve Holden
Denis Kasak wrote: > On Mon, Feb 23, 2009 at 9:12 PM, Steve Holden wrote: >> Denis Kasak wrote: >>> I assure you I am not confused about Python's object model / calling >>> system. I was arguing, from a purely theoretical standpoint, that the >>> same system Python uses could be described in terms

Re: Reference or Value?

2009-02-23 Thread Denis Kasak
On Mon, Feb 23, 2009 at 9:12 PM, Steve Holden wrote: > Denis Kasak wrote: >> I assure you I am not confused about Python's object model / calling >> system. I was arguing, from a purely theoretical standpoint, that the >> same system Python uses could be described in terms of >> call-by-reference

Re: Reference or Value?

2009-02-23 Thread Steve Holden
Denis Kasak wrote: > On Mon, Feb 23, 2009 at 8:41 PM, Christian Heimes wrote: >> Denis Kasak wrote >>> You could, however, argue that the swap function doesn't work as >>> expected (e.g. from a Pascal or a C++ POV) simply because the >>> underlying objects aren't mutable. The objects *do* get pass

Re: Reference or Value?

2009-02-23 Thread Denis Kasak
On Mon, Feb 23, 2009 at 8:41 PM, Christian Heimes wrote: > Denis Kasak wrote >> You could, however, argue that the swap function doesn't work as >> expected (e.g. from a Pascal or a C++ POV) simply because the >> underlying objects aren't mutable. The objects *do* get passed by >> reference; > > W

Re: Reference or Value?

2009-02-23 Thread Christian Heimes
Denis Kasak wrote > You could, however, argue that the swap function doesn't work as > expected (e.g. from a Pascal or a C++ POV) simply because the > underlying objects aren't mutable. The objects *do* get passed by > reference; We are getting down the same road every couple of months. Please do

Re: Reference or Value?

2009-02-23 Thread Brian Blais
On Feb 23, 2009, at 3:03 , Gabriel Genellina wrote: En Mon, 23 Feb 2009 03:54:16 -0200, Denis Kasak escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far as i understand things, the best model is: 1 - everything

Re: Reference or Value?

2009-02-23 Thread Steve Holden
Denis Kasak wrote: > On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano > wrote: >> On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: >> >>> as far as i understand things, the best model is: >>> >>> 1 - everything is an object >>> 2 - everything is passed by reference >> Except that is wrong.

Re: Reference or Value?

2009-02-23 Thread andrew cooke
Steven D'Aprano wrote: > On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: > >> as far as i understand things, the best model is: >> >> 1 - everything is an object >> 2 - everything is passed by reference > > Except that is wrong. If it were true, you could do this: [pointer swapping] i was

Re: Reference or Value?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 03:54:16 -0200, Denis Kasak escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far as i understand things, the best model is: 1 - everything is an object 2 - everything is passed by reference

Re: Reference or Value?

2009-02-22 Thread afriere
On Feb 23, 2:13 am, Torsten Mohr wrote: > Hi, > > how is the rule in Python, if i pass objects to a function, when is this > done by reference and when is it by value? > > def f1(a): >     a = 7 > > b = 3 > f1(b) > print b > => 3 > > Integers are obviously passed by value, lists and dicts by refer

Re: Reference or Value?

2009-02-22 Thread Denis Kasak
On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano wrote: > On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: > >> as far as i understand things, the best model is: >> >> 1 - everything is an object >> 2 - everything is passed by reference > > Except that is wrong. If it were true, you could d

Re: Reference or Value?

2009-02-22 Thread Steven D'Aprano
On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: > as far as i understand things, the best model is: > > 1 - everything is an object > 2 - everything is passed by reference Except that is wrong. If it were true, you could do this: def swap(x, y): y, x = x, y a = 1 b = 2 swap(a, b)

Re: Reference or Value?

2009-02-22 Thread Steven D'Aprano
On Sun, 22 Feb 2009 16:13:02 +0100, Torsten Mohr wrote: > Hi, > > how is the rule in Python, if i pass objects to a function, when is this > done by reference and when is it by value? Never, and never. > Integers are obviously passed by value, lists and dicts by reference. Your error is assum

Re: Reference or Value?

2009-02-22 Thread Andrew Koenig
"andrew cooke" wrote in message news:mailman.464.1235320654.11746.python-l...@python.org... > as far as i understand things, the best model is: > > 1 - everything is an object > 2 - everything is passed by reference > 3 - some objects are immutable > 4 - some (immutable?) objects are cached/reus

Re: Reference or Value?

2009-02-22 Thread andrew cooke
as far as i understand things, the best model is: 1 - everything is an object 2 - everything is passed by reference 3 - some objects are immutable 4 - some (immutable?) objects are cached/reused by the system andrew Torsten Mohr wrote: > Hi, > > how is the rule in Python, if i pass objects to

Re: Reference or Value?

2009-02-22 Thread MRAB
Torsten Mohr wrote: Hi, how is the rule in Python, if i pass objects to a function, when is this done by reference and when is it by value? def f1(a): a = 7 b = 3 f1(b) print b => 3 Integers are obviously passed by value, lists and dicts by reference. Is there a general rule? Some commo

Re: Reference or Value?

2009-02-22 Thread Duncan Booth
Torsten Mohr wrote: > how is the rule in Python, if i pass objects to a function, when is this > done by reference and when is it by value? > > def f1(a): > a = 7 > > b = 3 > f1(b) > print b >=> 3 > > Integers are obviously passed by value, lists and dicts by reference. > > Is there a gen

Re: Reference or Value?

2009-02-22 Thread Christian Heimes
Torsten Mohr schrieb: > Hi, > > how is the rule in Python, if i pass objects to a function, when is this > done by reference and when is it by value? > > def f1(a): > a = 7 > > b = 3 > f1(b) > print b > => 3 > > Integers are obviously passed by value, lists and dicts by reference. > > Is t

Reference or Value?

2009-02-22 Thread Torsten Mohr
Hi, how is the rule in Python, if i pass objects to a function, when is this done by reference and when is it by value? def f1(a): a = 7 b = 3 f1(b) print b => 3 Integers are obviously passed by value, lists and dicts by reference. Is there a general rule? Some common formulation? Thank