Skip to content

Instantly share code, notes, and snippets.

@dominickm
Created Oct 4, 2021
Embed
What would you like to do?
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

dominickm commented Oct 4, 2021

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