On Jun 9, 7:31 pm, a...@pythoncraft.com (Aahz) wrote:
> dmtr wrote:
>
> m = lambda:expando
> m.myattr = 1
> print m.myattr
> >1
>
> That's a *great* technique if your goal is to confuse people.
> --
Yeah. But it is kinda cute. Let's hope it won't get adapted
(adopted ;).
-- Dmitr
In article <86beb1fe-36ec-4a89-b926-3bb227c09...@g39g2000pri.googlegroups.com>,
dmtr wrote:
>
m = lambda:expando
m.myattr = 1
print m.myattr
>1
That's a *great* technique if your goal is to confuse people.
--
Aahz (a...@pythoncraft.com) <*> http://www.pythoncraf
Right.
>>> m = lambda:expando
>>> m.myattr = 1
>>> print m.myattr
1
-- Cheers, Dmitry
--
http://mail.python.org/mailman/listinfo/python-list
On 6/4/2010 10:25 PM, Alf P. Steinbach wrote:
As far as I can think of now, one cannot add attributes to *any*
builtin-class instance, but can add attributes to any user class which
does not have them disabled.
>>> [].a = 3
Traceback (most recent call last):
File "", line 1, in
[].a = 3
Attrib
* Terry Reedy, on 05.06.2010 03:01:
On 6/4/2010 8:01 PM, dmtr wrote:
Why does it have to be a one-liner? Is the Enter key on your keyboard
broken?
Nah. I was simply looking for something natural and intuitive, like: m
= object(); m.a = 1;
Usually python is pretty good providing these natural a
On 6/4/2010 8:01 PM, dmtr wrote:
Why does it have to be a one-liner? Is the Enter key on your keyboard
broken?
Nah. I was simply looking for something natural and intuitive, like: m
= object(); m.a = 1;
Usually python is pretty good providing these natural and intuitive
solutions.
As far as I
> Why does it have to be a one-liner? Is the Enter key on your keyboard
> broken?
Nah. I was simply looking for something natural and intuitive, like: m
= object(); m.a = 1;
Usually python is pretty good providing these natural and intuitive
solutions.
> You have a perfectly good solution: defin
On Thu, 03 Jun 2010 14:00:11 -0700, dmtr wrote:
> How can I create an empty object with dynamic attributes? It should be
> something like:
>
m = object()
m.myattr = 1
>
> But this doesn't work. And I have to resort to:
>
class expando(object): pass
m = expando()
m.myatt
* dmtr, on 03.06.2010 23:00:
How can I create an empty object with dynamic attributes? It should be
something like:
m = object()
m.myattr = 1
But this doesn't work. And I have to resort to:
class expando(object): pass
m = expando()
m.myattr = 1
Is there a one-liner that would do the thing
How can I create an empty object with dynamic attributes? It should be
something like:
>>> m = object()
>>> m.myattr = 1
But this doesn't work. And I have to resort to:
>>> class expando(object): pass
>>> m = expando()
>>> m.myattr = 1
Is there a one-liner that would do the thing?
-- Cheers, D
10 matches
Mail list logo