[Tutor] range function
Srinivas Iyyer
srini_iyyer_bio at yahoo.com
Sat Jan 29 23:34:32 CET 2005
Hi:
I have bunch of coordinates for various vectors.
example:
small vecs:
name cord. X cord. Y Sector no.
smvec1 75 100 1aa
smvec2 25 50 1aa
smvec3 135 155 1ab
large vecs: zone
Lvec1 10 50 1aa ut
Lvec1 60 110 1aa cd
Lvec1 130 180 1ab cd
Now I am checking if small vecs are falling in which
large vecs.
I initially tried by taking sm X and sm Y coordinates
into two variables smX smY and similarly LX and LY and
checking:
if smX >=lX and smY <= LY:
print line in large vect +'\t' + line in
small vec.
Unfortunately this failed. because LX and LY are not
matched together.
The other way by taking tuples:
for line in smallvecs:
cols = line.split('\t')
smvec_tup = zip(cols[1],cols[2])
for line2 in largevec:
cols = line2.split('\t')
lvec_tup = zip(cols[1]+'\t'+cols[2])
## from here I have no clue, :-( ###
if smvec_tup is in rane(lvec_tup):
print line+'\t'+line2
ultimately I want to say:
smvec1 smX smY LX LY Lvec1 cd
My question here is that is there any way that i can
ask python to check a tuple is falls in the range of
other tuple.
Also, members could u suggest more pythonian ways to
deal with this kind of problem.
thank you in advance
Srini
__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250
More information about the Tutor
mailing list