[ create a new paste ] login | about

Link: http://codepad.org/3NOEKrwz    [ raw code | output | fork ]

slevy1ster - Python, pasted on Jan 24:
#no const keyword in Python, so:
def constant(f):
    def fset(self, value):
        raise SyntaxError
    def fget(self):
        return f()
    return property(fget, fset)

class _Const(object):
    @constant
    def COMMA():
        return ','
    @constant
    def EMPTYSTR():
        return ''

CONST = _Const()

import re
line='1,2,3\n4,5,6\n7,8,9'
line = re.sub(CONST.COMMA, CONST.EMPTYSTR, line.rstrip())
print line
 
   


Output:
1
2
3
123
456
789


Create a new paste based on this one


Comments: