Python

Python3.1が出ていた

Python 3.1 Release | Python.org What’s New In Python 3.1 — Python 3.4.3 documentation 変更点については http://d.hatena.ne.jp/tkuro/20090617/1245224266 python3.1の新機能が良い・・・(´Д`;)ハアハア - Pashango’s Blog が参考になりました。 浮…

.recvfrom

socket.recvfrom()で返ってくるアドレスがおかしい? - 手をよく洗いましょうの続き どうもsocketの使い方がおかしかったらしい。 recvfromは基本的にUDPで使うものとのこと 日本麻酔科学会関西地方会 Yoshifumi Tanaka参照 TCPでconnectしたソケットはgetpe…

socket.recvfrom()で返ってくるアドレスがおかしい?

Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> s.c…

Pythonでの継承クラスから基底クラスのメソッド呼び出しにおけるsuper関数の振る舞い

Pythonで継承したクラスが基底クラスのメソッドを呼び出しする場合に 2種類の方法があるようです。 # -*- coding: cp932 -*- class A(object): def test(self, x): return x class B(A): def test2(self, x): return super(B, self).test(x) #super関数を使…

If-Modified-Since付きのGET

Pythonでダウンロードをするとき、If-Modified-Sinceを付けてGETしようとしていろいろ悩んだメモ import urllib2 req = urllib2.Request('http://example.com/') req.add_header('If-Modified-Since', "HTTP日付") try: foo = urllib2.urlopen(req) print fo…