PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC.

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Apr 9 16:14:03 CEST 2008


On 9 abr, 10:27, subhabrata.i... at hotmail.com wrote:

> comp.lang.python is supposed to be a serious group not anyone knowing
> nothing and giving comment.

Anyone is welcome to post in this group - from beginners to gurus, and
that's a very good thing. All people here is usually very kind and
helpful, and that's not very common on Usenet.

> Well, original code snippet I don't know
> why an expert person like you fails to understand, I told it almost
> can't you guess the next portion? Tough indeed, then. I've to take
> permission from my organization if we can bring out this code in
> public domain as we are working out an MT system that performs better
> than Systran. And if it is a public domain I donot have security for
> my code. Any one can copy.

How could anyone give some advise on what's wrong with your code, if
you don't show it? All you said is that you used urllib2 - there are
millions of ways to use the library, good and bad.

> But well if this group people are helping out of kindness, then I have
> to think.

Nobody here is being paid for helping others, they're all volunteers.
But even if there were some paid consultants, nobody has a crystall
ball, nobody can *guess* what's wrong with your code if you don't post
it.

About your crazy 500 if/elif: if all of them are like your posted
fragment, this needs a huge refactoring. After three repeats of the
same structure any sane programmer would say "hey, let's rearrange
this!". Someone posted an alternative, after guessing a bit what you
actually want to do.
Note that "a in b" and "a not in b" cover ALL possibilities ("tertium
non datur") so your 3-way ifs are wrong. If you want to determine
which strings from a set -if any- are contained in another string, use
some variant of the Aho-Corasick algorithm.

--
Gabriel Genellina



More information about the Python-list mailing list