[ create a new paste ] login | about

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

slevy1ster - Python, pasted on Jan 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#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()

line='1,2,3\n4,5,6\n7,8,9'
lines = line.replace(CONST.COMMA, CONST.EMPTYSTR)
print lines


Output:
1
2
3
123
456
789


Create a new paste based on this one


Comments: