[Idle-dev] KeyConfig, KeyBinding and other related issues.

Tal Einat taleinat at gmail.com
Sun Jun 15 14:39:31 CEST 2014


On Sun, Jun 15, 2014 at 2:53 PM, Saimadhav Heblikar
<saimadhavheblikar at gmail.com> wrote:
> Hi,
> I followed the above direction and made some progress.
> Lib/tkinter/__init__.py Line 998, gives some more info on the syntax
> for keysequence.
>
> https://gist.github.com/sahutd/289d2297eb83a020a6dd#file-test-keyseq-v2-diff.
> It only covers a few exceptions. I am posting this early, before I am
> far away in the wrong direction.
>
> Also, is the key_ok method intended as a replacement for the existing
> KeysOk method? Or are both going to exist?
>
>
> On 14 June 2014 15:46, Tal Einat <taleinat at gmail.com> wrote:
>>
>> To give a bit more direction on the implementation, the steps for the
>> parsing function should be roughly:
>>
>> 1) basic parsing: remove '<' and '>' and ends and split by '-'
>> 2) group parts into the three groups while checking that they are
>> valid (not empty, etc.)
>>
> Grouping required a single line of regex.
> pat = '^<(?P<modifiers>(({modifier})-){{0,3}})(({type})-)?({detail})>$'.format(modifier=modifier_regex,type=type_regex,
> detail=detail_regex)

I usually avoid building regexps from pieces, though, because I've had
bad experiences after doing that myself.

More importantly, how will you give informative error messages if the
regexp fails? For example, how will you tell the difference between a
missing '>', an invalid modifier, and a missing detail? That's the
downside with a regexp - it either matches or doesn't, and if not you
can't tell why.

I'll let Terry answer your other questions.

- Tal


More information about the IDLE-dev mailing list