PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC.
Steve Holden
steve at holdenweb.com
Tue Apr 8 10:19:26 EDT 2008
subhabrata.iisc at hotmail.com wrote:
> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.
> 1310 32 bit (Intel)] on win32 with IDLE 1.2.1
> My O/S is Windows XP SP2 I use 512 MB RAM.
> I am encountering the following problems:
> (i) a1=1
> a2=2
> a3=a1+a2
> print a3
> # The result is coming sometimes as 3 sometimes as vague numbers.
>
Sorry, this just isn't true. There is no known implementation for which
1+2 does not equal 3.
> (ii) x1="Bangalore is called the Silicon Valley of India"
> x2="NewYork"
> x3=x1.find(x2)
> print x3
> # The result of x3 is coming as -1 as well as +ve numbers.
>
Presumably you get -1 when the substring isn't found. Look at the
documentation of str.find() to discover *why* this happens.
> (iii) I have been designing one crawler using "urllib". For crawling
> one web page it is perfect. But when I am giving around 100 URLs by
> and their links and sublinks the IDLE is not responding. Presently I
> have been running with 10 URLs but can't it be ported?
>
Not enough information. "I have a program, please tell me waht is wrong
with it" overtaxes even this group's psychic abilities.
> (iv) I have designed a program with more than 500 if elif else but
> sometimes it is running fine sometimes it is giving hugely erroneous
> results, one view of the code:
I am afraid that for code like this "designed" is far too kind a term. I
would have suggested "thrown together".
On what analysis of your problem was this solution based?
> elif a4==3:
> print "YOU HAVE NOW ENTERED THREE WORDS"
> if a3[0] not in a6:
> if a3[1] not in a6:
> if a3[2] not in a6:
> print "a3[0] not in a6, a3[1] not in a6, a3[2] not
> in a6"
> elif a3[2] in a6:
> print "a3[0] not in a6, a3[1] not in a6, a3[2] in
> a6"
> else:
> print "NONE3.1"
> elif a3[1] in a6:
> if a3[2] not in a6:
> print "a3[0] not in a6, a3[1] in a6, a3[2] not in
> a6"
> elif a3[2] in a6:
> print "a3[0] not in a6,a3[1] in a6, a3[2] in a6"
> else:
> print "NONE3.2"
> else:
> print "NONE3.3"
> elif a3[0] in a6:
> if a3[1] not in a6:
> if a3[2] not in a6:
> print "a3[0] in a6, a3[1] not in a6, a3[2] not in
> a6"
> elif a3[2] in a6:
> print "a3[0] in a6, a3[1] not in a6, a3[2] in a6"
> else:
> print "NONE3.4"
> elif a3[1] in a6:
> if a3[2] not in a6:
> print "a3[0] in a6, a3[1] in a6, a3[2] not in a6"
> elif a3[2] in a6:
> print "a3[0] in a6, a3[1] in a6, a3[2] in a6"
> else:
> print "NONE3.5"
> else:
> print "NONE3.6"
> else:
> print "NONE3.7"
> Why it is behaving like that?
Like what? You don't even say what results you expect, and only describe
the results you *do* obtain as "hugely erroneous".
I have a car. I have turned the ignition key but it fails to start.
Please tell me what is wrong with it.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list