The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Newbie Problem - SyntaxError question
Discuss Newbie Problem - SyntaxError question in the Python Programming forum on Dev Shed. Newbie Problem - SyntaxError question Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 14th, 2012, 04:06 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 3
Time spent in forums: 1 h 16 sec
Reputation 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."
|

September 14th, 2012, 04:15 PM
|
 |
Contributing User
|
|
|
|
|
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!
|

September 14th, 2012, 04:21 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 3
Time spent in forums: 1 h 16 sec
Reputation 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?
|

September 14th, 2012, 04:25 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 3
Time spent in forums: 1 h 16 sec
Reputation 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?
|

September 14th, 2012, 04:59 PM
|
 |
Contributing User
|
|
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|