Python style questions

Cary O'Brien cobrien at Radix.Net
Fri Mar 16 10:25:21 EST 2001


I have a couple of style questons regarding larger Python programs.
I'd be interested in comments.

1. I have a class that handles communications with a remote service.
   It is fairly complex, having to deal with timeouts and retransmits
   and the like.  The class definition is getting bigger than I'd like.
   Should I

    a. Live with it
    b. Factor into mix-in classes
    c. Define some methods outside of the class definition.
    d. ???


2. One thing I've done is to define classes used only by another class
   inside that class.  For example, if a class A needs to keep track of a
   bunch of "things", then the class definition for the "things" is inside
   of the class definition of A.  This is

   a. SOP
   b. Brilliant
   c. Idiotic

3. I really miss not having a "switch" or "case" statement.  Sniff.

4. I need to change things like "88aa99bb" (hex string) into integers.  Should I

   a. use expr("0x"+s) 
   b. not use such things
   c. ???


That's it for now.  I'm sure I'll have more questions as time goes on.
I guess what I'm really interested is how to create readable, maintainable,
code for complex classes.

-- cary






More information about the Python-list mailing list