object as a reserved keyword

Discussion in 'Python' started by Lawrence Oluyede, Jul 20, 2003.

  1. 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.
    >>> class c(object): pass

    ....
    >>> object = 4
    >>> class c(object): pass

    ....
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    TypeError: int() takes at most 2 arguments (3 given)
    >>>


    Lawrence
     
    Lawrence Oluyede, Jul 20, 2003
    #1
    1. Advertising

  2. On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <>
    wrote:

    >I'd like to avoid oddities like this:


    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
     
    Lawrence Oluyede, Jul 20, 2003
    #2
    1. Advertising

  3. Lawrence Oluyede wrote:

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


    It's no different from overriding any of the builtins with a
    non-standard value:

    >>> int = float
    >>> float = str
    >>> str = lambda x: none
    >>> str = lambda x: None
    >>> file = 'elif'


    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 && && 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
     
    Erik Max Francis, Jul 20, 2003
    #3
  4. Lawrence Oluyede

    Ian Bicking Guest

    On Sun, 2003-07-20 at 04:29, Lawrence Oluyede wrote:
    > 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.
    > >>> class c(object): pass

    > ...
    > >>> object = 4
    > >>> class c(object): pass

    > ...
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > TypeError: int() takes at most 2 arguments (3 given)
    > >>>


    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
     
    Ian Bicking, Jul 20, 2003
    #4
  5. On Sun, 20 Jul 2003 02:39:07 -0700, Erik Max Francis <>
    wrote:

    >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.


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

    --
    Lawrence "Rhymes" Oluyede
    http://loluyede.blogspot.com
     
    Lawrence Oluyede, Jul 20, 2003
    #5
  6. Lawrence Oluyede

    Aahz Guest

    In article <>,
    Lawrence Oluyede <> wrote:
    >
    >Does it worth to make "object" keyword a reserved one?


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

    This is Python. We don't care much about theory, except where it intersects
    with useful practice. --Aahz
     
    Aahz, Jul 20, 2003
    #6
  7. Lawrence Oluyede

    Dan Bishop Guest

    Lawrence Oluyede <> wrote in message news:<>...
    > On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <>
    > wrote:
    >
    > >I'd like to avoid oddities like this:

    >
    > 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...


    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.
     
    Dan Bishop, Jul 20, 2003
    #7
  8. Quoth Mel Wilson:
    [...]
    > 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, [...]


    re.compile()

    --
    Steven Taschuk w_w
    ,-= U
    1 1
     
    Steven Taschuk, Jul 20, 2003
    #8
    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. metaperl
    Replies:
    32
    Views:
    920
    NickC
    Sep 15, 2006
  2. Delaney, Timothy (Tim)
    Replies:
    10
    Views:
    671
    Jason
    Sep 14, 2006
  3. Steve Holden
    Replies:
    0
    Views:
    396
    Steve Holden
    Sep 13, 2006
  4. rl
    Replies:
    2
    Views:
    687
  5. Replies:
    3
    Views:
    168
    osmium
    Nov 6, 2013
Loading...

Share This Page