Dynamically naming objects.

Kalibr space.captain.face at gmail.com
Sat Jun 7 10:14:53 EDT 2008


Thanks for all this info.

I'll try all your scripts out.

from what you guys have said, I did the following:

I set up a 'computer class' (I'lm leaving out the mutators)

class computer:

    def __init__(self, IP, owner, ph_connections, connections):

        assert isIP(IP) == True
        self.IP = IP
        self.owner = owner

        for i in ph_connections:
            assert isIP(i) == True
        self.ph_connections = ph_connections

        for i in connections:
            assert isIP(i) == True
        self.connections = connections

isIP(IP) is a function that checks if it looks like an IP based on
some rules.

Anyway....

I set up a list of users, each with their computer object named after
them, so:
users = ['Kal', 'Noob', 'Fred']

I ran through them with some code based vaguely on what you guys have
said:

for i in users:
    i = computer('<insert some sort of IP here>', i, [], [])

I set up the ph_connections and connections lists as empty for ease of
use.
Does this code seem right? I can't get it to work.



More information about the Python-list mailing list