Life's better without braces

Moshe Zadka moshez at math.huji.ac.il
Tue Feb 22 02:47:22 EST 2000


On 21 Feb 2000, Andrew M. Kuchling wrote:

> [1] Greg Ward just observed that it's possible to boot Linux and pass
> it "init=/usr/bin/emacs", to run Emacs as the single process on the
> system.The return of the Lisp Machine!

Way cool!

> chrdict = {0:'\000', 1:'\001', ... 255: '\377'}

You can use Python to write this dict to a file, you know ;-)

> def hasattr(obj, name):
>   s = 'obj.' + name
>   try:
>       exec s
>       return 1
> except AttributeError:
>       return 0

Andrew?

def hasattr(obj, name):
	try:
		getattr(obj, name)
		return 1
	except AttributeError:
		return 0

Your version has a bug.





More information about the Python-list mailing list