473,395 Members | 2,795 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,395 software developers and data experts.

Getting working directory of a module

440 256MB
Hi ,

I have a main module in particular path say "C:\\Sample\\Test\\main.py",and other modules are also located in the same location.I would like to find the path of the current working directory.

Is there any method/global function available for accessing this information?.

Thanks
PSB

I/P :

"C:\\Sample\\Test\\main.py" -- Working directory

O/P :
"C:\\Sample\\Test" -- Required working directory path
Apr 10 '07 #1
1 1528
bartonc
6,596 Expert 4TB
Hi ,

I have a main module in particular path say "C:\\Sample\\Test\\main.py",and other modules are also located in the same location.I would like to find the path of the current working directory.

Is there any method/global function available for accessing this information?.

Thanks
PSB

I/P :

"C:\\Sample\\Test\\main.py" -- Working directory

O/P :
"C:\\Sample\\Test" -- Required working directory path
The current working directory is set by the command that starts python [not by the path of the module that is started].

Expand|Select|Wrap|Line Numbers
  1. import os
  2. print os.getcwd()
Apr 11 '07 #2

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

Similar topics

1
by: rossz | last post by:
I was forced to reboot my linux server (power outage) and now apache php won't deal with mysql. I've double and triple checked /etc/php4/apache/php.ini and the proper settings are there. If I...
3
by: Kali K E | last post by:
Hi, I could not understand how I can do the following things in Python. Please help me. 1. First I have to find the current directory from where the script is invoked. 2. Next I have to form a...
8
by: Irmen de Jong | last post by:
What would be the best way, if any, to obtain the bytecode for a given loaded module? I can get the source: import inspect import os src = inspect.getsource(os) but there is no...
6
by: Peter Maas | last post by:
My goal is to have the top level of a directory tree in the Python path without touching anything outside the directory. I tried to create .pth files with the top level path in every subdirectory...
6
by: ZR | last post by:
Hi, I am trying to delete multiple files in a particular directory. The code will like this \\\ Dim s As String For Each s in Directory.GetFiles(...) system.io.file.delete(s) Next s ///
3
by: Sergio Correia | last post by:
I have a program in 'C:\Python25\Lib\site-packages\spam\spam.py' Importing and everything works fine: But the program calls a file located on the same folder (that is:...
3
by: Nathan Sokalski | last post by:
I am getting the list of subdirectories from a specified directory using System.IO.Directory.GetDirectories(), and would like to get only subdirectories that are not hidden or system directories. I...
5
by: Pekeika | last post by:
Good morning group, When I open my Python window, this is appearing instead of the command line >>>. (I'm somehow new to Python). File "boot_com_servers.py", line 21, in <module> File...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.