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 6084557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:32:08+00:00 2026-05-23T11:32:08+00:00

When programming in C# I usually write following arguments validation code: void Process(object item)

  • 0

When programming in C# I usually write following arguments validation code:

void Process(object item) {
    if (item == null) throw ArgumentNullException();
    // code
}

Is it ‘Pythonic’ to do similar validation in Python? I really don’t want anybody pass None to Process method. What type of Python Exception should I use? (There are no standard ArgError or something like this)

def Process(item):
  if item == None: raise ArgNoneError('item')
  # code

Thanks

  • 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-23T11:32:09+00:00Added an answer on May 23, 2026 at 11:32 am

    Usually, you’d just try to make do with the arguments you got — if someone passes None to your function it will fail anyway. There is no need to add complexity to your code without any benefit. Quite the contrary — often such tests prevent your code from working for cases it would work fine wwithout the tests.

    If you want to raise some error anyway, use TypeError — it is meant for this purpose.

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

Sidebar

Related Questions

Hey,...very simple question I usually write php but happen to be programming with ASP.NET
I enjoy programming, usually. Tedious stuff is easy to get done as quickly and
While going through many resources on multithreaded programming, reference to volatile specifier usually comes
As far as I understood it, BigInts are usually implemented in most programming languages
Warning: I have very little JavsScript experience. In my past programming experience, I usually
Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping,
Programming is learned by writing programs. But code reading is said to be another
I mostly write small scripts in python, about 50 - 250 lines of code.
There are a lot of Cassandra API:s available and usually the programming language preference
I am reading about Dynamic programming in Cormen etc book on algorithms. following is

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.