Forum: Python Mar 5th, 2009 |
| Replies: 8 Views: 795 attrib is commandline way to change file attributes (like dos command). On a DOS command window do, "help attrib" to see the options. |
Forum: Python Mar 5th, 2009 |
| Replies: 8 Views: 795 fn = 'c:\\file.txt'
p = os.popen('attrib +h ' + fn)
t = p.read()
p.close() |
Forum: Python Jul 4th, 2008 |
| Replies: 3 Views: 1,807 >>> import re
>>> data = '115Z2113-3-777-55789ABC7777'
>>> ds = data.split('-')
>>> out = '-'.join(ds[0:-1] + [re.split('[A-Z]', ds[-1])[0]])
>>> out
'115Z2113-3-777-55789'
HTH |
Forum: Python Jun 24th, 2008 |
| Replies: 3 Views: 1,174 Maybe you need to do a line by line match in a loop and then line/line number shouldn't be a problem. I'm not sure how much slower it may be compared to what you're doing now but you can e.g.... |
Forum: Python Jun 24th, 2008 |
| Replies: 3 Views: 1,369 Maybe this will get you started:
http://diveintopython.org/performance_tuning/index.html
HTH |
Forum: Python Jun 20th, 2008 |
| Replies: 5 Views: 1,517 If you want to be portable across *nix and windows, try something like:
import os
ps = '/tmp/my/path'.split(os.sep)
This will split the path into separate elements without you having to... |
Forum: Python Jun 20th, 2008 |
| Replies: 3 Views: 499 Without using lists:
#!/usr/bin/python
fh = open('nd.txt', 'r')
(page, nd) = fh.readline().split(',')
(last, lastnd) = (page, page)
print page, |
Forum: Python May 23rd, 2008 |
| Replies: 2 Views: 415 Nothing radical - basically worked on your original code:
def getChoice(bottom=False, cap=False):
while True:
try:
choice = int(raw_input("Please enter your choice:... |
Forum: Python May 23rd, 2008 |
| Replies: 5 Views: 1,367 You should indeed use existing/available python modules as you have many built-in functions available for exactly what you need instead of having to sift through output to do something specific.... |
Forum: Python Apr 24th, 2008 |
| Replies: 8 Views: 720 |
Forum: Python Apr 24th, 2008 |
| Replies: 6 Views: 705 April 1st, 2008
April 2nd, 2008
April 3rd, 2008
01: April 4th, 2008
02: April 5th, 2008
03: April 6th, 2008
04: April 7th, 2008
05: April 8th, 2008
06: April 9th, 2008
07: April 10th,... |
Forum: Python Mar 20th, 2008 |
| Replies: 4 Views: 561 >>> a = input("Number: ")
Number: 10
>>> b = 2 + a
>>> b
12
>>> outfile = open(str(b), 'w')
>>> outfile.write("Test line")
>>> outfile.close()
>>> quit() |
Forum: Python Mar 16th, 2008 |
| Replies: 5 Views: 1,168 Reading this it seem the requirement is to only use GUI to prompt for the password and use sudo functinality. Have you thought of calling gksu instead of sudo - gksu is a gtk frontend to sudo? i.e.:... |
Forum: Python Mar 13th, 2008 |
| Replies: 5 Views: 669 You're expectations are incorrect. You are doing this:
test = []
mylist = [[1,2,3],[4,5,6],[7,8,9]]
test.append(SuperList(mylist))
And are expecting this: |
Forum: Shell Scripting Mar 12th, 2008 |
| Replies: 5 Views: 3,005 Sorry, I know awk/sed was requested, but a python solution was so easy, couldn't help to post it:
#!python
(a, b) = ([], [])
(i,j)=(1,1)
diffchar=['.',':']
for line in open("sq.txt"): |
Forum: Python Mar 12th, 2008 |
| Replies: 10 Views: 5,081 Thanks. Actually, I realized that it should have been much more simpler:
sum([int(i) for i in list(raw_input("Enter integer:"))])
Sometimes the obvious isn't obvious to me :) |
Forum: Python Mar 11th, 2008 |
| Replies: 10 Views: 5,081 Here you go:
print reduce( lambda x,y: x+y, [int(i) for i in list(raw_input("Enter integer:"))] ) |