<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>*drawcode &#187; introspection</title>
	<atom:link href="http://blog.drawcode.com/index.php/tag/introspection/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.drawcode.com</link>
	<description>creative engineering, design and development</description>
	<lastBuildDate>Sat, 23 May 2009 19:51:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Dynamically Loading Classes in Python using Reflection/Inspection w/ Inspect Module</title>
		<link>http://blog.drawcode.com/2009/03/03/dynamically-loading-classes-in-python-using-reflectioninspection-w-inspect-module/</link>
		<comments>http://blog.drawcode.com/2009/03/03/dynamically-loading-classes-in-python-using-reflectioninspection-w-inspect-module/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 21:31:58 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[introspection]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.drawcode.com/?p=15</guid>
		<description><![CDATA[Python is a dynamic language that you can pretty much use for anything. One area that is pretty common is loading up a dynamic class. Let&#8217;s say you get back a list of classes and you want to initialize one into an object and use it. You can use the script below to load in [...]]]></description>
			<content:encoded><![CDATA[<p>Python is a dynamic language that you can pretty much use for anything.  One area that is pretty common is loading up a dynamic class.  Let&#8217;s say you get back a list of classes and you want to initialize one into an object and use it.  You can use the script below to load in a python class from introspection.</p>
<pre>    classname = "ClassToLookFor"
    the_module = __import__("my.module", globals(), locals(), [classname])
    the_class = getattr(the_module, classname)
    obj = the_class()</pre>
<p>More on introspection in Python (sometimes called Reflection in other languages like C# and Java):</p>
<ul>
<li><a href="http://docs.python.org/library/inspect.html" target="_blank">Python docs on introspection using the inspect module</a></li>
<li><a href="http://www.ibm.com/developerworks/library/l-pyint.html" target="_blank">IBM page on a tour of Python introspection</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.drawcode.com/2009/03/03/dynamically-loading-classes-in-python-using-reflectioninspection-w-inspect-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
