Some Basic questions on the use of CTRL and ALT Keys
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Nov 27 19:35:16 EST 2009
On Fri, 27 Nov 2009 12:41:42 -0800, joy99 wrote:
> Dear Group,
>
> I have written a small and simple program like the following:
>
> def alphabet1(n):
> file_open=open("/python26/alphabetlist1.txt","r")
> file_read=file_open.read()
> file_word=file_read.split()
> print file_word
>
> Here, I am using a file “alphabetlist1.txt” which I am reading and then
> splitting them into words.
>
> In this file “alphabetlist1.txt” I have arranged few alphabets like the
> following:
>
> a A
> b B
> c C
> d D
> E e
> F f
>
> Where, a/b/c/d/e/f are in lower case and A/B/C/D/E/F are in upper case
> which I can say as
> SHIFT+a
> SHIFT+b
> SHIFT+c
> SHIFT+d
> SHIFT+e
> SHIFT+f
>
> Now, in the list or anywhere in the program if I want to write
> CTRL+a/b/c/d/e/f or ALT+a/b/c/d/e/f for which I may assign any value I
> may feel not only cut/copy/paste.
>
> How would I represent them?
This question is badly defined. What are your constraints? Is this meant
to be a human-readable program? If so, you need to stick to ASCII text
and probably want something like:
a A CTRL-A ALT-A
b B CTRL-B ALT-B
...
but I'm not sure what the point of that would be.
Normally, control-combinations generate control-characters. For example,
CTRL-M would normally generate a carriage-return character. Depending on
your needs, you can write this as any of the following:
a description: CTRL-M
an escape sequence: \r
caret notation: ^M
the standard abbreviation: CR
the Unicode display glyph: ␍
or an actual carriage-return character.
Note that in ASCII control characters only have a standard definition for
the following:
ctrl-@
ctrl-A through ctrl-Z
ctrl-[
ctrl-\
ctrl-]
ctrl-^
ctrl-_
ctrl-?
See here for more:
http://en.wikipedia.org/wiki/Control_characters
As for Alt-combinations, I don't think there is any standard for what
they are. I believe that they are operating system specific, and possibly
even program specific.
--
Steven
More information about the Python-list
mailing list