2020年1月14日星期二

Method to get all attributes of a Python object

In order to get all the attributes of a Python object, we only need to do the following:

dir(obj)



E.g:


import autogluon as ag
dir(ag)
The output will be:

['AutoGluonObject', 'AutoGluonWarning', 'BaseTask', 'Bool', 'Categorical', 'Choice', 'DataLoader', 'DeprecationHelper', 'Dict', 'EasyDict', 'ImageClassification', 'Int', 'List', 'NestedSpace', 'ObjectDetection', 'Queue', 'Real', 'SampledDataset', 'Space', 'SplitSampler', 'TabularPrediction', 'Task', 'TextClassification', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'absolute_import', 'args', 'autogluon_function', 'autogluon_object', 'autogluon_register_args', 'autogluon_register_dict', 'base', 'check_sha1', 'classproperty', 'collect_params', 'core', 'custom_queue', 'dataloader', 'dataset', 'decorator', 'defaultdict', 'deprecate', 'download', 'edict', 'file_helper', 'files', 'func', 'generate_csv', 'get_cpu_count', 'get_data_rec', 'get_gpu_count', 'get_split_samplers', 'image_classification', 'in_ipynb', 'keydefaultdict', 'load', 'logging', 'make_deprecate', 'miscs', 'mkdir', 'mousover_plot', 'mxutils', 'obj', 'object_detection', 'optimizer', 'plot_network', 'plot_performance_vs_trials', 'plot_summary_of_models', 'plot_tabular_models', 'plots', 'raise_num_file', 'read_remote_ips', 'sagemaker_setup', 'sample_config', 'save', 'scheduler', 'searcher', 'serialization', 'space', 'sync_remote', 'tabular_prediction', 'task', 'text_classification', 'tqdm', 'try_import', 'try_import_catboost', 'try_import_cv2', 'try_import_lightgbm', 'try_import_mxboard', 'try_import_mxnet', 'unzip', 'update_params', 'util_decorator', 'utils', 'verbosity2loglevel', 'version', 'warning_filter']

I.e. all attributes of this object "ag".

没有评论:

发表评论