Created
October 4, 2021 11:53
-
-
Save dominickm/cf4b019fc098f2c3b10a25bd645ce52b to your computer and use it in GitHub Desktop.
Python Sample for CR 343
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
class Gungan(): | |
__instance = None | |
# whatever our particular hero does | |
def __init__(self) -> None: | |
# whatever config you want to do here | |
Gungan.__instance = self | |
# this is a very naive / sloppy singelton, you'll likey want something tighter | |
@static_method | |
def instnace() -> Gungan: | |
if Gungan.__instance = None: | |
Gungan() | |
return Gungan.__instance | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an example of being able to use type hinting on a return < Python 3.10. In 3.10 the
from __future__
will not be required. This requires Python 3.6+