Skip to content

Instantly share code, notes, and snippets.

@p-geon
Last active December 11, 2021 07:50
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 p-geon/67085bb6025c7903f49d91baa5c9ebbf to your computer and use it in GitHub Desktop.
Save p-geon/67085bb6025c7903f49d91baa5c9ebbf to your computer and use it in GitHub Desktop.
class AllVariablesNamePrinter:
def __init__(self):
self.a = 10
self.b = {
"ba": 1,
"bb": 2,
}
self.c = 20
def __call__(self):
print('> start')
[(print(x) if(x!=None) else None) for x in [(attr if(attr.startswith('__')==False) else None) for attr in dir(self)]]
print('> end')
if(__name__=='__main__'):
AllVariablesNamePrinter()()
@p-geon
Copy link
Author

p-geon commented Dec 11, 2021

スクリーンショット 2021-12-11 16 26 55

@p-geon
Copy link
Author

p-geon commented Dec 11, 2021

def all_variables_name_printer(cls: 'self') -> None:
    [(print(x) if(x!=None) else None) for x in [(attr if(attr.startswith('__')==False) else None) for attr in dir(cls)]]

@p-geon
Copy link
Author

p-geon commented Dec 11, 2021

def all_variables_name_printer(cls: 'self') -> None:
    print(cls.__dict__)

Thanks himako-san.

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