
Hidden features of Python - jdimov9
http://stackoverflow.com/questions/101268/hidden-features-of-python
======
dalke
A question from 2011, back when SO allowed more free-form discussion
questions.

An obvious thought is, given that most of the comments are about Python 2,
what's changed in Python 3? The top answer (chained comparisons), hasn't
changed. Indeed, I've only noticed a couple of changes.

re.DEBUG is not something I knew about. It does look handy, though watch out
for the cache. Interestingly, one thing has changed. Under Python 2, "a * "
was identical to "a{0,65535}", where the maximum value 65535 was taken to mean
'unlimited'.

    
    
      >>> import re
      >>> pat = re.compile("a*")
      >>> s = "a"*65555
      >>> len(pat.match(s).group(0))
      65555
      >>> pat = re.compile("a{0,65535}")  # this is equivalent to "a*"
      >>> len(pat.match(s).group(0))   # I expect 65535!
      65555
      >>> pat = re.compile("a{0,65534}")
      max_repeat 0 65534
        literal 97
      >>> len(pat.match(s).group(0))
      65534
    

Under Python 3.x, "a * " is now {0,4294967295} instead of {0,65535}.

The only other changes I noticed on the first page are that print is no longer
a statement, and "rot13" is no longer an encoding.

