under Linux I put my configs in “~/.programname”. Where should I place it in windows? What would be the recommendated way of opening the config file OS independent in python? Thanks! Nathan Answer Try: On linux this will return: On windows this will return: Which is a little ugly, so you’ll probably want to do this: EDIT: For what it’s
Tag: python
python xinetd client disconnection handling
This may or may not being a coding issue. It may also be an xinetd deamon issue, i do not know. I have a python script which is triggered from a linux server running xinetd. Xinetd has been setup to only allow one instance as I only want one machine to be able to connect to the service, which is
Parsing line with delimiter in Python
I have lines of data which I want to parse. The data looks like this: What I want to do is to have a subroutine that parse them and return 2 values (score and expect) for each line. However this function of mine doesn’t seem to work: Please advice what’s the right way to do it? Answer It looks like
Installing a Python program on Linux
I wrote a Python program. I would like to add to it an installation script that will set up everything necessary – like desktop icon, entry in the menu, home directory file, etc. I’m working on Linux (ubuntu). When a Python program is installed, what needs to happen in general? I know that it probably depends on the nature of
Python: Get Mount Point on Windows or Linux
I need a function to determine if a directory is a mount point for a drive. I found this code already which works well for linux: But I’m not sure how I would get this to work on windows. Can I just assume the mount point is the drive letter (e.g. C:)? I believe it is possible to have a
Is there a benefit to defining a class inside another class in Python?
What I’m talking about here are nested classes. Essentially, I have two classes that I’m modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn’t necessarily mean nesting, right? I have code that looks something like this: But now I’m wondering if there’s a situation where nesting would be better. Something like: