The Python Apprentice by Robert Smallshire and Austin Bingham
Author:Robert Smallshire and Austin Bingham [Robert Smallshire and Austin Bingham]
Language: eng
Format: epub, pdf
Publisher: leanpub.com
Published: 2016-01-21T00:00:00+00:00
Naturally, the consequence of the log() failure is the raising of another exception, also a ValueError.
Much better, and altogether more Pythonic, to forget about error return codes completely and revert to raising an exception from convert().
Re-raising exceptions
Instead of returning an unPythonic error code, we can emit our error message and re-raise the exception object weâre currently handling. This can be done by replacing the return -1 with a raise statement at the end of our exception handling block:
def convert(s): """Convert a string to an integer.""" try: return int(s) except (ValueError, TypeError) as e: print("Conversion error: {}".format(str(e)), file=sys.stderr) raise
Download
The Python Apprentice by Robert Smallshire and Austin Bingham.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Web Development with Julia and Genie by Ivo Balbaert & Adrian Salceanu(6074)
State Management with React Query by Daniel Afonso(3399)
Eleventy by Example by Robinson Bryan;(3319)
Architecting Vue.js 3 Enterprise-Ready Web Applications by Solomon Eseme(3032)
Building Python Web APIs with FastAPI by Abdulazeez Abdulazeez Adeshina(2930)
Digital Marketing with Drupal by José Fernandes(2821)
Becoming an Enterprise Django Developer by Michael Dinder(1238)
Building Python Web APIs with FastAPI: A fast-paced guide to building high-performance, robust web APIs with very little boilerplate code by Abdulazeez Abdulazeez Adeshina(1177)
Operator Training Simulator Handbook by Joseph Philip(1144)
Practical WebAssembly: Explore the fundamentals of WebAssembly programming using Rust by Sendil Kumar Nellaiyapen(1071)
Google Workspace User Guide: A Practical Guide to Using Google Workspace Apps Efficiently While Integrating Them With Your Data by Balaji Iyer(1060)
State Management with React Query by Afonso Daniel;(1040)
Hands-on Cloud Analytics with Microsoft Azure Stack: Transform Your Data to Derive Powerful Insights Using Microsoft Azure by Prashila Naik(1039)
Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python by Andros Fenollosa(992)
Modern Frontend Development with Node.js by Florian Rappl(923)
Building Data Science Applications with FastAPI by François Voron(916)
High Performance with Laravel Octane by R. Butti(910)
Kubernetes Design Patterns and Extensions by Onur Yilmaz(900)
JavaScript from Frontend to Backend by Unknown(813)
