Re: improve this newbie code/nested functions in Python?

2009-03-21 Thread Paul Hankin
On Mar 20, 3:21 am, Esmail ebo...@gmail.com wrote: Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this code? Also, I am using two nested functions, it seems that

Re: improve this newbie code/nested functions in Python?

2009-03-21 Thread Esmail
Paul Hankin wrote: I would decouple the speaker and the listener from the client, and make the client interface more abstract. Simple and descriptive interfaces can make code dramatically easier to understand. class ClientListener(Thread): def __init__(self, client, ...): ... def

Re: improve this newbie code/nested functions in Python?

2009-03-20 Thread Esmail
Hi! On Mar 20, 1:06 am, Terry Reedy tjre...@udel.edu wrote: What you wrote are two nested classes, not functions.   Ooops .. yes of course .. simple mistake (it was late .. :) In my opinion, neither should be nested.  Nothing is gained and something is lost. Neither are used by client;

Re: improve this newbie code/nested functions in Python?

2009-03-20 Thread pruebauno
On Mar 19, 10:21 pm, Esmail ebo...@gmail.com wrote: Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this code? Also, I am using two nested functions, it seems that

Re: improve this newbie code/nested functions in Python?

2009-03-20 Thread Esmail
On Mar 20, 2:02 pm, prueba...@latinmail.com wrote: On Mar 19, 10:21 pm, Esmail ebo...@gmail.com wrote: Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this

Re: improve this newbie code/nested functions in Python?

2009-03-20 Thread Terry Reedy
Esmail wrote: In my opinion, neither should be nested. Nothing is gained and something is lost. Neither are used by client; indeed both use client. I nested them because I see them as components of the client which keeps track of the connection parameters and makes the initial connection and

Re: improve this newbie code/nested functions in Python?

2009-03-20 Thread Esmail
To make a closure, the inner function *must* be nested in the outer. To be an instance method, a function *must* be a class attribute, and the easier way to indicate that is by nesting. In this case, the client does *not* use the other two classes, so the nesting is misleading.  I think the

improve this newbie code/nested functions in Python?

2009-03-19 Thread Esmail
Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this code? Also, I am using two nested functions, it seems that nested functions aren't used that much in Python - is that

Re: improve this newbie code/nested functions in Python?

2009-03-19 Thread Terry Reedy
Esmail wrote: Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this code? Also, I am using two nested functions, it seems that nested functions aren't used that much in