473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

os.getcwd gives me the wrong directory

Xx r3negade
Hi.
I have a script located in /home/jBrandt/Code/python/ftest.py.
When I print the results of os.getcwd(), however, it gives me /home/jBrandt/Code as the current working directory. I realize that I could change the cwd, but the directory name will not be the same on all computers. I've also tried os.curdir, and all it returns is a single dot (wtf?)

Anyway, I need a tried-and-true method for getting the cwd; any help would be appreciated.
May 24 '08 #1
1 6808
Laharl
849 Expert 512MB
The dot is a Unix/Linux shortcut that means current directory. Two dots means the parent directory to the current directory. As to the other issue...is the print call in a module being run from another script that is in the folder in question? It sounds like either that's the case or there's a hidden cd/os.chdir() call.
May 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: PeterF | last post by:
Hi, I've got the following problem: exec() and shell_exec(), etc. don't give anything back, just the error code 127 (command not found?!) For example, the following script: <?php exec("cat...
2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
7
by: Erik Bethke | last post by:
Hello All, I have found much help in the google archives but I am still stuck... here is my code snippet: path = os.getcwd() path = path.decode('UTF8') Now the trouble is I am getting that...
0
by: A.S. | last post by:
When i use FileSystemWatcher to monitor a local directory on my machine ,it works fine.But I need to monitor a file on a different server.So i set FileSystemWatcher1.path="\\server1\App\Data" ...
2
by: chiara | last post by:
Hi! This is a piece of a code I wrote. It was perfectly working but now it is giving me some problems I can not understand. I scan a directory (ss_data) and I count its alaments. then I print...
8
by: | last post by:
Wel, I am rebuilding the VC# 2002 project that I have deployment problems with the 2003 version, hoping this solves the problems, but now I encounter this wierd bug??? If I have the project, and...
2
by: Ken Yee | last post by:
First a little background: I've written an httphandler to handle wildcard extensions (i.e., I want to handle all URLs that come in rather than just URLs w/ a specific file extension so I can give...
1
by: Jona | last post by:
Issue: *Get the path location of my executable. Semi Fix.. *Using getcwd() or plainly giving no path would also do the job... say reading a file... *The problem is when I call other...
1
by: loial | last post by:
Trying to use ftplib.FTP.nlst() method to list the files in a directory on a FTP server. It works fine except when there are no files in the directory. Then it gives the error ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.