« 週末体調不良日記 |Main| Tシャツ展示即売日記 »

ぼそっと

def foo(left, top, right, bottom):
    "function for test"
    width = right - left
    hieght = top - botom
    print height, width
        
>>> checkfunc(foo)
variable 'botom' is global
variable 'height' is global
variable 'hieght' is not used
variable 'bottom' is not used
PythonにPerlの-wみたいなのないのかといわれたので作ってみた。 変数に代入されているけども読み出されていないと「not used」と警告される。 グローバル空間からのロードの警告もつけられる(オプショナル、デフォルトTrue) 指定した変数だけ警告を出力する対象から取り除くこともできる。
@deco_check(["set"])
def checkfunc(func,
          print_globals = True,
          print_not_used = True,
          print_func_name = False,
          surpress = []):
(以下略)
整理してラボブログに書く。

西尾泰和のブログ @ Cybozu Labs: Pythonでtypoを素早く察知する方法。書いた。

トラックバック(Trackback)

Trackback URL: http://www.nishiohirokazu.org/mt/mt-tb.cgi/631

ご意見・ご感想をお送りください(フィードバック)

(フィードバックはメールで送信され、基本的に表示されませんが、内容によっては公開させていただくこともございます。ご了承ください。Your comment doesn't appear the page immediately. If the comment has value to other people, it will be put on the page or subsequent entries. Thank you.)

上の情報は、いずれも未記入でかまいません。 All of above questions are optional.