473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

[2.3] object does not appear to be a reserved word

Is it potentially dangerous to use the variable 'object' in code?

Thanks,
Daniel Klein
Jul 18 '05 #1
4 1269

"Daniel Klein" <da*****@aracnet.com> wrote in message
news:v8********************************@4ax.com...
Is it potentially dangerous to use the variable 'object' in code?
"object" is, I believe, a built-in type in the builtins namespace.
As such, you can shadow it so it's inacessable. However,
the only place were that could cause problems is if you
use it as an identifier at the module level. I think.

John Roth
Thanks,
Daniel Klein

Jul 18 '05 #2

"Daniel Klein" <da*****@aracnet.com> wrote in message
news:v8********************************@4ax.com...
Is it potentially dangerous to use the variable 'object' in code?


Yes, it is potentially dangerous to use any of the names in the
builtin module. It is disrecommended for posted/public code without
good reason (intentional override).

TJR
Jul 18 '05 #3
John Roth wrote:
"Daniel Klein" <da*****@aracnet.com> wrote in message
news:v8********************************@4ax.com.. .

Is it potentially dangerous to use the variable 'object' in code?


"object" is, I believe, a built-in type in the builtins namespace.
As such, you can shadow it so it's inacessable. However,
the only place were that could cause problems is if you
use it as an identifier at the module level. I think.

Another place: errors in (copied) code which get silently ignored
because of the presence of the "object" type.

For instance, if you cut-and-past a few lines of (older, particularly
pre-2.2) code which uses the variable "object" into a new situation
which uses "item" (or whatever), the older code will often seem to be
functioning properly because it uses the type "object" as an instance,
instead of raising a NameError. Tends to result in subtle bugs, but not
likely enough to warrant breaking all the old code that used "object" as
an identifier by making it a keyword.

To answer the original question, yes, it's somewhat dangerous to use
"object" as an identifier in code. It's approximately equally dangerous
to use "str", "list", or "tuple" as an identifier. It's just that the
temptation to use "object" is greater when you're doing a lot of
polymorphic programming, and you'll find older code (pre 2.2) using it
without any concern whatsoever (because there was no object type back
then to cause a problem).

Each new built-in causes the same problem, it's just that "object" is so
fundamental an idea (both as a built-in and an identifer) that it's
probably the most likely source of such low-level conflicts going
forward. (e.g. enumerate, or zip are used in code once in a while, but
compared to "object" are fairly uncommon choices for an identifier).

Enjoy,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/


Jul 18 '05 #4
Thanks John., that's what I suspected.

This particular module uses the variable 'object' as an argument to
several methods and functions. I'll probably change it anyway, but I
was just curious as to why it seemed to run ok.

Thanks again for the confirmation.

Dan

On Sat, 6 Sep 2003 15:47:07 -0400, "John Roth"
<ne********@jhrothjr.com> wrote:

"Daniel Klein" <da*****@aracnet.com> wrote in message
news:v8********************************@4ax.com.. .
Is it potentially dangerous to use the variable 'object' in code?


"object" is, I believe, a built-in type in the builtins namespace.
As such, you can shadow it so it's inacessable. However,
the only place were that could cause problems is if you
use it as an identifier at the module level. I think.

John Roth

Thanks,
Daniel Klein


Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joshua Beall | last post by:
Hi All, What does the "const" reserved word in PHP4 do? I know it is a reserved word in PHP4, but the only references I can find to it are for PHP5. Here's what I want to do: Rather than...
106
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the...
2
by: Matthew Cascio | last post by:
My understanding is that using reserved words as column names is allowable as long as they are quoted. I am trying to create a table dynamically with columns defined by the first row of a text...
7
by: Michael Hill | last post by:
If I have: <a href="javascript:myfunct('cool_links')" id="cool_links"> and I refer to it as: function myfunct(mylink) { document.getElementById }
14
by: Matt | last post by:
I want to know if "int" is a primitive type, or an object? For example, the following two approaches yield the same result. > int t1 = int.Parse(TextBox2.Text); //method 1 > int t2 =...
6
by: gizmo | last post by:
I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). My problem is that I need to kill each...
28
by: ensemble | last post by:
I'm trying to utilized a more object-oriented approach to managing window events in javascript. Thus, I am creating a "controller" object to handle events and interact with the server. However, I...
6
by: Christoph Boget | last post by:
If I had an array like so: var bob = ; I can find out the size of the array by doing bob.length; Is there a comparable way to get the size of an object? So if I did:
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.