DEV Community

loading...

Discussion on: What is the most confusing thing to you in Python?

Collapse
nicoxxl profile image
Nicolas B. • Edited

Python does not forbid many things so try this:

class Hello:
  def __init__(self, z):
    self.z = z

  def do(self):
    print('Hello {}'.format(self.z))


class SeeYou:
  def __init__(self, z):
    self.z = z

  def do(self):
    print('See you {}'.format(self.z))

y = Hello('world')
y.do()
y.__class__ = SeeYou
y.do()
Collapse
math2001 profile image
Mathieu PATUREL

:smiley: Never thought of this before... That's cool! Thanks!