Skip to content

Instantly share code, notes, and snippets.

@non-static
Created December 1, 2013 09:05
Show Gist options
  • Save non-static/7730215 to your computer and use it in GitHub Desktop.
Save non-static/7730215 to your computer and use it in GitHub Desktop.
class Complex:
def __init__(self, real, imag, name):
self.r = real
self.i = imag
self.name = name
name = 'Complex_default'
r = 0.0
i = 1.1
doc = "default doc"
print(Complex.name)
Complex.name = "hello"
x = Complex(1.0, 2.3, 'x')
print((x.r, x.i))
print(x.name)
print(Complex.name)
x.name = 'zzzz'
print(x.name)
print()
y = Complex(9.3, 8.5, 'y')
print(y.r, y.i)
print(y.name)
print()
Complex.name = "world"
print(x.name, y.name)
print()
Complex.r = 0
print(x.r, y.r)
print(Complex.name)
print()
#x.doc = 'xxxxx'
Complex.doc = 'ccccccc'
print(x.doc)
print(Complex.doc)
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment