473,396 Members | 1,894 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,396 software developers and data experts.

knowing a file's own name


I'm looking for a way to identify a filename remotely. Put differently,
is there a way a file can get its own name from its globals()?

doit.py calls exec() on a second py script, tpairs.py, to obtain a dict
of the
globals in tpairs.py. How can I add the filename, "tpairs.py," to the
resulting dict?
i.e.:

# - - - - - - - - - - - - - - - -
# -- tpairs.py
# - - - - - - - - - - - - - - - -
this = "this"
that = "that"
gdict = globals()

# - - - - - - - - - - - - - - - -
# -- doit.py
# - - - - - - - - - - - - - - - -
#!/usr/bin/env python

theFile = "./tpairs.py"
theDict = {}
execfile(theFile, theDict)

# somehow add theFile to gdict, i.e.:
# gdict['theFile'] = theFile
Thanks in advance!
Scott

Jul 18 '05 #1
0 891

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: IGC | last post by:
I have a requirement to record in a database when a file is finished downloading to the end-user. Currently when a user clicks a download icon for a file it directs to an ASP page that records the...
0
by: CodeMotion | last post by:
I have access to an internet directory and files will be placed in this directory periodically. I am writing a service to poll that directory and download the files for processing. I have figured...
4
by: Charles Law | last post by:
Is there a way to dynamically remove an event handler from an event without knowing the name of the handler? For example, how can ClassB remove the handler without knowing the name, or how many...
30
by: Franck PEREZ | last post by:
Hello, I'm developing a small XML marshaller and I'm facing an annoying issue. Here's some sample code: ########### My test application ############ class Foo(object): #The class I'd like to...
3
by: Familjen Karlsson | last post by:
Here is an example from the help on the keword OleDbConnection, in VB.Net, they don't give the path to the database just the word localhost. How can it connect to the database without knowing where...
4
by: Jason | last post by:
I need to open a file for reading, but I only know part of it's name. The file I want to read is in the format of xxx-yyyy-zzz.EXT The last three digits of the file name are different on each...
7
by: chad | last post by:
let's say I'm transferring a large file like 100MB over to a folder. The program detects when the file arrives. However, I can't figure out how to know when the file is totally transferred over....
0
by: Salem | last post by:
hi, i need to programmatically get the wsdl file of a certain web service to create the corresponding proxy on the fly. knowing the service i want to use, how can i get its wsdl file and create the...
4
by: noama | last post by:
Hi, I want to make a script that will call the run() func of some other scripts who's name the main script will read from a file. i.e, the main script will: 1. read the file 2. for each <name>...
8
by: Ron | last post by:
I am building a dynamic image loading class. I have a list of properties that have associated images in a specified directory. The problem they are multiple formats which are not known at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.