Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > object as a reserved keyword

Reply
Thread Tools

object as a reserved keyword

 
 
Lawrence Oluyede
Guest
Posts: n/a
 
      07-20-2003

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
 
Reply With Quote
 
 
 
 
Lawrence Oluyede
Guest
Posts: n/a
 
      07-20-2003
On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <(E-Mail Removed)>
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
 
Reply With Quote
 
 
 
 
Erik Max Francis
Guest
Posts: n/a
 
      07-20-2003
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.velocityreviews.com/forums/(E-Mail Removed) && 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
 
Reply With Quote
 
Ian Bicking
Guest
Posts: n/a
 
      07-20-2003
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



 
Reply With Quote
 
Lawrence Oluyede
Guest
Posts: n/a
 
      07-20-2003
On Sun, 20 Jul 2003 02:39:07 -0700, Erik Max Francis <(E-Mail Removed)>
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
(E-Mail Removed)
 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      07-20-2003
In article <(E-Mail Removed)>,
Lawrence Oluyede <(E-Mail Removed)> 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 ((E-Mail Removed)) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
 
Reply With Quote
 
Dan Bishop
Guest
Posts: n/a
 
      07-20-2003
Lawrence Oluyede <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
> On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <(E-Mail Removed)>
> 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.
 
Reply With Quote
 
Steven Taschuk
Guest
Posts: n/a
 
      07-20-2003
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
(E-Mail Removed) ,-= U
1 1

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"ack" is reserved keyword in VHDL? rl VHDL 2 07-18-2008 03:28 AM
Are Python's reserved words reserved in places they dont need to be? metaperl Python 32 09-15-2006 02:02 PM
RE: Are Python's reserved words reserved in places they dont needtobe? Delaney, Timothy (Tim) Python 10 09-14-2006 04:17 PM
Re: Are Python's reserved words reserved in places they dont needtobe? Steve Holden Python 0 09-13-2006 08:44 AM
[2.3] object does not appear to be a reserved word Daniel Klein Python 4 09-07-2003 01:49 AM



Advertisments