Do they belong to you? Claim these comments.
bearophile
Is this you? Claim Profile »
9 months ago
in Commentary on Python from a Java programming perspective - Part 2 - How duck typing influences class design and design principles on /var/log/mind
Sorry for not being clear. In one answer of mine I have shown you that you have to use s.__class__, because type(s) is broken/wrong there.
The successive answer of mine refers to the Abstract Base Classes of Python3, that are absent from Python2.5, and that may interest you, so you may take a look at them:
http://www.python.org/dev/peps/pep-3119/
The successive answer of mine refers to the Abstract Base Classes of Python3, that are absent from Python2.5, and that may interest you, so you may take a look at them:
http://www.python.org/dev/peps/pep-3119/
9 months ago
in Commentary on Python from a Java programming perspective - Part 2 - How duck typing influences class design and design principles on /var/log/mind
I also suggest to take a look at ABC of Python3.
1 reply
Dhananjay Nene
Didn't understand what you were referring to. Are you suggesting that I need to revisit some of my basic understanding or are you pointing me towards some document or source of information ?
9 months ago
in Commentary on Python from a Java programming perspective - Part 2 - How duck typing influences class design and design principles on /var/log/mind
order = [Circle, Square] # the order in which to draw the shapes
shapes = [Circle(1,1,5), Square(2,4,3), Circle(3,3,7), Square(4,2,4)]
shapes.sort(key=lambda s: order.index(s.__class__))
for shape in shapes:
shape.draw()
shapes = [Circle(1,1,5), Square(2,4,3), Circle(3,3,7), Square(4,2,4)]
shapes.sort(key=lambda s: order.index(s.__class__))
for shape in shapes:
shape.draw()
9 months ago
in Commentary on Python from a Java programming perspective - Part 2 - How duck typing influences class design and design principles on /var/log/mind
shapes.sort(key=lambda s: order.index(type(s)))
for shape in shapes:
shape.draw()
for shape in shapes:
shape.draw()
1 reply
Dhananjay Nene
Thanks.