converting perl to python - simple questions.

sweeting at neuronet.com.my sweeting at neuronet.com.my
Sun Apr 25 10:57:30 EDT 1999


In my ongoing saga to build a chinese-language search engine, I've found a
great deal of groundwork already. The bad news (for me) is that this was all
in Perl so I've had a rather distressing day :
(a) learning perl
(b) converting the scripts to python so that I can build objects with them.

Anyway, since I know that there are a few ex-perlmongers on the list,
would somebody be so kind as to confirm whether I've translated the following
code snippets correctly :

a) Perl's "defined".
   [perl]
   if (defined($x{$token})

   [python]
   if (x.has_key(token) and x[token]!=None) :

b) RE's.
   [perl]
   if ($mytext !~ /^\s$/)

   [python]
   if not (re.match('^\s$'), mytext)


Since I know neither perl nor chinese, it would be nice if somebody
could help me remove one of the variables in my debugging.

Thanking you :)

chas






-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




More information about the Python-list mailing list