Thread: Invalid Syntax

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Invalid Syntax


    I know very little about Python. I am running Win-Python 3.3 and trying to interpret word2mediawiki from GitHub.

    I am getting invalid syntax errors on the closing quotes of regular expressions and when passing parameters to some functions. For example:


    Code:
    C:\word2mediawiki\pywikipedia>python login.py -force
    
    Traceback (most recent call last):
      File "login.py", line 58, in <module>
        import re, os, query
      File "C:\word2mediawiki\pywikipedia\query.py", line 29, in <module>
        import wikipedia as pywikibot
      File "C:\word2mediawiki\pywikipedia\wikipedia.py", line 3950
        rImage = re.compile(ur'\[\[(?P<namespace>%s)(?P<filename>%s)(?P<params>%s*?)
    \]\]' % (namespacePattern, imagePattern, paramPattern))
    
        ^
    SyntaxError: invalid syntax
    I am assuming either that the version of Python I have doesn't support this syntax or I need to install a module. But my assumptions don't help me decide what to do to fix the problem.

    Thanks for any assistance.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,896
    Rep Power
    481
    Yes, use python2.7 .
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Yes, use python2.7 .
    Thank you so much. It works now. Clearly Python has a major code branching.....


    I realize after doing some research on this problem, why I don't do Python programming. This is just another reason. No backward compatibility and no apparent way for me to figure out what syntax of code works with what version of Python. For something heavily endorsed by Google I expected much much better support.

    This rant on StackOverflow really got me and the OP going:

    Flying in the face of its 'batteries included' motto, Python ships without a package manager. Adding insult to injury, Pip is ironically difficult to install. The official documentation tells users to install modules from source. That's tedious for the experienced, and tactless to newbies.

    *sigh*
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    114
    Rep Power
    3
    Originally Posted by SChalice
    I realize after doing some research on this problem, why I don't do Python programming. This is just another reason. No backward compatibility and no apparent way for me to figure out what syntax of code works with what version of Python.
    Did you actually bother to look? This took me about thirty seconds to find. (Granted, I already knew roughly where to look. But is it that much of a leap to consider that the "what's new" section of the language docs might be the place?)

    Also, the built-in package manager is coming in 3.4.

IMN logo majestic logo threadwatch logo seochat tools logo