Why is it different from the example on the tutorial?

rxjwg98 at gmail.com rxjwg98 at gmail.com
Sun Jul 6 08:13:55 EDT 2014


Hi,

I type the following sample codes on Python, but it echoes differently.

Regular expressions are compiled into pattern objects, which have methods for
various operations such as searching for pattern matches or performing string
substitutions.

>>>
>>> import re
>>> p = re.compile('ab*')
>>> p  
<_sre.SRE_Pattern object at 0x...>


What I get on Python console:

$ python
Python 2.7.5 (default, Oct  2 2013, 22:34:09)
[GCC 4.8.1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> p = re.compile('ab*')
  File "<stdin>", line 1
    p = re.compile('ab*')
    ^
SyntaxError: invalid syntax
>>>


Thanks,



More information about the Python-list mailing list