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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:39:43+00:00 2026-06-13T05:39:43+00:00

I have a class with multiple vectors from measurements. I need to iterate over

  • 0

I have a class with multiple vectors from measurements. I need to iterate over these vectors but would like to use only chosen measurements. The simplified version of what I build so far is below:

import pylab as pl
class IterationReturn(object):
    def __init__(self):
        self.a = (1,2,3,4,5,6,7,8,9)
        self.b = (10,20,30,40,50,60,70,80,90)
        self.c = (-1,-2,-3,-4,-5,-6,-7,-8,-9)
        self.i = 0

    def returnNextSet(self):
        self.aIter = self.a[self.i]
        self.bIter = self.b[self.i]
        self.cIter = self.c[self.i]
        self.i +=1
        return (self.aIter, self.bIter, self.cIter)               

if __name__ == '__main__':
    iteration = IterationReturn()
    for i in range(len(iteration.a)): 
        # x takes aIter value from iteration.returnNextSet()
        # y takes bIter value from iteration.returnNextSet()        
        x,y = iteration.returnNextSet()    
        pl.scatter(x, y)
    pl.show()

I don’t want to use x,y,z = iteration.returnNextSet() which would work in this example, but in practice I have many more values and do not want to assign them all. I can’t find a way to assign only to aIter and bIter.

I have an error:

    x,y = iteration.returnNextSet()      
ValueError: too many values to unpack

In my problem I have many measurements (a,b, … ,z) and for example I want to assign x=d and y=k
I also think it should be done in different way from the beginning like designing new class with inheritance but not sure how to do that. Would appreciate your help

  • 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-13T05:39:44+00:00Added an answer on June 13, 2026 at 5:39 am

    Not quite sure why you’d want to do this, but here’s one way:

    class Test(object):
        def __init__(self):
            self.a = (1,2,3,4,5,6,7,8,9)
            self.b = (10,20,30,40,50,60,70,80,90)
            self.c = (-1,-2,-3,-4,-5,-6,-7,-8,-9)
    
        def iter_over(self, *args):
            items = [getattr(self, arg) for arg in args]
            return zip(*items)
    
    t = Test()
    for a, c in t.iter_over('a', 'c'):
        print a, c
    
    1 -1
    2 -2
    3 -3
    4 -4
    5 -5
    6 -6
    7 -7
    8 -8
    9 -9
    

    Or:

    for items in t.iter_over('c', 'b', 'a'):
        print items[1] # will be b (or 2nd passed above) etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that refers to UiApplication.getUiApplication() multiple times, would there be any
If we have a class that inherits from multiple interfaces, and the interfaces have
we have a C++ class which basically reads and writes vectors from a binary
How can I have multiple class constraints, so if A is an Eq and
Hi I have a class with multiple methods in which I require synchronized blocks
I have FrameChangeAnimation class which takes multiple spritesheets and duration. So lets say I
In Django, when you have a parent class and multiple child classes that inherit
I have a class that I want to contain multiple objects of something I
I have segmentation fault problem with my multiple class files project. Without making empty
I have a class with a complex construction process with many parameters. Multiple clients

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.