[ create a new paste ] login | about

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

Python, pasted on May 21:
1
2
3
4
5
6
7
8
9
10
from functools import partial

b = 2  # b points to value 2
some_partial = partial(int, base=b) # some_partial.base points to value 2
print(some_partial('1010100001'))

b = 16 # b points to value 16
print(some_partial('DEADBEEF')) # some_partial.base still points to value 2: error

    


Output:
1
2
3
4
5
673
Traceback (most recent call last):
  Line 8, in <module>
    print(some_partial('DEADBEEF')) # some_partial.base still points to value 2: error
ValueError: invalid literal for int() with base 2: 'DEADBEEF'


Create a new paste based on this one


Comments: