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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:01:07+00:00 2026-05-23T12:01:07+00:00

What I mean is, if for example I get an error like Traceback (most

  • 0

What I mean is, if for example I get an error like

Traceback (most recent call last):
  File "score_keeper-test.py", line 106, in <module>
    app = program()
  File "score_keeper-test.py", line 37, in __init__
    self.label1.set_text(team1_name)
TypeError: Gtk.Label.set_text() argument 1 must be string, not None

Is there any way to make python print something like “You MUST enter a name in the TWO boxes” instead of the error above?

  • 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-23T12:01:08+00:00Added an answer on May 23, 2026 at 12:01 pm

    The Pythonic idiom is EAFP: easier to ask for forgiveness than permission. In this case:

    try:
        self.label1.set_text(team1_name)
    except TypeError:
        print "You MUST enter a name in the TWO boxes"
    

    Note how I explicitly catch TypeError. This is recommended by PEP 8 — Style Guide for Python Code (essential reading for any Python programmer):

    When catching exceptions, mention specific exceptions whenever possible instead of using a bare except: clause.

    An alternative (not-recommended) approach would be:

    if team1_name:
        self.label1.set_text(team1_name)
    else:
        print "You MUST enter a name in the TWO boxes"
    

    …which is an example of LBYL: Look before you leap. This style can leave your code littered in if-statements.

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

Sidebar

Related Questions

What does it mean to call a class like this: class Example { public:
For an example of what I mean, search on Google for Last.fm. The first
Here's an example of what I mean: I have an array: array('type'=>'text', 'class'=>'input', 'name'=>'username',
concrete example http://img246.imageshack.us/img246/602/6x7gridsm.png By address I mean the location if you were counting left
what does the colon mean in php in the following example. ::1 if($host ==
For example in $(CC) $(CFLAGS) -c -o $@ $< what do they mean?
I mean, is there a coded language with human style coding? For example: Create
I'm looking for an example algorithm of smart pagination. By smart, what I mean
OK, probably best to give an example here of what I mean. Imagine a
I like the user to pick an audio file from the available list of

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.