Re: How to determine an object is "scriptable"

2006-03-30 Thread Daniel Evers
Richard Brodie wrote: > subscriptable: supports an indexing operator, like a list does. Right. You can check this e.g. with hasattr(x, "__getitem__") because the __getitem__ method is used for indexing. Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: combine doxygen and doc-strings?

2005-11-18 Thread Daniel Evers
You're maybe searching for epydoc: http://epydoc.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: What do you use as symbols for Python ?

2005-11-12 Thread Daniel Evers
Peter Otten wrote: > > You should ditch what follows and instead add just > > def __iter__(self): > return iter(self.__keys) Mhh. I should start learning the builtins ... :) > To see the problem with your original code (an object serving as its own > iterator) try the f

Re: Internal Variables

2005-11-11 Thread Daniel Evers
Hi! The sys module provides some useful information, e.g.: builtin_module_names -- tuple of module names built into this interpreter version -- the version of this interpreter as a string version_info -- version information as a tuple hexversion -- version information encoded as a single integer

Re: What do you use as symbols for Python ?

2005-11-11 Thread Daniel Evers
Hi! Never would have thought of this... I mixed this with the class-version and created a new class derived from "str" for easier printing and added an iterator: --- class Enum: class Type(str): def __init__(self, name): self.__name = name

Re: iterate over class variables

2005-11-10 Thread Daniel Evers
Hi! You can iterate over the internal dictionary: >>> class Test: ... def __init__(self): ... self.x = 5 ... self.y = 6 ... self.z = "Hallo" ... >>> x = Test() >>> print x.__dict__ {'y': 6, 'x': 5, 'z': 'Hallo'} >>> for key, value in x.__dict__.items(): ..

Re: How to convert a number to hex number?

2005-11-08 Thread Daniel Evers
Hi! Try hex: >>> hex(120) '0x78' Consider converting string -> int using the int()-function: >>> print int.__doc__ int(x[, base]) -> integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representa