James Stroud wrote:
> That **kwargs insists on using the C-side interface is precisely the
> annoyance
> to which I am referring. I should be able to write a dictionary-like
> interface in python and **kwargs should in turn be able to use it. If the
> retort is that the C-side interface is use
Robert Kern wrote:
> James Stroud wrote:
>
> > Does anyone else find the following annoying:
> >
> > py> from UserDict import UserDict
> > py> aud = UserDict({"a":1, "b":2})
> > py> def doit(**kwargs):
> > ... print kwargs
>
> UserDict only exists for backwards compatibility with old code that us
On Tuesday 08 November 2005 22:54, Robert Kern wrote:
> James Stroud wrote:
> > Does anyone else find the following annoying:
> >
> > py> from UserDict import UserDict
> > py> aud = UserDict({"a":1, "b":2})
> > py> def doit(**kwargs):
> > ... print kwargs
> > ...
> > py> aud
> > {'a': 1, 'b': 2}
James Stroud wrote:
> Does anyone else find the following annoying:
>
> py> from UserDict import UserDict
> py> aud = UserDict({"a":1, "b":2})
> py> def doit(**kwargs):
> ... print kwargs
> ...
> py> aud
> {'a': 1, 'b': 2}
> py> doit(**aud)
> Traceback (most recent call last):
> File "", line
On Monday 07 November 2005 20:36, Alex Martelli wrote:
> Ron Adam <[EMAIL PROTECTED]> wrote:
> > James Stroud wrote:
> > > Hello All,
> > >
> > > How does one make an arbitrary class (e.g. class myclass(object))
> > > behave like a list in method calls with the "*something" operator? What
> > > I m
James Stroud wrote:
> I was attempting to re-define iter of a subclassed list, to find the
> "magic" method, but it didn't work.
>>> class List(list):
... def __iter__(self): return iter("abc")
...
>>> a = List([1,2,3])
>>> list(a)
['a', 'b', 'c']
>>> tuple(a)
(1, 2, 3)
list-to-tuple conver
On Mon, 7 Nov 2005 20:39:46 -0800, James Stroud <[EMAIL PROTECTED]> wrote:
>On Monday 07 November 2005 20:21, Robert Kern wrote:
>> James Stroud wrote:
>> > Hello All,
>> >
>> > How does one make an arbitrary class (e.g. class myclass(object)) behave
>> > like a list in method calls with the "*som
Alex Martelli wrote:
> Ron Adam <[EMAIL PROTECTED]> wrote:
>
>
>>James Stroud wrote:
>>>And, how about the "**something" operator?
>>>
>>>James
>>
>>A dictionary would be pretty much the same except subclassed from a
>>dictionary of course.
>
>
> I believe this one is correct (but I have no
On Monday 07 November 2005 20:36, Alex Martelli wrote:
> > > I've looked at getitem, getslice, and iter. What is it if not one of
> > > these?
>
> Obviously James hadn't looked at __iter__ in the RIGHT way!
I was attempting to re-define iter of a subclassed list, to find the "magic"
method, but i
James Stroud wrote:
> Hello All,
>
> How does one make an arbitrary class (e.g. class myclass(object)) behave like
> a list in method calls with the "*something" operator? What I mean is:
>
> myobj = myclass()
>
> doit(*myobj)
Make it iterable:
>>> class Foo(object):
... def __iter__(se
Ron Adam <[EMAIL PROTECTED]> wrote:
> James Stroud wrote:
>
> > Hello All,
> >
> > How does one make an arbitrary class (e.g. class myclass(object)) behave
> > like a list in method calls with the "*something" operator? What I mean
> > is:
>
> You need to base myclass on a list if I understand
On Monday 07 November 2005 20:21, Robert Kern wrote:
> James Stroud wrote:
> > Hello All,
> >
> > How does one make an arbitrary class (e.g. class myclass(object)) behave
> > like a list in method calls with the "*something" operator? What I mean
> > is:
> >
> > myobj = myclass()
> >
> > doit(*myob
James Stroud wrote:
> Hello All,
>
> How does one make an arbitrary class (e.g. class myclass(object)) behave like
> a list in method calls with the "*something" operator? What I mean is:
You need to base myclass on a list if I understand your question.
class myclass(list):
def __init__
James Stroud wrote:
> Hello All,
>
> How does one make an arbitrary class (e.g. class myclass(object)) behave like
> a list in method calls with the "*something" operator? What I mean is:
>
> myobj = myclass()
>
> doit(*myobj)
>
> I've looked at getitem, getslice, and iter. What is it if not o
14 matches
Mail list logo