On 04/05/14 13:54, Dave Angel wrote:
Alan Gauld Wrote in message:
I assumed (never assume!) that it returned a reference to the original.
I really, really, hate the way Python handles this :-(
It's not clear to me what you would change. Would you only provide
methods (like sort) that mang
Alan Gauld Wrote in message:
>>> (not a copy!) to the sorted item.
>>
>> sorted() does make a copy of the list:
>
> Really? That's a bummer.
> I assumed (never assume!) that it returned a reference to the original.
> I really, really, hate the way Python handles this :-(
>
It's not clear to me
On 04/05/14 11:31, Steven D'Aprano wrote:
On Sun, May 04, 2014 at 10:00:08AM +0100, Alan Gauld wrote:
For the specific case of sort you can always use
the sorted() function which does return a reference
(not a copy!) to the sorted item.
sorted() does make a copy of the list:
Really? That's
On Sun, May 04, 2014 at 10:00:08AM +0100, Alan Gauld wrote:
> For the specific case of sort you can always use
> the sorted() function which does return a reference
> (not a copy!) to the sorted item.
sorted() does make a copy of the list:
py> a = [2, 5, 3, 4, 1]
py> sorted(a), a
([1, 2, 3, 4,
On 28/04/14 19:45, taserian wrote:
I can't claim to be new to programming, but I've dabbled in Python over
and over again to get small problems and puzzles resolved. One thing
that I find I can't keep straight are the methods that change a list in
place, vs. those that return a copy (sometimes tr
On 28Apr2014 14:45, taserian wrote:
I can't claim to be new to programming, but I've dabbled in Python over and
over again to get small problems and puzzles resolved. One thing that I
find I can't keep straight are the methods that change a list in place, vs.
those that return a copy (sometimes
On 4/28/2014 11:45 AM, taserian wrote:
Is there some sort of rule-of-thumb to determine if a function is
in-place or returns a value?
my rule of thumb is to ask:
Python 2.7.5 (default, May 15 2013, 22:44:16)
[MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license
Hi Antonio,
Unfortunately, I don't think it's apparent whether or not a function
applies mutations or is a pure computation. In Python, those are by
convention or documentation rather than part of the language. There
are other programming languages can control the effects and scope of
mutation,
I can't claim to be new to programming, but I've dabbled in Python over and
over again to get small problems and puzzles resolved. One thing that I
find I can't keep straight are the methods that change a list in place, vs.
those that return a copy (sometimes transformed) of the list.
Call me old-