On Tue, 30 May 2017 12:00 pm, Kunal Jamdade wrote:
> I tried to understand overriding methods on per instance class. But i am
> not getting it. Can you help me in getting the mail. Or can u suggest me at
> least what should i read before reading "this topic"?
>
> Can you explain me with one more
I tried to understand overriding methods on per instance class. But i am
not getting it. Can you help me in getting the mail. Or can u suggest me at
least what should i read before reading "this topic"?
Can you explain me with one more example?
On Tue, May 16, 2017 at 9:30 AM, Nathan Ernst
wrot
There is another way to do it, but it's not pretty, and I don't recommend
it:
>>> class Foo:
... pass
...
>>> from functools import partial
>>> f = Foo()
>>> def hello(self, arg):
... print("hello", arg)
...
>>> f.hello = partial(hello, f)
>>> f.hello("world")
hello world
This basically re
It is common to add an attribute to a class, then over-ride it in the
instance:
class Document:
pagesize = "A4"
def __init__(self, pagesize):
self.pagesize = pagesize
A little-known fact, not appreciated by users of less powerful OOP
languages: Python supports per-instance cust