473,320 Members | 1,974 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.

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.
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
Jul 18 '05 #1
7 2117
On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <ra***@dot.com>
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
Jul 18 '05 #2
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 && ma*@alcyone.com && 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
Jul 18 '05 #3
On Sun, 20 Jul 2003 02:39:07 -0700, Erik Max Francis <ma*@alcyone.com>
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
rh****@NOSPAMmyself.com
Jul 18 '05 #4
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

Jul 18 '05 #5
In article <vt********************************@4ax.com>,
Lawrence Oluyede <ra***@dot.com> 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 (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
Jul 18 '05 #6
Lawrence Oluyede <ra***@dot.com> wrote in message news:<7d********************************@4ax.com>. ..
On Sun, 20 Jul 2003 11:29:03 +0200, Lawrence Oluyede <ra***@dot.com>
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.
Jul 18 '05 #7
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
st******@telusplanet.net ,-= U
1 1

Jul 18 '05 #8

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

Similar topics

4
by: Daniel Klein | last post by:
Is it potentially dangerous to use the variable 'object' in code? Thanks, Daniel Klein
12
by: Michael Foord | last post by:
Here's a little oddity with 'print' being a reserved word... >>> class thing: pass >>> something = thing() >>> something.print = 3 SyntaxError: invalid syntax >>> print something.__dict__...
16
by: Fuzzyman | last post by:
Hello, To create a classic (old style) class, I write : class foo: pass To do the equivalent as a new style class, I write : class foo(object):
2
by: Shayne H | last post by:
Is it possible to apply some attribute to allow the use of a reserved keyword as a name for a class member? eg Class Foo Sub Stop() ... End Sub End Class
6
by: n8agrin | last post by:
I've been doing some level of PHP programming for many years now, and have in the past few months started implementing lots of the core PHP5 features into a new project, when I noticed some...
31
by: metaperl | last post by:
-- python -i File "<stdin>", line 1 class = "algebra" ^ SyntaxError: invalid syntax Why isn' t the parser smart enough to see that class followed by an identifier is used for class...
2
by: Miro | last post by:
I created a field in a db called "Password" If i do that, the Update row command throws an exception error. If I call the field PWord then it works great. Is this a reserved word for an...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
6
by: BBands | last post by:
I gather that 'with' is on its way to becoming a reserved word. Is this something that will break? import Gnuplot gp = Gnuplot.Gnuplot(debug=1) data = Gnuplot.Data(, with='linespoints')...
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
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.