Which $TERM to use to have both 256 colors and mouse move events in python curses?

You can always make your own, using infocmp (to show the contents of an entry), and tic (to compile an entry). If you do not have permission to write in the system area, it goes to $HOME/.terminfo

Start by comparing xterm-1003 and xterm-256color:

> infocmp -x xterm-1003 xterm-256color
comparing xterm-1003 to xterm-256color.
    comparing booleans.
        ccc: F:T.
    comparing numbers.
        colors: 8, 256.
        pairs: 64, 32767.
    comparing strings.
        initc: NULL, '\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\'.
        setab: '\E[4%p1%dm', '\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m'.
        setaf: '\E[3%p1%dm', '\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m'.
        setb: '\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.
        setf: '\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.
        XM: '\E[?1003%?%p1%{1}%=%th%el%;', NULL.

Essentially, all you are interested in is adding the XM capability to a copy of xterm-256color.

So...

  1. infocmp -x xterm-256color >foo
  2. edit foo, adding the XM string
  3. tic -x foo

The "-x" option is needed for tic to compile the XM capability, which is an extended (user-defined) capability which ncurses happens to recognize as noted in comments for the terminal database.