<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>cheeseshop</author_name>
  <author_url>https://blog.hatena.ne.jp/cheeseshop/</author_url>
  <blog_title>Pythonを書く</blog_title>
  <blog_url>https://cheeseshop.hatenadiary.org/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>Python2.5から使えます。他言語の人が見ると違和感があるかもしれませんが、Perlの後置ifのような書き方になります。 ## CやPerlの「a ? b : c」と同じ x = b if a else c 「普段はbだけど、もしaが成立しなければc」という覚え方をすればいいかもしれません。 これとは別に、andとorを使って擬似的な三項演算子を作ることもできます。 x = a and b or c こっちのほうがCの三項演算子と順番が同じなので分かりやすいし、Python2.4でも使えます。ただしbが偽値（0、空文字列、None）だと誤動作するので注意が必要です。</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fcheeseshop.hatenadiary.org%2Fentry%2F20070723%2F1197351180&quot; title=&quot;三項演算子 - Pythonを書く&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>2007-07-23 14:33:00</published>
  <title>三項演算子</title>
  <type>rich</type>
  <url>https://cheeseshop.hatenadiary.org/entry/20070723/1197351180</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
