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 reference Except that

Re: Reference or Value?

2009-02-24 Thread Gabriel Genellina
En Tue, 24 Feb 2009 06:44:01 -0200, andrew cooke and...@acooke.org 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

Re: Reference or Value?

2009-02-24 Thread andrew cooke
Gabriel Genellina wrote: En Tue, 24 Feb 2009 06:44:01 -0200, andrew cooke and...@acooke.org 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

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 2 - everything is passed by

Re: Reference or Value?

2009-02-24 Thread Tim Rowe
2009/2/24 Steven D'Aprano st...@pearwood.info: 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

Re: Reference or Value?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 03:54:16 -0200, Denis Kasak denis.ka...@gmail.com escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far as i understand things, the best model is: 1 -

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 thinking of

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 ste...@remove.this.cybersource.com.au 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-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 denis.ka...@gmail.com escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far

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 don't

Re: Reference or Value?

2009-02-23 Thread Denis Kasak
On Mon, Feb 23, 2009 at 8:41 PM, Christian Heimes li...@cheimes.de 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

Re: Reference or Value?

2009-02-23 Thread Steve Holden
Denis Kasak wrote: On Mon, Feb 23, 2009 at 8:41 PM, Christian Heimes li...@cheimes.de 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

Re: Reference or Value?

2009-02-23 Thread Denis Kasak
On Mon, Feb 23, 2009 at 9:12 PM, Steve Holden st...@holdenweb.com 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

Re: Reference or Value?

2009-02-23 Thread Steve Holden
Denis Kasak wrote: On Mon, Feb 23, 2009 at 9:12 PM, Steve Holden st...@holdenweb.com 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

Re: Reference or Value?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 17:17:04 -0200, Brian Blais bbl...@bryant.edu escribió: On Feb 23, 2009, at 3:03 , Gabriel Genellina wrote: En Mon, 23 Feb 2009 03:54:16 -0200, Denis Kasak denis.ka...@gmail.com escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano

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 wrong. If it were

Re: Reference or Value?

2009-02-22 Thread Denis Kasak
On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

Re: Reference or Value?

2009-02-22 Thread afriere
On Feb 23, 2:13 am, Torsten Mohr tm...@s.netic.de 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

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 there a general

Re: Reference or Value?

2009-02-22 Thread Duncan Booth
Torsten Mohr tm...@s.netic.de 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

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

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 a

Re: Reference or Value?

2009-02-22 Thread Andrew Koenig
andrew cooke and...@acooke.org 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

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 assuming

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)