python32 pyhackathon-201011

22
Python 3.2 ふるかわとおる 株式会社ビープラウド @torufurukawa #bucho

Upload: toru-furukawa

Post on 25-Jun-2015

1.600 views

Category:

Technology


0 download

DESCRIPTION

Python 3.2 概要

TRANSCRIPT

Page 1: Python32 pyhackathon-201011

Python  3.2

ふるかわとおる  株式会社ビープラウド  @torufurukawa  #bucho  

Page 2: Python32 pyhackathon-201011

もうすぐリリース

•  11/13  alpha  4  •  12/04  beta  1  •  12/18  beta  2  •  01/08  RC1  •  01/22  RC2  •  02/05  release

Page 3: Python32 pyhackathon-201011

Python  Language  Moratorium    

Python  3.1  リリース後2年間は  文法、セマンティクス、  

ビルトインを変更しない  [PEP  3003]  

Page 4: Python32 pyhackathon-201011

3.2  では言語に変更がない

•  2010/06/27  Python  3.1  •  2011/02/05  Python  3.2  •  2012/06/27  モラトリアム終了  

Page 5: Python32 pyhackathon-201011

FAQ:  Python  3.2  使うべき?

Page 6: Python32 pyhackathon-201011

答:  あなた次第

hOp://wiki.python.org/moin/Python2orPython3  

Page 7: Python32 pyhackathon-201011

もっともな言い訳が必要

Page 8: Python32 pyhackathon-201011

いくつかネタを

•  logging  •  .pyc  •  Japanese  characters    

Page 9: Python32 pyhackathon-201011

logging  モジュール

•  標準ライブラリ  •  What’s  New  in  Python  3.2  の第1項目

Page 10: Python32 pyhackathon-201011

Before:  API  or  .ini  ファイルで設定 my_logger  =\          logging.getLogger('MyLogger')  my_logger.setLevel(logging.DEBUG)   handler  =\          logging.handlers.RotaangFileHandler(                  LOG_FILENAME,  maxBytes=20,                  backupCount=5)   my_logger.addHandler(handler)  

[handlers]  keys=consoleHandler   [formaOers]  keys=simpleFormaOer   [logger_root]  level=DEBUG  handlers=consoleHandler   [logger_simpleExample]  level=DEBUG  handlers=consoleHandler  qualname=simpleExample  propagate=0

Page 11: Python32 pyhackathon-201011

Ager:  辞書で設定 {"version":  1,    "formaOers":  {"brief":  {"format":  "%(levelname)-­‐8s:  %(name)-­‐15s:  %(message)s"},                                  "full":  {"format":  "%(ascame)s  %(name)-­‐15s  %(levelname)-­‐8s  %(message)s"},                                  },    "handlers":  {"console":  {                                        "class":  "logging.StreamHandler",                                        "formaOer":  "brief",                                        "level":  "INFO",                                        "stream":  "ext://sys.stdout"},                              "console_priority":  {                                        "class":  "logging.StreamHandler",                                        "formaOer":  "full",                                        "level":  "ERROR",                                        "stream":  "ext://sys.stderr"},                              },    "root":  {"level":  "DEBUG",  "handlers":  ["console",  "console_priority"]}}

Page 12: Python32 pyhackathon-201011

辞書使えるよ!  JSON  とかで設定できるね  logging  しようぜ

辞書なしで使ってるし  logging  使わねーし

Page 13: Python32 pyhackathon-201011

.pyc  はバージョンごとに生成

Page 14: Python32 pyhackathon-201011

Before:  foo.py  à foo.pyc

•  複数バージョンで同じモジュールをインポートすると .pyc  が再生成される  

 

Page 15: Python32 pyhackathon-201011

Ager:  Python  のバージョンごとに pyc

__pycache__/foo.cpython-­‐32.pyc

Page 16: Python32 pyhackathon-201011

スピンアップ短縮に  期待!  

スクリプト共有しないし  

Page 17: Python32 pyhackathon-201011

日本語ファイル名

Page 18: Python32 pyhackathon-201011

Before:    ファイル名のエンコーディングが危うい

•  UTF-­‐8  想定  •  Windows  では、mbcs  でエンコードできなくても ‘ignore’

Page 19: Python32 pyhackathon-201011

Ager:  システムロケール

•  システムロケールのエンコーディングを使う  •  Windows  では mbcs  エンコードできなければエラー  

•  os.fsencode()  •  os.fsdecode()  

Page 20: Python32 pyhackathon-201011

日本語ファイル名を使う  アプリがしがし  開発するぜ  

もう対処してるし

Page 21: Python32 pyhackathon-201011

いくつかネタを紹介しました

•  logging  •  .pyc  •  Japanese  file  names  

Page 22: Python32 pyhackathon-201011

使う理由を教えてください

•  使わない理由は分かってます  •  あえて、使ってる人は、何やってるの?