<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'str.format problem' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'str.format problem' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 23:45:31 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 23:45:31 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>str.format problem</title>
      <link>http://www.programmersheaven.com/mb/python/411092/411092/strformat-problem/</link>
      <description>I have made a function that will output '{0}' when 0 is given and '{1}' for everything else.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
class offset(str):
    def __init__(self,x):
        self.x=x
    def __repr__(self):
        return repr(str({int(bool(self.x))}))
    
    def end(self,end_of_loop):
    #Ignore this def it works how I want it to.
        if self.x==end_of_loop:
            return '{2}'
        else:
            return self
&lt;/pre&gt;&lt;br /&gt;
What I would like to do is offset(1).format('first', 'next') but that only outputs '1' for some reason.  What can I do?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/411092/411092/strformat-problem/</guid>
      <pubDate>Tue, 22 Dec 2009 08:59:40 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>
