lifewithpython.com
Life with Python: 4月 2015
http://www.lifewithpython.com/2015_04_01_archive.html
Python Tips: Python で簡易サーバを走らせる. ターミナルからの python コマンドでサーバを立ち上げることができます。 Python 2 と Python 3 では組み込みのライブラリの構成が異なっているためコマンドが若干異なります。 Python2.7 -m SimpleHTTPServer 8080. Python -m http.server 8080. いずれも末尾の 8080 の部分はポート番号です。このサンプルでは 8080 としていますが特に 8080 である必要はなく、利用したいポート番号を指定することができます。ポート番号を省略した場合はいずれも 8000 がデフォルトで選択されるようになっています。 Python Tips:string の format 内で {} を出力したい. Python の format で {} を出力する方法をご紹介します。 まず python の format とは何のことを言っているかといいますと、次の文字列の format メソッドのことを指しています。 フォーマットのシンタックス - Python 公式ドキュメント.
lifewithpython.com
Python Tips:pip そのものをアップデートしたい - Life with Python
http://www.lifewithpython.com/2015/07/pip-upgrade-itself.html
Python Tips:pip そのものをアップデートしたい. Python のパッケージ管理コマンドである pip 自身をアップデートする方法をご紹介します。 Pip は pip そのものが PyPI パッケージとなっているので pip コマンドでアップデートすることができます。 PyPI パッケージをアップデートするには `pip install` に `- upgrade` オプションを付けて実行します。 Pip install - upgrade pip. しばらく気づきませんでしたが、 2014 年の年末頃のアップデートから pip のバージョンが 1.5 から 6.0 となり、最初の 1 を取った形でのバージョン表記になったようです。引き続き活発に開発が進められているようで頼もしいです。 Python - How do I update pip itself from inside my virtual environment? プログラミング言語 Python の使い方について書いています。 Pythonで一番最初に入れるべきパッケージ setuptools と pip.
protocolostomy.com
Python | Musings of an Anonymous Geek
http://www.protocolostomy.com/category/python
Musings of an Anonymous Geek. Made with only the finest 1's and 0's. Archive for the ‘Python’ Category. Laquo; Older Entries. What I’ve Been Up To. Sunday, August 5th, 2012. I use my blog as a sort of informal record of what I accomplished over the course of the year, hurdles I ran into, etc. I also sometimes use it to start a dialog about something, or to ‘think out loud’ about ideas. So it’s partially for my own reference. I’m participating again for the third year in the Program Committee and an...
lifewithpython.com
Life with Python: 2月 2015
http://www.lifewithpython.com/2015_02_01_archive.html
Collectons の Counter というクラスを使うときれいに書くことができます。 以上です。少し変更して標準入力を受け付けるようにすると、ちょっとした英単語カウンタとして使えます。 Python: Split string with multiple delimiters - Stack Overflow. Python Tips:標準入力を 1 行ずつ処理したい. Python で標準入力から入力を得て 1 行ずつ処理する方法をご紹介します。 ちょっとしたコマンドラインツールを作るときに 1 行ずつ処理できれば便利かと思います。 やり方はいくつか考えられるかと思いますが、ひとつカンタンな方法は fileinput ライブラリを使う方法です。 ライブラリを読み込み import fileinput # 入力の各行に対して処理を行う for line in fileinput.input(): # some process. pass. たとえば、単語の数を行ごとに数えてみたいなら次のようにすれば OK です。 次の内容のファイル sample.txt があったとすると. 生成される合成リストの...
gavinroy.com
PyCon by Network Adapter Manufacturer
https://gavinroy.com/posts/pycon-by-network-adapter-manufacturer.html
Gavin M. Roy. PyCon by Network Adapter Manufacturer. On Friday, Doug Hellmann. Fame commented on Twitter. That he'd be interested in the breakdown of laptop vendors for people attending PyCon, something I had been pondering that morning as well. The results confirmed the impression one gets just walking around and looking at what people are using:. A pretty strong showing of Apple devices. It appears that the lower end numbers are either mobile devices on the network or network gear.
protocolostomy.com
Scripting | Musings of an Anonymous Geek
http://www.protocolostomy.com/category/scripting
Musings of an Anonymous Geek. Made with only the finest 1's and 0's. Archive for the ‘Scripting’ Category. Laquo; Older Entries. What I’ve Been Up To. Sunday, August 5th, 2012. I use my blog as a sort of informal record of what I accomplished over the course of the year, hurdles I ran into, etc. I also sometimes use it to start a dialog about something, or to ‘think out loud’ about ideas. So it’s partially for my own reference. I’m participating again for the third year in the Program Committee and...
protocolostomy.com
Uncategorized | Musings of an Anonymous Geek
http://www.protocolostomy.com/category/uncategorized
Musings of an Anonymous Geek. Made with only the finest 1's and 0's. Archive for the ‘Uncategorized’ Category. Laquo; Older Entries. Sending Alerts With Graphite Graphs From Nagios. Friday, February 24th, 2012. Also, note that I assume you already know Nagios, how to install new command scripts, and all that. It’s really easy to figure this stuff out in Nagios, and it’s well-documented elsewhere, so I don’t cover anything here but the configuration of this new feature. One thing that *is* pretty nice abo...
lifewithpython.com
Life with Python: 5月 2015
http://www.lifewithpython.com/2015_05_01_archive.html
変数 abc があるかどうかをチェック try: abc except NameError: # なかった場合の処理. ただ変数がそのスコープにあるかどうかだけでなく、もう少し厳密にチェックしたい場合には locals() globals() が使えます。 locals() はローカルスコープの名前を、 globals() はグローバルスコープの名前一覧を格納したリストです。 ローカルスコープでチェック if 'abc' in locals(): # あった場合の処理 else: # なかった場合の処理. グローバルスコープでチェック if 'abc' in globals(): # あった場合の処理 else: # なかった場合の処理. ちなみに、変数名ではなく、クラスが特定の名前のプロパティやメソッドを持つかどうかをチェックしたい場合には hasattr() や dir() が利用できます。 まずは、最もシンプルな dict 型を使った方法から。 さらに Python 2 系では Python 2.7 から導入された Counter クラスを使った方法もあります。 Counting repeated...
pymotw.com
Python Module of the Week - Python Module of the Week
https://pymotw.com/2
If you find this information useful, consider picking up a copy of my book, The Python Standard Library By Example. Subscribe in a reader. Python Module of the Week. The Python Module of the Week. Series, or PyMOTW, is a tour of the Python. Standard library through short examples. This is version 1.132, last updated Aug 06, 2016 to cover the ConfigParser. Complete Table of Contents. Lists all articles and subsections. Background on the project. Quick access to all modules. All functions, classes, terms.
SOCIAL ENGAGEMENT