By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

operator overloading on built-ins

P: n/a
could you explaint me the difference between the two following
Python 2.5 (r25:51908, Oct 7 2006, 23:45:05)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
File "<stdin>", line 1
SyntaxError: invalid syntax

The first works as expect, but the second.

Regards Rainer

Nov 9 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a
r.***** wrote:
Integer object "(1)" followed by method call ".__cmp__(10)"
File "<stdin>", line 1
SyntaxError: invalid syntax
Floating point number "1." followed by "__cmp__(10)".

Nov 9 '07 #2

P: n/a
On Thu, 08 Nov 2007 22:53:16 -0800, r.grimm wrote:
As the dot is an operator like ``+`` or ``/`` you can also add spaces to
avoid the ambiguity:

In [493]: 1 . __cmp__(10)
Out[493]: -1

In [494]: 1 .__cmp__(10)
Out[494]: -1

Marc 'BlackJack' Rintsch
Nov 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.