FOIC question, EXPERT LEVEL How to alter mro in runtime?
Name:
Anonymous
2015-05-03 22:45
Impl(object):
def __init__(self):
pass
def shit(self):
pass
StdoutImpl(Impl):
def shit(self):
print("A shit has been shat.")
StderrImpl(Impl):
def shit(self):
__import__("sys").stderr.write("A shit has been shat to stderr.\n")
class MyApplicationg(object):
def __init__(self, implname):
if implname == "stderr":
magic(StderrImpl, self)
else:
magic(StdoutImpl, self)
def magic(cls, object):
# ?????????????
# ????????????????
# ?????????
pass
Name:
Anonymous
2015-05-03 22:48
Oh shit I forgot, I want MyApplication
to call self.shit()
in its methods.
Name:
Anonymous
2015-05-03 22:50
def magic(cls, object_):
instance = cls()
for k in dir(instance):
object_.setattr(k, getattr(instance, k))
Name:
GET FUCK OUT
2015-05-03 22:51
ONE WORD:
THE FORCED INDENTATION OF CODE
THREAD OVER
Name:
Anonymous
2015-05-03 22:56
>>4OK, I shall get out now.
Name:
Anonymous
2015-05-04 13:58
http://stackoverflow.com/questions/20822850/change-python-mro-at-runtime .-=-. .--.
__ .' '. / " )
_ .' '. / .-. \ / .-'\
( \ / .-. \ / / \ \ / / ^
\ `-` / \ `-' / \ `-` /
/prog/`-.-` '.____.' `.____.'
Name:
Anonymous
2015-05-04 14:31
>>1>>2>>3>>4>>5>>6If it ain't LISP, it's crap.
Name:
Anonymous
2015-05-04 15:26
>>6Why was that op so clear while
>>1-san was so ambiguous?
Name:
Anonymous
2015-05-04 17:16
>>7Protip: Use a hyphen to reference many continuous posts at once (
>>1-6). Use commas to reference non-continuous posts (
>>1,3,5).
You can mix these, too:
>>1-3,5-7,9