<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>nishiohirokazu</author_name>
  <author_url>https://blog.hatena.ne.jp/nishiohirokazu/</author_url>
  <blog_title>西尾泰和のはてなダイアリー</blog_title>
  <blog_url>https://nishiohirokazu.hatenadiary.org/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>Pythonでは条件節の中に代入文を書くことができない。この制限は初心者が「代入と値が同じかどうかの比較を間違える」というありがちなミスをしてバグの原因になるのを防いでいる。が、しかしそのせいでif文の前で一時的な変数に値を代入しなければいけないのはちょっとめんどくさい。 import re data = &quot;aaaabbbbaaaa&quot; m = re.search(&quot;b+&quot;, data) if m: print &quot;'b+' is found at&quot;, m.start() 一つの解決法はスタックを導入することだ。僕のbigstackライブラリを使えば下のように書ける。 import re impo…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fnishiohirokazu.hatenadiary.org%2Fentry%2F20080214%2F1202981087&quot; title=&quot;条件文の前の代入を取り除く - 西尾泰和のはてなダイアリー&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>2008-02-14 18:24:47</published>
  <title>条件文の前の代入を取り除く</title>
  <type>rich</type>
  <url>https://nishiohirokazu.hatenadiary.org/entry/20080214/1202981087</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
