<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CODARE &#187; Python</title>
	<atom:link href="http://codare.net/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://codare.net</link>
	<description>Programadores, uni-vos!</description>
	<lastBuildDate>Tue, 29 Sep 2009 12:00:01 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='codare.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/d9589f1266f7b80a398397e3165f7c56?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>CODARE &#187; Python</title>
		<link>http://codare.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codare.net/osd.xml" title="CODARE" />
	<atom:link rel='hub' href='http://codare.net/?pushpress=hub'/>
		<item>
		<title>Python: Introspeção de atributos e métodos com vars(), locals() e dir()</title>
		<link>http://codare.net/2009/09/25/python-introspecao-de-atributos-e-metodos-com-vars-locals-e-dir/</link>
		<comments>http://codare.net/2009/09/25/python-introspecao-de-atributos-e-metodos-com-vars-locals-e-dir/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 12:00:59 +0000</pubDate>
		<dc:creator>Lauro Cesar</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[atributos]]></category>
		<category><![CDATA[locals]]></category>
		<category><![CDATA[vars]]></category>

		<guid isPermaLink="false">http://codare.net/?p=479</guid>
		<description><![CDATA[Para descobrir os atributos de um objeto podemos utilizar:
objeto.__dict__

vars(objeto)
Para descobrir os atributos de uma classe:
vars(Classe())
Se utilizar vars() sem argumentos, funciona como locals(), listando todas as variáveis.
Para listar métodos e atributos de um objeto:
dir(objeto)
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codare.net&blog=417062&post=479&subd=codare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Para descobrir os atributos de um objeto podemos utilizar:</p>
<pre>objeto.__dict__

vars(objeto)</pre>
<p>Para descobrir os atributos de uma classe:</p>
<pre>vars(Classe())</pre>
<p>Se utilizar vars() sem argumentos, funciona como locals(), listando todas as variáveis.</p>
<p>Para listar métodos e atributos de um objeto:</p>
<pre>dir(objeto)</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codare.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codare.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codare.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codare.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codare.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codare.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codare.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codare.wordpress.com/479/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codare.wordpress.com/479/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codare.wordpress.com/479/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codare.net&blog=417062&post=479&subd=codare&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://codare.net/2009/09/25/python-introspecao-de-atributos-e-metodos-com-vars-locals-e-dir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e695c2389b7d5dfae9b15bd39b3379c?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">olarva</media:title>
		</media:content>
	</item>
		<item>
		<title>Python: Teste condicional e estruturas de dados vazias</title>
		<link>http://codare.net/2009/06/03/python-teste-condicional-e-estruturas-de-dados-vazias/</link>
		<comments>http://codare.net/2009/06/03/python-teste-condicional-e-estruturas-de-dados-vazias/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 12:00:43 +0000</pubDate>
		<dc:creator>Thiago Santos</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[overload]]></category>
		<category><![CDATA[__len__]]></category>
		<category><![CDATA[__nonzero__]]></category>

		<guid isPermaLink="false">http://codare.net/?p=430</guid>
		<description><![CDATA[Classes que implementam o método __len__, quando testadas com if, este método é invocado. Portanto, para uma lista vazia, o teste falha.
x = [];

if x:
    print "OK" # Nao imprime nada
Para mudar este comportamento, basta reimplementar o método __nonzero__.
class MyList(list):
    def __nonzero__(self):
        [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codare.net&blog=417062&post=430&subd=codare&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Classes que implementam o método __len__, quando testadas com if, este método é invocado. Portanto, para uma lista vazia, o teste falha.</p>
<pre>x = [];

if x:
    print "OK" # Nao imprime nada</pre>
<p>Para mudar este comportamento, basta reimplementar o método __nonzero__.</p>
<pre>class MyList(list):
    def __nonzero__(self):
        return True

x = MyList();

if x:
    print "OK" # Imprime OK</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codare.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codare.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codare.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codare.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codare.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codare.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codare.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codare.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codare.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codare.wordpress.com/430/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codare.net&blog=417062&post=430&subd=codare&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://codare.net/2009/06/03/python-teste-condicional-e-estruturas-de-dados-vazias/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b0cc38b3fd34093be7be0818d07c37ac?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Thiago Santos</media:title>
		</media:content>
	</item>
	</channel>
</rss>