Windows doesn't have a HOME environment variable, but it does have
HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically
populate os.environ with HOME, where HOME =
os.path.join(os .environ['HOMEDRIVE'], os.environ['HOMEPATH'])?
If this was done, then modules such as pdb, which load resource files
from HOME, would work under Windows.
Alternatively, here is a patch to make pdb.py read .pdbrc under
Windows.
*** pdb_orig.py Mon Jun 16 01:26:30 2003
--- pdb.py Sat Oct 29 11:11:07 2005
***************
*** 65,72 ****
--- 65,76 ----
# Read $HOME/.pdbrc and ./.pdbrc
self.rcLines = []
+ envHome = ''
if 'HOME' in os.environ:
envHome = os.environ['HOME']
+ elif 'HOMEDRIVE' in os.environ and 'HOMEPATH' in os.environ:
+ envHome = os.path.join(os .environ['HOMEDRIVE'],
os.environ['HOMEPATH'])
+ if envHome:
try:
rcFile = open(os.path.jo in(envHome, ".pdbrc"))
except IOError: 11 3915 ji***********@g mail.com napisa(a): Windows doesn't have a HOME environment variable, but it does have HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically populate os.environ with HOME, where HOME = os.path.join(os .environ['HOMEDRIVE'], os.environ['HOMEPATH'])?
MS recommends using %USERPROFILE%, as the above in many cases returns
"C:\", which is wrong.
--
Jarek Zgoda http://jpa.berlios.de/
Cool, even better. So what's best, having code to add HOME
(=USERPROFILE) to os.environ, or change the various places that HOME is
used to check for USERPROFILE? ji***********@g mail.com wrote: Cool, even better. So what's best, having code to add HOME (=USERPROFILE) to os.environ, or change the various places that HOME is used to check for USERPROFILE?
Best solution would be to have portable function that returns
user home directory and knows about all platfom quirks.
--
Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl
If you lost your left arm, your right arm would be left.
On Sat, 29 Oct 2005 18:43:44 +0200, Maciej Dziardziel <fi*****@fiedzi a.prv.pl> wrote: ji***********@g mail.com wrote:
Cool, even better. So what's best, having code to add HOME (=USERPROFILE) to os.environ, or change the various places that HOME is used to check for USERPROFILE?
Best solution would be to have portable function that returns user home directory and knows about all platfom quirks.
Why is that better than Python creating a HOME in os.environ, if it doesn't
already exist? I can think of a few reasons it's better, and a few reasons
it's worse.
/Jorgen
--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Jorgen Grahn wrote: Best solution would be to have portable function that returns user home directory and knows about all platfom quirks.
Why is that better than Python creating a HOME in os.environ, if it doesn't already exist? I can think of a few reasons it's better, and a few reasons it's worse.
First, it is possible that HOME viariable already exists and has different
meaning, (if python is used as embedded scripting language it can be
defined by application), Second, there is a group of path related functions
in os.path (or ntpath), including expanduser, and its better to use
function than relay on some interpreter behaviour that may be different on
jython or ironpython.
--
Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl
How come in Scooby Doo Fred and Daphne were always on the same team and
Velma, Scooby and Shaggy were always on the same team? Doesn't seem quite
right now that you think about it, does it?
On Mon, 31 Oct 2005 12:26:30 +0100, Maciej Dziardziel <fi*****@fiedzi a.prv.pl> wrote: Jorgen Grahn wrote:
Best solution would be to have portable function that returns user home directory and knows about all platfom quirks.
Why is that better than Python creating a HOME in os.environ, if it doesn't already exist? I can think of a few reasons it's better, and a few reasons it's worse.
First, it is possible that HOME viariable already exists and has different meaning, (if python is used as embedded scripting language it can be defined by application),
And on systems where $HOME exists, that's what this new abstraction would
have to use internally anyway, so us Unix users won't lose anything. OK, I
accept the reasoning.
/Jorgen
--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Having a function is definitely cleaner. Creating a HOME environment
variable where one does not exist in the calling shell is misleading.
There are 10 modules in the python 2.3 lib directory that contain
os.environ['HOME']:
lib\ftplib.py
lib\mailbox.py
lib\mailcap.py
lib\netrc.py
lib\ntpath.py
lib\os2emxpath. py
lib\pdb.py
lib\posixpath.p y
lib\rfc822.py
lib\user.py
It's probably not a huge effort to change these (but that's easy for me
to say ...) It would be nice to start of with having a standard way to
find out what the home directory is.
> ji***********@g mail.com napisa(a): MS recommends using %USERPROFILE%, as the above in many cases returns "C:\", which is wrong.
I'm guessing this is why IDLE creates a directory in the root of my
Win98 system whenever I use it. It would be great if this could be
fixed for the next version.
--
Ben Sizer.
Maciej Dziardziel wrote: ...there is a group of path related functions in os.path (or ntpath), including expanduser, and its better to use function...
On Nov 01, ji***********@g mail.com wrote: Having a function is definitely cleaner. Creating a HOME environment variable where one does not exist in the calling shell is misleading. ... It would be nice to start of with having a standard way to find out what the home directory is.
I think that is what Maciej has already pointed out.
Just to clarify then:
os.path.expandu ser('~') is the universal/portable means to find a
user's home directory, regardless of platform. So use of HOME or
USERPROFILE or whatever in scripts should be discouraged.
Someone please correct me if the above is wrong. I haven't tried on a
mac, but linux and windows seem to behave well; i.e., linux looks for
HOME, and windows appears to combine HOMEDRIVE and HOMEPATH if HOME is
not set. Details are in the 2.4.2 sources' "Python24/Lib/posixpath.py"
if you're curious.
--
_ _ ___
|V|icah |- lliott http://micah.elliott.name md*@micah.ellio tt.name
" " """ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Дамјан Георгиевски |
last post by:
Hi,
I'm making a small PyQT app, and it will also have a config file (any type
is ok) for several options.
I would also like to add a gui for changing the config options but I don't
want to make design the GUI. I'd be satisfied if the GUI is automatically
generated from the config file (or config file specification).
Is there some...
|
by: Steve Wathen |
last post by:
I need to create a database where each record is an invoice originally
stored as a csv file. Currently these csv files are loaded in excel to
display them. Each invoice has a variable number of rows and variable
number of columns(see example below). The start of each row has a
document reference which is the same for every line of one invoice....
|
by: Sam |
last post by:
My db looks after the hiring and lending of equipment, the form which books
out equipment hired prints a signout sheet and automatically inserts an
appointment into outlook advising the operator on the due date that a
particular hire is due.
I have used microsoft's automated appointment code to do this, what I would
also like the code to do...
|
by: Phil Longworth |
last post by:
Im very new to Access 97 and Im sure I should be able to do this but
cant work out how.
Im bulding a database for my stamp collection. I have two tables; one
with details of all the individual stamps, and one with details of
covers/envelopes the stamps are fixed to. Each indivdual stamp has a
specific reference number (not an auto-number). ...
|
by: Scott Simonson |
last post by:
Does anyone know of a way to create import/export specifications via code? I
want my users to able to create a table when needed but in order to allow
importing into and exporting out of I need these specifications in place.
I'd like to have it automatic somehow, possibly through a button.
Thanks
| |
by: Nagib Abi Fadel |
last post by:
Is it possible to create a session variable for each user in Postresql ??
Thx
|
by: K.S.Sreeram |
last post by:
Hi everybody,
I'm having trouble using os.path.expanduser('~') on windows. It uses
$HOME or ($HOMEDRIVE+$HOMEPATH), but this doesn't work with windows
machines which are part of a domain. On such machines, the HOME envvar
may not be set at all, and the HOMEPATH envvar may be set to '\\'!!
Here's an implementation of getHomeDir which tries...
|
by: Tony |
last post by:
I'm working on project that plays movies using Windows Media Player and
I'm controlling everything with JavaScript. Per the client I only need
to support IE 6 or greater which happens to make things a bit easier.
What I need to do is create a playlist and play it using JavaScript. I
keep on getting close but not close enough to play the dang...
|
by: siddnair54 |
last post by:
Hey Guys, i have created a windows application in c#.
I want to create a setup in such a way that once the application is installed, it should start automatically when the windows starts up. Can you help me with this?
Can i put the application in System tray or something, or is there any other way?
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |