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

  • SEARCH
  • Home
  • 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 537311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:54:49+00:00 2026-05-13T09:54:49+00:00

A friend was burned when starting to learn Python, and now sees the language

  • 0

A friend was “burned” when starting to learn Python, and now sees the language as perhaps fatally flawed.

He was using a library and changed the value of an object’s attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him “forever” to figure out what was wrong. His objection to Python is thus that it allows one to accidentally add attributes to an object.

Unit tests don’t provide a solution to this. One doesn’t write unit tests against an API being used. One may have a mock for the class, but the mock could have the same typo or incorrect assumption about the attribute name.

It’s possible to use __setattr__() to guard against this, but (as far as I know), no one does.

The only thing I’ve been able to tell my friend is that after several years of writing Python code full-time, I don’t recall ever being burned by this. What else can I tell him?

  • 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-13T09:54:49+00:00Added an answer on May 13, 2026 at 9:54 am

    “changed the value of an object’s attribute” Can lead to problems. This is pretty well known. You know it, now, also. That doesn’t indict the language. It simply says that you’ve learned an important lesson in dynamic language programming.

    1. Unit testing absolutely discovers this. You are not forced to mock all library classes. Some folks say it’s only a unit test when it’s tested in complete isolation. This is silly. You have to trust the library modules — it’s a feature of your architecture. Rather than mock them, just use them. (It is important to write mocks for your own newly-developed libraries. It’s also important to mock libraries that make expensive API calls.)

      In most cases, you can (and should) test your classes with the real library modules. This will find the misspelled attribute name.

    2. Also, now that you know that attributes are dynamic, it’s really easy to verify that the attribute exists. How?

      Use interactive Python to explore the classes before writing too much code.

      Remember, Python is not Java and it’s not C. You can execute Python interactively and determine immediately if you’ve spelled something wrong. Writing a lot of code without doing any interactive confirmation is — simply — the wrong way to use Python.

      A little interactive exploration will find misspelled attribute names.

    3. Finally — for your own classes — you can wrap updatable attributes as properties. This makes it easier to debug any misspelled attribute names. Again, you know to check for this. You can use interactive development to confirm the attribute names.

    Fussing around with __setattr__ creates problems. In some cases, we actually need to add attributes to an object. Why? It’s simpler than creating a whole subclass for one special case where we have to maintain more state information.


    Other things you can say:

    I was burned by a C program that absolutely could not be made to work because of ______. [Insert any known C-language problem you want here. No array bounds checking, for example] Does that make C fatally flawed?

    I was burned by a DBA who changed a column name and all the SQL broke. It’s painful to unit test all of it. Does that make the relational database fatally flawed?

    I was burned by a sys admin who changed a directory’s permissions and my application broke. It was nearly impossible to find. Does that make the OS fatally flawed?

    I was burned by a COBOL program where someone changed the copybook, forgot to recompile the program, and we couldn’t debug it because the source looked perfect. COBOL, however, actually is fatally flawed, so this isn’t a good example.

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

Sidebar

Ask A Question

Stats

  • Questions 289k
  • Answers 289k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SHSetInputContext is the api that lets you control the autocomplete… May 13, 2026 at 5:36 pm
  • Editorial Team
    Editorial Team added an answer recv will return when there is data in the internal… May 13, 2026 at 5:36 pm
  • Editorial Team
    Editorial Team added an answer There are lots of serialVersionUID! Others in ResultSetMetaData like columnNoNulls,… May 13, 2026 at 5:36 pm

Related Questions

Long version... A co-worker asserted today after seeing my use of while (1) in
A friend was in need of an algorithm that would let him loop through
A friend was having trouble figuring out how to assign Ctrl + + as
A friend was showing me an API made with a COM Object and a
So a friend was telling me how a game was hacked and how the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.