Say I have a bunch of ax1,ax2,ax3... and I want to run them through a plotting function:
def plotxy(ax,x,y): x = np.array(x) y = np.array(y) ax.plot(
I'm probably missing something in your question, but why don't you just use a simple loop?
for ax in ( ax1, ax2, ..., axn ): plotxy(ax,x,y)
You can also avoid the explicit listing all variables:
axes = ( locals()['ax%d'%i] for i in range(1, n+1) ) for ax in axes: plotxy(ax,x,y)