LoginSignup
0
0

Python Simplenamespaceの利用

Last updated at Posted at 2024-04-21

SimpleNamespaceを使うと、辞書型にkeyを使わずに参照をすることができる。

ex. configという辞書を作りたい時
従来:

config = {}
config['abc'] = '001'

であるが、SimpleNamespaceを使うと、

from types import SimpleNamespace

config = SimpleNamespace()
config.abc = '001'

のようにかけて楽である。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0