Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 709981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:33:50+00:00 2026-05-14T04:33:50+00:00

I’m not sure if I like Python’s dynamic-ness. It often results in me forgetting

  • 0

I’m not sure if I like Python’s dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app/process/etc.

Over time I got better predicting where these could pop up and adding explicit type checking, but because I’m only human I miss one occasionally and then some end-user finds it.

So I’m interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers?

Please share…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:33:50+00:00Added an answer on May 14, 2026 at 4:33 am

    forgetting to check a type

    This doesn’t make much sense. You so rarely need to “check” a type. You simply run unit tests and if you’ve provided the wrong type object, things fail. You never need to “check” much, in my experience.

    trying to call an attribute and
    getting the NoneType (or any other)
    has no attribute x error.

    Unexpected None is a plain-old bug. 80% of the time, I omitted the return. Unit tests always reveal these.

    Of those that remain, 80% of the time, they’re plain old bugs due to an “early exit” which returns None because someone wrote an incomplete return statement. These if foo: return structures are easy to detect with unit tests. In some cases, they should have been if foo: return somethingMeaningful, and in still other cases, they should have been if foo: raise Exception("Foo").

    The rest are dumb mistakes misreading the API’s. Generally, mutator functions don’t return anything. Sometimes I forget. Unit tests find these quickly, since basically, nothing works right.

    That covers the “unexpected None” cases pretty solidly. Easy to unit test for. Most of the mistakes involve fairly trivial-to-write tests for some pretty obvious species of mistakes: wrong return; failure to raise an exception.

    Other “has no attribute X” errors are really wild mistakes where a totally wrong type was used. That’s either really wrong assignment statements or really wrong function (or method) calls. They always fail elaborately during unit testing, requiring very little effort to fix.

    A lot of them are pretty harmless but if not handled correctly they can bring down your entire app/process/etc.

    Um… Harmless? If it’s a bug, I pray that it brings down my entire app as quickly as possible so I can find it. A bug that doesn’t crash my app is the most horrible situation imaginable. “Harmless” isn’t a word I’d use for a bug that fails to crash my app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a JSP page retrieving data and when single or double quotes are
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
I'm looking for suggestions for debugging... If you view this site in Firefox or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.