[Python] Python exception or return code.

Giorgio Zoppi giorgio.zoppi a gmail.com
Sab 28 Feb 2015 15:06:04 CET


Vorrei aprire una discussione senza cadere nella trappola del
expert beginner.
In Python in quali casi e' preferibile usare eccezzioni o in quali casi e'
preferibile usare return codes. Secondo la teoria, spiegata in *Framework
Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET
Libraries*, :
"Exceptions integrate well with object-oriented languages. Object-oriented
languages tend to impose constraints on member signatures that are not
imposed by functions in non-OO languages. *For example, in the case of
constructors, operator overloads, and properties, the developer has no
choice in the return value.* For this reason, it is not possible to
standardize on return-value-based error reporting for object-oriented
frameworks. *An error reporting method, such as exceptions, which is out of
band of the method signature is the only option.*"

Ma ne la vita quotidiana si apprende dell'esperienza e non solo dalla
teoria. Durante la vostra esperienza vi e' capitato di decidere questo?
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20150228/9eace542/attachment.html>


Maggiori informazioni sulla lista Python