[docs] Bug report

Christian Yeganeh christianyeganeh at gmail.com
Tue May 3 19:51:04 EDT 2016


I have found a bug. Its small and not harmful. But its still there. If you take the string of a tuple, it will not always return the correct string. 
If you have a tuple with only one element and cast it using str() it will put the comma at the end of the string before the ) as if there was a second element. 

sample code:
>>> class testclass:
...     def __repr__(s): return 'a'
... 
>>> (1,2)[1:]
(2,)
>>> tuple([1])
(1,)
>>> tuple(['a'])
('a',)
>>> tuple(tuple([1]))
(1,)
>>> tuple([testclass(),1,'a'])[1:2]
(1,)
>>> (1,2,testclass())[2:]
(a,)
>>> #no matter what way you get it as lon as its a single element it includes the , after the element
... 
>>> #however with multiple elements
... 
>>> tuple([1,2])
(1, 2)
>>> (1,2)
(1, 2)
>>> (1,2,3)[1:]
(2, 3)

Christian Yeganeh


More information about the docs mailing list