Skip to content

Instantly share code, notes, and snippets.

@dominickm
Created October 4, 2021 11:53
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 dominickm/cf4b019fc098f2c3b10a25bd645ce52b to your computer and use it in GitHub Desktop.
Save dominickm/cf4b019fc098f2c3b10a25bd645ce52b to your computer and use it in GitHub Desktop.
Python Sample for CR 343
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
@dominickm
Copy link
Author

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+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment