-
-
Save g00cey/329932879d0e94ea642f881e4a336962 to your computer and use it in GitHub Desktop.
generic python
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
docker run --rm -v "$PWD":/src -w /src python python test.py | |
{'name': 'Tom', 'age': 12} | |
{'name': 'Tom', 'age': 12} |
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 typing import TypeVar, Sequence | |
from typing import TypedDict | |
class Person(TypedDict): | |
pass | |
class PersonInt(Person): | |
name: str | |
age: int | |
class PersonString(Person): | |
name: str | |
age: str | |
def pvars(obj): | |
try: | |
print(vars(obj)) | |
except: | |
print(obj) | |
person0 = PersonInt(name='Tom', age=12) | |
pvars(person0) | |
person1 = PersonString(person0) | |
pvars(person1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment