@anonymous/

OfficialBlueUmbrellabird

Python 2.7

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7665044641075152","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"Y2xhc3MgRGF0YWJhc2U6CiAgICBjb25uZWN0aW9uID0gTm9uZQogICAgCiAgICBkZWYgX19pbml0X18oc2VsZik6CiAgICAgICAgcHJpbnQgIkluc3RhbnRpYXRpbmchIgogICAgCiAgICBkZWYgY29ubmVjdF9kYnMoc2VsZik6CiAgICAgICAgaWYgc2VsZi5jb25uZWN0aW9uIGlzIG5vdCBOb25lOgogICAgICAgICAgICByZXR1cm4gc2VsZi5jb25uZWN0aW9uCiAgICAgICAgICAgIAogICAgICAgIHNlbGYuY29ubmVjdGlvbiA9IDEKICAgICAgICByZXR1cm4gc2VsZi5jb25uZWN0aW9uCiAgICAgICAgCgpjbGFzcyBVc2VyOgogICAgZGIgPSBOb25lCiAgICAKICAgIGRlZiBfX2luaXRfXyhzZWxmKToKICAgICAgICBzZWxmLmRiID0gRGF0YWJhc2UoKQogICAgCiAgICBkZWYgc2F2ZV91c2VyKHNlbGYpOgogICAgICAgIHByaW50IHNlbGYuZGIuY29ubmVjdF9kYnMoKQogICAgICAgIApVID0gVXNlcigpCmZvciBpIGluIHJhbmdlKDMwKToKICAgIFUuc2F2ZV91c2VyKCkgIyBPbmx5IGluc3RhbnRpYXRlcyB0aGUgY29ubmVjdGlvbiBvbmNlLCB0aGVuIHJldXNlcyBpdCAzMHg="},"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
class Database:
    connection = None
    
    def __init__(self):
        print "Instantiating!"
    
    def connect_dbs(self):
        if self.connection is not None:
            return self.connection
            
        self.connection = 1
        return self.connection
        

class User:
    db = None
    
    def __init__(self):
        self.db = Database()
    
    def save_user(self):
        print self.db.connect_dbs()
        
U = User()
for i in range(30):
    U.save_user() # Only instantiates the connection once, then reuses it 30x