Search Results

Showing results 1 to 17 of 17
Search took 0.01 seconds.
Search: Posts Made By: rikxik
Forum: Python Mar 5th, 2009
Replies: 8
Views: 795
Posted By rikxik
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
Posted By rikxik
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
Posted By rikxik
>>> 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
Posted By rikxik
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
Posted By rikxik
Maybe this will get you started:

http://diveintopython.org/performance_tuning/index.html

HTH
Forum: Python Jun 20th, 2008
Replies: 5
Solved: split path
Views: 1,517
Posted By rikxik
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
Posted By rikxik
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
Posted By rikxik
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
Posted By rikxik
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
Posted By rikxik
Super Jumbo rats?
Forum: Python Apr 24th, 2008
Replies: 6
Views: 705
Posted By rikxik
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
Posted By rikxik
>>> 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
Posted By rikxik
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
Posted By rikxik
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
Posted By rikxik
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
Solved: integer sum
Views: 5,081
Posted By rikxik
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
Solved: integer sum
Views: 5,081
Posted By rikxik
Here you go:


print reduce( lambda x,y: x+y, [int(i) for i in list(raw_input("Enter integer:"))] )
Showing results 1 to 17 of 17

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC