@dispatch(object)
def shape(expr):
 s = list(discover(expr).shape)
 for (i, elem) in enumerate(s):
  try:
   s[i] = int(elem)
  except TypeError:
   pass
 return tuple(s)

@ dispatch ( object ) def shape ( expr ) : s = list ( discover ( expr ) . shape ) for ( i , elem ) in enumerate ( s ) : try : s [ i ] = int ( elem ) except TypeError : pass return tuple ( s )
shape of expression .