Accessing parent objects

Terry Reedy tjreedy at udel.edu
Sun Mar 25 11:33:59 EDT 2018


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





More information about the Python-list mailing list