"Robert Rawlins - Think Blue" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> Wider fragments of code don't really exists at this moment in time
No but specifying the problem too narrowly tends to get you an
unidiomatic solution.

> Basically I'm trying to create a class that contains an array of MAC
> address, these look something like this 'FD:E4:55:00:FG:A9.

You rarely want to use 'array' in the standard library; there are some
use cases for it but they are rare. More often you want to use the
list type. However, here you really want to use a set: having
decided that, the code is so trivial, it's hardly worth making a new
class.

>>> s = set()
>>> s.add('FD:E4:55:00:FG:A9')
>>> s.remove('FD:E4:55:00:FG:A9')
>>> s = set()
>>> s.add('FD:E4:55:00:FG:A9')
>>> 'FD:E4:55:00:FG:A9' in s
True
>>> s.remove('FD:E4:55:00:FG:A9')
>>> 'FD:E4:55:00:FG:A9' in s
False
>>> s.clear()

Of course, you might want to add sanity checks like
'G' is not a hex digit in a real implementation.




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to