<p>Pexpect can be used to automate tasks in python (does not need TCL to be installed). One of the simplest routines of this class is the 'run()' routine. It accepts a dictionary of expected question patterns as keys and the responses as values. For example</p>

<p>pexpect.run ('scp foo myname@host.example.com:.', events={'(?i)password': mypassword})</p>

<p>I know that usually '?' is used to indicate 0 or 1 occurrences of previous literal in the string (for regular expressions that is). However, over here, this does not seem to be the meaning. </p>

<p>Can experts comment on what is it?</p>

https://docs.python.org/library/re.html#regular-expression-syntax
(?...)    This is an extension
  notation (a "?" following a "(" is not
  meaningful otherwise). The first
  character after the "?" determines
  what the meaning and further syntax of
  the construct is. Extensions usually
  do not create a new group;
  (?P...) is the only exception to
  this rule. Following are the currently
  supported extensions.
(?iLmsux)    (One or more letters from
  the set "i", "L", "m", "s", "u", "x".)
  The group matches the empty string;
  the letters set the corresponding
  flags (re.I, re.L, re.M, re.S, re.U,
  re.X) for the entire regular
  expression. This is useful if you wish
  to include the flags as part of the
  regular expression, instead of passing
  a flag argument to the compile()
  function.
Note that the (?x) flag changes how
  the expression is parsed. It should be
  used first in the expression string,
  or after one or more whitespace
  characters. If there are
  non-whitespace characters before the
  flag, the results are undefined.
So in this case the string is a regular expression, and is set to be case-insensitive.