<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python3.8 Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/python3-8/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/python3-8/</link>
	<description></description>
	<lastBuildDate>Fri, 29 May 2020 06:53:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>python3.8 Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/python3-8/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>:= 海象运算符 Walrus Operator &#8211; Python Weekly EP2</title>
		<link>https://zxi.mytechroad.com/blog/python/walrus-operator-python-weekly-ep2/</link>
					<comments>https://zxi.mytechroad.com/blog/python/walrus-operator-python-weekly-ep2/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Fri, 29 May 2020 06:52:38 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python3.8]]></category>
		<category><![CDATA[walrus]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6830</guid>

					<description><![CDATA[<p>[crayon-663a0d8cb4065398711408/]</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/python/walrus-operator-python-weekly-ep2/">:= 海象运算符 Walrus Operator &#8211; Python Weekly EP2</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title=":= 海象运算符 Walrus Operator - Python Weekly EP2" width="500" height="375" src="https://www.youtube.com/embed/ojhTG9Ctt0I?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<div class="responsive-tabs">
<h2 class="tabtitle">Python3</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
import re
import io

# Example 1:
a = [0] * 100
if len(a) &gt; 10:
  print(f&quot;List is too long ({len(a)} elements, expected &lt;= 10)&quot;)

n = len(a)
if n &gt; 10:
  print(f&quot;List is too long ({n} elements, expected &lt;= 10)&quot;)

if (x := len(a)) &gt; 10:
  print(f&quot;List is too long ({x} elements, expected &lt;= 10)&quot;)

# Example 2, bad
ads = &quot;Now 20% off till 6/18&quot;

m1 = re.search(r'(\d+)% off', ads)
discount1 = float(m1.group(1)) / 100 if m1 else 0.0

discount2 = float(m2.group(1)) / 100 if (m2 := re.search(r'(\d+)% off', ads)) else 0.0

print(f'{discount1 = }, {discount2 = }')

# Example 3
f1 = io.StringIO(&quot;123456789&quot;)
x1 = f1.read(4)
while x1 != '':
  print(x1)
  x1 = f1.read(4)

f2 = io.StringIO(&quot;123456789&quot;)
while (x2 := f2.read(4)) != '':
  print(x2)

# Example 4
prog_langs = {'c++', 'python', 'java'}
langs = ['C++', 'Java', 'PYthon', 'English', '中文']

l1 = [lang.lower() for lang in langs if lang.lower() in prog_langs]
print(l1)

l2 = [l for lang in langs if (l := lang.lower()) in prog_langs]
print(l2)</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/python/walrus-operator-python-weekly-ep2/">:= 海象运算符 Walrus Operator &#8211; Python Weekly EP2</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/python/walrus-operator-python-weekly-ep2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
