"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote, oder schrieb, of het geskryf:
| Hendrik van Rooyen schrieb:
| > Hi,
| >
| > for S where S is a Standard Python type:
| > The slice notation S[n] returns either:
| > The n'th element of S, or
| > The value of the dictionary entry who
"Paul Boddie" <[EMAIL PROTECTED]> Wrote:
| Hendrik van Rooyen wrote:
| >
| > There seems to be no common methods such as-
| > "prepend" - for adding something to the beginning
| > "append" - for adding something to the end
| > "insert[j]" - for adding something somewhere in the middle
Brendon Towle wrote:
>> b) http://pyfaq.infogami.com/why-doesn-t-list-sort-return-the-sorted-list
>>(this also explains how to handle your specific use case)
>
> Well, I posted working code, so I thought it should have been obvious
> that I knew how to handle my use case, and was (am) lookin
Brendon Towle wrote:
> My third response is that it's *always* possible to shoot yourself in
> the foot. Protecting a naive user from one particular metatarsal
> projectile insertion at the expense of letting the power-user write more
> concise code seems a bad tradeoff to me -- but, I'm not in
"Brendon Towle" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]...
Message: 3
Date: Fri, 25 Aug 2006 15:28:46 +0200
From: "Fredrik Lundh" <[EMAIL PROTECTED]>
Subject: Re: Consistency in Python
Brendon Towle wr
Message: 3 Date: Fri, 25 Aug 2006 15:28:46 +0200 From: "Fredrik Lundh" <[EMAIL PROTECTED]> Subject: Re: Consistency in Python Brendon Towle wrote: So, my question is: Someone obviously thought that it was wise and proper to require the longer versions that I write above. Why? a
Brendon Towle wrote:
> So, my question is: Someone obviously thought that it was wise and
> proper to require the longer versions that I write above. Why?
a) maybe they had a working carriage return key ?
b) http://pyfaq.infogami.com/why-doesn-t-list-sort-return-the-sorted-list
(this also exp
Date: 25 Aug 2006 04:22:37 -0700From: "Paul Boddie" <[EMAIL PROTECTED]>Subject: Re: Consistency in PythonTo: python-list@python.orgMessage-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; charset="iso-8859-1"Paul McGuire wrote: But with mutators that return self, a client could write any of these:b
Paul McGuire wrote:
>
> There's nothing wrong with returning self from a mutator. This was a common
> idiom in Smalltalk (the syntax for this was "^self", which was probably the
> most common statement in any Smalltalk program), and permitted the chaining
> of property mutators into a single line,
"Paul Boddie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Moreover, append and insert return
> no result because the change occurs within an existing object - if you
> were to return a reference to the changed object, it would be the same
> reference as the one you already had.
Hendrik van Rooyen wrote:
>
> There seems to be no common methods such as-
> "prepend" - for adding something to the beginning
> "append" - for adding something to the end
> "insert[j]" - for adding something somewhere in the middle
>
> Or have I missed something ?
[...]
> BTW - I und
Hendrik van Rooyen schrieb:
> Hi,
>
> for S where S is a Standard Python type:
> The slice notation S[n] returns either:
> The n'th element of S, or
> The value of the dictionary entry whose key is n.
>
> This is beautiful because as a programmer you don't have to worry what S
Hi,
for S where S is a Standard Python type:
The slice notation S[n] returns either:
The n'th element of S, or
The value of the dictionary entry whose key is n.
This is beautiful because as a programmer you don't have to worry what S is...
(and as an aside - This consistency h
"Robert Kern" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> In many, many fonts 'l' and '1' look close enough to be easily mistaken
> for one another
In the default font used by Outlook Express, displayed on my 1078x786
screen, the only difference I can see, using a magnifying g
James wrote:
[James Stroud wrote:]
>>Also, you shouldn't use "1", I mean "l", as a variable name. It gets confusing
>>because "l", I mean "1", looks a lot like "1", I mean "l".
>
> I have seen the same warnning above significantly several times.
> Is this problem originally came from the similari
Steve Holden wrote:
> Kay Schluehr wrote:
> > Mike Meyer wrote:
> >
> >
> >>Yes, but the function "sorted" is more useful than a list method
> >>"sorted" in a duck typing language.
> >
> >
> > I don't see what this has to do with "duck typing"? sorted() is simply
> > a generic function accepting d
> Also, you shouldn't use "1", I mean "l", as a variable name. It gets confusing
> because "l", I mean "1", looks a lot like "1", I mean "l".
I have seen the same warnning above significantly several times.
Is this problem originally came from the similarities between 'l' and
'1'
or from bad looki
Kay Schluehr wrote:
> Mike Meyer wrote:
>
>
>>Yes, but the function "sorted" is more useful than a list method
>>"sorted" in a duck typing language.
>
>
> I don't see what this has to do with "duck typing"? sorted() is simply
> a generic function accepting different types. I'm not aware that
>
Terry Reedy wrote:
> "Kay Schluehr" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > On the other hand there exists no sorted() method for tuples or lists
> > like join() for strings but it is implemented as a function in Python24
> > that returns a new sorted container. I consider
Mike Meyer wrote:
> Yes, but the function "sorted" is more useful than a list method
> "sorted" in a duck typing language.
I don't see what this has to do with "duck typing"? sorted() is simply
a generic function accepting different types. I'm not aware that
sorted() requires a specific interface
"Kay Schluehr" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On the other hand there exists no sorted() method for tuples or lists
> like join() for strings but it is implemented as a function in Python24
> that returns a new sorted container. I consider this as an
> inconsistency
"Kay Schluehr" <[EMAIL PROTECTED]> writes:
> If you define
>
sep = ""
sep.join(["d","o","g"])
> "dog"
sep
> ''
>
> sep is preserved and a new "dog" string is generated. Since sep is
> immutable there is no way to manipulate it inplace.
>
> On the other hand there exists no sorted() m
Dave Benjamin <[EMAIL PROTECTED]> writes:
> Mike Meyer wrote:
>> Dave Benjamin <[EMAIL PROTECTED]> writes:
>>>Python is actually quite consistent in this regard: methods that
>>>modify an object in-place return None;
>> Um, no. list.pop comes to mind as an immediate counterexample. It may
>> be the
[EMAIL PROTECTED] wrote:
> Let's say I define a list of pairs as follows:
> >>l = [('d', 3), ('a', 2), ('b', 1)]
>
> Can anyone explain why this does not work?
> >>h = {}.update(l)
>
> and instead I have to go:
> >>h = {}
> >>h.update(l)
> to initialize a dictionary with the given list of pairs?
>
Dave Benjamin wrote:
> Mike Meyer wrote:
>> Dave Benjamin <[EMAIL PROTECTED]> writes:
>>
>>>Python is actually quite consistent in this regard: methods that
>>>modify an object in-place return None;
>>
>> Um, no. list.pop comes to mind as an immediate counterexample. It may
>> be the only one...
Mike Meyer wrote:
> Dave Benjamin <[EMAIL PROTECTED]> writes:
>
>>Python is actually quite consistent in this regard: methods that
>>modify an object in-place return None;
>
> Um, no. list.pop comes to mind as an immediate counterexample. It may
> be the only one...
I'm sure there are counterexa
Dave Benjamin <[EMAIL PROTECTED]> writes:
> Python is actually quite consistent in this regard: methods that
> modify an object in-place return None;
Um, no. list.pop comes to mind as an immediate counterexample. It may
be the only one...
http://www.mired.org/home/mwm/
Indepe
[EMAIL PROTECTED] wrote:
> Let's say I define a list of pairs as follows:
>
>>>l = [('d', 3), ('a', 2), ('b', 1)]
>
>
> Can anyone explain why this does not work?
>
>>>h = {}.update(l)
>
>
> and instead I have to go:
>
>>>h = {}
>>>h.update(l)
>
> to initialize a dictionary with the given l
On 8 Sep 2005 16:03:12 -0700, [EMAIL PROTECTED] wrote:
>Let's say I define a list of pairs as follows:
>>>l = [('d', 3), ('a', 2), ('b', 1)]
>
>Can anyone explain why this does not work?
>>>h = {}.update(l)
>
>and instead I have to go:
>>>h = {}
>>>h.update(l)
>to initialize a dictionary with the
update updates the dictionary in place - it actually returns None, not
the updated dict. However, you can construct a dictionary from a list
of (key, value) pairs using dict(list). Example:
>>>l = [('foo', 'bar'), ('baz', 'qig')]
>>>d = dict(l)
>>>print d
{'foo': 'bar', 'baz': 'qig'}
--
http://m
This is the difference between mutable and immutable types. In this sense it
is consistent.
If you want to do the former in one shot:
h = dict(l)
Also, you shouldn't use "1", I mean "l", as a variable name. It gets confusing
because "l", I mean "1", looks a lot like "1", I mean "l".
James
Let's say I define a list of pairs as follows:
>>l = [('d', 3), ('a', 2), ('b', 1)]
Can anyone explain why this does not work?
>>h = {}.update(l)
and instead I have to go:
>>h = {}
>>h.update(l)
to initialize a dictionary with the given list of pairs?
when an analagous operation on strings works
32 matches
Mail list logo