[BangPypers] Latest Cricket News in Command Line

Nitin Dahra nitinkd at gmail.com
Mon Oct 4 20:05:52 CEST 2010


On 4 October 2010 18:43, Gopalakrishnan Subramani
<gopalakrishnan.subramani at gmail.com> wrote:
> I don't think, I will be giving you the complete working code, here is
> sample one.
>
> sites = {
> 0: "<<BBCLink>>",
> 1: "<<CricInfoLink>>"
> }
>
> X= input('BBC Cricket News:1 , Cricinfo Cricket News:2 \n enter your choice:
> ')
>
> if sites.has_key((int(X)):

has_key function for dicts is deprecated and not present in 3.x at
all. Just use -
int(X) in sites

Apparently, 'in' is also faster than 'has_key'

Regards,
Nitin


More information about the BangPypers mailing list