Seebs wrote:
> On 2010-10-07, TP wrote:
>> Diez B. Roggisch wrote:
>>> A safer alternative for these cases is using tuples, because they are
>>> immutable.
>
>> The problem with tuples is that it is not easy to modify them:
>
> This is probably the best post-and-response I've seen in the last c
On 10/6/2010 3:22 PM, TP wrote:
Hi,
I have a function f that calls itself recursively. It has a list as second
argument, with default argument equal to None (and not [], as indicated at:
http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
This sort of function is an exception. I
TP writes:
> Diez B. Roggisch wrote:
>
>> Back to your example: your solution is perfectly fine, although a bit
>> costly and more error-prone if you happen to forget to create a copy.
>> A safer alternative for these cases is using tuples, because they are
>> immutable.
>
> Thanks Diez for your
On Wed, Oct 6, 2010 at 10:25 PM, TP wrote:
> Diez B. Roggisch wrote:
>
>> Back to your example: your solution is perfectly fine, although a bit
>> costly and more error-prone if you happen to forget to create a copy.
>> A safer alternative for these cases is using tuples, because they are
>> immut
On 2010-10-07, TP wrote:
> Diez B. Roggisch wrote:
>> A safer alternative for these cases is using tuples, because they are
>> immutable.
> The problem with tuples is that it is not easy to modify them:
This is probably the best post-and-response I've seen in the last couple
of months.
-s
--
C
Steven D'Aprano wrote:
>> I think I prefer doing an explicit copy.copy, because it allows to
>> remind the reader that it is very important to take care of that.
>
> I think a comment is better for that. It's better to explicitly say
> something is important than to assume the reader will guess.
Diez B. Roggisch wrote:
> Back to your example: your solution is perfectly fine, although a bit
> costly and more error-prone if you happen to forget to create a copy.
> A safer alternative for these cases is using tuples, because they are
> immutable.
Thanks Diez for your explanation.
The proble
On Wed, 06 Oct 2010 23:00:10 +0200, TP wrote:
> I think I prefer doing an explicit copy.copy, because it allows to
> remind the reader that it is very important to take care of that.
I think a comment is better for that. It's better to explicitly say
something is important than to assume the re
TP writes:
> Hi,
>
> I have a function f that calls itself recursively. It has a list as second
> argument, with default argument equal to None (and not [], as indicated at:
> http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
>
> This is the outline of my function:
>
> def f ( a
Chris Torek wrote:
>>import copy from copy
>
> [from copy import copy, rather]
Yes, sorry.
> Note that if f() is *supposed* to be able to modify its second
> parameter under some conditions, you would want to make the copy
> not at the top of f() but rather further in, and in this case,
> that
In article
TP wrote:
>I have a function f that calls itself recursively. It has a list as second
>argument, with default argument equal to None (and not [], as indicated at:
>http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
>
>This is the outline of my function:
>
>def f ( arg
Hi,
I have a function f that calls itself recursively. It has a list as second
argument, with default argument equal to None (and not [], as indicated at:
http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
This is the outline of my function:
def f ( argument, some_list = None ):
12 matches
Mail list logo