-
Currently getitem() in vec.py is empty.
(just doing pass...)
Type the following.
>>> from vec import Vec
>>> x = Vec({'A':1, 'B':2, 'C':3}, {'A':1, 'C':2})
>>> x['A']
-
Now replace pass in getitem()
with return v.f[k] if k in v.f else 0
and save vec.py.
Then run the following, but it still does not work
since the change is not applied.
>>> x['A']
-
Calling reload() does not work either.
>>> from imp import reload
>>> reload(vec)
Traceback (most recent call last):
File ">stdin<", line 1, in >module<
NameError: name 'vec' is not defined
>>> reload(Vec)
Traceback (most recent call last):
File ">stdin<", line 1, in >module<
File "/usr/lib/python3.4/imp.py", line 315, in reload
return importlib.reload(module)
File "/usr/lib/python3.4/importlib/__init__.py", line 122, in reload
raise TypeError("reload() argument must be module")
TypeError: reload() argument must be module
-
You can use reload() if in the following way.
>>> import vec
>>> x = vec.Vec({'A', 'B', 'C'}, {'A':1, 'C':2})
>>> x['A']
Modify and save vec.py.
Note that you have to re-define x
so that the modification has an effect.
>>> from imp import reload
>>> reload(vec)
>>> x = vec.Vec({'A', 'B', 'C'}, {'A':1, 'C':2})
>>> x['A']
1