This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ber
Recipients ber, docs@python
Date 2013-06-19.21:03:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371675805.26.0.18697522409.issue18267@psf.upfronthosting.co.za>
In-reply-to
Content
http://docs.python.org/3.4/library/xmlrpc.client.html as of 2013-06-19 20:35 UTC
has a divide example and the output can misslead the learning reader
towards the new behaviour of python3 with the '/' binary operator for division.

server code:
  def divide(x, y):
    return x/y
client code:
  multicall.divide(7,3)
[..]
  print("7+3=%d, 7-3=%d, 7*3=%d, 7/3=%d" % tuple(result))

The client call results into:
  python3 client.py 
7+3=10, 7-3=4, 7*3=21, 7/3=2

This is missleading because '7/3' is now resulting to a float in python3 (see PEP238).The example probably was copied over from the python2 documentation
where '7/3' result to int. The implicit conversion from float to int is done
in the string formatting.

Proposal replace the print line with
  print("7+3=%d, 7-3=%d, 7*3=%d, 7/3=%g" % tuple(result))
to get 
  7+3=10, 7-3=4, 7*3=21, 7/3=2.33333
or
  print(repr(tuple(result)))
to get
(10, 4, 21, 2.3333333333333335)
History
Date User Action Args
2013-06-19 21:03:25bersetrecipients: + ber, docs@python
2013-06-19 21:03:25bersetmessageid: <1371675805.26.0.18697522409.issue18267@psf.upfronthosting.co.za>
2013-06-19 21:03:25berlinkissue18267 messages
2013-06-19 21:03:25bercreate