[Tutor] Help me Be Pythonic

Sean 'Shaleh' Perry shalehperry@attbi.com
Tue, 28 May 2002 18:44:17 -0700 (PDT)


> 
> In pseudo code, how can I think about this task like a python
> programmer. Would I have a urlcheck object that was passed the
> data and checked for different types? What's the pythonic way
> to:
> 
> open file or command line arguments
>     check url for .com
>     if text found print "succes" 
>     else print "unavailable"
>     check url for .org
>     if text found print "succes" 
>     else print "unavailable"
> 

for name on command line:
  for type in (com, net, org):
    if name_exists('name.type'):
      print yes
    else:
      print no

def name_exists(name):
  do stuff here

is pseudo code of how I would approach it.