another thread on Python threading

Steve Howell showell30 at
Sun Jun 3 23:52:59 CEST 2007

--- "cgwalters at" <cgwalters at> wrote:
> One random idea is to for Python 3000, make the
> equivalent of
> __slots__ the default, *but* instead gather
> the set of attributes from all member variables set
> in __init__.  

Are you suggesting to do this at startup time or

The pitfall here is that to reduce code duplication,
you might initialize certain variables in a method
called by __init__, because your object might want to
return to its initial state.  An example might be an
object that flipflops between waiting for headers and
waiting for payloads.  You might have code like this:

class MessageReader:
    def __init__(self, incoming_port):
        self.incoming_port = incoming_port

    def start_waiting_for_headers(self):
        self.waiting_for_headers = ''
        self.header = ''
        self.payload = ''

    def handle_payload(self):

    # ...

Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.

More information about the Python-list mailing list