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

    Join Date
    Sep 2012
    Posts
    9
    Rep Power
    0

    Newbie Problem - SyntaxError question


    OK, I started reading the Tutorial. I got to Chapter 2 and specifically item 2.2.5 The Customization Modules. I followed the instructions on that page (see below). I typed in "import site" and pressed the enter key and then I typed the "site.getusersitepackages()" part (see below). When I do that I get a message back "SyntaxError invalid syntax".

    I am running under Windows 7. So, how do I correct the statement so that it works. There is a little carrot below the last quote mark.

    The actual command I typed in is:

    site.getusersitepackages() 'C:/Python27/Lib/site-packages'

    Here is the actual text from the Tutoral:

    "Python provides two hooks to let you customize it: sitecustomize and usercustomize. To see how it works,
    you need first to find the location of your user site-packages directory. Start Python and run this code:
    >>> import site
    >>> site.getusersitepackages()
    ’/home/user/.local/lib/python3.2/site-packages’
    Now you can create a file named usercustomize.py in that directory and put anything you want in it. It will
    affect every invocation of Python, unless it is started with the -s option to disable the automatic import.
    sitecustomize works in the same way, but is typically created by an administrator of the computer in the global
    site-packages directory, and is imported before usercustomize. See the documentation of the site module for
    more details."
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,851
    Rep Power
    481
    Interesting, perhaps not an unreasonable interpretation of the instructions. But incorrect.

    These lines are input to python. Don't type the 4 character python prompt ">>> "

    >>> import site
    >>> site.getusersitepackages()


    The next line was sample output from python, and not, as you expected, merely a funky paragraph wrapping mistake.

    Cheers!
    [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
    Sep 2012
    Posts
    9
    Rep Power
    0

    I am not typing in those leading > characters


    I am not typing those leading '>' characters

    First, I started the Python Command application within Windows

    So, when this starts, I get the following:

    "Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>"

    So, those three ">" are present when I start typing.

    Now, what?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    9
    Rep Power
    0

    Lets restart this reply


    OK, I just typed in "site.getusersitepackages()" command

    The system replied with:

    'C:\\Users\\dr55069\\AppData\\Roaming\\Python\\Python27\\site-packages'

    So, how do I can that value?
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,851
    Rep Power
    481
    Just remember that python can be customized.

    Move directly to chapter 3. Obviously, you cannot customize python, or do much of anything with it until you've learned that

    OBJECT.method(argument) 'string'

    is invalid syntax.


    You might also request www.python.org to reorder the tutorial chapters because that's ridiculous.


    The problem is akin to software manuals, in that most first explain "changes from last version" rather than explaining in a general sense what the software does.


    Move on to the next section.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo