How to change the direction in which a menu is displayed?
Looking at your picture, I think you rather mean that you want to change on which side of the 'menu starter' widget the menu is displayed (left vs right)? A menu “direction” would rather refer to order in which its items are displayed (top to bottom or vice-versa)

In any case, side or direction, you cannot control this from py script, this is handled by internal UI code (based on several factors like type of menu, position, available area on top/bottom/left/right, etc.).