Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> class X(str):
- ... def myMethod( self ):
- ... return int(self)
- ...
- >>> s=X("Hi Mom")
- >>> s.lower()
- 'hi mom'
- >>> s.myMethod()
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "<stdin>", line 3, in myMethod
- ValueError: invalid literal for int() with base 10: 'Hi Mom'
- >>> z=X("271828")
- >>> z.lower()
- '271828'
- >>> z.myMethod()
- 271828
Add Comment
Please, Sign In to add comment