WebFaction
Community site: login faq

Consider the following python code:

import os
print os.getcwdu()

I use getcwdu() to get the script file's location. For some reason when I run the script from the command line it gives me the correct path whereas when I run it from a django view it prints /.

How come?
How can I get the path to the running script from within a view or from within a script run by a view?

asked 08 Feb '11, 07:16

Jonathan
281813
accept rate: 0%

edited 08 Feb '11, 07:16


Could you try the methods listed here?

http://www.faqs.org/docs/diveintopython/regression_path.html

permanent link

answered 08 Feb '11, 07:43

neeravk
1.5k3412
accept rate: 41%

The link you sent talks about os.getcwd() which is the same as os.getcwdu() that I used, except that the latter returns a unicode instead of a string. So I don't see how it helps

(08 Feb '11, 09:08) Jonathan
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×19
×1

question asked: 08 Feb '11, 07:16

question was seen: 2,578 times

last updated: 08 Feb '11, 09:08

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM