Re: Immutable and Mutable Types

2008-03-18 Thread Duncan Booth
Stargaming [EMAIL PROTECTED] wrote: On Mon, 17 Mar 2008 16:03:19 +, Duncan Booth wrote: For the answer I actually want each asterisk substitutes for exactly one character. Played around a bit and found that one: Python 3.0a3+ (py3k:61352, Mar 12 2008, 12:58:20) [GCC 4.2.3 20080114

Re: Immutable and Mutable Types

2008-03-18 Thread Terry Reedy
Duncan Booth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Stargaming [EMAIL PROTECTED] wrote: | | On Mon, 17 Mar 2008 16:03:19 +, Duncan Booth wrote: | | For the answer I actually want each asterisk substitutes for exactly one | character. | | Played around a bit and

Immutable and Mutable Types

2008-03-17 Thread Bernard Lim
Hi, I'm reading the Python Reference Manual in order to gain a better understanding of Python under the hood. On the last paragraph of 3.1, there is a statement on immutable and mutable types as such: paraphrase Depending on implementation, for immutable types, operations that compute new

Re: Immutable and Mutable Types

2008-03-17 Thread Dan Bishop
Bernard Lim wrote: Hi, I'm reading the Python Reference Manual in order to gain a better understanding of Python under the hood. On the last paragraph of 3.1, there is a statement on immutable and mutable types as such: paraphrase Depending on implementation, for immutable types

Re: Immutable and Mutable Types

2008-03-17 Thread Ben Finney
Bernard Lim [EMAIL PROTECTED] writes: paraphrase Depending on implementation, for immutable types, operations that compute new values may or may not actually return a reference to any existing object with the same type and value, while for mutable objects this is (strictly)? not allowed.

Re: Immutable and Mutable Types

2008-03-17 Thread cokofreedom
a = 1 b = 1 a is b True id(a) 10901000 id(b) 10901000 Isn't this because integers up to a certain range are held in a single memory location, thus why they are the same? -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutable and Mutable Types

2008-03-17 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: a = 1 b = 1 a is b True id(a) 10901000 id(b) 10901000 Isn't this because integers up to a certain range are held in a single memory location, thus why they are the same? As the OP said: paraphrase Depending on implementation, for immutable types,

Re: Immutable and Mutable Types

2008-03-17 Thread Duncan Booth
Diez B. Roggisch [EMAIL PROTECTED] wrote: Which is exactly what happens - the actual implementation chose to cache some values based on heuristics or common sense - but no guarantees are made in either way. Here's a puzzle for those who think they know Python: Given that I masked out part of

Re: Immutable and Mutable Types

2008-03-17 Thread Duncan Booth
[EMAIL PROTECTED] wrote: a = 1 b = 1 a is b True id(a) 10901000 id(b) 10901000 Isn't this because integers up to a certain range are held in a single memory location, thus why they are the same? Yes, in *some* implementations of Python this is exactly what happens. The exact

Re: Immutable and Mutable Types

2008-03-17 Thread Steven D'Aprano
On Mon, 17 Mar 2008 10:40:43 +, Duncan Booth wrote: Here's a puzzle for those who think they know Python: Given that I masked out part of the input, which version(s) of Python might give the following output, and what might I have replaced by asterisks? There's too many variables -- at

Re: Immutable and Mutable Types

2008-03-17 Thread Stargaming
On Mon, 17 Mar 2008 10:40:43 +, Duncan Booth wrote: Here's a puzzle for those who think they know Python: Given that I masked out part of the input, which version(s) of Python might give the following output, and what might I have replaced by asterisks? a = 1 b = if a is b:

Re: Immutable and Mutable Types

2008-03-17 Thread Duncan Booth
Steven D'Aprano [EMAIL PROTECTED] wrote: On Mon, 17 Mar 2008 10:40:43 +, Duncan Booth wrote: Here's a puzzle for those who think they know Python: Given that I masked out part of the input, which version(s) of Python might give the following output, and what might I have replaced by

Re: Immutable and Mutable Types

2008-03-17 Thread Duncan Booth
Stargaming [EMAIL PROTECTED] wrote: On Mon, 17 Mar 2008 10:40:43 +, Duncan Booth wrote: Here's a puzzle for those who think they know Python: Given that I masked out part of the input, which version(s) of Python might give the following output, and what might I have replaced by

Re: Immutable and Mutable Types

2008-03-17 Thread Stargaming
On Mon, 17 Mar 2008 16:03:19 +, Duncan Booth wrote: For the answer I actually want each asterisk substitutes for exactly one character. Played around a bit and found that one: Python 3.0a3+ (py3k:61352, Mar 12 2008, 12:58:20) [GCC 4.2.3 20080114 (prerelease) (Debian 4.2.2-7)] on linux2

Re: Immutable and Mutable Types

2008-03-17 Thread Duncan Booth
Stargaming [EMAIL PROTECTED] wrote: On Mon, 17 Mar 2008 16:03:19 +, Duncan Booth wrote: For the answer I actually want each asterisk substitutes for exactly one character. Played around a bit and found that one: Python 3.0a3+ (py3k:61352, Mar 12 2008, 12:58:20) [GCC 4.2.3 20080114

Re: Immutable and Mutable Types

2008-03-17 Thread Matthew Woodcraft
In article [EMAIL PROTECTED], Duncan Booth [EMAIL PROTECTED] wrote: I don't have a copy of 1.4 to check so I'll believe you, but you can certainly get the output I asked for with much more recent versions. For the answer I actually want each asterisk substitutes for exactly one character.

Re: Immutable and Mutable Types

2008-03-17 Thread Duncan Booth
Matthew Woodcraft [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Duncan Booth [EMAIL PROTECTED] wrote: I don't have a copy of 1.4 to check so I'll believe you, but you can certainly get the output I asked for with much more recent versions. For the answer I actually want each