Re: Question about consistency in python language

2005-09-11 Thread Terry Reedy
"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

Re: Question about consistency in python language

2005-09-11 Thread Robert Kern
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

Re: Question about consistency in python language

2005-09-11 Thread Kay Schluehr
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

Re: Question about consistency in python language

2005-09-11 Thread James
> 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

Re: Question about consistency in python language

2005-09-10 Thread Steve Holden
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 >

Re: Question about consistency in python language

2005-09-09 Thread Kay Schluehr
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

Re: Question about consistency in python language

2005-09-09 Thread Kay Schluehr
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

Re: Question about consistency in python language

2005-09-09 Thread Terry Reedy
"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

Re: Question about consistency in python language

2005-09-09 Thread Mike Meyer
"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

Re: Question about consistency in python language

2005-09-09 Thread Mike Meyer
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

Re: Question about consistency in python language

2005-09-08 Thread Kay Schluehr
[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? >

Re: Question about consistency in python language

2005-09-08 Thread Erik Max Francis
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...

Re: Question about consistency in python language

2005-09-08 Thread Dave Benjamin
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

Re: Question about consistency in python language

2005-09-08 Thread Mike Meyer
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

Re: Question about consistency in python language

2005-09-08 Thread Dave Benjamin
[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

Re: Question about consistency in python language

2005-09-08 Thread Bengt Richter
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

Re: Question about consistency in python language

2005-09-08 Thread Sam Pointon
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

Re: Question about consistency in python language

2005-09-08 Thread James Stroud
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

Question about consistency in python language

2005-09-08 Thread lechequier
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