Understanding syntax in Python
Question: I am trying to use PodSixNet library in Python to implement a multiplayer
game. As I have seen a few tutorials online, the server file is as follows:

    
    
    import PodSixNet.Channel
    import PodSixNet.Server
    from time import sleep
    
    class ClientChannel(PodSixNet.Channel.Channel):
        def Network(self, data):
            print data
    
    class BoxesServer(PodSixNet.Server.Server):
        channelClass = ClientChannel
    
        def __init__(self, *args, **kwargs):
             PodSixNet.Server.Server.__init__(self, *args, **kwargs)
    

What does the line `channelClass = ClientChannel`mean?

`channelClass` is definitely not an instance of the `ClientChannel` class
because the instance declaration is not correct. So what is it then?


Answer: All this does is create the `BoxesServer.channelClass` class attribute. It is
just a reference to another class.

Why would you do that? Well, the `PodSixNet.Server.Server` is flexible, it
doesn't hardcode the class it'll use to create channels for new connections.
Instead, it'll look for the `self.channelClass` attribute, and use that to
create new channel instances. See the [`Server.handle_accept()` method
source](https://github.com/chr15m/PodSixNet/blob/master/PodSixNet/Server.py#L22-L35):

    
    
    self.channels.append(self.channelClass(conn, addr, self, self._map))
    

Calling `self.channelClass()` then creates an instance of whatever class is
assigned to that attribute. This lets you swap out the channel class easily
when defining new subclasses.

Note that the `PodSixNet.Server.Server()` class can also take the channel
class as an argument when creating an instance. That'll then override the
class attribute you set.

