[Tutor] comparing lists, __lt__ and __gt__

Alan Gauld alan.gauld at btinternet.com
Sun Jul 29 02:11:36 CEST 2007

"Sara Johnson" <sarliz73 at yahoo.com> wrote

> Thanks Alan.  That said, any idea what it means in this context?
> for key in skeys:
>        fracmiss=1.*numberMissing(z[key].values())/nsites #note 
> decimal multiplication, 1.*
>        outstring="%s has %4.1f%% missing" % (key,100*fracmiss)
>        if fracmiss >>0

None whatsoever, it looks like an error to me!

That having been saisd their is another use for >> which is to append
output to a file, as in:

print 'hello world' >> myfile

sends the string to myfile instead of to stdout. (Although I couldn't 
get this to
work when I tried it!)

Alan G.

----- Original Message ----
From: Alan Gauld <alan.gauld at btinternet.com>
To: tutor at python.org
Sent: Saturday, July 28, 2007 5:03:05 PM
Subject: Re: [Tutor] comparing lists, __lt__ and __gt__

"Sara Johnson" <sarliz73 at yahoo.com> wrote

> What if there is a '<<' or '>>'?
> Does that just mean the same thing (maybe a little over emphasized..
> ;)

The double chevron operator is for bit-shifting its not a camparison
So no operator override function exists.

> I thought I saw this when I was learning boolean expressions,
> but I don't recall.

Possibly, because its often used to manipulate bitpatterns in
conjunction with bitwise boolean comparisons (and/or/xor etc)


Alan Gauld
Author of the Learn to Program web site

Tutor maillist  -  Tutor at python.org

Be a better Heartthrob. Get better relationship answers from someone 
who knows. Yahoo! Answers - Check it out.


> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list