Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19249
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <massimo.dipierro@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'bug': 0.02; 'everybody,': 0.07; 'prints': 0.07; 'python': 0.08; '__future__': 0.09; 'from:name:massimo di pierro': 0.09; 'def': 0.13; '2.7': 0.13; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; "'int'": 0.16; 'from:addr:massimo.dipierro': 0.16; 'massimo': 0.16; '(most': 0.21; 'changed': 0.23; 'division': 0.23; 'operand': 0.23; 'traceback': 0.24; 'code': 0.25; 'skip:_ 20': 0.26; 'import': 0.27; 'somebody': 0.27; 'problem': 0.29; 'print': 0.29; 'class': 0.29; '3.x': 0.30; 'apologies.': 0.30; 'typeerror:': 0.30; 'x-mailer:apple mail (2.1084)': 0.30; 'message-id:@gmail.com': 0.33; 'to:addr:python-list': 0.33; 'last):': 0.34; 'file': 0.35; 'problem.': 0.36; 'charset:us-ascii': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'could': 0.37; 'some': 0.38; 'received:209.85': 0.38; 'received:192': 0.38; 'help': 0.39; 'received:192.168.1': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'hope': 0.61; 'header:Message-Id:1': 0.62; 'direct': 0.66; 'reproduced': 0.84; 'ask,': 0.91; 'type(s)': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; bh=+g+UUy+c32wRwe7dpnXsxeg8wR5Jm8lYf+h0SkQgaS4=; b=eZq762uBoLY03op1Ze8S8+LizBeVZZylpZjXm0faZitakCtrrd8genSTFfM8bsv2TO fEiPdnXWHLYhGrbgRsas+y89g4A1dii7MhZKDF1rsRUJz8VB/7J1X20hbE/dRFxJht24 R2xKycEfRXW3ivEec62l683BfS2+TLXkEt4FM= |
| From | Massimo Di Pierro <massimo.dipierro@gmail.com> |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | quoted-printable |
| Subject | __future__ and __rdiv__ |
| Date | Sun, 22 Jan 2012 23:22:49 -0600 |
| To | python-list@python.org |
| Mime-Version | 1.0 (Apple Message framework v1084) |
| X-Mailer | Apple Mail (2.1084) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4950.1327296175.27778.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1327296175 news.xs4all.nl 6846 [2001:888:2000:d::a6]:57332 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19249 |
Show key headers only | View raw
Hello everybody,
I hope somebody could help me with this problem. If this is not the right place to ask, please direct me to the right place and apologies.
I am using Python 2.7 and I am writing some code I want to work on 3.x as well. The problem can be reproduced with this code:
# from __future__ import division
class Number(object):
def __init__(self,number):
self.number=number
def __rdiv__(self,other):
return other/self.number
print 10/Number(5)
It prints 2 as I expect. But if I uncomment the first line, I get:
Traceback (most recent call last):
File "test.py", line 8, in <module>
print 10/Number(5)
TypeError: unsupported operand type(s) for /: 'int' and 'Number'
Is this a bug or the __future__ division in 3.x changed the way operators are overloaded? Where can I read more?
Massimo
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
__future__ and __rdiv__ Massimo Di Pierro <massimo.dipierro@gmail.com> - 2012-01-22 23:22 -0600
csiph-web