User input masks - Access Style

flebber flebber.crue at gmail.com
Fri Dec 31 09:15:52 EST 2010


On Dec 28 2010, 12:21 am, Adam Tauno Williams <awill... at whitemice.org>
wrote:
> On Sun, 2010-12-26 at 20:37 -0800, flebber wrote:
> > Is there anyay to use input masks in python? Similar to the function
> > found in access where a users input is limited to a type, length and
> > format.
>
> <http://faq.pygtk.org/index.py?file=faq14.022.htp&req=show>
>
> Typically this is handled by a callback on a keypress event.

Sorry

Regarding 137 of the re module, relating to the code above.

# validate the input is in the correct format (usually this would be
in
# loop that continues until the user enters acceptable data)
if re.match(r'''^[0-9]{2}:[0-9]{2}:[0-9]{2}$''', timeInput) == None:
        print("I'm sorry, your input is improperly formated.")
        sys.exit(1)

EDIT: I just needed to use raw_input rather than input to stop this
input error.

Please enter time in the format 'MM:SS:HH':
11:12:13
Traceback (most recent call last):
  File "C:\Documents and Settings\renshaw\workspace\Testing\src
\Time.py", line 13, in <module>
    timeInput = input()
  File "C:\Eclipse\plugins\org.python.pydev_1.6.3.2010100422\PySrc
\pydev_sitecustomize\sitecustomize.py", line 176, in input
    return eval(raw_input(prompt))
  File "<string>", line 1
    11:12:13
      ^
SyntaxError: invalid syntax




More information about the Python-list mailing list