Advertisement
DarkPotatoKing

String Subclass Python

Oct 26th, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. class String(str):
  2.  
  3.     def reverse(self):
  4.         self = self[::-1] #reverses the string
  5.         print self #prints 'DCBA'
  6.  
  7. s = String('ABCD')
  8. s.reverse()
  9. print  s #prints 'ABCD'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement