@SnoopJeDi/

BlankGrayRatio

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.001080481926307053","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"cHJpbnQoIi4uLmRvaW5nIHRoaW5ncyB0aGUgd3Jvbmcgd2F5Li4uIikKCmNsYXNzIFdyb25nQ2FyOgogICIiIiBUaGlzIGNsYXNzIHNob3dzIHdoeSBDTEFTUyBBVFRSSUJVVEVTIChiZWxvdykgYXJlIGdlbmVyYWxseSBXUk9ORyAiIiIKICBtb2RlbCA9ICdOaXNzYW4nCiAgbXBnID0gMzAKCiAgZGVmIF9faW5pdF9fKHNlbGYpOgogICAgcGFzcwoKbmlzc2FuID0gV3JvbmdDYXIoKQpwcmludChmJ0JlZm9yZSBtb2RpZmljYXRpb24sIG5pc3Nhbi5tb2RlbCBpczoge25pc3Nhbi5tb2RlbH0nKQoKIyBJIHdhbnQgYSBTRVBBUkFURSBjYXIgdGhhdCdzIGEgSG9uZGEsIG5vdywKIyBhbmQgdGhlIG9ubHkgd2F5IHRvIGRvIGl0IGlzLi4uCldyb25nQ2FyLm1vZGVsID0gJ0hvbmRhJwpob25kYSA9IFdyb25nQ2FyKCkKCnByaW50KGYnQWZ0ZXIgbW9kaWZpY2F0aW9uLCBob25kYS5tb2RlbCBpczoge2hvbmRhLm1vZGVsfScpCnByaW50KGYnQWZ0ZXIgbW9kaWZpY2F0aW9uLCBuaXNzYW4ubW9kZWwgaXM6IHtuaXNzYW4ubW9kZWx9ICAodWggb2ghKVxuJykKCiMgbW9kZWwgaXMgYSBDTEFTUyBBVFRSSUJVVEUsIHNvIGl0IHdpbGwgY2hhbmdlIG9uIGV2ZXJ5IGluc3RhbmNlIGlmCiMgaXQgZXZlciBjaGFuZ2VzLiBUaGlzIGRvZXNuJ3QgbWFrZSBzZW5zZSEgRXZlcnkgY2FyIG9iamVjdCBoYXMgaXRzCiMgb3duIHByb3BlcnRpZXMs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hLm1vZGVsfSwgbXBnPXtob25kYS5tcGd9JykKCiMgbm90aWNlIHRoYXQgdGhlIG1wZyBwcm9wZXJ0eSBvZiB0aGUgbmlzc2FuIG9iamVjdCBkaWQgTk9UIGNoYW5nZSwgYmVjYXVzZSB3aGF0CiMgd2UgYXJlIGNoYW5naW5nIGlzIGFuIElOU1RBTkNFIEFUVFJJQlVURQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
print("...doing things the wrong way...")

class WrongCar:
  """ This class shows why CLASS ATTRIBUTES (below) are generally WRONG """
  model = 'Nissan'
  mpg = 30

  def __init__(self):
    pass

nissan = WrongCar()
print(f'Before modification, nissan.model is: {nissan.model}')

# I want a SEPARATE car that's a Honda, now,
# and the only way to do it is...
WrongCar.model = 'Honda'
honda = WrongCar()

print(f'After modification, honda.model is: {honda.model}')
print(f'After modification, nissan.model is: {nissan.model}  (uh oh!)\n')

# model is a CLASS ATTRIBUTE, so it will change on every instance if
# it ever changes. This doesn't make sense! Every car object has its
# own properties, and if we want to change them, it should only change
# that one object!

print("...doing things the right way...")

class RightCar:
  """ This class sets model and mpg as INSTANCE ATTRIBUTES """

  def __init__(self, model='Nissan', mpg=30):  # we can still have defaults
    self.model = model  # these are INSTANCE ATTRIBUTES, i.e. only on THIS object
    self.mpg = mpg

nissan = RightCar()
honda = RightCar(model='Honda')

print(f'Before modification, nissan: model={nissan.model}, mpg={nissan.mpg}')
print(f'Before modification, honda: model={honda.model}, mpg={honda.mpg}')

# oops, the fuel injectors in the Honda got dirty, so the mpg has to go down!

honda.mpg = 25

print(f'After modification, nissan: model={nissan.model}, mpg={nissan.mpg}')
print(f'After modification, honda: model={honda.model}, mpg={honda.mpg}')

# notice that the mpg property of the nissan object did NOT change, because what
# we are changing is an INSTANCE ATTRIBUTE