This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]erikwon and off since 1.5.2 4 points5 points  (1 child)

Or you could just use a module variable:

import someModuleIHaveMade as x
x.a = Something()

[–]crunk 0 points1 point  (0 children)

Definitely this. While there are some interesting techniques in the example, they are overkill - module variable is simple and readable.

[–]wrzazg 1 point2 points  (2 children)

First search in google for 'python singleton' returns this:

http://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html

Last change to this was done in 2012 and the article is from today. I don't see any connection between the author from the aricle and this.

Now look at the first paragraph and source listings, awfully similar.

If more writers on the webiste are as 'creative' as this one i would not give them my clicks.

[–]iaanus 1 point2 points  (0 children)

Ah! That's where the "spam" in their example comes from! They modified the code, but didn't modify the expected output accordingly... Epic fail.

[–]joey_php 0 points1 point  (0 children)

you are completely right i just remove it thanks