Consider the following simple example:
import pandas as pd
mytable = pd.read_csv('test.dat',sep='\t')
mytable["z"] = mytable.x + mytable.y
mytable["q"] = mytable.z**2
mytable
for example with cat test.dat:
x y
1 5
2 6
3 7
4 8
If I use something like this for example from ipython3 I want to "factor out" the mytable keyword as in this pseudo code:
import pandas as pd
mytable = pd.read_csv('test.dat',sep='\t')
cd mytable
z = x + y
q = z**2
mytable
Are there any possibilities to simplify syntax like this. It is ok, if the solutions uses additional ipython features.
Remark: I used a "cd" keyword following pgf/tikz syntax where something like this is possible.
withkeyword from Pascal. I think there is no such thing in Python possible without massive hacking. After all Python strives to keep each line expressive without too much context. Think of the explicitness ofselfin methods which is exactly the opposite of your approach. See also stackoverflow.com/questions/2279180/… for the same question in C/C++.