Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In py2.x you can return anything you want, but in py3.x you'll get errors if you return different types of values(objects) because you can't compare two different type of objects in py3.x</p> <p><a href="http://docs.python.org/2/reference/expressions.html#not-in" rel="nofollow">Docs:</a>(py2.x):</p> <blockquote> <p>The operators <code>&lt;</code>, <code>&gt;</code>, <code>==</code>, <code>&gt;=</code>, <code>&lt;=</code>, and <code>!=</code> compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily.</p> <p>In the future, the comparison rules for objects of different types are likely to change.</p> </blockquote> <p>Py2.x:</p> <pre><code>&gt;&gt;&gt; x = [1, '2', [3]] &gt;&gt;&gt; x.sort() &gt;&gt;&gt; x [1, [3], '2'] </code></pre> <p>Py3.x:</p> <pre><code>&gt;&gt;&gt; x = [1, '2', [3]] &gt;&gt;&gt; x.sort() Traceback (most recent call last): x.sort() TypeError: unorderable types: str() &lt; int() </code></pre> <p><a href="http://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons" rel="nofollow">What's new in python3</a>:</p> <blockquote> <p>The ordering comparison operators (<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;=</code>, <code>&gt;</code>) raise a <code>TypeError</code> exception when the operands don’t have a meaningful natural ordering. Thus, expressions like <code>1 &lt; ''</code>, <code>0 &gt; None</code> or <code>len &lt;= len</code> are no longer valid, and e.g. <code>None &lt; None</code> raises <code>TypeError</code> instead of returning <code>False</code>. A corollary is that sorting a heterogeneous list no longer makes sense – all the elements must be comparable to each other. Note that this does not apply to the <code>==</code> and <code>!=</code> operators: objects of different incomparable types always compare unequal to each other.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload