[cse491] Function overloading and Python

Phil Deschaine deschai5 at gmail.com
Sun Oct 4 20:45:00 PDT 2009


Is it possible?  Google isn't helping much.


The reason I ask is that the hw says the following:
*
All data processing must take place in a function
``handle_connection`` that takes at least one parameter and up to
two::

def handle_connection(client_sock, stuff=None):

and returns a tuple ``(close_flag, stuff)``, where ``close_flag``
indicates whether or not this connection should now be closed, and
``stuff`` is a black box that will be passed into the function
on calls subsequent to the first call, e.g. ::

# first time
(flag, stuff) = handle_connection(client_sock)

# second time (flag was true, so connection was kept & processed)
(flag, stuff) = handle_connection(client_sock, stuff)
*


I tried calling the function I made (using the main while loop that's been
written for us already) and I get the following error:
*TypeError: handle_connection() takes exactly 2 arguments (1 given)*

Thanks,
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/cse491-fall-2009/attachments/20091004/373bec8c/attachment.htm>


More information about the cse491-fall-2009 mailing list