Introspection, importing and Flash

Robert Brewer fumanchu at amor.org
Tue Jun 29 15:55:29 CEST 2004


Sorry if this is HTML--I'm using Outlook Web Access while on vacation :(
 
1) If I understand you correctly, __listattr__ is spelled __dir__ .
 
2) Move AMFPython.py into site-packages and call it amf.py. Rename the class AMFPython to AMF. Then write:
 
import amf
instance = amf.AMF()
 
It's the word "Python" in "AMFPython" that's redundant. ;)
 
 
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
 

	-----Original Message----- 
	From: Vsevolod (Simon) Ilyushchenko [mailto:simonf at cshl.edu] 
	Sent: Tue 6/29/2004 6:33 AM 
	To: python-list at python.org 
	Cc: 
	Subject: Introspection, importing and Flash
	
	

	Hi,
	
	Last year I have written a Perl module to serve as a backend to
	Macromedia Flash applications: http://www.simonf.com/amfperl
	
	I have just rewritten it in Python, which I have not used before. Thus,
	a couple of questions which I was not able to solve with online research:
	
	1. To send an arbitrary object to Flash, I would like to use
	introspection to find out the values of all its instance variables. How
	can I get their names? I've read about __dict__,  __slots__, and
	__getattr__, but I am not sure what would be the most universal way to
	get all the instance variable names from both old-style and new-style
	objects. I would need something like __listattr__, which does not exist.
	
	2. Python class importing works in a rather confusing way. In Perl, I
	have a top-level class AMF::Perl, which I "import" once and then create
	its instance like this: "new AMF::Perl". The file Perl.pm lives in the
	AMF directory.
	
	In Python, the most concise way I found was to have AMFPython.py in the
	AMF directory, place __init__.py with "import AMFPython" in the AMF
	directory, then say in my top-level script
	        import AMF
	        instance =  AMF.AMFPython.AMFPython()
	Which is rather redundant. I'd like to do something not more complicated
	than:
	
	        import AMF.AMFPython as AMF
	        instance = AMF()
	
	but I don't know if it's possible.
	
	Thanks,
	Simon
	--
	
	Simon (Vsevolod ILyushchenko)   simonf at cshl.edu
	                                http://www.simonf.com
	
	Terrorism is a tactic and so to declare war on terrorism
	is equivalent to Roosevelt's declaring war on blitzkrieg.
	
	Zbigniew Brzezinski, U.S. national security advisor, 1977-81
	
	--
	http://mail.python.org/mailman/listinfo/python-list
	



More information about the Python-list mailing list