Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You don't. Use dataclasses instead to get type checking.

Otherwise there are tons of tricks to get what you want. To add to the list posted in sibling:

    a = vars(a) # readonly
    print(a.foo)
or

    class Obj: pass; 
    a = Obj()
    a.foo = 20


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: