<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>xef</author_name>
  <author_url>https://blog.hatena.ne.jp/xef/</author_url>
  <blog_title>Soleil cou coupe</blog_title>
  <blog_url>https://xef.hatenadiary.org/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>Rubyの先頭のアルファベット別に要素をグループ分けするサンプルを書き換えてみる。 が、ちょっとコケた。 groupbyの挙動を見てみよう。 from collections import defaultdict from itertools import groupby animals = [&quot;cat&quot;, &quot;bat&quot;, &quot;bear&quot;, &quot;camel&quot;, &quot;alpaca&quot;] d = defaultdict(list) for k, g in groupby(animals, key=lambda x: x[0]): d[k].append(list(g)) print list(g) &quot;&quot;&quot; …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fxef.hatenadiary.org%2Fentry%2F20120416%2Fp1&quot; title=&quot;itertools.groupbyを使ってみる - Soleil cou coupe&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2012-04-16 00:00:01</published>
  <title>itertools.groupbyを使ってみる</title>
  <type>rich</type>
  <url>https://xef.hatenadiary.org/entry/20120416/p1</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
