RE: Are Python's reserved words reserved in places they dont needtobe?

Discussion in 'Python' started by Delaney, Timothy (Tim), Sep 13, 2006.

  1. Antoon Pardon wrote:

    > This is just an idea of mine, nothing I expect python to adapt.
    > But just suppose the language allowed for words in bold. A word
    > in bold would be considered a reserved word, a word in non bold
    > would be an identifier.


    Exactly how am I supposed to use my text editor to make words bold? Is
    every text editor supposed to understand a "python format" for code?

    Besides, I don't like bold for keywords (or anything in code) - I like
    my keywords blue (RGB 0, 0, 255). Of course, with a "python format", I
    could make *my* keywords blue. But I can pretty much guarantee that my
    preferred editor will not ever understand "python format".

    Tim Delaney
    Delaney, Timothy (Tim), Sep 13, 2006
    #1
    1. Advertising

  2. Re: Are Python's reserved words reserved in places they dont need tobe?

    On 2006-09-13, Delaney, Timothy (Tim) <> wrote:
    > Antoon Pardon wrote:
    >
    >> This is just an idea of mine, nothing I expect python to adapt.
    >> But just suppose the language allowed for words in bold. A word
    >> in bold would be considered a reserved word, a word in non bold
    >> would be an identifier.

    >
    > Exactly how am I supposed to use my text editor to make words bold? Is
    > every text editor supposed to understand a "python format" for code?


    The standard answer here to people complaining about their editor not
    working well with python is that they should use a better editor.

    > Besides, I don't like bold for keywords (or anything in code)


    So? I don't like to append an "_" to make a reserved keyword into
    an identifier. What individual people like or not is not a big
    concern.

    > - I like
    > my keywords blue (RGB 0, 0, 255). Of course, with a "python format", I
    > could make *my* keywords blue. But I can pretty much guarantee that my
    > preferred editor will not ever understand "python format".


    <Shrug>, Different options are possible, in a file the keywords
    could just be prefixed with a Ctrl-K, and depending on the editor or its
    setting, this could be shown bold or blue or whatever. I don't care
    about the specifics at this point. I just wanted to make clear there
    is the option to make/show the distiction between identifiers and keywords
    more explicitly.

    --
    Antoon Pardon
    Antoon Pardon, Sep 13, 2006
    #2
    1. Advertising

  3. Delaney, Timothy (Tim)

    Duncan Booth Guest

    RE: Are Python's reserved words reserved in places they dont need tobe?

    "Delaney, Timothy (Tim)" <> wrote:

    > Antoon Pardon wrote:
    >
    >> This is just an idea of mine, nothing I expect python to adapt.
    >> But just suppose the language allowed for words in bold. A word
    >> in bold would be considered a reserved word, a word in non bold
    >> would be an identifier.

    >
    > Exactly how am I supposed to use my text editor to make words bold? Is
    > every text editor supposed to understand a "python format" for code?


    I guess you would do it the same way other languages have implemented this
    in the past: use bold if your editor supports it and use something else if
    it doesn't.

    Algol 68 has the concept that keywords and identifiers with the same
    spelling are distinguished in some way (and if I remember correctly there
    were compiler options that let you specify what sort of stropping you were
    using). There was case stropping: case not otherwise being significant you
    could indicate a reserved word by uppercasing it e.g. BEGIN; or various
    punctuation conventions .begin. 'BEGIN' @begin or your editor might
    indicate reserved words using a different font e.g. bold.

    I see wikipedia's entry on stropping says that Atlas Autocode let you strop
    keywords by underlining them using backspace and overstrike. That must have
    been real fun to type.

    One of the big advantages of stropping is of course that you don't have to
    print or view source code using the same convention as you used when
    entering the text. So you might use case stropping to type your source code
    in, but then print listings with keywords bolded and lowercased.

    So for Python you would have a magic comment similar to how you specify
    encoding to specify the type of stropping in use and your editor would
    recognise the comment and display the file using whichever stropping
    convention you prefer for viewing.

    Personally I think a simpler idea to get round clashes of reserved words
    and identifiers would be to adopt something similar to c#'s @ escape. You
    could simply allow the lexer to accept @'something' as an alternative
    spelling for the identifier something, but with no restrictions on the
    characters that such an identifier could contain. so for manipulating html
    you would be able to write:

    element.@'class' = "whatever"

    instead of having to call setattr or use some other kludge.

    If Python did have a mechanism like this to escape identifiers then you
    could implement stropping completely outside the language: you could have
    an editor which displays keywords in one font and identifiers in another
    (as most editors already do), and then when saving simply escape any
    identifiers which are not otherwise valid. It wouldn't even be a big
    change: the editor could probably guess your intent correctly 99% of the
    time.
    Duncan Booth, Sep 13, 2006
    #3
  4. Re: Are Python's reserved words reserved in places they dont need tobe?

    >> Exactly how am I supposed to use my text editor to make words bold? Is
    >> every text editor supposed to understand a "python format" for code?

    >
    > The standard answer here to people complaining about their editor not
    > working well with python is that they should use a better editor.


    In general, that is true for the 21st century. But under certain
    circumstances, one might be forced to use a vi over a limited b/w terminal
    to fix that goddamn bug on the live system.

    Even though you don't care about the pesky details, it boils down to
    introducing an escape mechanism that will surround whatever identifiers
    there are. Which looks crap in anything except and python-aware editor.

    But I bet you don't work with e.g. subversion to display diffs and the
    like...

    Diez
    Diez B. Roggisch, Sep 13, 2006
    #4
  5. Re: Are Python's reserved words reserved in places they dont need tobe?

    On 2006-09-13, Diez B. Roggisch <> wrote:
    >>> Exactly how am I supposed to use my text editor to make words bold? Is
    >>> every text editor supposed to understand a "python format" for code?

    >>
    >> The standard answer here to people complaining about their editor not
    >> working well with python is that they should use a better editor.

    >
    > In general, that is true for the 21st century. But under certain
    > circumstances, one might be forced to use a vi over a limited b/w terminal
    > to fix that goddamn bug on the live system.


    AFAIR, even those terminals had a form of highlighting. And personnaly
    I would think PEP 0263 would be potentially more annoying than this
    idea in those circumstances.

    > Even though you don't care about the pesky details, it boils down to
    > introducing an escape mechanism that will surround whatever identifiers
    > there are. Which looks crap in anything except and python-aware editor.
    >
    > But I bet you don't work with e.g. subversion to display diffs and the
    > like...


    I wouldn't be surprised that looking at diffs from files that use
    PEP 0263 could look like crap too. Yes some decisions can cause
    some tools to be less usefull. I would say that the right cause
    of action is then to adapt those tools. Not to let something like
    that stop your decision.

    --
    Antoon Pardon
    Antoon Pardon, Sep 13, 2006
    #5
  6. Re: Are Python's reserved words reserved in places they dont need tobe?

    >> In general, that is true for the 21st century. But under certain
    >> circumstances, one might be forced to use a vi over a limited b/w
    >> terminal to fix that goddamn bug on the live system.

    >
    > AFAIR, even those terminals had a form of highlighting. And personnaly
    > I would think PEP 0263 would be potentially more annoying than this
    > idea in those circumstances.


    How so? Because some less important string literals might be fucked up?
    Certainly can that cause trouble, but having the trouble for each and every
    keyword is a huge difference.

    >> Even though you don't care about the pesky details, it boils down to
    >> introducing an escape mechanism that will surround whatever identifiers
    >> there are. Which looks crap in anything except and python-aware editor.
    >>
    >> But I bet you don't work with e.g. subversion to display diffs and the
    >> like...

    >
    > I wouldn't be surprised that looking at diffs from files that use
    > PEP 0263 could look like crap too. Yes some decisions can cause
    > some tools to be less usefull. I would say that the right cause
    > of action is then to adapt those tools. Not to let something like
    > that stop your decision.


    The same reasoning as above applies.

    And sure you would say that - the day you admit to have suggested a stupid
    thing won't be in my hopefully long-standing life span.

    Diez
    Diez B. Roggisch, Sep 13, 2006
    #6
  7. Re: Are Python's reserved words reserved in places they dont need tobe?

    On 2006-09-13, Diez B. Roggisch <> wrote:
    >>> In general, that is true for the 21st century. But under certain
    >>> circumstances, one might be forced to use a vi over a limited b/w
    >>> terminal to fix that goddamn bug on the live system.

    >>
    >> AFAIR, even those terminals had a form of highlighting. And personnaly
    >> I would think PEP 0263 would be potentially more annoying than this
    >> idea in those circumstances.

    >
    > How so? Because some less important string literals might be fucked up?
    > Certainly can that cause trouble, but having the trouble for each and every
    > keyword is a huge difference.


    Viewing such an unimportant string literal might lockup your terminal,
    because your terminal interprets it as somekind of control sequence.
    Your keyword trouble would probably be less than looking at html code
    in those circumstances.

    >>> Even though you don't care about the pesky details, it boils down to
    >>> introducing an escape mechanism that will surround whatever identifiers
    >>> there are. Which looks crap in anything except and python-aware editor.
    >>>
    >>> But I bet you don't work with e.g. subversion to display diffs and the
    >>> like...

    >>
    >> I wouldn't be surprised that looking at diffs from files that use
    >> PEP 0263 could look like crap too. Yes some decisions can cause
    >> some tools to be less usefull. I would say that the right cause
    >> of action is then to adapt those tools. Not to let something like
    >> that stop your decision.

    >
    > The same reasoning as above applies.
    >
    > And sure you would say that - the day you admit to have suggested a stupid
    > thing won't be in my hopefully long-standing life span.


    That you don't like it, is not the same as stupid. Your two arguments
    against, have nothing to do with the quality of the suggestion within
    the langauge but only with problems of the envinronment.

    You know, if I want, I can probably turn up some old terminal where
    you can only type uppercase letters. What if under certain circumstance
    I would be forced, to use this old thing. Would I then have a rightfull
    complaint against python because it is case significant?

    --
    Antoon Pardon
    Antoon Pardon, Sep 13, 2006
    #7
  8. Re: Are Python's reserved words reserved in places they dont need tobe?

    On Wed, 13 Sep 2006 07:45:02 +0000, Antoon Pardon wrote:

    >>> This is just an idea of mine, nothing I expect python to adapt.
    >>> But just suppose the language allowed for words in bold. A word
    >>> in bold would be considered a reserved word, a word in non bold
    >>> would be an identifier.


    [snip]

    > <Shrug>, Different options are possible, in a file the keywords
    > could just be prefixed with a Ctrl-K, and depending on the editor or its
    > setting, this could be shown bold or blue or whatever. I don't care
    > about the specifics at this point. I just wanted to make clear there
    > is the option to make/show the distiction between identifiers and keywords
    > more explicitly.


    But surely all you are doing is changing the reserved word from (say)
    "return" to "\x0breturn". Once you do that, you can bet that people will
    complain that they want to have identifiers in bold too, why can't they
    create a name "\x0breturn", and somebody will come up with an even more
    complicated scheme for accommodating them... wash, rinse, repeat.


    --
    Steven D'Aprano
    Steven D'Aprano, Sep 14, 2006
    #8
  9. Re: Are Python's reserved words reserved in places they dont need?tobe?

    "Delaney, Timothy (Tim)" wrote:
    > Antoon Pardon wrote:
    >
    >> This is just an idea of mine, nothing I expect python to adapt.
    >> But just suppose the language allowed for words in bold. A word
    >> in bold would be considered a reserved word, a word in non bold
    >> would be an identifier.

    >
    > Exactly how am I supposed to use my text editor to make words bold? Is
    > every text editor supposed to understand a "python format" for code?


    That's easy: <b>pass</b>, <b>return</b>, ...
    Hmm, that's too verbose, maybe it would be better to do it just by
    appending a underscore to the word: pass_, return_, ...

    wink_
    --
    Roberto Bonvallet
    Roberto Bonvallet, Sep 14, 2006
    #9
  10. Re: Are Python's reserved words reserved in places they dont need tobe?

    On 2006-09-14, Steven D'Aprano <> wrote:
    > On Wed, 13 Sep 2006 07:45:02 +0000, Antoon Pardon wrote:
    >
    >>>> This is just an idea of mine, nothing I expect python to adapt.
    >>>> But just suppose the language allowed for words in bold. A word
    >>>> in bold would be considered a reserved word, a word in non bold
    >>>> would be an identifier.

    >
    > [snip]
    >
    >> <Shrug>, Different options are possible, in a file the keywords
    >> could just be prefixed with a Ctrl-K, and depending on the editor or its
    >> setting, this could be shown bold or blue or whatever. I don't care
    >> about the specifics at this point. I just wanted to make clear there
    >> is the option to make/show the distiction between identifiers and keywords
    >> more explicitly.

    >
    > But surely all you are doing is changing the reserved word from (say)
    > "return" to "\x0breturn". Once you do that, you can bet that people will
    > complain that they want to have identifiers in bold too, why can't they
    > create a name "\x0breturn", and somebody will come up with an even more
    > complicated scheme for accommodating them... wash, rinse, repeat.


    Do you really think this is a serious possibility? As far as I can see,
    that \x0b that will be prepended to differentiate keywords from
    identifiers is a technique called stropping, that has been used with
    some algol languages. Have you any knowledge of people programming algol
    who asked for the use of stropped identifiers?

    I think I really would be amazed to find out there were such people,
    but then I have been amazed before. So I really would like to know.

    --
    Antoon Pardon
    Antoon Pardon, Sep 14, 2006
    #10
  11. Delaney, Timothy (Tim)

    Jason Guest

    Re: Are Python's reserved words reserved in places they dont need tobe?

    Antoon Pardon wrote:
    > On 2006-09-14, Steven D'Aprano <> wrote:
    > > On Wed, 13 Sep 2006 07:45:02 +0000, Antoon Pardon wrote:
    > >
    > >>>> This is just an idea of mine, nothing I expect python to adapt.
    > >>>> But just suppose the language allowed for words in bold. A word
    > >>>> in bold would be considered a reserved word, a word in non bold
    > >>>> would be an identifier.

    > >
    > > But surely all you are doing is changing the reserved word from (say)
    > > "return" to "\x0breturn". Once you do that, you can bet that people will
    > > complain that they want to have identifiers in bold too, why can't they
    > > create a name "\x0breturn", and somebody will come up with an even more
    > > complicated scheme for accommodating them... wash, rinse, repeat.

    >
    > Do you really think this is a serious possibility? As far as I can see,
    > that \x0b that will be prepended to differentiate keywords from
    > identifiers is a technique called stropping, that has been used with
    > some algol languages. Have you any knowledge of people programming algol
    > who asked for the use of stropped identifiers?
    >
    > I think I really would be amazed to find out there were such people,
    > but then I have been amazed before. So I really would like to know.


    Don't restrict yourself to something like that! Use HTML to indicate
    purpose of your python programs! So, your identifiers must be between
    <b> and </b> tags. You strings will have to sit inside of a CDATA
    section to work right, and you get all sorts of entity substitutions
    for free!

    "My program doesn't work anymore."
    "Are your function names between h3 tags?"

    (Secretly repulsed, yet fascinated....)
    --Jason
    Jason, Sep 14, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miel Bronneberg

    reserved words

    Miel Bronneberg, Nov 26, 2004, in forum: XML
    Replies:
    1
    Views:
    520
    Martin Honnen
    Nov 26, 2004
  2. metaperl
    Replies:
    32
    Views:
    879
    NickC
    Sep 15, 2006
  3. Steve Holden
    Replies:
    0
    Views:
    385
    Steve Holden
    Sep 13, 2006
  4. Tricky

    Newer reserved words

    Tricky, Dec 2, 2008, in forum: VHDL
    Replies:
    2
    Views:
    597
  5. Replies:
    3
    Views:
    145
    osmium
    Nov 6, 2013
Loading...

Share This Page