Re: Separators inside a var name

2008-06-09 Thread Kam-Hung Soh
being too obsessive about this, but that didn't stop me from posting. Comments? -- http://mail.python.org/mailman/listinfo/python-list Groovy allows spaces in method names. See following request and thread: http://jira.codehaus.org/browse/GROOVY-2857 -- Kam-Hung Soh http://kamhungso

Re: sendKey

2008-06-08 Thread Kam-Hung Soh
Vista and ActiveState Python 2.5.1.1. import SendKeys SendKeys.SendKeys("""^c""") Thank you! -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: readline() & seek() ???

2008-06-06 Thread Kam-Hung Soh
Chris wrote: On Jun 6, 5:13 am, Kam-Hung Soh <[EMAIL PROTECTED]> wrote: Tim Roberts wrote: DataSmash <[EMAIL PROTECTED]> wrote: I have a text file that contains thousands of lines and each line is 256 characters long. This is my task: For each line in the file, move to the 25th c

Re: readline() & seek() ???

2008-06-05 Thread Kam-Hung Soh
27;outputfile.txt','w') for line in open('inputfile.txt'): if line[24] == 'T': fout.write( line[34:39] + ',' ) Should the last line be ... fout.write(','.join(line[34:39]) -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding file details...

2008-05-29 Thread Kam-Hung Soh
st=ns.GetDetailsOf(i, c) if artist: print ns.GetDetailsOf(i, 0), artist break Roger I shall give that a go. (is the module you reference this one? http://python.net/crew/mhammond/win32/Downloads.html ) If you installed ActiveState's Python, the win3

Re: Finding file details...

2008-05-29 Thread Kam-Hung Soh
reak Roger Great tip, Roger! This solution works for WMA files (I don't have any MP3 files handy), so I think it would work for any media files in Windows. -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: convert string number to real number - ValueError: invalid literal for int() with base 10: '"2"'

2008-05-28 Thread Kam-Hung Soh
3.00") HTH Matthias -- http://mail.python.org/mailman/listinfo/python-list Thanks for the tip, Matthias. I knew that there had to be a way to handle arbitrary precision numbers. -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: convert string number to real number - ValueError: invalid literal for int() with base 10: '"2"'

2008-05-27 Thread Kam-Hung Soh
) for cell in row] ['Date', 'No.', 'Description', 'Debit', 'Credit'] ['3/17/2006', 5678, 'ELECTRONIC PAYMENT', '', 11.449] ['3/04/2007', 5678, 'THE HOME DEPOT 263 SomeCity FL', '', 25.399] -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators when?

2008-05-27 Thread Kam-Hung Soh
See: http://www.python.org/doc/2.4/whatsnew/whatsnew24.html Dunno of a general way view a list of features versus releases, other than reading the "What's New in Python x" documents. Maybe some enterprising developer can compile this list? Hint, hint. -- Kam-Hung Soh http://kamhu

Re: Separate output for log file and stdout

2008-05-19 Thread Kam-Hung Soh
an connect a pipe to that command. Maybe look at "subprocess -- Subprocess management" in http://docs.python.org/lib/module-subprocess.html -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Kam-Hung Soh
y scripting new features. - Interface between databases, Excel and text files. - Convert data between flat files and XML. - Manage files for build processes. - Automating processes (e.g. checkout, builds, FTP). Wish I had some reasons to make a GUI application in Python. -- Kam-Hung Soh http://kam

Re: comparison of files using set function

2008-05-17 Thread Kam-Hung Soh
roceed . Thanks a lot 1. Test with a small number of short files with a clear idea of the expected result. 2. Use better variable names. Names such as file1_search, file2_search, gi, gi2, A, B, C and D make it nearly impossible to understand your code. -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: set function

2008-05-16 Thread Kam-Hung Soh
le: s1 = set([1,2,3]) s2 = set([3,4,5]) s1 & s2 set([3]) You can populate your sets using an iterable, such as the lines from a file. Example: s1 = set(file(r'blah.txt')) -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: Accepting text input

2008-05-14 Thread Kam-Hung Soh
On Thu, 15 May 2008 12:36:29 +1000, Collin <[EMAIL PROTECTED]> wrote: Kam-Hung Soh wrote: On Wed, 14 May 2008 11:02:36 +1000, Collin <[EMAIL PROTECTED]> wrote: Gabriel Genellina wrote: En Mon, 12 May 2008 01:54:28 -0300, Collin <[EMAIL PROTECTED]> escribió: Collin wro

Re: Accepting text input

2008-05-13 Thread Kam-Hung Soh
-list You don't need to import any module to use ".lower()"; it is a method of a string. raw_input() returns a string, so you can use methods of a string. Try the following statement to see what happens: "ABCDE".lower() -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: anonymous assignment

2008-05-12 Thread Kam-Hung Soh
) l [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] l[:4] # first four elements [0, 1, 2, 3] l[::2] # every second element [0, 2, 4, 6, 8] l[:4:2] # every second element in the first four elements [0, 2] -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: python vs. grep

2008-05-12 Thread Kam-Hung Soh
sliding window? See http://www.gnu.org/software/sed/manual/sed.html, Section 4.13 -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: do you fail at FizzBuzz? simple prog test

2008-05-12 Thread Kam-Hung Soh
o test your faith. -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: firefox add-on to grab python code handily?

2008-05-10 Thread Kam-Hung Soh
eading indentation marks such as "> " before you paste sample code into your IDE: getclip | sed "s/> //" | putclip See http://kamhungsoh.com/blog/2008/05/more-uses-of-getclip-putclip.html -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: anagram finder / dict mapping question

2008-05-10 Thread Kam-Hung Soh
On Sat, 10 May 2008 18:06:17 +1000, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: "Kam-Hung Soh" <[EMAIL PROTECTED]> writes: On Sat, 10 May 2008 07:19:38 +1000, <[EMAIL PROTECTED]> wrote: > What would be the best method to print the top results, the one's

Re: do you fail at FizzBuzz? simple prog test

2008-05-10 Thread Kam-Hung Soh
ot;FizzBuzz") or (not x%3 and "Fizz") or (not x%5 and "Buzz") or x, xrange(1,101)) -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: anagram finder / dict mapping question

2008-05-09 Thread Kam-Hung Soh
last three items: sorted((len(anagrams[key]), key) for key in anagrams.keys())[-3:] -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: anagram finder / dict mapping question

2008-05-08 Thread Kam-Hung Soh
I found the other tips in parallel responses useful to me too! -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: anagram finder / dict mapping question

2008-05-08 Thread Kam-Hung Soh
.sort() sortedword = (''.join(word)) if sortedword in mapdic: print line On 2008-05-07 19:25:53 -0600, "Kam-Hung Soh" <[EMAIL PROTECTED]> said: On Thu, 08 May 2008 11:02:12 +1000, dave <[EMAIL PROTECTED]>

Re: anagram finder / dict mapping question

2008-05-07 Thread Kam-Hung Soh
ave the letters 'a', 'd', 'e' and 'm'. Refer "Programming Pearls" by Jon Bentley. -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: open filename with spaces in path

2008-05-06 Thread Kam-Hung Soh
On Wed, 07 May 2008 09:09:08 +1000, Kam-Hung Soh <[EMAIL PROTECTED]> wrote: On Wed, 07 May 2008 08:36:35 +1000, Michael Robertson <[EMAIL PROTECTED]> wrote: I'm having trouble opening a file in linux, whose path has spaces in it. $ mkdir my\ test $ echo test > my\ te

Re: open filename with spaces in path

2008-05-06 Thread Kam-Hung Soh
7;) >>> open('./test') works just fine. Couldn't test on Linux, but in Windows ... os.chdir('C:\temp\my test') Traceback (most recent call last): File "", line 1, in WindowsError: [Error 123] The filename, directory name, or volume label synt

Re: creating a list from a inconsistent text file

2008-05-02 Thread Kam-Hung Soh
ot inconsistent. > How do I convert that line into a list? Use the `csv` module in the standard library. Ciao, Marc 'BlackJack' Rintsch Hello Marc; Thanks for the input! I am worried about the comma in the "" data items, how do I tell Python to look for the "&quo

Re: sed to python: replace Q

2008-04-30 Thread Kam-Hung Soh
On Wed, 30 Apr 2008 17:12:15 +1000, Kam-Hung Soh <[EMAIL PROTECTED]> wrote: On Wed, 30 Apr 2008 15:27:36 +1000, Raymond <[EMAIL PROTECTED]> wrote: For some reason I'm unable to grok Python's string.replace() function. Just trying to parse a simple IP address, wrap

Re: sed to python: replace Q

2008-04-30 Thread Kam-Hung Soh
regular expressions. Try: import re p = re.compile("^.*\[") q = re.compile("].*$") q.sub('',p.sub('', line)) Is there a decent description of string.replace() somewhere? Raymond Section 3.6.1 String Functions -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: computing with characters

2008-04-30 Thread Kam-Hung Soh
On Wed, 30 Apr 2008 16:13:17 +1000, SL <[EMAIL PROTECTED]> wrote: How can I compute with the integer values of characters in python? Like 'a' + 1 equals 'b' etc Try: ord('a') See also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65117 -- Kam

Re: problem with listdir

2008-04-26 Thread Kam-Hung Soh
.1 "String literals". Could there be some files in that directory whose name is not a valid Windows file name? Windows file names cannot have the following symbols: \ / : * ? " < > | -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: Is massive spam coming from me on python lists?

2008-04-21 Thread Kam-Hung Soh
rian Vanderburg II No worries. People should (I hope) just ignore the sender address when they receive spam. -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: index of list of lists

2008-04-18 Thread Kam-Hung Soh
estring', 1, 2], ['oneother', 2, 4]] > for alist in someList: > if alist[0] == 'somestring': > print "Found it at index %d" % someList.index( alist ) > # if you know it will only occur once you might say: > break > > HTH,

Re: Finally had to plonk google gorups.

2008-04-16 Thread Kam-Hung Soh
ill file variable (use Firefox about:config and filter for "kill") and enable case-insensitive search (open the script, search for "compile()" and add a second parameter "i"). (Posted via GG, but I'm open to an alternative web-based Usenet service.) -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: how to remove \n in the list

2008-04-13 Thread Kam-Hung Soh
t; > > how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > > -- > Gabriel Genellina Also: map(str.rstrip, l) -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list

Re: How is GUI programming in Python?

2008-04-09 Thread Kam-Hung Soh
ge Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform." -- Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman -- http://mail.python.org/mailman/listinfo/python-list