str.format problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


str.format problem

gibberoshgibberosh Posts: 2Member
I have made a function that will output '{0}' when 0 is given and '{1}' for everything else.

class offset(str):
def __init__(self,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}'
return self
What I would like to do is offset(1).format('first', 'next') but that only outputs '1' for some reason. What can I do?
Sign In or Register to comment.