Re: Unique Elements in a List

2005-05-09 Thread runes
This is not the most beautiful idiom, but it works... d = {} for k in data: try: d[k] += 1 except: d[k] = 1 for k,v in d.items(): if v == 1: print k -- http://mail.python.org/mailman/listinfo/python-list

Re: win32- system call - getting results back into python

2005-05-07 Thread runes
You wil have to use rsvnlook log \arms) or svnlook log \\arms) to escape the \. Popen usually return a file-like object, so you maye to use file methods like .read() ex: d = os.popen('dir /b') print d.read() -- http://mail.python.org/mailman/listinfo/python-list

Re: using variables with modules

2005-05-05 Thread runes
The only problem I can see, is trailing whitespace from the ip.txt file. Perhaps ClientIP.strip() will help? -- http://mail.python.org/mailman/listinfo/python-list

Re: using variables with modules

2005-05-05 Thread runes
I tested your code and made a few changes: import _winreg import sys readfile = open(C:\scripts\ip.txt, 'r') IPList = readfile.readlines() for ClientIP in IPList: ClientIP = ClientIP.strip() ClientIP = r'\\' + ClientIP try: key = _winreg.ConnectRegistry(ClientIP,

Re: Getting PID for process

2005-04-29 Thread runes
On XP/2003 at least, os.system('taskkill /pid le pid') will do. -- http://mail.python.org/mailman/listinfo/python-list

Setting win32 console title from Python

2005-04-28 Thread runes
Hi, I'm trying to set the title of the console window (CMD.EXE) in Windows. I want it set to the basename of the current directory and it should stay after the script has finished. Now, the console title is easily set with the DOS-command 'title NewTitle'. But I'd like to do this from a Python

Re: Setting win32 console title from Python

2005-04-28 Thread runes
Whenever you start an application from the command prompt the title is modified by appending a dash and the name of the program you started. When the application terminates the title is reset (to remove the name of the running program). So any change to the title will only last until the next

Re: Setting win32 console title from Python

2005-04-28 Thread runes
Hi Jay. It seems like my requirement is a light edition of your. I like having many console windows open, and to make it easier to switch between them, I like to name them. Todays solution is rather tedious - a batch file that calls a python script that isolates the directory name and stores it

Re: Setting win32 console title from Python

2005-04-28 Thread runes
Hi Duncan, sorry, I was unprecise. I'm thinking of a script, called t.py that can be used in the console like an ordinary command. Som if I change directory from S:\scripts to d:\projects and execute the script the title changes to projects etc. I have that functionality today with a

Re: Which IDE is recommended?

2005-04-27 Thread runes
I used Boa for a Win32 project. It helped me enormously. It's very easy to design windows etc. But the generated python code is not beautiful. -- http://mail.python.org/mailman/listinfo/python-list

Re: Behaviour of str.split

2005-04-18 Thread runes
The behaviour of .split(*) is not that strange as the splitpoint always disappear. The re.split() have a nice option to keep the splitpoint which the str.split should have, I think. One expectation I keep fighting within myself is that I expect mystring.split('') to return ['m', 'y', 's', 't',

Re: Behaviour of str.split

2005-04-18 Thread runes
[Tim N. van der Leeuw] Fortunately, this is easy to write as: list(mystring). Sure, and map(None, mystring) Anyways, I have settled with this bevaviour, more or less ;-) Rune -- http://mail.python.org/mailman/listinfo/python-list

Finding name of running script

2005-04-17 Thread runes
Is it a more pythonic way of finding the name of the running script than these? from os import sep from sys import argv print argv[0].split(sep)[-1] # or print locals()['__file__'].split(sep)[-1] # or print globals()['__file__'].split(sep)[-1] --

Re: Finding name of running script

2005-04-17 Thread runes
Thanks! That's os.path.basename() I guess. It's better, but still complex. I have a _nof_ = argv[0].split(sep)[-1] in my script template and use it under the usage() function to tell what the script does, like: cf.py counts files in directory or directory structure If I change the filename, I

Piping data into script under Win32

2005-04-15 Thread runes
I trying to figure out a way to make a python script accept data output from another process under Windows XP, but I fail miserably. I have a vague memory having read this is not possible with Python under Windows... But googling for a clue I came across this from /Learning Python/ (Lutz Ascher)

Re: Piping data into script under Win32

2005-04-15 Thread runes
You being so sure about what you were saying, was what I needed. Thanks! Under Windows, I'm used to rely on the PATHEXT env. variable, so I typically don't write python scriptname.py args, but just scriptname args. So: type countlines.py | python countlines.py = Success type countlines.py |

Re: Piping data into script under Win32

2005-04-15 Thread runes
Thanks James! I'll post the explanation if I find it ;-) Rune -- http://mail.python.org/mailman/listinfo/python-list

Re: Python documentation moronicities (continued)

2005-04-13 Thread runes
Seems like criticising the manual is som kind of heresy. So be it. You know, the Re documentation contains many pages. Ufortunately I didn't dwell with the first introductory paragraph, I was trying to solve a particular problem. I'm not that used to looking for links to external sources in the

Re: Python documentation moronicities (continued)

2005-04-12 Thread runes
why cannot this piece of shit writing give a single example of usage? Actually, I can understand your frustration even if you should enhance your vocabulary slightly. I often struggle with the Python documnetation myself and I can't understand why a couple of examples are so hard to give. When

Re: Python documentation moronicities (continued)

2005-04-12 Thread runes
Thank you for being so friendly! I found the Howto through Google. Somehow I didn't see that link in the documentation. And please do not make any assumptions about my reading of manuals. -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting iterations

2005-04-10 Thread runes
[Andrew Dalke] I therefore disagree with the idea that simple string concatenation is always to be eschewed over string interpolation. Andrew, what you write makes sense. I've never really tested it, just read it several places, fx here:

Re: Counting iterations

2005-04-09 Thread runes
You should avoid the a + b + c -kind of concatenation. As strings at immutable in Python you actually makes copies all the time and it's slow! The alternative used in Steven Bethard's example is preferable. -- http://mail.python.org/mailman/listinfo/python-list

Re: sparse sets of integers?

2005-04-04 Thread runes
You have sets in Python 2.3x and 2.4x. I don't know if they can handle your amounts of data, but i guess so. -- http://mail.python.org/mailman/listinfo/python-list