Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
Unknown Quality Score

No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.

0 Endorsements
Ranked #12.3K
Ranked #2K
~14.7K People Reached
Favorite Forums
Favorite Tags

15 Posted Topics

Member Avatar for mahela007

[CODE=python] fn = 'c:\\file.txt' p = os.popen('attrib +h ' + fn) t = p.read() p.close() [/CODE]

Member Avatar for mahela007
0
12K
Member Avatar for dinilkarun

[CODE=python] >>> 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' [/CODE] HTH

Member Avatar for woooee
0
417
Member Avatar for haikur

Maybe this will get you started: [URL="http://diveintopython.org/performance_tuning/index.html"]http://diveintopython.org/performance_tuning/index.html[/URL] HTH

Member Avatar for Miyuki
0
128
Member Avatar for Agni

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. download a big plain-text e-book and do some tests. HTH

Member Avatar for Agni
0
124
Member Avatar for reyev

If you want to be portable across *nix and windows, try something like: [CODE=python] import os ps = '/tmp/my/path'.split(os.sep) [/CODE] This will split the path into separate elements without you having to specify '/' or '\' as separator. HTH

Member Avatar for reyev
0
137
Member Avatar for parmenio79

Without using lists: [CODE=python] #!/usr/bin/python fh = open('nd.txt', 'r') (page, nd) = fh.readline().split(',') (last, lastnd) = (page, page) print page, for i in fh: (page, nd) = i.strip().split(',') if nd == 'ND': print last if lastnd != last else "" lastnd = page print page, last = page print last …

Member Avatar for rikxik
0
90
Member Avatar for FreezeBlink

Nothing radical - basically worked on your original code: [CODE=python] def getChoice(bottom=False, cap=False): while True: try: choice = int(raw_input("Please enter your choice: ")) if ((bottom != False) and (choice <= bottom)): print "Choice should be greater than", bottom continue if ((cap != False) and (choice >= cap)): print "Choice should …

Member Avatar for rikxik
0
87
Member Avatar for FreezeBlink

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. Using python modules instead of calling os-specific commands keeps your programs portable and they perform better. However, just in case …

Member Avatar for rikxik
0
193
Member Avatar for sanoski

[CODE] 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, 2008 08: April 11th, 2008 09: April 12th, 2008 10: April 13th, 2008 …

Member Avatar for sanoski
1
265
Member Avatar for wyno
Member Avatar for rysin

[CODE] >>> a = input("Number: ") Number: 10 >>> b = 2 + a >>> b 12 >>> outfile = open(str(b), 'w') >>> outfile.write("Test line") >>> outfile.close() >>> quit() C:\Python>type 12 Test line [/CODE]

Member Avatar for 1337455 10534
0
134
Member Avatar for 1337455 10534

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.: [CODE] # example # ... from os import system # ... system("gksu …

Member Avatar for 1337455 10534
0
207
Member Avatar for volcs

You're expectations are incorrect. You are doing this: [CODE] test = [] mylist = [[1,2,3],[4,5,6],[7,8,9]] test.append(SuperList(mylist)) [/CODE] And are expecting this: [CODE] [[1,2,3],[4,5,6],[7,8,9]] # I want to get this, but I only get [] [/CODE] Shouldn't you be expecting: [CODE] [COLOR="Red"][[/COLOR][[1,2,3],[4,5,6],[7,8,9]][COLOR="Red"]][/COLOR] [/CODE] You are appending to an empty list, another …

Member Avatar for katharnakh
0
104
Member Avatar for Zelores

Here you go: [CODE] print reduce( lambda x,y: x+y, [int(i) for i in list(raw_input("Enter integer:"))] ) [/CODE]

Member Avatar for Zelores
0
197
Member Avatar for cdfd1982

Sorry, I know awk/sed was requested, but a python solution was so easy, couldn't help to post it: [CODE] #!python (a, b) = ([], []) (i,j)=(1,1) diffchar=['.',':'] for line in open("sq.txt"): line=line.strip() if i == 1: a = list(line) elif i == 2: b = list(line) elif i == 3: …

Member Avatar for rikxik
0
141

The End.