Skip to main content

Part of the book series: Textbooks on Political Analysis ((TPA))

  • 1426 Accesses

Abstract

As you start to write more complex programs and deal with larger data sets, you will encounter more edge cases. Examples of this include missing data, data that is not in the type that you expected, or difficulty converting between various formats required by external APIs. Many of these errors cannot be detected until runtime (in part due to Python’s dynamic typing but this is not entirely to blame).

Electronic Supplementary Material The online version of this chapter (https://doi.org/10.1007/978-3-030-36826-5_12) contains supplementary material, which is available to authorized users.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    One common approach to this would be to add a randomizer argument to your function. In your tests, you can pass a randomizer that is in fact deterministic, and thus know exactly what the behavior should be at runtime. This practice is known as “dependency injection” and is frequently a useful strategy for making code more testable.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Cutler, J., Dickenson, M. (2020). Practical Programming. In: Computational Frameworks for Political and Social Research with Python. Textbooks on Political Analysis. Springer, Cham. https://doi.org/10.1007/978-3-030-36826-5_12

Download citation

Publish with us

Policies and ethics