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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:32:04+00:00 2026-05-27T09:32:04+00:00

Python is all about writing beautiful code. So, I was running pylint to check

  • 0

Python is all about writing beautiful code. So, I was running pylint to check the “beautifulness” of my code, when I bump into something:

Unused variable ‘myvar1’

From this part of my code:

for myvar1, myvar2 in mylist:
    # Do stuff just using myvar2

mylist is a list of tuples, so I’m unwrapping the tuples into two variables (myvar1 and myvar2). I’m defining those two variables just to unwrap the second one, because I don’t need the other.

So, here’s my question: Is there a way to tell the interpreter to unwrap the tuple, but not assing the first part (for example). In some other languages you can do something like:

for _, myvar in mylist:
    # Do stuff with myvar

or

for *, myvar in mylist:
    # Do stuff with myvar

That means: I don’t care about the first part of the tuple, I just need the second one.

NOTE: I know that this could be an option for what I’m asking:

for mytuple in mylist:
    # Do stuff with mytuple[1]

But that’s by far less readable.

  • 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-27T09:32:05+00:00Added an answer on May 27, 2026 at 9:32 am

    In addition to @RaymondHettinger’s answer: Pylint also does not complain about unused variables if their names start with a single underscore. This means that you can use:

    for _myvar1, myvar2 in mylist:
    

    getting the best of both worlds:

    • no Pylint warning,
    • and information about the record structure

    This works for function / method prototypes too and avoids warnings about unused parameters, which you can often get when deriving from a base class in an OO framework.

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

Sidebar

Related Questions

I write code with Python using Django framework. Now I have read about all
I make no claims to know anything at all about writing Python scripts or
When I first started reading about Python, all of the tutorials have you use
I use cvs to maintain all my python snippets, notes, c, c++ code. As
I'm writing a PyQt (Python bindings for the all-powerful Qt library) application and a
python newbie here. I'm writing the code to control an experiment that has multiple
Often when I'm using Python I'll find myself writing list comprehensions that look something
Recently, I write a python code to insert HTML text into table. After my
I have a Python Flask app I'm writing, and I'm about to start on
I am writing some Python code to implement some of the concepts I have

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.