開発環境
- macOS Mojave - Apple
- Emacs (Text Editor)
- Python 3.7 (プログラミング言語)
Head First Python 第2版 ―頭とからだで覚えるPythonの基本 (Paul Barry (著)、嶋田 健志 (監修)、木下 哲也 (翻訳)、オライリージャパン)の9章(コンテキストマネジメントプロトコル - with 文を使う)、自分で考えてみよう(p. 341)を取り組んでみる。
コード(Emacs)
Python 3
import mysql.connector
dbconfig = {'host': '127.0.0.1',
'user': 'vsearch',
'password': 'vsearchpasswd',
'database': 'vsearchlogDB', }
class UseDataBase:
def __init__(self, config: dict) -> None:
self.configuration = config
if __name__ == '__main__':
udb = UseDataBase(dbconfig)
print(udb)
for p in dir(udb):
if not p.startswith('__'):
print(p)
入出力結果(Terminal, Jupyter(IPython))
$ python3 DBcm.py <__main__.UseDataBase object at 0x10943c908> configuration $
0 コメント:
コメントを投稿