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.

classification
Title: Stronger type enforcement (feature request)
Type: enhancement Stage: resolved
Components: Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: John Michael Lafayette, r.david.murray
Priority: normal Keywords:

Created on 2015-10-09 06:08 by John Michael Lafayette, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg252588 - (view) Author: John Michael Lafayette (John Michael Lafayette) Date: 2015-10-09 06:08
With a lot of languages, I can tell
that the type I am getting is an instance of the declared type I'm assigning it to.

Example:
Cat c = Factory.make("cat"
Animal d = Factory.make("dog")

Python:
val c = Factory.make("cat")

Problem with this is that it is not necessarily obvious to the reader what the type of c is. I suggest that you provide an option to strengthen python's type checking by allowing users to replace val with the expected type of the object and then allow the interpreter to check that the real type being assigned is an instance of the expected type. An option like -strong for strong typing.
msg252614 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-10-09 14:08
Check out the types module and PEP 484.
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69537
2015-10-09 14:08:51r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg252614

resolution: out of date
stage: resolved
2015-10-09 06:08:07John Michael Lafayettecreate