ce
training.
Thanks for your patience.
Jim
-Original Message-
From: tutor-bounces+james.homme=highmark@python.org
[mailto:tutor-bounces+james.homme=highmark@python.org] On Behalf Of Alan
Gauld
Sent: Monday, December 12, 2011 2:58 PM
To: tutor@python.org
Subject: Re: [Tutor] Need
James H wrote:
Is that the same problem with using the len function on sequences
> and open on files, or is it different?
I don't think so. I'm not sure which problem you are referring to with
these?
Neither return None...
But a python list is mutable. I'm hardly an expert, but the idea is
A()
creates an instance of A.
But like I said I'm not an expert.
> -Original Message-
> From: tutor-bounces+james.homme=highmark@python.org
> [mailto:tutor-bounces+james.homme=highmark@python.org] On Behalf Of Alan
> Gauld
> Sent: Saturday, December 10, 2011
...@python.org] On Behalf Of Alan
Gauld
Sent: Saturday, December 10, 2011 4:16 AM
To: tutor@python.org
Subject: Re: [Tutor] Need Explanation...
On 10/12/11 07:41, sunil tech wrote:
> /def app(x):/
> / return x.append(100)/
> /
> /p = app(a)/
> /
> /now list holds appended val
*Thank you all...*
*for your previous time. :)
*
On Sun, Dec 11, 2011 at 2:56 PM, Alan Gauld wrote:
> On 11/12/11 03:23, Lie Ryan wrote:
>
> If returning 'self' is the default expected behavior, it would cause
>> inconsistencies with respect to immutable types. For example, `5
>> .__add__(2)`, on
On 11/12/11 03:23, Lie Ryan wrote:
If returning 'self' is the default expected behavior, it would cause
inconsistencies with respect to immutable types. For example, `5
.__add__(2)`, one could expect it to return 5 instead of 7.
That's not a case where default behaviour would be invoked.
I'm t
On 12/11/2011 04:04 AM, Alan Gauld wrote:
On 10/12/11 16:46, Steven D'Aprano wrote:
circumstances, regardless of which behaviour was choosen for append, it
would catch out some people some time.
Probably, although if returning 'self' were the default (which
of course only makes sense in a pure
>> Smalltalk's mechanism stands in stark contrast to the mixed
>> model in Python. (OTOH Smalltalk overall is a frustrating
>> experience for me, I would like to love it but never quite
>> get there... :-)
>
>Personally, I found that returning a copy of a seemed more logical- after all,
>if you
On Dec 10, 2011, at 12:04 PM, Alan Gauld wrote:
> On 10/12/11 16:46, Steven D'Aprano wrote:
>
>> ...the alternative would also have caught out everybody at some point.
>> Consider a hypothetical Python where mutator methods returned a result:
>>
>> a = [1, 2, 3]
>> b = a.append(4)
>>
>> Does t
On 10/12/11 16:46, Steven D'Aprano wrote:
...the alternative would also have caught out everybody at some point.
Consider a hypothetical Python where mutator methods returned a result:
a = [1, 2, 3]
b = a.append(4)
Does this mean...?
* append 4 to a, then return a (and therefore a and b are
a
Alan Gauld wrote:
[...]
Because app() returns the result of append().
But append() returns None, since it modifies the list in place.
This is one of the few features of Python I dislike. It would not have
been difficult to make these modifier methods return the thing modified.
This style would
On 10/12/11 07:41, sunil tech wrote:
/def app(x):/
/ return x.append(100)/
/
/p = app(a)/
/
/now list holds appended value [1,2,3,100]/
/but p is empty... why it is?/
Because app() returns the result of append().
But append() returns None, since it modifies the list in place.
This is one
On Sat, Dec 10, 2011 at 1:11 PM, sunil tech wrote:
> hi,
>
> Consider a list: a = [1,2,3]
>
> & a simple function, which when called it will append 100 to the list.
>
> def app(x):
> return x.append(100)
>
> p = app(a)
>
> now list holds appended value [1,2,3,100]
> but p is empty... why it i
*hi,*
*
*
*Consider a list: a = [1,2,3]*
*
*
*& a simple function, which when called it will append 100 to the list.*
*
*
*def app(x):*
* return x.append(100)*
*
*
*p = app(a)*
*
*
*now list holds appended value [1,2,3,100]*
*but p is empty... why it is?*
*
*
*please teach.*
___
14 matches
Mail list logo