Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

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

>>4
OK, I shall get out now.

Name: Anonymous 2015-05-04 13:58

http://stackoverflow.com/questions/20822850/change-python-mro-at-runtime
.-=-. .--.
__ .' '. / " )
_ .' '. / .-. \ / .-'\
( \ / .-. \ / / \ \ / / ^
\ `-` / \ `-' / \ `-` /
/prog/`-.-` '.____.' `.____.'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List