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
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
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
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,
On XP/2003 at least,
os.system('taskkill /pid le pid') will do.
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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',
[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
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]
--
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
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)
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 |
Thanks James! I'll post the explanation if I find it ;-)
Rune
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
[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:
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
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
23 matches
Mail list logo