On Thu, Feb 23, 2017 at 09:40:14PM +1100, Steven D'Aprano wrote:
> How do instance attributes normally get set? In the __init__ method:
>
> class MyClass:
> def __init__(self):
> self.attribute = None
>
>
> If the __init__ method does get run, it doesn't get the chance to create
>
On Wed, Feb 22, 2017 at 10:49 PM, Zachary Ware
wrote:
> On Wed, Feb 22, 2017 at 10:25 PM, boB Stepp wrote:
>
> I'll give you a couple of hints. First, try this:
>
> print('defining A')
> class A:
> print('Setting a on class A')
When I typed this in I was surprised to find that the print()
Thank you to everyone that provided illumination in this thread!
Things seem much clearer now, which caused me to realize that what I
wrote below cannot work as written (Even though I did copy and paste
it from the interpreter):
On Wed, Feb 22, 2017 at 10:53 PM, boB Stepp wrote:
> On Wed, Feb 22,
On Wed, Feb 22, 2017 at 10:25:58PM -0600, boB Stepp wrote:
> I am trying to wrap my head around the mechanics of inheritance in
> Python 3.
Here is a simplified picture of how inheritence usually works in Python.
For an instance `spam`, when you look up an attribute (which includes
methods), Pyt
On 23/02/17 04:25, boB Stepp wrote:
> I am trying to wrap my head around the mechanics of inheritance in
> Python 3. I thought that all attributes of a superclass were
> accessible to an instance of a subclass.
For class attributes that happens automatically.
>>> class A:
a = 'A'
On Wed, Feb 22, 2017 at 10:25:58PM -0600, boB Stepp wrote:
> I am trying to wrap my head around the mechanics of inheritance in
> Python 3. I thought that all attributes of a superclass were
> accessible to an instance of a subclass. But when I try the
> following:
>
> py3: class A:
> ... de
boB Stepp wrote:
> On Wed, Feb 22, 2017 at 10:25 PM, boB Stepp
> wrote:
>> I am trying to wrap my head around the mechanics of inheritance in
>> Python 3. I thought that all attributes of a superclass were
>> accessible to an instance of a subclass. But when I try the
>> following:
>>
>> py3: c
On 2017-02-22 20:53, boB Stepp wrote:
On Wed, Feb 22, 2017 at 10:25 PM, boB Stepp
wrote:
I am trying to wrap my head around the mechanics of inheritance in
Python 3. I thought that all attributes of a superclass were
accessible to an instance of a subclass. But when I try the
following:
py3:
On Wed, Feb 22, 2017 at 10:25 PM, boB Stepp wrote:
> I am trying to wrap my head around the mechanics of inheritance in
> Python 3. I thought that all attributes of a superclass were
> accessible to an instance of a subclass. But when I try the
> following:
>
> py3: class A:
> ... def __init
On Wed, Feb 22, 2017 at 10:25 PM, boB Stepp wrote:
> I am trying to wrap my head around the mechanics of inheritance in
> Python 3. I thought that all attributes of a superclass were
> accessible to an instance of a subclass.
>
> Obviously I am horribly misunderstanding something, and being
> cur
I am trying to wrap my head around the mechanics of inheritance in
Python 3. I thought that all attributes of a superclass were
accessible to an instance of a subclass. But when I try the
following:
py3: class A:
... def __init__(self):
... self.aa = 'class A'
...
py3: class B(A)
11 matches
Mail list logo