python - Access class hierarchy attribute -


given class named datastream

class datastream(object):     def __init__(self):         self.start = start         self.input_val = input_val 

and class named indatastream:

class  indatastream(datastream):     def __init__(self):         super( indatastream, self).__init__()         self.ready = ready  stream = indatastream() 

i want send datastream part of stream function, like:

function(stream.datastream) 

is there nice way task?

if you're looking access instance of datastream instance of class indatastream, may consider using composition instead of inheritance:

class indatastream(object):     def __init__(self):         self.ready = ready         self.datastream = datastream() 

then can do:

stream = indatastream() function(stream.datastream) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -