Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #4743
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Florian Lindner <mailinglists@xgm.de> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] Warum liefert // ein float? |
| Date | Thu, 6 Apr 2017 11:02:59 +0200 |
| Lines | 76 |
| Message-ID | <mailman.172.1491469415.2961.python-de@python.org> (permalink) |
| References | <ea8deb7d-44d8-4f77-3922-90e41b49a439@xgm.de> <a5f1d6f1-89bf-b1f6-b688-c932620ce23f@chrisarndt.de> <afbefdbe-7546-6912-7732-d68a9f78bf46@xgm.de> |
| Mime-Version | 1.0 |
| Content-Type | multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BpNHtDNHwJEHBfooop0I4ksRkQJjNk7bu" |
| X-Trace | news.uni-berlin.de 4RkaR11wpADvzw/wpmIdGQAxALukDZEV8PP+YDbppnQA== |
| Return-Path | <mailinglists@xgm.de> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 |
| In-Reply-To | <a5f1d6f1-89bf-b1f6-b688-c932620ce23f@chrisarndt.de> |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <afbefdbe-7546-6912-7732-d68a9f78bf46@xgm.de> |
| X-Mailman-Original-References | <ea8deb7d-44d8-4f77-3922-90e41b49a439@xgm.de> <a5f1d6f1-89bf-b1f6-b688-c932620ce23f@chrisarndt.de> |
| Xref | csiph.com de.comp.lang.python:4743 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Am 06.04.2017 um 10:12 schrieb Christopher Arndt: > Am 06.04.2017 um 09:52 schrieb Florian Lindner: >> Warum liefert // ein float zurück, obwohl das Ergebnis, immer eine eine Ganzzahl ist (in dem Sinne, dass es keine >> Nachkommestellen hat)? > > Der Grund ist die Python Type Coercion. Bei Operationen mit > unterschiedlichen Typen der Argumente, werden beide vor der Operation zu > einem gemeinsamen, kompatiblen Typ konvertiert, der dann auch den Typ > des Ergebnisses bestimmt. > > Daher auch: > > 10 // 3 == 3 aber: >>> type(6 / 3) <class 'float'> siehe https://www.python.org/dev/peps/pep-0238/ Finde es so auch logisch, also 6 / 3 -> float. Fände es aber umgedreht auch logischer, wenn 6.0 // 3.0 -> int, da (. // .) prinzipiell eine Ganzzahl zurückgibt. Grüße, Florian
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] Warum liefert // ein float? Florian Lindner <mailinglists@xgm.de> - 2017-04-06 11:02 +0200
csiph-web