On May 17, 1:09 am, Carl Banks <[EMAIL PROTECTED]> wrote:
> On May 16, 4:46 am, "甜瓜" <[EMAIL PROTECTED]> wrote:
>
> > Howdy,
> > I wonder why below does not work.
>
> > a = object()
> > a.b = 1# dynamic bind attribute failed...
>
> > To make it correct, we have to create a new class:
>
On May 16, 4:46 am, "甜瓜" <[EMAIL PROTECTED]> wrote:
> Howdy,
> I wonder why below does not work.
>
> a = object()
> a.b = 1# dynamic bind attribute failed...
>
> To make it correct, we have to create a new class:
> class MyClass(object): pass
> a = MyClass()
> a.b = 1 # OK
>
> Doe
"Ìð¹Ï" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| > # an efficient 'Pair' class holding two objects
| > class Pair(object):
| >__slots__ = 'first', 'second'
| >
| > Instances of Pair take up even less room that 2-element tuples
| > because they don't carry the size informat
"甜瓜" <[EMAIL PROTECTED]> writes:
>> # an efficient 'Pair' class holding two objects
>> class Pair(object):
>>__slots__ = 'first', 'second'
>>
>> Instances of Pair take up even less room that 2-element tuples
>> because they don't carry the size information in the object.
>>
>> Now, if the obje
On May 16, 4:26 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> 甜瓜 wrote:
> > I wonder why below does not work.
>
> > a = object()
> > a.b = 1# dynamic bind attribute failed...
>
> The implementation of slots depends on that behaviour:
>
> http://docs.python.org/ref/slots.html
>
> > Does t
On May 16, 10:21 am, castironpi <[EMAIL PROTECTED]> wrote:
> On May 16, 9:41 am, castironpi <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On May 16, 8:56 am, castironpi <[EMAIL PROTECTED]> wrote:
>
> > > On May 16, 8:51 am, castironpi <[EMAIL PROTECTED]> wrote:
>
> > > > On May 16, 4:26 am, Peter Otten
On May 16, 9:41 am, castironpi <[EMAIL PROTECTED]> wrote:
> On May 16, 8:56 am, castironpi <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On May 16, 8:51 am, castironpi <[EMAIL PROTECTED]> wrote:
>
> > > On May 16, 4:26 am, Peter Otten <[EMAIL PROTECTED]> wrote:
>
> > > > 甜瓜 wrote:
> > > > > I wonder
On May 16, 8:56 am, castironpi <[EMAIL PROTECTED]> wrote:
> On May 16, 8:51 am, castironpi <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On May 16, 4:26 am, Peter Otten <[EMAIL PROTECTED]> wrote:
>
> > > 甜瓜 wrote:
> > > > I wonder why below does not work.
>
> > > > a = object()
> > > > a.b = 1
On May 16, 4:16 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> "甜瓜" <[EMAIL PROTECTED]> writes:
> > Howdy,
> > I wonder why below does not work.
>
> > a = object()
> > a.b = 1# dynamic bind attribute failed...
>
> Because the default object class doesn't have a dict or other
> indicatio
On May 16, 8:51 am, castironpi <[EMAIL PROTECTED]> wrote:
> On May 16, 4:26 am, Peter Otten <[EMAIL PROTECTED]> wrote:
>
> > 甜瓜 wrote:
> > > I wonder why below does not work.
>
> > > a = object()
> > > a.b = 1# dynamic bind attribute failed...
>
> > The implementation of slots depends o
On May 16, 4:26 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> 甜瓜 wrote:
> > I wonder why below does not work.
>
> > a = object()
> > a.b = 1# dynamic bind attribute failed...
>
> The implementation of slots depends on that behaviour:
>
> http://docs.python.org/ref/slots.html
>
> > Does t
2008/5/16 Hrvoje Niksic <[EMAIL PROTECTED]>:
> "甜瓜" <[EMAIL PROTECTED]> writes:
>
>> Howdy,
>> I wonder why below does not work.
>>
>> a = object()
>> a.b = 1# dynamic bind attribute failed...
>
> Because the default object class doesn't have a dict or other
> indication of state. It's
甜瓜 wrote:
> I wonder why below does not work.
>
> a = object()
> a.b = 1# dynamic bind attribute failed...
The implementation of slots depends on that behaviour:
http://docs.python.org/ref/slots.html
> Does this strange behavior break the LSP (Liskov substitution principle)?
Can y
"甜瓜" <[EMAIL PROTECTED]> writes:
> Howdy,
> I wonder why below does not work.
>
> a = object()
> a.b = 1# dynamic bind attribute failed...
Because the default object class doesn't have a dict or other
indication of state. It's a "pure" Python object whose only visible
properties are
"甜瓜" <[EMAIL PROTECTED]> writes:
> Howdy,
> I wonder why below does not work.
>
> a = object()
> a.b = 1# dynamic bind attribute failed...
>
> To make it correct, we have to create a new class:
> class MyClass(object): pass
> a = MyClass()
> a.b = 1 # OK
It's annoyingly diffic
Howdy,
I wonder why below does not work.
a = object()
a.b = 1# dynamic bind attribute failed...
To make it correct, we have to create a new class:
class MyClass(object): pass
a = MyClass()
a.b = 1 # OK
Does this strange behavior break the LSP (Liskov substitution principle)?
16 matches
Mail list logo