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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:32:49+00:00 2026-06-14T03:32:49+00:00

If I understood correctly, it’s better not to use an expression for a local

  • 0

If I understood correctly, it’s better not to use an expression for a local variable that’s already a global function in Python. So I believe this

list = [1,2,3]

is disrecommended in favor of

mylist = [1,2,3]

because list is already a built-in object in Python and mylist is not. However, I’m not always sure whether I should or should not use some expression (e.g. dir, num or cnt). Is there any comprehensive overview of the strings I’d better avoid for naming local variables?

  • 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-06-14T03:32:50+00:00Added an answer on June 14, 2026 at 3:32 am

    The names to avoid are keywords (which will give you an error, so are easy to spot) and builtins, which will get silently masked. Here’s a snippet of code to test for bad names:

    from keyword import kwlist
    
    def bad_name(name):
        return name in dir(__builtins__) + kwlist
    

    … and here’s a list (for Python 3.3):

    Builtin functions, types etc.

    abs                 all                 any                 ascii
    bin                 bool                bytearray           bytes
    callable            chr                 classmethod         compile
    complex             copyright           credits             delattr
    dict                dir                 divmod              enumerate
    eval                exec                exit                filter
    float               format              frozenset           getattr
    globals             hasattr             hash                help
    hex                 id                  input               int
    isinstance          issubclass          iter                len
    license             list                locals              map
    max                 memoryview          min                 next
    object              oct                 open                ord
    pow                 print               property            quit
    range               repr                reversed            round
    set                 setattr             slice               sorted
    staticmethod        str                 sum                 super
    tuple               type                vars                zip
    

    Anything in CamelCase (like the builtin exceptions) or beginning with a double underscore is excluded from the list above, as you shouldn’t be using those anyway.

    Keywords

    False               None                True                and
    as                  assert              break               class
    continue            def                 del                 elif
    else                except              finally             for
    from                global              if                  import
    in                  is                  lambda              nonlocal
    not                 or                  pass                raise
    return              try                 while               with
    yield
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I understand it correctly this means extern void foo(); that the function foo
Did I understood correctly that you can't subscribe to an event other than using
I just need someone to tell me if I understood correctly when to use
I've read somewhere that offline_access is/will be deprecated. If I understood correctly this means
Have I understood correctly that all threads have copy of method's variables in their
I'm running mod_python under Apache. If I've understood correctly, each Apache process runs its
Do I understand correctly that CCLabelBMFont only loads the font texture once, no matter
Why does this not work? Do I not understand delegate covariance correctly? public delegate
I am not sure if I understand the usage of crossdomain.xml correctly. I am,
I'm new using Unity and, if I understood correctly, it works using C# language.

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.