Matching Pure Numeric and '' with Python re

2006-10-27 Thread Wijaya Edward
Hi, Given this list: list = ['0123', '1A34' , '333-' , '' ] I want to match only this element '0123' (pure numeric) and '' (empty element). Why this construct doesn't work? p = re.compile("''+|[0-9]+") m = p.match(word) if m: print word, Nam

RE: Slurping All Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
From: [EMAIL PROTECTED] on behalf of Wijaya Edward Sent: Thu 10/26/2006 11:47 PM To: python-list@python.org Subject: Slurping All Content of a File into a Variable Hi, How can we slurp content of a single file into one variable? I tried this

Slurping All Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
Hi, How can we slurp content of a single file into one variable? I tried this: >>> myfile_content = open('somefile.txt') >>> print myfile_content, >>> But it doesn't print the content of the file. Regards, -- Edward WIJAYA SINGAPORE Institute For Infocomm Research - Dis

RE: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Wijaya Edward
;\xc7', '\xd5', '\xbc','FOO','BAR] What's the best way to do it? -- Edward WIJAYA SINGAPORE From: [EMAIL PROTECTED] on behalf of Cameron Walsh Sent: Fri 10/27/2006 12:03 PM To: python-list@python.org Subject: Re: How to S

How to Split Chinese Character with backslash representation?

2006-10-26 Thread Wijaya Edward
Hi all, I was trying to split a string that represent chinese characters below: >>> str = '\xc5\xeb\xc7\xd5\xbc' >>> print str2, ??? >>> fields2 = split(r'\\',str) >>> print fields2, ['\xc5\xeb\xc7\xd5\xbc'] But why the split function here doesn't seem to do the job for obtaining the desire

Insert Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
Hi, How can we slurp all content of a single file into one variable? I tried this: >>> myfile_content = open('somefile.txt') >>> print myfile_content, >>> But it doesn't print the content of the file. Regards, -- Edward WIJAYA SINGAPORE Institute For Infocomm Research -

RE: Printing Hidden Character in Python

2006-10-26 Thread Wijaya Edward
From: [EMAIL PROTECTED] on behalf of Ben Finney Sent: Thu 10/26/2006 4:59 PM To: python-list@python.org Subject: Re: Printing Hidden Character in Python Wijaya Edward <[EMAIL PROTECTED]> writes: > How can we print out the hidden character like "\n", "\r" e

Printing Hidden Character in Python

2006-10-26 Thread Wijaya Edward
Hi, How can we print out the hidden character like "\n", "\r" etc in Python? -- Edward WIJAYA SINGAPORE Institute For Infocomm Research - Disclaimer - This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notif

Problem Commenting within Filehandle Iteration

2006-10-26 Thread Wijaya Edward
Hi all, I have the following code: import sys import re ham_count = 0 spam_count = 0 myfile = open('full/index') for line in myfile.readlines(): p = re.compile('ham') m = p.match(line) if m: print line, else: #print

Auto Completion for Python in VIM editor

2006-10-23 Thread Wijaya Edward
Dear all, Perl and C/C++ have perl-support.vim and c.vim by Fritz Mehner that support a very convenient auto completion shortcut in visual mode (e.g \aw for While construct). Does anybody know if such a comprehensive scripts also exist for Python? python.vim doesn't seem to suppor this kind o

RE: Where to find pydoc?

2006-10-18 Thread Wijaya Edward
Hi, Can you be specific on which URLs can I find "python-tools". Cause I tried the one under easy_install, I still can't find it. Thanks and hope to hear from you again. -- Edward WIJAYA SINGAPORE From: [EMAIL PROTECTED] on behalf of Fredrik Lundh Sent: Mon 1

RE: Where to find pydoc?

2006-10-16 Thread Wijaya Edward
7; Rintsch Sent: Mon 10/16/2006 5:00 PM To: python-list@python.org Subject: Re: Where to find pydoc? In <[EMAIL PROTECTED]>, Wijaya Edward wrote: > > I tried to call pydoc from my Linux box. > To my realization that it doesn't contain > pydoc. > > I thought this mod

Where to find pydoc?

2006-10-16 Thread Wijaya Edward
I tried to call pydoc from my Linux box. To my realization that it doesn't contain pydoc. I thought this module should be a default module. Can anybody suggest where can I find the module? I tried: $ easy_install pydoc Searching for pydoc Reading http://sqlobject.org/

Loops Control with Python

2006-10-13 Thread Wijaya Edward
Can we make loops control in Python? What I mean is that whether we can control which loops to exit/skip at the given scope. For example in Perl we can do something like: OUT: foreach my $s1 ( 0 ...100) { IN: foreach my $s2 (@array) { if ($s1 == $s2) { n

Python Best Practice References

2006-10-13 Thread Wijaya Edward
Can anybody suggest any references (links, books, etc)about this? I'm thinking of something similar with D.Conway's "Perl Best Practice". -- Edward WIJAYA SINGAPORE Institute For Infocomm Research - Disclaimer - This email is confidential and may be privileged. If you

Click and Drag Functionality in Web Apps with Python

2006-10-12 Thread Wijaya Edward
Hi, Some recent webapps like Kiko , Google's gadget , and spreadsheets to name a few, have this functionality. I wonder how can this funcitonalities be implemented in Python. Do you guys hav

Hands on Documentation for Python methods and Library

2006-10-04 Thread Wijaya Edward
Hi, One can do the following with Perl $ perldoc -f chomp $ perldoc -f function_name or $ perldoc List::MoreUtils $ perldoc Some::Module Can we do the same thing in Python? -- Edward SINGAPORE Institute For Infocomm Research - Disclaimer - This email is conf

Benchmarking Python's subroutines/function

2006-10-03 Thread Wijaya Edward
Hi, How does one benchmark multiple subroutines in Python? Is there a built-in library for that? -- Regards, Edward WIJAYA SINGAPORE Institute For Infocomm Research - Disclaimer - This email is confidential and may be privileged. If you are not the intended recipien

RE: Howto pass Array/Hash into Function

2006-10-03 Thread Wijaya Edward
Thanks for your understanding Steve. Furthermore, my related concern is how does Python actually deal with 'reference' in Perl. But now, it is clear to me now that Python simply treats them as object. Regards, Edward WIJAYA SINGAPORE From: [EMAIL PROTECTED]

Howto pass Array/Hash into Function

2006-10-03 Thread Wijaya Edward
Hi, How can I pass Array, Hash, and a plain variable in to a function at the same time. I come from Perl. Where as you probably know it is done like this: sub myfunc { my ($plain_var, $hash_ref,$arref) = @_; # Do sth with those variables return; } I wonder how can that be do