osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessing parent objects


On 3/25/2018 11:01 AM, Jugurtha Hadjar wrote:
> 
> On 03/25/2018 03:25 PM, Terry Reedy wrote:
>> On 3/25/2018 7:42 AM, Jugurtha Hadjar wrote:
>>
>>> class C2(object):
>>> ???? def __init__(self, parent=None):
>>> ???????? self.parent = parent
>>
>> Since parent is required, it should not be optional.
>>
> 
> You can still call it the way you'd call it if it were a positional 
> argument.

You totally missed my point.  Given the definition above, 'parent' can 
be passed either way, but self.parent must be not be None and therefore 
'parent' should not have the unreplaced default value None.  It should 
either have a legal default value or no default value.

-- 
Terry Jan Reedy