Hatena::Groupfukuoka-py

uchikoshi22.py

|

2011-10-14

hashlibモジュールことはじめ

17:49

文字列ハッシュ化をする必要性がでてきたので、サラッと調べてみました。


●セキュアハッシュとは...



Pythonハッシュ値を生成する

(例)ここでは「zuzuPost」という文字列ハッシュ値を生成します。

ドキュメントに沿って基本通りに

# Python 2.6を使っています。
# 文字列追加の為あえて、zuzuとPost部に分けてます。
>>> import hashlib
>>> hs = hashlib.sha224()
>>> hs.update("zuzu")
>>> hs.update("Post")
>>> hs.digest()
'\x97\n\x1f4\t\rG9\xcd\x9ev\r\xde#\xd2\xd9\\\x8b\x13\x9c\xd5\x1b&M\xb32\xad@'

②ちょっと短くしてみます。

>>> hashlib.sha224("zuzuPost").digest()
'\x97\n\x1f4\t\rG9\xcd\x9ev\r\xde#\xd2\xd9\\\x8b\x13\x9c\xd5\x1b&M\xb32\xad@'

SiingiSiingi2012/02/21 04:30A few years ago I'd have to pay seomone for this information.

lmpctcowvtlmpctcowvt2012/02/22 01:22M4vtnt , [url=http://chkfiackadod.com/]chkfiackadod[/url], [link=http://soutwzuuaaag.com/]soutwzuuaaag[/link], http://ayeohipdnmxl.com/

idtyshdzlidtyshdzl2012/02/29 02:55nTxvv8 <a href="http://goxnvflflfjl.com/">goxnvflflfjl</a>

2011-09-26

EmacsをPython用IDEとしてセットアップ

07:23

1. python-mode.elをインストール

ダウンロード先はこちら↓

https://launchpad.net/python-mode

$ wget http://launchpad.net/python-mode/trunk/6.0.2/+download/python-mode.el-6.0.2.tar.gz

$ tar zxvf python-mode.el-6.0.2.tar.gz

$ cd python-mode.el-6.0.2

$ cp python-mode.el $HOME/.emacs.d/

.emacsファイルに下記を追記

(add-to-list `load-path "~/.emacs.d/")
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))


2. ipythonをインストール

$ sudo apt-get install ipython

$ wget http://ipython.scipy.org/dist/ipython.el

$ cp ipython.el $HOME/.emacs.d


3. ipython-mode.elをインストール

$ wget http://ipython.scipy.org/dist/ipython.el

$ cp ipython.el $HOME/.emacs.d/

.emacsファイルに下記を追記

(setq python-python-command "/usr/bin/ipython")
(require `ipython)

※注意

C-c !だと普通にPython Shellが起動するので、M-x python-shellを実行しないとemacs内でipythonは実行されません。

4. pylookupをインストール

$ apt-get install python2.6-doc


5. autopairをインストール

autopair.elをダウンロード

$ wget http://autopair.googlecode.com/svn/trunk/autopair.el

$ cp autopair.el > $HOME/.emacs.d/

.emacsファイルに下記を追記

(autoload 'autopair-global-mode "autopair" nil t)
(autopair-global-mode)

(add-hook 'python-mode-hook
          #'(lambda ()
              (push '(?' . ?')
                    (getf autopair-extra-pairs :code))
              (setq autopair-handle-action-fns
                    (list #'autopair-default-handle-action
                          #'autopair-python-triple-quote-action))))

6. pep8とpylintをインストール

$ sudo apt-get install pylint pep8

$ wget http://gist.github.com/raw/302847/3331473995b55cc578e7d63dd82474749367c29c/python-pep8.el

$ cp python-pep8.e. $HOME/.emacs.d/

$ wget http://gist.github.com/raw/302848/60961ad1134e7bec5d836857fb67109245548dad/python-pylint.el

$ cp python-pylint.el /home/zuzu/.emacs.d/

.emacsファイルに下記を追記

(require 'python-pep8)
(require 'python-pylint)
(add-hook 'before-save-hook 'delete-trailing-whitespace)

7. ipdbをインストール

$ sudo easy_install ipdb


8. Yasnippetインストール

$ wget http://yasnippet.googlecode.com/files/yasnippet-bundle-0.6.1c.el.tgz

$ tar zxvf yasnippet-bundle-0.6.1c.el.tgz

$ cp yasnippet-bundle.el $HOME/.emacs.d/

$ mkdir $HOME/.emacs.d/my-snippets

.emacsファイルに下記を追記

(require 'yasnippet-bundle)
(yas/initialize)
(yas/load-directory "~/.emacs.d/my-snippets/")

参考URL

Configuring Emacs as a Python IDE

JamKnorpJamKnorp2017/05/15 23:34Clavamox No Prescription Best Place To Buy Tretinoin 0.05 Stendra 50mg Erectile Dysfunction Exeter Orlistat By Mail Viagra Packstation <a href=http://byuvaigranonile.com>viagra</a> Direct Free Shipping Pyridium Buy Drugs Cash On Delivery Purchase Arava Levitra Prix Orodispersible

RonalddoorpRonalddoorp2017/08/30 13:45<a href=http://acheterfinasteridesansordonnance.com/>acheter finastГ©ride</a>
acheter du finasteride
<a href=" http://acheterfinasteridesansordonnance.com/ ">acheter finasteride</a>
acheter finasteride sans ordonnance

ColinGofColinGof2017/08/30 14:51<a href=http://acheterclomidenlignefrance.com/>acheter clomid livraison rapide</a>
clomid acheter sur internet
<a href=" http://acheterclomidenlignefrance.com/ ">ou acheter du clomid relance</a>
acheter clomid sans ordonnance

StevenPenStevenPen2017/08/30 14:51<a href=http://sildenafilpfizer50mgprix.com/>sildenafil pfizer 25 mg</a>
sildenafil pfizer 50 mg comprimГ© pelliculГ© boГ®te de 24 prix
<a href=" http://sildenafilpfizer50mgprix.com/ ">sildenafil pfizer 100 mg</a>
sildenafil pfizer 100 mg

ClarkVomClarkVom2017/08/30 14:52<a href=http://sildenafil100mgprixenpharmacieenfrance.com/>sildamax sildenafil citrate tablets 100mg</a>
what is sildenafil citrate 100mg
<a href=" http://sildenafil100mgprixenpharmacieenfrance.com/ ">avis sildenafil 100mg</a>
sildenafil 50mg ou 100mg

JuliusFrEctJuliusFrEct2017/08/30 14:52<a href=http://tadalafil20mgpaschereninde.com/>cialis tadalafil 20mg</a>
tadalafil 20mg avis
<a href=" http://tadalafil20mgpaschereninde.com/ ">tadalafil 20mg prix</a>
tadalafil 20mg effets secondaires

SamuelflurnSamuelflurn2017/08/30 14:54<a href=http://acheteramoxicilline500enligne.com/>amoxicilline 500 mg gГ©lules</a>
amoxicilline mylan pharma 500
<a href=" http://acheteramoxicilline500enligne.com/ ">amoxicilline mylan 500 mg gГ©lule boГ®te de 12</a>
amoxicilline teva 500 mg

TimothylarTimothylar2017/08/30 14:55<a href=http://acheteramoxicillinesansordonnance.com/>amoxicilline 1g sans ordonnance</a>
amoxicilline 1g sans ordonnance
<a href=" http://acheteramoxicillinesansordonnance.com/ ">equivalent amoxicilline sans ordonnance</a>
derive amoxicilline sans ordonnance

CharliecewCharliecew2017/08/30 14:55<a href=http://acheterpropeciasansordonnance.com/>propecia generique</a>
propecia achat
<a href=" http://acheterpropeciasansordonnance.com/ ">hair loss propecia</a>
buy propecia

CharlesCrymnCharlesCrymn2017/08/30 14:58<a href=http://vardenafilprixenpharmacieacaen.com/>vardenafil prix en pharmacie</a>
acheter vardenafil
<a href=" http://vardenafilprixenpharmacieacaen.com/ ">vardenafil prix en pharmacie</a>
acheter vardenafil france

JamesloasyJamesloasy2017/08/30 15:12<a href=http://acheteramoxicillinepascherenfrance.com/>acheter amoxicilline sans ordonnance</a>
acheter amoxicilline 1g
<a href=" http://acheteramoxicillinepascherenfrance.com/ ">acheter amoxicilline 1g</a>
acheter amoxicilline sans ordonnance

HowardziseeHowardzisee2017/08/31 07:07<a href=http://viagrahap30.org/>female viagra review</a>
how does female viagra work
<a href=" http://viagrahap30.org/ ">female viagra company</a>
female viagra name

MichaelRefMichaelRef2017/08/31 07:15<a href=http://viagraning30.org/>pfizer viagra coupon</a>
pfizer viagra coupon
<a href=" http://viagraning30.org/ ">viagra coupon 2015</a>
viagra coupon 2015

RalphNafRalphNaf2017/08/31 07:19<a href=http://fortperhat30.org/>best price cialis 5mg</a>
cvs price for cialis
<a href=" http://fortperhat30.org/ ">price of cialis</a>
cialis price

JasonfemJasonfem2017/08/31 07:20<a href=http://parlittga30.org/>where can i buy cialis over the counter</a>
buy real cialis online
<a href=" http://parlittga30.org/ ">buy cialis</a>
buy cialis canada

BrettbydayBrettbyday2017/08/31 07:22<a href=http://viagralac30.org/>cheap generic viagra 100mg</a>
generic for viagra
<a href=" http://viagralac30.org/ ">is generic viagra available</a>
is there generic viagra

JamessibJamessib2017/08/31 07:26<a href=http://feheckevent30.org/>cialis cost vs viagra cost</a>
viagra vs cialis forum
<a href=" http://feheckevent30.org/ ">viagra vs cialis vs levitra</a>
cost viagra vs cialis

KennethguemeKennethgueme2017/08/31 07:26<a href=http://howduca30.org/>viagra 50 mg for sale</a>
viagra for sale nyc
<a href=" http://howduca30.org/ ">herb viagra for sale</a>
real viagra for sale

BriangitagBriangitag2017/08/31 07:50<a href=http://viagragot30.org/>buy viagra</a>
buy viagra cheaper
<a href=" http://viagragot30.org/ ">buy viagra</a>
where to buy viagra

LloydpseuhLloydpseuh2017/08/31 07:50<a href=http://viagrathen30.org/>what is herbal viagra</a>
chinese herbal viagra
<a href=" http://viagrathen30.org/ ">reload herbal viagra</a>
best herbal viagra

HaroldSedHaroldSed2017/08/31 08:08<a href=http://thenronkin30.org/>cialis for sale india</a>
cialis for sale toronto
<a href=" http://thenronkin30.org/ ">cheap cialis for sale</a>
viagra cialis levitra for sale

FrancismoxFrancismox2017/08/31 08:09<a href=http://viagraund30.org/>natural viagra gnc</a>
viagra natural para hombres casero
<a href=" http://viagraund30.org/ ">all natural viagra</a>
natural alternative to viagra

JasonjagJasonjag2017/08/31 08:09<a href=http://retlehen30.org/>when will cialis become generic</a>
what is the generic for cialis
<a href=" http://retlehen30.org/ ">generic cialis reviews</a>
cialis generic name

MelvinGauseMelvinGause2017/08/31 08:10<a href=http://dintrolha.org/>where can i buy prednisone online</a>
where can i buy prednisone over the counter
<a href=" http://dintrolha.org/ ">buy prednisone</a>
buy prednisone online without prescription

DamiangroubDamiangroub2017/08/31 08:11<a href=http://tertsepa.org/>best place to buy generic viagra online</a>
canadian pharmacy generic viagra
<a href=" http://tertsepa.org/ ">generic viagra india</a>
how much will generic viagra cost

JasonfemJasonfem2017/09/01 07:23<a href=http://parlittga30.org/>buy cialis online usa</a>
buy cialis in mexico
<a href=" http://parlittga30.org/ ">where to buy cialis</a>
buy generic cialis

KennethguemeKennethgueme2017/09/01 07:23<a href=http://howduca30.org/>brand viagra for sale</a>
viagra pills for sale
<a href=" http://howduca30.org/ ">viagra single packs for sale</a>
herb viagra for sale

DamiangroubDamiangroub2017/09/01 07:23<a href=http://tertsepa.org/>is there a generic viagra</a>
canadian pharmacy generic viagra
<a href=" http://tertsepa.org/ ">when will generic viagra be available</a>
generic viagra online

MelvinGauseMelvinGause2017/09/01 07:27<a href=http://dintrolha.org/>buy prednisone online</a>
buy generic prednisone online
<a href=" http://dintrolha.org/ ">can i buy prednisone over the counter</a>
where can i buy prednisone over the counter

ThomassuectThomassuect2017/09/02 08:00<a href=http://finasterideforsale01.org/>minoxidil and finasteride for sale</a>
finasteride tablets for sale
<a href=" http://finasterideforsale01.org/ ">topical finasteride for sale</a>
finasteride tablets for sale

JamesRomJamesRom2017/09/02 08:11<a href=http://sildenafilcost01.org/>sildenafil generic cost</a>
cost of sildenafil on private prescription
<a href=" http://sildenafilcost01.org/ ">cost of sildenafil 20 mg</a>
sildenafil citrate 20 mg cost

RogervenRogerven2017/09/02 17:10<a href=http://purchaseviagra01.org/>purchase viagra no prescription</a>
can i purchase viagra online
<a href=" http://purchaseviagra01.org/ ">purchase viagra online</a>
viagra purchase

JustingerJustinger2017/09/02 17:13<a href=http://buylisinopril01.org/>where to buy lisinopril</a>
where to buy lisinopril
<a href=" http://buylisinopril01.org/ ">buy lisinopril uk</a>
how to buy lisinopril online

DavidtakDavidtak2017/09/02 17:13<a href=http://buyvalacyclovir01.org/>buy valacyclovir 1000 mg</a>
buy valacyclovir
<a href=" http://buyvalacyclovir01.org/ ">buy valacyclovir online</a>
buy valacyclovir

EugeneGrereEugeneGrere2017/09/02 17:16<a href=http://cheappropecia01.org/>how to get propecia cheap</a>
cheap propecia reddit
<a href=" http://cheappropecia01.org/ ">buy cheap propecia</a>
buy cheap propecia no prescription

MichaelnaxMichaelnax2017/09/02 17:16<a href=http://azithromycincost01.org/>cost of azithromycin</a>
azithromycin cost no insurance
<a href=" http://azithromycincost01.org/ ">azithromycin 500 mg cost</a>
azithromycin cost at walmart

HeathfrattHeathfratt2017/09/02 17:21<a href=http://buypropecia01.org/>buy propecia uk</a>
where to buy propecia
<a href=" http://buypropecia01.org/ ">buy cheap propecia no prescription</a>
buy propecia online no prescription

RichardKARGORichardKARGO2017/09/02 17:21<a href=http://prednisoloneprice01.org/>prednisone 20 mg price</a>
prednisone 20 mg price
<a href=" http://prednisoloneprice01.org/ ">prednisone price walgreens</a>
prednisone street price

MatthewPayncMatthewPaync2017/09/02 17:21<a href=http://azithromycinforsale01.org/>azithromycin 500mg for sale</a>
azithromycin 500mg for sale
<a href=" http://azithromycinforsale01.org/ ">azithromycin 1g for sale</a>
azithromycin for sale

DavideluthDavideluth2017/09/02 18:43<a href=http://amoxicillinforsale01.org/>amoxicillin 200 mg for sale</a>
amoxicillin for sale canada
<a href=" http://amoxicillinforsale01.org/ ">amoxicillin antibiotics for sale</a>
amoxicillin 500mg dosage for sale

RickynouptRickynoupt2017/09/03 07:53<a href=http://buyazithromycin02.org/>buy azithromycin 500mg</a>
where to buy azithromycin
<a href=" http://buyazithromycin02.org/ ">azithromycin buy online overnight</a>
buy azithromycin online

JamesPayoxJamesPayox2017/09/03 07:53<a href=http://zithromaxprice02.org/>zithromax price costco</a>
zithromax price walmart
<a href=" http://zithromaxprice02.org/ ">zithromax z-pak price</a>
zithromax price philippines

JeffreyframnJeffreyframn2017/09/03 08:14<a href=http://viagraprice02.org/>low price viagra</a>
viagra price cvs
<a href=" http://viagraprice02.org/ ">price of viagra</a>
viagra 100mg street price

JacobtrauhJacobtrauh2017/09/03 08:32<a href=http://buymisoprostol02.org/>buy mifepristone and misoprostol online</a>
buy misoprostol online
<a href=" http://buymisoprostol02.org/ ">misoprostol buy online</a>
buy mifepristone and misoprostol online

JamesSpawsJamesSpaws2017/09/03 08:32<a href=http://cheaptadalafil02.org/>buy tadalafil cheap online</a>
cheap tadalafil online
<a href=" http://cheaptadalafil02.org/ ">cheap tadalafil cipa certified</a>
buy generic tadalafil online cheap

StevenLipStevenLip2017/09/03 08:34<a href=http://purchasecialis02.org/>cialis purchase</a>
online cialis purchase
<a href=" http://purchasecialis02.org/ ">purchase cheap cialis soft tabs</a>
purchase cialis

ScottbowScottbow2017/09/03 08:34<a href=http://prednisonecost02.org/>prednisone 5 mg cost</a>
cost of prednisone 20mg
<a href=" http://prednisonecost02.org/ ">prednisone cost walmart</a>
prednisone cost rite aid

RobertjakRobertjak2017/09/03 08:36<a href=http://nolvadexforsale02.org/>nolvadex serm for sale</a>
nolvadex pct for sale
<a href=" http://nolvadexforsale02.org/ ">nolvadex uk for sale</a>
nolvadex liquid for sale

HowardLalHowardLal2017/09/03 08:37<a href=http://metforminsale02.org/>metformin for sale online</a>
metformin 1000 mg for sale
<a href=" http://metforminsale02.org/ ">metformin for sale online</a>
metformin tegte phrmacy sale

RobertonoindRobertonoind2017/09/03 08:37<a href=http://amoxicillinprice02.org/>amoxicillin cvs price</a>
amoxicillin 500mg price
<a href=" http://amoxicillinprice02.org/ ">amoxicillin cvs price</a>
price of amoxicillin without insurance

PeterKemPeterKem2017/09/03 08:38<a href=http://valtrexprice02.org/>valtrex price walmart</a>
valtrex 1 gram price
<a href=" http://valtrexprice02.org/ ">valtrex price without insurance</a>
price of valtrex without insurance

RichardusecyRichardusecy2017/09/05 05:57<a href=http://viagraforsale04.com/>brand viagra for sale</a>
generic viagra for sale
<a href=" http://viagraforsale04.com/ ">herb viagra for sale</a>
viagra for sale online

AlfredrhiskAlfredrhisk2017/09/05 06:11<a href=http://buyviagra04.com/>best place to buy generic viagra online</a>
buy real viagra online
<a href=" http://buyviagra04.com/ ">buy viagra online usa</a>
where to buy viagra

WinfredshomyWinfredshomy2017/09/05 06:12<a href=http://viagraprice04.com/>100 mg viagra price</a>
viagra price cvs
<a href=" http://viagraprice04.com/ ">pfizer viagra 100mg price</a>
viagra 100mg price

JamesjapJamesjap2017/09/05 06:32<a href=http://purchaseviagra04.com/>purchase viagra</a>
purchase cheap viagra online
<a href=" http://purchaseviagra04.com/ ">purchase viagra from canada</a>
where can you purchase viagra

AntoniobobAntoniobob2017/09/05 06:33<a href=http://orderviagra04.com/>viagra mail order</a>
is it legal to order viagra online
<a href=" http://orderviagra04.com/ ">order viagra on line</a>
is it illegal to order viagra online

WinfredshomyWinfredshomy2017/09/05 16:12<a href=http://viagraprice04.com/>viagra street price</a>
pfizer viagra price
<a href=" http://viagraprice04.com/ ">price of viagra in canada</a>
viagra 50 mg price

RichardusecyRichardusecy2017/09/05 16:12<a href=http://viagraforsale04.com/>generic viagra for sale</a>
herbal viagra for sale
<a href=" http://viagraforsale04.com/ ">viagra for sale</a>
viagra for sale online

JamesjapJamesjap2017/09/05 16:17<a href=http://purchaseviagra04.com/>purchase viagra</a>
best place to purchase viagra online
<a href=" http://purchaseviagra04.com/ ">purchase viagra no prescription</a>
safe online purchase of viagra

AlfredrhiskAlfredrhisk2017/09/05 16:17<a href=http://buyviagra04.com/>how to buy viagra</a>
where can i buy viagra
<a href=" http://buyviagra04.com/ ">where to buy viagra</a>
buy real viagra online

AntoniobobAntoniobob2017/09/05 16:17<a href=http://orderviagra04.com/>order viagra without prescription</a>
how to order viagra online
<a href=" http://orderviagra04.com/ ">order viagra from india</a>
how to order viagra online

MatthewnixMatthewnix2017/09/06 07:08<a href=http://canadianpharmacycialis5.com/>canadian online pharmacy cialis</a>
canadian pharmacy cialis 5 mg
<a href=" http://canadianpharmacycialis5.com/ ">cialis from canadian pharmacy</a>
canadian pharmacy cialis 40 mg

JosephrorJosephror2017/09/06 07:08<a href=http://cialisgenericbestprice5.com/>cialis 5mg price</a>
price of cialis
<a href=" http://cialisgenericbestprice5.com/ ">cialis canada price</a>
cialis 20 mg price walgreens

JamesedumpJamesedump2017/09/06 07:10<a href=http://viagracoupononline5.com/>viagra coupon card</a>
coupon for viagra
<a href=" http://viagracoupononline5.com/ ">viagra coupon walgreens</a>
viagra coupon walgreens

JerrymopJerrymop2017/09/06 07:10<a href=http://genericviagraonline5.com/>viagra generic name</a>
is there a generic for viagra
<a href=" http://genericviagraonline5.com/ ">generic viagra names</a>
does generic viagra work

MichaelGobMichaelGob2017/09/06 07:12<a href=http://genericcialisonline5.com/>generic cialis reviews</a>
generic cialis canada
<a href=" http://genericcialisonline5.com/ ">buy cialis generic</a>
cialis generic date

MatthewcopMatthewcop2017/09/06 07:14<a href=http://buyingcialischeap5.com/>buying cialis online</a>
buying cialis online safely
<a href=" http://buyingcialischeap5.com/ ">buying cialis in mexico</a>
buying cialis online

MatthewPeabeMatthewPeabe2017/09/06 07:15<a href=http://bestplacetobuycialisonline5.com/>where to buy cialis over the counter</a>
best place to buy cialis online forum
<a href=" http://bestplacetobuycialisonline5.com/ ">buy cialis cheap</a>
best place to buy cialis online

WalternorieWalternorie2017/09/06 07:15<a href=http://cialiscoupononline5.com/>coupon cialis</a>
free cialis coupon
<a href=" http://cialiscoupononline5.com/ ">cialis coupon</a>
coupon for cialis

JosephinvenJosephinven2017/09/06 07:16<a href=http://howmuchdoescialiscost5.com/>cost of cialis at walgreens</a>
cialis cost
<a href=" http://howmuchdoescialiscost5.com/ ">cialis for daily use cost</a>
cialis cost

RichardTugRichardTug2017/09/07 03:26<a href=http://vegasslotsonline6.org/>vegas slots online free</a>
vegas slots online
<a href=" http://vegasslotsonline6.org/ ">las vegas slots online</a>
vegas online slots

RichardOrdeTRichardOrdeT2017/09/07 03:26<a href=http://onlinecasinoslots6.org/>online casino slots</a>
play free casino slots online
<a href=" http://onlinecasinoslots6.org/ ">slots online casino</a>
best online casino slots

WillieLotWillieLot2017/09/07 03:31<a href=http://casinogamesonline6.org/>casino free games online</a>
online free casino slot games
<a href=" http://casinogamesonline6.org/ ">online casino games win real money</a>
casino games online

BrianOrariBrianOrari2017/09/07 03:31<a href=http://slotmachinegames6.org/>quick hit slot machine games</a>
slot machine free games
<a href=" http://slotmachinegames6.org/ ">free slot machine games with free spins</a>
free slot machine games

HeathVakHeathVak2017/09/07 05:04<a href=http://freespinscasino6.org/>norsk casino free spins</a>
double u casino free spins
<a href=" http://freespinscasino6.org/ ">online casino free roulette spins</a>
online casino free spins

WilliamJoigoWilliamJoigo2017/09/07 05:04<a href=http://playslotsonline6.org/>play quick hits slots online free</a>
play slots machines online
<a href=" http://playslotsonline6.org/ ">play free online slots</a>
play quick hits slots online free

JimmieLarJimmieLar2017/09/07 05:04<a href=http://freespinsslots6.org/>free spins slots</a>
free slots games free spins
<a href=" http://freespinsslots6.org/ ">slots machines free spins</a>
slots free games free spins

ThomasstambThomasstamb2017/09/07 05:04<a href=http://americanroulette6.org/>roulette wheel american</a>
american roulette strategies
<a href=" http://americanroulette6.org/ ">how to win american roulette in casino</a>
american roulette free

RoberttroubRoberttroub2017/09/07 05:05<a href=http://casinocardgame6.org/>rules to casino card game</a>
play casino card game
<a href=" http://casinocardgame6.org/ ">casino card game</a>
rules to card game casino

HowardkefHowardkef2017/09/07 05:06<a href=http://casinoslotmachine6.org/>how to pick a winning slot machine at a casino</a>
slot machine free casino
<a href=" http://casinoslotmachine6.org/ ">slot machine casino</a>
slot machine casino

ElmerVetElmerVet2017/09/07 05:06<a href=http://onlinecasinonodeposite6.org/>vegas casino online no deposit bonus</a>
online casino no deposit bonus keep what you win
<a href=" http://onlinecasinonodeposite6.org/ ">no deposit online casino</a>
online casino no deposit bonus usa

JerrywradoJerrywrado2017/09/07 05:12<a href=http://freeslots7776.org/>free online slots 777</a>
777 slots free play
<a href=" http://freeslots7776.org/ ">free slots for fun 777</a>
free games slots 777

SteveBoumpSteveBoump2017/09/07 05:14<a href=http://onlinekasino6.org/>dutty moonshine & kid kasino everybody lyrics</a>
evro kasino
<a href=" http://onlinekasino6.org/ ">kasino portal</a>
michael kasino

StanleyMipStanleyMip2017/09/07 05:14<a href=http://3cardpokeronline6.org/>3 card poker online for free</a>
3 card poker game online
<a href=" http://3cardpokeronline6.org/ ">3 card poker online</a>
3 card poker free online

RickydonRickydon2017/09/07 05:14<a href=http://playonlineroullette6.org/>play roulette online real money</a>
play roulette for free online
<a href=" http://playonlineroullette6.org/ ">play online roulette</a>
play roulette online for free

WaynezorgeWaynezorge2017/09/08 00:45<a href=http://prednisoneprice7.com/>prednisone 20 mg price</a>
prednisone price canada
<a href=" http://prednisoneprice7.com/ ">prednisone 20 mg price walmart</a>
price of prednisone

ErnestvowErnestvow2017/09/08 00:45<a href=http://viagraforsale7.com/>cheap viagra for sale</a>
viagra for men for sale
<a href=" http://viagraforsale7.com/ ">viagra for sale on craigslist</a>
viagra for sale

RuebenChariRuebenChari2017/09/08 04:42<a href=http://tadalafilbestprice7.com/>comparison price tadalafil</a>
best price tadalafil 20 mg
<a href=" http://tadalafilbestprice7.com/ ">tadalafil 10mg price</a>
best price for tadalafil

CalvinwrocaCalvinwroca2017/09/08 04:47<a href=http://buylevitraonline7.com/>best place to buy levitra online</a>
buy generic levitra
<a href=" http://buylevitraonline7.com/ ">best place to buy levitra online</a>
buy levitra online

CraigpiozyCraigpiozy2017/09/08 04:47<a href=http://buyzithromax7.com/>buy zithromax without prescription</a>
buy zithromax without prescription
<a href=" http://buyzithromax7.com/ ">where to buy zithromax</a>
where can i buy zithromax over the counter

DustinDycleDustinDycle2017/09/08 04:54<a href=http://cialisprice7.com/>cialis 5mg price walmart</a>
cialis price
<a href=" http://cialisprice7.com/ ">cialis 5mg price walmart</a>
cialis 20 mg price

JoshuabedJoshuabed2017/09/08 04:54<a href=http://viagracost7.com/>how much does viagra cost at walmart</a>
viagra cost per pill
<a href=" http://viagracost7.com/ ">viagra generic cost</a>
cost of viagra pills

JamiewaymnJamiewaymn2017/09/08 04:54<a href=http://sertralineprice7.com/>sertraline 50 mg price</a>
sertraline 100mg price wallgreen
<a href=" http://sertralineprice7.com/ ">price of sertraline</a>
walmart sertraline price

MelvinontoNMelvinontoN2017/09/08 04:55<a href=http://zoloftcost7.com/>generic zoloft cost</a>
cost of zoloft at walmart
<a href=" http://zoloftcost7.com/ ">zoloft cost with insurance</a>
how much does generic zoloft cost

JaredhasteJaredhaste2017/09/08 04:59<a href=http://clomidforsale7.com/>clomid for sale</a>
clomid supplement for men for sale
<a href=" http://clomidforsale7.com/ ">clomid fertility pills for sale</a>
clomid fertility pills for sale

JosephbugJosephbug2017/09/08 04:59<a href=http://ciprofloxacinprice7.com/>price of ciprofloxacin</a>
ciprofloxacin ophthalmic solution dosage price
<a href=" http://ciprofloxacinprice7.com/ ">ciprofloxacin dexamethasone ear drops price</a>
ciprofloxacin dexamethasone ear drops price

JimmymofJimmymof2017/09/09 07:43<a href=http://buyfinasteride8.com/>finasteride buy online usa</a>
can i buy finasteride over the counter
<a href=" http://buyfinasteride8.com/ ">buy propecia finasteride 1mg</a>
buy finasteride europe

KeithNenKeithNen2017/09/09 07:43<a href=http://sildenafilprice8.com/>sildenafil 100mg tablets price</a>
sildenafil best price
<a href=" http://sildenafilprice8.com/ ">sildenafil 100mg price</a>
sildenafil walgreens price

AnthonyIcownAnthonyIcown2017/09/09 07:47<a href=http://buylasix8.com/>buy lasix overnight delivery</a>
buy lasix furosemide
<a href=" http://buylasix8.com/ ">buy lasix diuretic</a>
where can i buy lasix without a prescription

JacobquateJacobquate2017/09/09 07:47<a href=http://orderlevitraonline8.com/>how to order levitra online</a>
mail order levitra
<a href=" http://orderlevitraonline8.com/ ">best place to order levitra online</a>
levitra online order

StevenbopStevenbop2017/09/09 07:47<a href=http://sdfdsfsdfsdfdssdf.com/>disulfiram buy in usa</a>
where can i buy disulfiram
<a href=" http://sdfdsfsdfsdfdssdf.com/ ">where can i buy disulfiram</a>
disulfiram buy online without a prescription

WilliamSmupsWilliamSmups2017/09/09 07:50<a href=http://buytamoxifen8.com/>tamoxifen buy online</a>
tamoxifen buy
<a href=" http://buytamoxifen8.com/ ">buy tamoxifen online</a>
tamoxifen buy

TerryfePTerryfeP2017/09/09 07:51<a href=http://tadalafilcost8.com/>tadalafil 20mg cost rite aid</a>
tadalafil generic 20 mg cost walgreens
<a href=" http://tadalafilcost8.com/ ">tadalafil cost cvs</a>
tadalafil cost

OrvilleObedyOrvilleObedy2017/09/09 07:51<a href=http://propranololprice8.com/>propranolol 80 mg price</a>
price of propranolol
<a href=" http://propranololprice8.com/ ">propranolol price walmart</a>
propranolol price 40mg

MelvinNaishMelvinNaish2017/09/09 07:51<a href=http://orderviagra8.com/>order viagra online cheap</a>
order generic viagra online
<a href=" http://orderviagra8.com/ ">order viagra</a>
how to order viagra pills

HectorvogHectorvog2017/09/09 07:53<a href=http://buyvaltrex8.com/>buy generic valtrex</a>
can you buy valtrex on line
<a href=" http://buyvaltrex8.com/ ">where to buy valtrex over the counter</a>
where to buy acyclovir zovirax famciclovir famvir and valacyclovir valtrex

FrankdenFrankden2017/09/09 07:53<a href=http://sildenafilforsale8.com/>sildenafil 100mg tablets for sale</a>
sildenafil tablets 100mg for sale
<a href=" http://sildenafilforsale8.com/ ">sildenafil citrate for sale street value</a>
sildenafil citrate for sale

MichaeljuilmMichaeljuilm2017/09/09 07:55<a href=http://buyviagra8.com/>buy generic viagra online cheap</a>
buy discount viagra
<a href=" http://buyviagra8.com/ ">viagra buy viagra</a>
buy cheap viagra online canadian pharmacy

MartinDupMartinDup2017/09/09 08:01<a href=http://orderclomid8.com/>is it safe to order clomid online</a>
order clomid online
<a href=" http://orderclomid8.com/ ">order clomid online</a>
order clomid online 2017

AntonioIcofsAntonioIcofs2017/09/09 08:01<a href=http://valacyclovirprice8.com/>price of valacyclovir usa</a>
valacyclovir price without insurance
<a href=" http://valacyclovirprice8.com/ ">valacyclovir hcl 1 gram tablet price</a>
valacyclovir price without insurance

AnthonyPapAnthonyPap2017/09/09 08:01<a href=http://buyantabuse8.com/>where to buy antabuse</a>
where can i buy antabuse
<a href=" http://buyantabuse8.com/ ">is it safe to buy antabuse online</a>
buy antabuse online

ErnestvowErnestvow2017/09/10 18:08<a href=http://viagraforsale7.com/>liquid viagra for sale</a>
liquid viagra for sale
<a href=" http://viagraforsale7.com/ ">viagra for women for sale</a>
generic viagra for sale

MelvinontoNMelvinontoN2017/09/10 18:34<a href=http://zoloftcost7.com/>how much does zoloft cost</a>
how much does zoloft cost without insurance
<a href=" http://zoloftcost7.com/ ">cost zoloft without insurance</a>
cost of zoloft with insurance

JoshuabedJoshuabed2017/09/10 18:38<a href=http://viagracost7.com/>cost of 100mg viagra</a>
viagra cost per pill
<a href=" http://viagracost7.com/ ">viagra generic cost</a>
viagra vs cialis cost

RichardusecyRichardusecy2017/09/10 18:49<a href=http://viagraforsale04.com/>cheap viagra for sale online</a>
viagra for sale near me
<a href=" http://viagraforsale04.com/ ">viagra for sale canada</a>
cheap viagra for sale

RickynouptRickynoupt2017/09/10 18:49<a href=http://buyazithromycin02.org/>buy azithromycin online usa</a>
azithromycin buy online usa
<a href=" http://buyazithromycin02.org/ ">where can i buy azithromycin over the counter</a>
where can i buy azithromycin for chlamydia

AntoniobobAntoniobob2017/09/10 18:50<a href=http://orderviagra04.com/>viagra order</a>
mail order viagra
<a href=" http://orderviagra04.com/ ">mail order viagra</a>
how to order viagra online safely

AlfredrhiskAlfredrhisk2017/09/10 18:50<a href=http://buyviagra04.com/>how to buy viagra</a>
buy viagra from canada
<a href=" http://buyviagra04.com/ ">can i buy viagra over the counter</a>
can you buy viagra online

JosephrorJosephror2017/09/10 18:58<a href=http://cialisgenericbestprice5.com/>viagra vs cialis price</a>
cialis 20 mg price
<a href=" http://cialisgenericbestprice5.com/ ">cialis generic best price</a>
cialis price cvs

JerrymopJerrymop2017/09/10 19:00<a href=http://genericviagraonline5.com/>generic viagra without a doctor prescription</a>
generic name for viagra
<a href=" http://genericviagraonline5.com/ ">best place to buy generic viagra online</a>
canadian pharmacy generic viagra

WilliamFouttWilliamFoutt2017/09/10 19:21<a href=http://buyprednisolone02.org/>where can i buy prednisolone online</a>
buy prednisolone
<a href=" http://buyprednisolone02.org/ ">buy prednisolone no prescription</a>
buy prednisolone for cats

WinfredshomyWinfredshomy2017/09/10 19:37<a href=http://viagraprice04.com/>best price viagra</a>
price of viagra 100mg
<a href=" http://viagraprice04.com/ ">low price viagra</a>
viagra price walmart

JosephinvenJosephinven2017/09/10 20:17<a href=http://howmuchdoescialiscost5.com/>cost of cialis without insurance</a>
cialis cost walmart
<a href=" http://howmuchdoescialiscost5.com/ ">cialis cost walmart</a>
cialis cost

RichardSmuthRichardSmuth2017/09/11 17:35<a href=http://resumewritingservice10.com/>professional resume writing service</a>
sales resume writing service
<a href=" http://resumewritingservice10.com/ ">monster resume writing service</a>
writing resume service

EdwardBeiskEdwardBeisk2017/09/11 17:41<a href=http://paperwritingservice10.com/>research paper writing service</a>
student paper writing service
<a href=" http://paperwritingservice10.com/ ">custom research paper writing service</a>
best paper writing service forum

MatthewimiftMatthewimift2017/09/11 17:41<a href=http://buypapersonline10.com/>buy a paper online</a>
buy paper online
<a href=" http://buypapersonline10.com/ ">buy paper towels online</a>
buy research paper online cheap

JerryGooraJerryGoora2017/09/11 17:41<a href=http://buyingresearchpaper10.com/>buying a research paper</a>
buying research paper
<a href=" http://buyingresearchpaper10.com/ ">what is the best website for buying a research paper</a>
buying people for research paper

DavidMefDavidMef2017/09/11 18:12<a href=http://writemypaper10.com/>i have four journal papers my advisor told me i do not need to write dissertation</a>
write my research papers
<a href=" http://writemypaper10.com/ ">how do i see what grade i write my papers at</a>
write my research papers

GustavoAlincGustavoAlinc2017/09/11 18:21<a href=http://writingaresearchpaper10.com/>writing a psychology research paper</a>
the first step to writing a research paper is
<a href=" http://writingaresearchpaper10.com/ ">writing an outline for a research paper</a>
imagine you are writing a research paper on social networking sites which of the following thesis

ArthurcroreArthurcrore2017/09/11 18:21<a href=http://paperwriter10.com/>free online paper writer</a>
professional research paper writer
<a href=" http://paperwriter10.com/ ">paper writer service</a>
professional research paper writer

JamesjedJamesjed2017/09/11 18:27<a href=http://howtowritearesearchpaper10.com/>how to write a conclusion for a research paper</a>
how to write an abstract for a research paper
<a href=" http://howtowritearesearchpaper10.com/ ">how to write an abstract for a research paper apa</a>
how to write an introduction to a research paper

DanielbooraDanielboora2017/09/11 18:27<a href=http://customwrappingpaper10.com/>custom wrapping tissue paper</a>
custom gift wrapping paper manufacturer
<a href=" http://customwrappingpaper10.com/ ">custom made gift wrapping paper</a>
create custom wrapping paper

DavidEscalDavidEscal2017/09/11 18:30<a href=http://essaywritingservice10.com/>cheap essay writing service</a>
essay writing service reviews
<a href=" http://essaywritingservice10.com/ ">reliable essay writing service</a>
legit essay writing service

RichardRainoRichardRaino2017/09/11 18:30<a href=http://resumepaper10.com/>an applicant should always print their rГ©sumГ© on paper that is _____.</a>
best resume paper
<a href=" http://resumepaper10.com/ ">southworth resume paper</a>
walmart resume paper

LloydWaymnLloydWaymn2017/09/11 18:40<a href=http://buyaresearchpaper10.com/>where to buy a good research paper</a>
buy a research paper now
<a href=" http://buyaresearchpaper10.com/ ">where can i buy a research paper</a>
where to buy a good research paper

MichaelIcoriMichaelIcori2017/09/11 19:05<a href=http://writemyessay10.com/>write my essay org</a>
can someone write my essay for me
<a href=" http://writemyessay10.com/ ">write my essay for me free online</a>
can someone write my essay for me

CharlesVawCharlesVaw2017/09/11 19:42<a href=http://writemyessayforme10.com/>can someone write my essay for me</a>
write my scholarship essay for me
<a href=" http://writemyessayforme10.com/ ">write my essay for me no plagiarism</a>
write my history essay for me

HenryunoldHenryunold2017/09/11 19:44<a href=http://paperhelp10.com/>paper help reviews</a>
i need help writing a paper
<a href=" http://paperhelp10.com/ ">help with research paper</a>
help writing essay paper

HowardelareHowardelare2017/09/13 07:53<a href=http://casinolive12.com/>live casino buffet</a>
csgo live casino
<a href=" http://casinolive12.com/ ">maryland live casino hours</a>
indiana live casino

MichaelGamMichaelGam2017/09/13 07:53<a href=http://onlinecasinorealmoney12.com/>casino online real money</a>
online casino game real money
<a href=" http://onlinecasinorealmoney12.com/ ">online casino games that pay real money</a>
real money online casino

JamesDreapJamesDreap2017/09/13 08:43<a href=http://goldennuggetonline12.com/>golden nugget online casino</a>
golden nugget online promo code
<a href=" http://goldennuggetonline12.com/ ">golden nugget online casino login</a>
golden nugget online promo code

CharlesHeemyCharlesHeemy2017/09/13 08:43<a href=http://playgamesformoney12.com/>play games for money apps</a>
play free games online for money
<a href=" http://playgamesformoney12.com/ ">play card games for money</a>
play games online for real money for free

HaroldAspizHaroldAspiz2017/09/13 08:45<a href=http://accasino12.com/>resorts casino ac</a>
resorts casino ac phone number
<a href=" http://accasino12.com/ ">best casino in ac</a>
ac casino hotel

StevenPlabsStevenPlabs2017/09/13 10:09<a href=http://realmoneyslots12.com/>play online casino for real money</a>
online casino game real money
<a href=" http://realmoneyslots12.com/ ">online real money casino slots</a>
win real money online casino for free

WaynebougsWaynebougs2017/09/13 10:42<a href=http://howtowinmoneyonline12.com/>how to win free money online instantly</a>
how to win quick money online
<a href=" http://howtowinmoneyonline12.com/ ">how to win big money online</a>
how to win free money online playing games

2011-09-14

複数行のCSVの書き込み

16:30

Pythonで複数行のCSVの書き込みをおさらいしておきます。


その前に、一行だけCSVに書きこむ方法も念の為メモ。

#!/usr/bin/env python

import csv

csvfile = "/tmp/spam.csv"
csvdata = ["spam", "eggs"]

writer = csv.writer(file(csvfile, 'w'))
writer.writerow(csvdata)

上のコードを実行すると、/tmp/spam.csvファイルの中身はこうなります。

spam,eggs




なので、複数行書きこむときはこうします。


#!/usr/bin/env python

import csv

csvdata = [ ["New Zealand", "Wellington"], ["Japan", "Tokyo"]  ]
csvfile = "/tmp/spam.csv"

writer = csv.writer(file(csvfile, 'w'))
for row in csvdata:
    writer.writerow(row)

これで、/tmp/spam.csvファイルの中身はこうなります。

New Zealand,Wellington

Japan,Tokyo

ChampChamp2011/10/07 17:14Thanks guys, I just about lost it lokonig for this.

oelbynoedzwoelbynoedzw2011/10/08 21:27hXfNNH <a href="http://ykuqwbsmlbgp.com/">ykuqwbsmlbgp</a>

mpyhsydnimpyhsydni2011/10/09 02:04BOxAHq , [url=http://cuxrgcrqrxwz.com/]cuxrgcrqrxwz[/url], [link=http://rrjngcygtuhx.com/]rrjngcygtuhx[/link], http://oggecvybrijj.com/

ywherzsvywherzsv2011/10/11 02:09nQAGrX <a href="http://tcwztfbupntp.com/">tcwztfbupntp</a>

hvtufpeobhvtufpeob2011/10/13 00:55ArlcC3 , [url=http://onftovqegusk.com/]onftovqegusk[/url], [link=http://tdlmexfcfuny.com/]tdlmexfcfuny[/link], http://dlaozvomfmhs.com/

2011-09-11

妥当な日付かどうかチェックする

17:00


GAEでdatastoreにputする前に日付が正しい値かどうかチェックしたくて、妥当な日付かどうかチェックする関数を調べてみました。


from datetime import date

def validate_date(y, m, d):
  try:
    date(int(y), int(m), int(d))
    return True
  excpet ValueEror:
    return False

次の方法ではうまくいきません。


from datetime import date

def validate_date(y, m, d):
  if date(int(y), int(m), int(d)):
    return True
  else:
    return False

日付が正しくなければdate関数はValueErrorを返します。

ValueErrorはBooleanではないので、誤った日付のときにFalseを返せず、if文で判定する前にエラーが発生するので最初のソースのように例外処理を行う必要があります。

リスト内包表記のおさらい

16:42

次のリスト内包表記を説明するためにPython初心者の読める冗長なコードにしてみました。


?単純な内包表記

>>> spam = [1,2,3,4,5]
>>> eggs = [x*2 for x in spam]
>>> spam
[1, 2, 3, 4, 5]
>>> eggs
[2, 4, 6, 8, 10]
>>>
# 上の内包表記と等価のlambda式
>>> eggs = map(lambda x: x*2, spam)
>>> eggs
[2, 4, 6, 8, 10]

?解説用の冗長なコード

>>> spam = [1,2,3,4,5]
>>> eggs = []
>>> count = 0
>>> while len(spam) > count:
...     x = spam[count]
...     eggs.append(x*2)
...     count += 1
...
>>> eggs
[2, 4, 6, 8, 10]

リスト内包表記やlambda式(+map関数)を使えるようになると便利なんですが、慣れるまで頭が右往左往していたので、久しぶりに整理してみました。

lambdaの最初の一歩

16:41

lambdaのイメージがすぐわからなくなってしまうので、一旦整理。

lambda式はdefステートメントと同様、関数関数オブジェクト)の作成に使用する手段の一つです。

(初めてのPythonの369ページ)

構文: lambda 引数: 式


ということで、

与えられた引数の2倍の値を戻す関数をlambda式とdefステートメントでつくります


?defステートメント

def double(spam):
  return spam * 2

?lambda式

lambda x: x * 2

defステートメントを使って呼び出すときは、関数名に引数を与えれることで戻り値を得ます。

>>> def double(spam):
...   return spam * 2
...
>>> double(2)
4
>>> double(10)
20


lambda式は関数名がないので、呼び出すときは一旦変数に代入してから呼び出すことでdefステートメントと同じような使い方ができます。


>>> lambda x: x * 2
<function <lambda> at 0xb77db56c>
>>> double = lambda x: x*2
>>> double(2)
4
>>> double(8)
16
>>>

自分ではlambda式のイメージが湧いたんですがどうでしょうか?

多次元リストのソート

13:51

多次元リストを手軽にソートする方法を練習してみました。


①まず、ソートする対象になるリストを作ります。

>>> list = [ [2, "d", "1100"], [7, "z", "10"], [0, "t"] ]
>>> list
[[2, 'd', '1100'], [7, 'z', '10'], [0, 't']]

②内側のリストの1個目の要素をもとにソートするだけであれば次のように簡単にソートできます。

>>> list.sort()
>>> list
[[0, 't'], [2, 'd', '1100'], [7, 'z', '10']]

③これが2番目以降の要素をもとにソートしようとするとほんのちょっとだけ面倒になります。

>>> list.sort(lambda x, y: cmp(x[1], y[1]))
>>> list
[[2, 'd', '1100'], [0, 't'], [7, 'z', '10']]

④注意点として、ソート対象にする内側のリストの中に、1つでもソート対象となる要素のない短いリストがあれば次のようにエラーになります。

>>> list.sort(lambda x, y: cmp(x[2], y[2]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <lambda>
IndexError: list index out of range

⑤最後に、cmp関数を使った場合、文字列としてソートしてしまします。


数値としてソートする場合は、cmpの中のオブジェクトをint関数で囲んであげる必要があります。


※2行目と5行目を見比べてください。


>>> list = [[2,"d", "1100"],[7,"z","10"],[0,"t","120"]]
>>> list.sort(lambda x, y: cmp(x[2], y[2]))
>>> list
[[7, 'z', '10'], [2, 'd', '1100'], [0, 't', '120']]
>>> list.sort(lambda x, y: cmp(int(x[2]), int(y[2])))
>>> list
[[7, 'z', '10'], [0, 't', '120'], [2, 'd', '1100']]

Ubuntuのpyexiv2で画像Exif情報を読み取り

13:45

Ubuntu10.04で画像のExif情報を操作したい場合、いくつか方法がありますが、今回はpyexiv2を試してみました。


Ubuntu10.04環境では、パッケージが用意されているので、コマンド一発でインストールができます。

$ sudo apt-get install python-pyexiv2

インストールは簡単ですが、ここから注意が必要です。


pyexiv2のチュートリアル通りにやろうとすると、ImageMetadataメソッドを使うとき、ImageMetadataをインポートするときにエラーが出ます。




>>> metadata = pyexiv2.ImageMetadata('test.jpg')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageMetadata'
>>>
>>> from pyexiv2 import ImageMetadata
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name ImageMetadata

そこで、pyexiv2のhelp (help(pyexiv2)で見れます)の中を見てみると、ImageMetadataの記述がどこにもないんですが、ImageMetadataを使わないでExifタグの一覧を表示する方法が書かれています。


Ubuntu上でうまくいかなかったチュートリアルの方法(WindowsXP上ではエラーはでませんでした)と、うまくいったhelpに書かれている手順の両方をメモしておきます。



// チュートリアルの手順 (ubuntuでは失敗しました)

>>> import pyexiv2
>>> metadata = pyexiv2.ImageMetadata('test.jpg')
>>> metadata.read()

// helpの手順 (ubuntuでも実行できました)
>>> import pyexiv2
>>> image = pyexiv2.Image('test/smiley.jpg')
>>> image.readMetadata()
>>> print image.exifKeys()


これでようやくスタートラインに立てました。


現在、画像のExif情報を扱う簡単な(アプリと呼ぶほど大きくもない)スクリプトを書いています。

Pythonのopen()関数の注意点

11:24

Pythonでファイルを作成しようと思って検索すると以下のようなosモジュールを使ったコードをよく見かけることになると思います。


import os
f = os.open('spam.txt', 'w')
f.write('')
f.close()

ところが、実際にこのコードを実行しようとすると、2行目の段階で次のエラーメッセージに直面します。

Traceback (most recent call last):

File "<stdin>", line 1, in <module>



このエラーが出ないようにしてPythonでファイルを作成するために2つの方法を紹介します。


  1. 組み込み関数のopen()を使う
  2. osモジュールの正しい使い方を覚える


1. 組み込み関数のopen()を使う

Pythonには組み込み関数のopen()があります。osモジュールの方がより詳細なファイルアクセスができますが、組み込み関数のopen()の方が簡単かつ、実行結果も早い(みたい)です。


組み込み関数open()を使ってファイルの新規作成をするには

# spam.txtとうファイルを作って、eggsという文字列を書き込みます。
>>> f = open('spam.txt', 'w')
>>> f.write('eggs')
>>> f.close()

もっと詳しいことを知りたいときは↓

http://docs.python.org/library/functions.html#open




2. osモジュールの正しい使い方を覚える

ここでは簡単にコードだけ紹介します。

詳細は↓のドキュメントをご確認ください。



>>> import os
>>> f = os.open('eggs.txt', os.O_CREAT)
>>> f = os.open('eggs.txt', os.O_RDWR)
>>> os.write(f, 'spam')
4
>>> os.close(f)

5行目に表示される数字の4ですが、これはos.write()で実際にファイルに書き込まれたデータのバイト数を返して表示しています。


osモジュールを使う注意点として、


import osをfrom os import *と書いてしまうと、組み込み関数のopen()よりもosモジュールのopen()が優先されて組み込み関数のopen()が使えなくなるので、組み込み関数のopen()を使う時はfrom os import *とは書かないようにしましょう。

HinesHines2011/10/06 20:32Kudos to you! I hadn't thoguht of that!

weoivpweoivp2011/10/07 02:38qTOAir <a href="http://nwsrnizbsrnp.com/">nwsrnizbsrnp</a>

paiyypwvpaiyypwv2011/10/07 21:09JTrjhm , [url=http://gaqcbloiwcic.com/]gaqcbloiwcic[/url], [link=http://szrplnghtifb.com/]szrplnghtifb[/link], http://pumzstfmdbjx.com/

sumtnxsumtnx2011/10/11 00:00Pg0z8x <a href="http://haocmyvcmyab.com/">haocmyvcmyab</a>

xccloupfatxccloupfat2011/10/12 22:14WUVaf9 , [url=http://vsdcxztdnfnw.com/]vsdcxztdnfnw[/url], [link=http://qgmnnximnmek.com/]qgmnnximnmek[/link], http://rztzkpwelkvo.com/

IoryIory2012/08/21 14:43Yup, that sohuld defo do the trick!

qhczvtwokpqqhczvtwokpq2012/08/22 12:47FLbvjo <a href="http://hlhmoevhtelv.com/">hlhmoevhtelv</a>

ndwyeskdkhndwyeskdkh2012/08/25 01:55P7Tams , [url=http://qwkxjwjmizib.com/]qwkxjwjmizib[/url], [link=http://bapdceiwwbaw.com/]bapdceiwwbaw[/link], http://sraioevuykwc.com/

2011-03-13

GAEアプリをKayで2か国語対応する練習

08:41

練習のために/gaeディレクトリにzzlab-toysという名前のプロジェクトを作り、そのプロジェクトにbillingualというアプリケーションを事前につくっています。


やっていることは<http://kay-docs-jp.shehas.net/tutorial.html:title=Kayチュートリアル>と同じです。


1。settings.pyのUSE_I18Nを有効にする。

AfterBefore
USE_I18N = TrueUSE_I18N = False


2. models.pyでlazy_gettextをインポートします。

lazy_gettextをインポートして、_ で利用できるようにしておきます。

from kay.i18n import lazy_gettext as _ 

3. 2か国語対応にしたいmodelの項目にverbose_nameを追加する。

ここでは、Categoryクラスのnameフィールドを2か国語対応することを事前に表していることを意味します。

AfterBefore
class Category(db.Model):

name = db.StringProperty(required=True, verbose_name=_(u'Name'))

class Category(db.Model):

name = db.StringProperty(required=True)

4. テンプレートファイル内の文字列を2か国語対応するためにtransタグを追加します。


AfterBefore
<p>{% trans %}Billingual{% endtrans %} - TEST</p> <p>BillingualTEST</p>



5. 2か国語対応させるために3と4でマーク(指定)した文字列を抽出します

$ python2.5 manage.py extract_messages -a

▼コマンドの実行結果

Running on Kay-1.0.0

Extracting from /gae/zzlab-toys/billingual

billingual/__init__.py

billingual/models.py

billingual/urls.py

billingual/views.py

billingual/templates/index.html

All done.


6. 日本語用のpoファイルを作成します

$ python manage.py add_translations -a -l ja

▼コマンドの実行結果

Running on Kay-1.0.0

/usr/local/src/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py:64: DeprecationWarning: the sha module is deprecated; use the hashlib module instead

import sha

/usr/local/src/google_appengine/google/appengine/tools/dev_appserver_login.py:33: DeprecationWarning: the md5 module is deprecated; use hashlib instead

import md5

Creating billingual/i18n/ja/LC_MESSAGES/messages.po.

Cant open file. Skipped billingual/i18n/jsmessages.pot.

Created catalog for ja

Cant open file. Skipped /home/ziruchi/0_code/gae/zzlab-toys/i18n/messages.pot.

Cant open file. Skipped /home/ziruchi/0_code/gae/zzlab-toys/i18n/jsmessages.pot.

Created catalog for ja


※ POファイルとは...

po ファイルとは国際化のメッセージ・ファイルで日本語用には ja.po という名称に割り当てられています。

参照: http://www.yk.rim.or.jp/~hi_saito/awk/japanize.html


7. poファイルに翻訳を追加します。

poファイルの場所 -> zzlab-toys/billingual/i18n/ja/LC_MESSAGES/messages.po

※ zzlab-toysは今回の練習用に作ったアプリケーション名です。

AfterBefore

#: billingual/models.py:9

msgid "Name"

msgstr "名前"


#: billingual/templates/index.html:8

msgid "Billingual"

msgstr "2か国語"

#: billingual/models.py:9

msgid "Name"

msgstr ""


#: billingual/templates/index.html:8

msgid "Billingual"

msgstr ""


8. 7で編集したpoファイルを有効にするために、poファイルをコンパイルします。

$ python2.5 manage.py compile_translations -a

▼コマンドの実行結果

Running on Kay-1.0.0

Compiling billingual/i18n

Compiling billingual/i18n/ja/LC_MESSAGES/messages.po

All done.

i18n folder missing

i18n folder missingとエラーとも見えるメッセージが出ますが、気にする必要はないようです。



9. コンパイル終了後に、アプリケーションにアクセスすると日本語がメイン言語になっているブラウザでは3と4でマークした箇所が7で編集したとおりの日本語表記になっています。



★余談。。。

私の環境(Ubuntu)ではGoogle Chromeブラウザ(通常のメインブラウザ)の言語は英語のみとして、上記の2か国語テスト用としてUbuntuのパッケージのChromium Web Browserの言語を日本語表記テスト用に使い分けています。

MrsbgMrsbg2012/08/19 09:35Very true! Makes a chngae to see someone spell it out like that. :)

cnyzvvitcnyzvvit2012/08/19 20:21HqO9xw <a href="http://cgvhoimczurw.com/">cgvhoimczurw</a>

dukbdwacidukbdwaci2012/08/21 19:37NYSg6I <a href="http://usdpssmoqqnz.com/">usdpssmoqqnz</a>

|