nozayasu-memo

プログラムのメモ

2017-08-01から1ヶ月間の記事一覧

codenize.tools piculetでAWS別アカウントにsecurity groupを移行する

aws

事前準備 アカウントA(既存)の接続情報とアカウントB(移行先)の接続情報を用意 > cat ~/.aws/credentials [A] aws_access_key_id = aws_access_key_id_for_A aws_secret_access_key = aws_secret_access_key_for_A [B] aws_access_key_id = aws_access_k…

more_itertools chunkedの処理を読む

実際のコードは以下 def chunked(iterable, n): """Break *iterable* into lists of length *n*: >>> list(chunked([1, 2, 3, 4, 5, 6], 3)) [[1, 2, 3], [4, 5, 6]] If the length of *iterable* is not evenly divisible by *n*, the last returned list w…

more_itertoolsでリストを小分けにする

大きめIDのリストを一定量の塊に分解しながら、DBに問い合わせをして後続の処理とかをしたいケースがあった そんな時にmore_itertoolsを使ったら読みやすくなったという話 結果から、more_itertoolsのchunkedを使うと次のような書き方ができる >>> from more…