object as a reserved keyword

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lawrence Oluyede

    object as a reserved keyword


    Does it worth to make "object" keyword a reserved one?
    I'd like to avoid oddities like this:

    Python 2.3c1 (#44, Jul 18 2003, 14:32:36) [MSC v.1200 32 bit (Intel)]
    on win32
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> class c(object): pass[/color][/color][/color]
    ....[color=blue][color=green][color=darkred]
    >>> object = 4
    >>> class c(object): pass[/color][/color][/color]
    ....
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    TypeError: int() takes at most 2 arguments (3 given)[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]

    Lawrence
  • Lawrence Oluyede

    #2
    Re: object as a reserved keyword

    On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <[email protected] m>
    wrote:
    [color=blue]
    >I'd like to avoid oddities like this:[/color]

    I just noticed that it's the same thing with other builtin types such
    as list, dict and so on... Hope anyone exlpain me the reason to that.
    Maybe is beyond my views...

    Lawrence

    Comment

    • Erik Max Francis

      #3
      Re: object as a reserved keyword

      Lawrence Oluyede wrote:
      [color=blue]
      > Does it worth to make "object" keyword a reserved one?
      > I'd like to avoid oddities like this:[/color]

      It's no different from overriding any of the builtins with a
      non-standard value:
      [color=blue][color=green][color=darkred]
      >>> int = float
      >>> float = str
      >>> str = lambda x: none
      >>> str = lambda x: None
      >>> file = 'elif'[/color][/color][/color]

      If someone wants to be abusive, he can. The idea behind Python is that
      everyone will behave like adults, so there's little need to worry about
      these kinds of things.

      --
      Erik Max Francis && [email protected] && http://www.alcyone.com/max/
      __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
      / \ Do we really want to go to Mars / Do we really want to try
      \__/ Cassandra Wilson

      Comment

      • Lawrence Oluyede

        #4
        Re: object as a reserved keyword

        On Sun, 20 Jul 2003 02:39:07 -0700, Erik Max Francis <[email protected] m>
        wrote:
        [color=blue]
        >If someone wants to be abusive, he can. The idea behind Python is that
        >everyone will behave like adults, so there's little need to worry about
        >these kinds of things.[/color]

        Yeah, thanks. Is this kind of idea that I'm not used to

        --
        Lawrence "Rhymes" Oluyede
        Blogger ist ein Veröffentlichungs-Tool von Google, mit dem du ganz einfach deine Gedanken der Welt mitteilen kannst. Mit Blogger kannst du problemlos Texte, Fotos und Videos in deinem persönlichen Blog oder deinem Team-Blog veröffentlichen.

        rhymes@NOSPAMmy self.com

        Comment

        • Ian Bicking

          #5
          Re: object as a reserved keyword

          On Sun, 2003-07-20 at 04:29, Lawrence Oluyede wrote:[color=blue]
          > Does it worth to make "object" keyword a reserved one?
          > I'd like to avoid oddities like this:
          >
          > Python 2.3c1 (#44, Jul 18 2003, 14:32:36) [MSC v.1200 32 bit (Intel)]
          > on win32
          > Type "help", "copyright" , "credits" or "license" for more information.[color=green][color=darkred]
          > >>> class c(object): pass[/color][/color]
          > ...[color=green][color=darkred]
          > >>> object = 4
          > >>> class c(object): pass[/color][/color]
          > ...
          > Traceback (most recent call last):
          > File "<stdin>", line 1, in ?
          > TypeError: int() takes at most 2 arguments (3 given)[color=green][color=darkred]
          > >>>[/color][/color][/color]

          That's not odd or even bad... so you get an exception. That can happen
          all the time when you do silly things. Now...

          class object: pass

          *That* would be bad, cause later on you'll do...


          class Whatever(object ):
          ...
          x = property(get_x, set_x)

          I can totally imagine going nuts trying to figure out what went wrong
          with that...

          Ian



          Comment

          • Aahz

            #6
            Re: object as a reserved keyword

            In article <vtnkhvoqcet2bg meidae1st46m7q9 [email protected]>,
            Lawrence Oluyede <[email protected] m> wrote:[color=blue]
            >
            >Does it worth to make "object" keyword a reserved one?[/color]

            Maybe. Python strives for a minimal syntax. Many identifiers that
            would be keywords in other languages are simply names in the builtin
            namespace.
            --
            Aahz (aahz@pythoncra ft.com) <*> http://www.pythoncraft.com/

            This is Python. We don't care much about theory, except where it intersects
            with useful practice. --Aahz

            Comment

            • Dan Bishop

              #7
              Re: object as a reserved keyword

              Lawrence Oluyede <[email protected] m> wrote in message news:<7dokhvgv1 2fdbha8sun6c6q6 58cth5uq2c@4ax. com>...[color=blue]
              > On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <[email protected] m>
              > wrote:
              >[color=green]
              > >I'd like to avoid oddities like this:[/color]
              >
              > I just noticed that it's the same thing with other builtin types such
              > as list, dict and so on... Hope anyone ex[pl]ain me the reason to that.
              > Maybe is beyond my views...[/color]

              I understand his problem.

              When I write in other languages and need a meaningless variable name,
              I tend to use an abbreviation for the variable's type.

              public void foo(String str) {/* ... */}
              public void foo(List list) {/* ... */}

              As you can see, this convention doesn't carry over very well to
              Python.

              Comment

              • Steven Taschuk

                #8
                Re: object as a reserved keyword

                Quoth Mel Wilson:
                [...][color=blue]
                > Plus it's not impossible that somebody could export a
                > name in the set of standard names from a module or a
                > class and accomplish something useful. I'm having trouble
                > finding a convincing example, [...][/color]

                re.compile()

                --
                Steven Taschuk w_w
                staschuk@telusp lanet.net ,-= U
                1 1

                Comment

                Working...