1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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'

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

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?