On Tue, 19 Feb 2013 22:38:32 -0500, Terry Reedy wrote:
> On 2/18/2013 7:18 PM, Steven D'Aprano wrote:
>> Terry Reedy wrote:
>>
>>> On 2/18/2013 6:47 AM, John Reid wrote:
>>>
I was hoping namedtuples could be used as replacements for tuples
in all instances.
>>>
>>> This is a mistake in
In article ,
Chris Angelico wrote:
> On Wed, Feb 20, 2013 at 2:38 PM, Terry Reedy wrote:
> > Liskov Substitution Principle (LSP): I met this over 15 years ago reading
> > debates among OOP enthusiasts about whether Rectangle should be a subclass
> > of Square or Square a subclass of Rectangle,
On Wed, Feb 20, 2013 at 2:38 PM, Terry Reedy wrote:
> Liskov Substitution Principle (LSP): I met this over 15 years ago reading
> debates among OOP enthusiasts about whether Rectangle should be a subclass
> of Square or Square a subclass of Rectangle, and similarly, whether Ostrich
> can be a legi
On 2/18/2013 7:18 PM, Steven D'Aprano wrote:
Terry Reedy wrote:
On 2/18/2013 6:47 AM, John Reid wrote:
I was hoping namedtuples could be used as replacements for tuples
in all instances.
This is a mistake in the following two senses. First, tuple is a class
with instances while namedtuple
On Mon, 18 Feb 2013 23:48:46 -0800, raymond.hettinger wrote:
[...]
> If your starting point is an existing iterable such as s=['Guido',
> 'BDFL', 1], you have a couple of choices: p=Person(*s) or
> p=Person._make(s). The latter form was put it to help avoid unpacking
> and repacking the argumen
On Mon, 18 Feb 2013 23:48:46 -0800, raymond.hettinger wrote:
[...]
> If your starting point is an existing iterable such as s=['Guido',
> 'BDFL', 1], you have a couple of choices: p=Person(*s) or
> p=Person._make(s). The latter form was put it to help avoid unpacking
> and repacking the argumen
Pardon me for the double-post, if any, my news client appears to have
eaten my first reply.
On Mon, 18 Feb 2013 23:48:46 -0800, raymond.hettinger wrote:
[...]
> If your starting point is an existing iterable such as s=['Guido',
> 'BDFL', 1], you have a couple of choices: p=Person(*s) or
> p=Pe
On Mon, 18 Feb 2013 23:48:46 -0800, raymond.hettinger wrote:
[...]
> If your starting point is an existing iterable such as s=['Guido',
> 'BDFL', 1], you have a couple of choices: p=Person(*s) or
> p=Person._make(s). The latter form was put it to help avoid unpacking
> and repacking the argumen
On 19/02/13 01:47, alex23 wrote:
> On Feb 18, 9:47 pm, John Reid wrote:
>> See http://article.gmane.org/gmane.comp.python.ipython.user/10270 for more
>> info.
>
> One quick workaround would be to use a tuple where required and then
> coerce it back to Result when needed as such:
>
> def sleep
On 19/02/13 00:18, Steven D'Aprano wrote:
> Terry Reedy wrote:
>
>> On 2/18/2013 6:47 AM, John Reid wrote:
>>
>>> I was hoping namedtuples could be used as replacements for tuples
>> > in all instances.
>>
>> This is a mistake in the following two senses. First, tuple is a class
>> with instan
Steven D'Aprano wrote:
py> class MyDict(dict):
... @classmethod
... def fromkeys(cls, func):
... # Expects a callback function that gets called with no arguments
... # and returns two items, a list of keys and a default value.
... return super(MyDict, cls).fromkeys
Steven D'Aprano wrote:
Terry Reedy wrote:
In fact, one reason to subclass a class is to change the initialization
api.
That might be a reason that people give, but it's a bad reason from the
perspective of interface contracts, duck-typing and the LSP.
Only if you're going to pass the cla
On Monday, February 18, 2013 6:09:16 AM UTC-8, John Reid wrote:
> I'm aware how to construct the namedtuple and the tuple. My point was
> that they use different syntaxes for the same operation and this seems
> to break ipython. I was wondering if this is a necessary design feature
> or perhaps jus
Oscar Benjamin wrote:
> On 19 February 2013 00:18, Steven D'Aprano
> wrote:
>> Terry Reedy wrote:
>>> On 2/18/2013 6:47 AM, John Reid wrote:
> [snip]
Is this a problem with namedtuples, ipython or just a feature?
>>>
>>> With canSequence. If isinstance was available and the above were writte
On Feb 18, 9:47 pm, John Reid wrote:
> See http://article.gmane.org/gmane.comp.python.ipython.user/10270 for more
> info.
One quick workaround would be to use a tuple where required and then
coerce it back to Result when needed as such:
def sleep(secs):
import os, time, parallel_helper
On 19 February 2013 00:18, Steven D'Aprano
wrote:
> Terry Reedy wrote:
>> On 2/18/2013 6:47 AM, John Reid wrote:
[snip]
>>> Is this a problem with namedtuples, ipython or just a feature?
>>
>> With canSequence. If isinstance was available and the above were written
>> before list and tuple could b
Terry Reedy wrote:
> Initializaing a namedtuple from an iterable is unusual, and
> hence gets the longer syntax. I
I quick look through our codebase agrees with that. I found 27
namedtuple classes. 21 were initialized with MyTuple(x, y, z) syntax.
Three used MyTuple(*data).
Most interesti
Terry Reedy wrote:
> On 2/18/2013 6:47 AM, John Reid wrote:
>
>> I was hoping namedtuples could be used as replacements for tuples
> > in all instances.
>
> This is a mistake in the following two senses. First, tuple is a class
> with instances while namedtuple is a class factory that produces
On 2/18/2013 6:47 AM, John Reid wrote:
I was hoping namedtuples could be used as replacements for tuples
> in all instances.
This is a mistake in the following two senses. First, tuple is a class
with instances while namedtuple is a class factory that produces
classes. (One could think of n
On 18/02/13 14:53, Oscar Benjamin wrote:
> On 18 February 2013 14:23, John Reid wrote:
> [snip]
>> That said it would be nice to know the rationale for
>> namedtuple.__new__ to have a different signature to tuple.__new__. I'm
>> guessing namedtuple._make has a similar interface to tuple.__new__. D
On 18 February 2013 14:23, John Reid wrote:
[snip]
> That said it would be nice to know the rationale for
> namedtuple.__new__ to have a different signature to tuple.__new__. I'm
> guessing namedtuple._make has a similar interface to tuple.__new__. Does
> anyone know what the rationale was for thi
On 18/02/13 14:15, Oscar Benjamin wrote:
> On 18 February 2013 14:09, John Reid wrote:
>> On 18/02/13 12:11, Dave Angel wrote:
>>> On 02/18/2013 06:47 AM, John Reid wrote:
Hi,
I was hoping namedtuples could be used as replacements for tuples in
all instances. There seem to be
On 18 February 2013 13:51, John Reid wrote:
> On 18/02/13 12:03, Oscar Benjamin wrote:
>> On 18 February 2013 11:47, John Reid wrote:
>>> Hi,
>>>
>>> I was hoping namedtuples could be used as replacements for tuples in all
>>> instances.
>> namedtuples are not really intended to serves as tuples
On 18/02/13 14:12, Oscar Benjamin wrote:
> On 18 February 2013 13:51, John Reid wrote:
>> On 18/02/13 12:03, Oscar Benjamin wrote:
>>> On 18 February 2013 11:47, John Reid wrote:
Hi,
I was hoping namedtuples could be used as replacements for tuples in all
instances.
>>> name
On 18 February 2013 14:09, John Reid wrote:
> On 18/02/13 12:11, Dave Angel wrote:
>> On 02/18/2013 06:47 AM, John Reid wrote:
>>> Hi,
>>>
>>> I was hoping namedtuples could be used as replacements for tuples in
>>> all instances. There seem to be some differences between how tuples
>>> and namedt
On 18/02/13 12:11, Dave Angel wrote:
> On 02/18/2013 06:47 AM, John Reid wrote:
>> Hi,
>>
>> I was hoping namedtuples could be used as replacements for tuples in
>> all instances. There seem to be some differences between how tuples
>> and namedtuples are created. For example with a tuple I can do:
On 18/02/13 12:03, Oscar Benjamin wrote:
> On 18 February 2013 11:47, John Reid wrote:
>> Hi,
>>
>> I was hoping namedtuples could be used as replacements for tuples in all
>> instances.
> namedtuples are not really intended to serves as tuples anywhere. They
> are intended to provide lightweight
On 18/02/13 12:05, Oscar Benjamin wrote:
> On 18 February 2013 12:03, Oscar Benjamin wrote:
>> On 18 February 2013 11:47, John Reid wrote:
>>> I'm seeing this problem because of the following code in IPython:
>>>
>>> def canSequence(obj):
>>> if isinstance(obj, (list, tuple)):
>>> t
On 02/18/2013 06:47 AM, John Reid wrote:
Hi,
I was hoping namedtuples could be used as replacements for tuples in all
instances. There seem to be some differences between how tuples and namedtuples
are created. For example with a tuple I can do:
a=tuple([1,2,3])
with namedtuples I get a Type
On 18 February 2013 12:03, Oscar Benjamin wrote:
> On 18 February 2013 11:47, John Reid wrote:
>> I'm seeing this problem because of the following code in IPython:
>>
>> def canSequence(obj):
>> if isinstance(obj, (list, tuple)):
>> t = type(obj)
>> return t([can(i) for i in o
On 18 February 2013 11:47, John Reid wrote:
> Hi,
>
> I was hoping namedtuples could be used as replacements for tuples in all
> instances.
namedtuples are not really intended to serves as tuples anywhere. They
are intended to provide lightweight, immutable, hashable objects with
*named* (rather
Hi,
I was hoping namedtuples could be used as replacements for tuples in all
instances. There seem to be some differences between how tuples and namedtuples
are created. For example with a tuple I can do:
a=tuple([1,2,3])
with namedtuples I get a TypeError:
from collections import namedtuple
32 matches
Mail list logo