python - Variable greater than -


is possible make variable in python equal number greater number? example:

x = >26 

pretty wondering trying trying make if number in list of integers on 26 take number , change number under 26 depending on number is. sorry 1 small thing in bigger project hard explain all

yes, you can customize class's behaviour in comparison operations behaviour.

class equaltoanygreaterthan(object):     def __init__(self, n):         self.n = n      def __eq__(self, other):         return other > self.n      def __ne__(self, other):         return other <= self.n   egt26 = equaltoanygreaterthan(26)  print egt26 ==  1 # false print egt26 == 26 # false  print egt26 == 27 # true  print egt26 == 99 # true  print 21 == egt26 # false print 89 == egt26 # true  print 21 != egt26 # true print 89 != egt26 # false 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -