On 30/06/15 21:38, Ben Finney wrote:
def __str__(self):
return """Here are your data:
%s
""" % list.__str__(self)
Python allows any class to participate in multiple inheritance, and
that's not determined at the point of writing your class. So you
can never assume you kn
"Marilyn Davis" writes:
> Hello Python Tutors,
>
> A student has asked a question that has me stumped. We are using 2.7.
>
> Looking at this code:
>
> #!/usr/bin/python
>
> class MyList(list):
>
> def __str__(self):
> return """Here are your data:
> %s
> """ % list.__str__(se
Thank you so much Alan and Steve.
We are good now.
Marilyn
On Tue, June 30, 2015 6:10 am, Steven D'Aprano wrote:
> On Mon, Jun 29, 2015 at 11:47:45PM -0700, Marilyn Davis wrote:
>
>> Hello Python Tutors,
>>
>>
>> A student has asked a question that has me stumped. We are using 2.7.
>>
>
> Ooh
On Mon, Jun 29, 2015 at 11:47:45PM -0700, Marilyn Davis wrote:
> Hello Python Tutors,
>
> A student has asked a question that has me stumped. We are using 2.7.
Ooh, nice one! That had me stumped for a while too, but I think I have
the solution. I wrote this class to investigate:
class MyList(l
On 30/06/15 07:47, Marilyn Davis wrote:
class MyList(list):
def __str__(self):
return """Here are your data:
%s
""" % list.__str__(self)
def main():
a = MyList([1,2])
print a
But if we add the special method:
def __repr__(self):
return "MyList
Hello Python Tutors,
A student has asked a question that has me stumped. We are using 2.7.
Looking at this code:
#!/usr/bin/python
class MyList(list):
def __str__(self):
return """Here are your data:
%s
""" % list.__str__(self)
def main():
a = MyList([1,2])
print