Converting from perl

sp00fD sp00fD at yahoo.com
Tue Aug 24 20:43:01 EDT 1999


In article <m3ogfwrfwo.fsf at atrus.jesus.cam.ac.uk>,
  Michael Hudson <mwh21 at cam.ac.uk> wrote:
> sp00fD <sp00fD at yahoo.com> writes:
>
> > I'm converting to python from perl and just created my first ...

> It might be easier to do this using a dictionary:
>
> arg2hosts = {
>     "AIX":("athena","dev","detroit","la","laredo","miami",
>            "newark","sat","savannah","seattle","titan"),
>     "SUN":("eclipse", "hercules", "scdev","scprod","sol"),
>     "BACKUP":("eclipse", "hercules", "scdev","scprod", "sol",
"athena")
> }
>
> try:
>     self.hosts = arg2hosts[self.args()]
> except KeyError:
>     self.hosts = self.ask_for_hosts()
>

Thanks, I'll do that, the thought crossed my mind, but I couldn't
decide whether to be a memory tightwad or not, you make a good point.

> >                                 os.system("rcp %s %s:%s" % \
> >                                 (_stuff[0], host, _stuff[1]))
> >                 except os.error:
> >                         print "Error during system() function -
oops"
>
> Note that this will not catch errors in executing the command passed
> to os.system - you need to look at the return code for that.

How do I do that?
foo = os.system("..")?

>
> To be honest, I don't see a lot of value in wrapping this up in a
> class. For a straight through shell scripty type job like this I
> generally don't bother. Python is not about ramming methodologies down
> your throat.
>

Honestly, me neither, more than anything I wanted to get a feel for
them, basically I was bound and determined to create a class, but when I
was done, it was obviously stupid.  Unfortunately, most of the stuff I
do is "straight through shell scripty" so, hopefully I can figure out
some decent way to use the OO features of python for that.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list