Skip to content

Instantly share code, notes, and snippets.

@tspycher
Last active April 29, 2019 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tspycher/f7d6a07b0e4b99fd7d2b95af1a5cfbd7 to your computer and use it in GitHub Desktop.
Save tspycher/f7d6a07b0e4b99fd7d2b95af1a5cfbd7 to your computer and use it in GitHub Desktop.
name = "Hubert"
class Thing():
attributes = {
"size": 12,
"weigth": 20,
"name": "a thing"
}
@property
def name(self):
global name
return name
def create_string(self, y:int=20):
nums = ""
for n in range(y):
nums += str(n)
return nums
def division(self, a:float, b:float) -> float:
try:
return a / b
except Exception as e:
return 0
def get_attribute(self, name):
for k,v in self.__class__.attributes.items():
if k == name:
return v
def get_a_list(self):
x = [1,2,3,4,5]
for y in x:
if y == 1:
x.append(6)
return x
x = Thing()
print(x.create_string(10))
print(x.name)
print(x.division(10, 5))
print(x.get_attribute("name"))
print(x.get_a_list())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment