<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Software Engineer]]></title><description><![CDATA[Hey Its your boy Rajesh Pudasaini working as a Software Engineer based on Kathmandu Nepal. I love doing programming but recently started exploring Golang and Blockchain Technology]]></description><link>https://blog.rajeshpudasaini.com.np</link><generator>RSS for Node</generator><lastBuildDate>Sat, 16 May 2026 21:37:02 GMT</lastBuildDate><atom:link href="https://blog.rajeshpudasaini.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Django Key (id)=(244584) already exists, Django unique constraint primary key]]></title><description><![CDATA[Replace stock_price with the table name on which you got the unique constraint issues.
SELECT MAX(id) FROM stock_price;

ALTER SEQUENCE stock_price_id_seq START WITH 245000;

ALTER SEQUENCE stock_price_id_seq RESTART;]]></description><link>https://blog.rajeshpudasaini.com.np/django-key-id244584-already-exists-django-unique-constraint-primary-key</link><guid isPermaLink="true">https://blog.rajeshpudasaini.com.np/django-key-id244584-already-exists-django-unique-constraint-primary-key</guid><category><![CDATA[Django]]></category><category><![CDATA[Python]]></category><category><![CDATA[Issue]]></category><dc:creator><![CDATA[Razyesh Pudasaini]]></dc:creator><pubDate>Wed, 18 Jan 2023 15:17:22 GMT</pubDate><content:encoded><![CDATA[<p>Replace stock_price with the table name on which you got the unique constraint issues.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">MAX</span>(<span class="hljs-keyword">id</span>) <span class="hljs-keyword">FROM</span> stock_price;
</code></pre>
<pre><code class="lang-sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">SEQUENCE</span> stock_price_id_seq <span class="hljs-keyword">START</span> <span class="hljs-keyword">WITH</span> <span class="hljs-number">245000</span>;
</code></pre>
<pre><code class="lang-sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">SEQUENCE</span> stock_price_id_seq RESTART;
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Python walrus operator is weird...]]></title><description><![CDATA[Python walrus operator (:=) was introduced in Python 3.8. This operator helps most of the developers to assign variables in the middle of an expression. 
Let's have a quick look, how walrus operator comes into hand.
def add(x):
      return x + 1

# ...]]></description><link>https://blog.rajeshpudasaini.com.np/python-walrus-operator-is-weird</link><guid isPermaLink="true">https://blog.rajeshpudasaini.com.np/python-walrus-operator-is-weird</guid><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Razyesh Pudasaini]]></dc:creator><pubDate>Wed, 11 Aug 2021 15:50:06 GMT</pubDate><content:encoded><![CDATA[<p>Python walrus operator (:=) was introduced in Python 3.8. This operator helps most of the developers to assign variables in the middle of an expression. </p>
<h3 id="lets-have-a-quick-look-how-walrus-operator-comes-into-hand">Let's have a quick look, how walrus operator comes into hand.</h3>
<pre><code>def <span class="hljs-keyword">add</span>(x):
      <span class="hljs-keyword">return</span> x + <span class="hljs-number">1</span>

# <span class="hljs-keyword">before</span> <span class="hljs-keyword">using</span> walrus <span class="hljs-keyword">operator</span> 
<span class="hljs-keyword">if</span> <span class="hljs-keyword">add</span>(x) &gt; <span class="hljs-number">5</span>:
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">add</span>(x)

# <span class="hljs-keyword">using</span> walrus <span class="hljs-keyword">operator</span>
<span class="hljs-keyword">if</span> (res := <span class="hljs-keyword">add</span>(x)) &gt; <span class="hljs-number">5</span>:
    <span class="hljs-keyword">return</span> res
</code></pre><p>Before using the walrus operator we are calling the add function twice, but using the walrus operator we don't have to call the walrus operator twice.</p>
<h3 id="so-what-is-weird-about-walrus-operator-actually-its-a-fact">So, What is weird about walrus operator (actually its a fact)</h3>
<h4 id="1-operator-precedence">1. Operator Precedence</h4>
<pre><code><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">add</span>(<span class="hljs-params">x</span>):</span>
      <span class="hljs-keyword">return</span> x + <span class="hljs-number">1</span>

<span class="hljs-comment"># using walrus operator</span>
<span class="hljs-keyword">if</span> res := add(x) &gt; <span class="hljs-number">5</span>:
    <span class="hljs-keyword">return</span> res
</code></pre><p>So, what do you think after removing the parenthesis, what it will be going to return (a number)??
 Actually, it will return a Boolean (False or True) because of operator precedence. Since the Comparison operator has higher precedence it will be going to execute first and Boolean value will be assigned to res and it will return Boolean.</p>
<h4 id="2-direct-assignment">2. Direct Assignment</h4>
<p>Walrus operators come into hand during the execution of valid expressions, Like if or for statements.</p>
<pre><code>a := <span class="hljs-keyword">add</span>(x) <span class="hljs-meta"># gives <span class="hljs-meta-keyword">error</span></span>
(a := <span class="hljs-keyword">add</span>(x)) <span class="hljs-meta"># doesn't give <span class="hljs-meta-keyword">error</span></span>
print(a)
</code></pre><p>So, these two things I found weird (but actually it's not weird it's a fact) in the Python walrus operator, if you are familiar with other weird things about python walrus please add a comment below.</p>
]]></content:encoded></item></channel></rss>