Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 14th, 2012, 04:06 PM
danielrose01 danielrose01 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 3 danielrose01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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."

Reply With Quote
  #2  
Old September 14th, 2012, 04:15 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,393 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 15 h 37 m 10 sec
Reputation Power: 383
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!

Reply With Quote
  #3  
Old September 14th, 2012, 04:21 PM
danielrose01 danielrose01 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 3 danielrose01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #4  
Old September 14th, 2012, 04:25 PM
danielrose01 danielrose01 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 3 danielrose01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #5  
Old September 14th, 2012, 04:59 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,393 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 15 h 37 m 10 sec
Reputation Power: 383
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Newbie Problem - SyntaxError question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap