Python quickly recycles objects, and in your comparison operation, those VARCHAR objects are lost as soon as id() is called on them, so that the same id is used again.
try it like this: >>> s1 = String(1) >>> s2 = String(1) >>> id(s1) == id(s2) False On Mar 28, 2013, at 6:44 AM, Hetii <[email protected]> wrote: > Hi :) > > Could someone explain this cases: > from sqlalchemy.dialects.mysql.base import * > > In [8]: VARCHAR(1) == VARCHAR(1) > Out[8]: False > > In [9]: id(VARCHAR(1)) == id(VARCHAR(1)) > Out[9]: True > > In [10]: id(VARCHAR(1)), id(VARCHAR(1)) > Out[10]: (40383696, 40383696) > > Why comparator return False when its the same id ? > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
