<?xml version="1.0" encoding="ISO-8859-15"?>
<rss version="2.0"><channel>
<title>how to write functional python</title>
<link>http://sange.fi/~atehwa/cgi-bin/piki.cgi/</link>
<description>Recent changes in how to write functional python</description>
<item><title>how to write functional python</title>
<link>http://sange.fi/~atehwa/cgi-bin/piki.cgi/how%20to%20write%20functional%20python</link>
<guid>http://sange.fi/~atehwa/cgi-bin/piki.cgi/#1660810531</guid>
<description>&lt;p&gt;[...]

&lt;p&gt;# Don't modify data structures. No .append(). # Don't modify 
variables. You ''can'' assign to a variable that doesn't exist yet. # 
If you break the above rules, do it only within a function. Especially, 
don't ever modify data that you got as an argument, gave as an 
argument, or got as a return value of a subcall. You can, however, 
return values that you modified earlier, and give as argument values 
that you modified earlier. # Don't refer inherently stateful data 
structures (such as iterators) multiple times. The easiest way to 
achieve this is not to give them a name (i.e. not assign them 
anywhere). &lt;ins&gt;If you need to put them into data structures, convert 
them to something rereadable, such as list.&lt;/ins&gt; 

&lt;p&gt;[...]

&lt;p&gt;Here are the non-destructive variants (returning new data structures 
instead of modifying the existing one) of the builtin operations: {{{ 
Destructive Non-destructive ls.append(x) ls + [x] ls.clear() [] 
ls.copy() ls ls.extend(ls2) ls + ls2 ls.pop(i) &lt;ins&gt;# or del&lt;/ins&gt; 
ls[i] &lt;ins&gt;ls[:i] + ls[i+1:]&lt;/ins&gt; ls.reverse() reversed(ls) ls.sort() 
sorted(ls) ls.insert(i, x) [*ls[:i], x, *ls[i:]] ls[i] = x [*ls[:i], x, 
*ls[i+1:]] ls[i:j] = ls2 ls[:i] + ls2 + ls[j:] }}} 

&lt;p&gt;[...]

</description>
<pubDate>Thu, 18 Aug 2022 08:15:31 +0000</pubDate>
</item>

</channel></rss>
