Python Forum
how to add class instance attributes from list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to add class instance attributes from list
#1
hi everyone,
My questions is follows
lets say i have
class BaseClass:
    def __init__(self, atr_1=None, atr_2=None, atr_3=None):
        pass
I want to create class instance by passing attributes in the list.

Here is the tricky part, my list of attributes let say has less items..
a_list = ["att_1_data", "att_2_data", "att_4_data"]
1. how i can pass this list of attributes without iterating over list items
2. how can i skip the att_3_data (leave default as None as you see att_3_data is missing from list) and continue to next attr_4_data
I guess somehow i need to use keyword argument..
hope I was able to describe the problem
THANKS
Reply


Messages In This Thread
how to add class instance attributes from list - by 999masks - Jul-22-2019, 05:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read module/class from list of strings? popular_dog 1 475 Oct-04-2023, 03:08 PM
Last Post: deanhystad
Question [solved] Classes, assign an attributes to a class not to instances.. SpongeB0B 4 934 May-20-2023, 04:08 PM
Last Post: SpongeB0B
  [Solved] Novice question to OOP: can a method of class A access attributes of class B BigMan 1 1,313 Mar-14-2022, 11:21 PM
Last Post: deanhystad
  Distinguishing different types of class attributes Drone4four 4 2,099 Feb-21-2022, 06:34 PM
Last Post: deanhystad
  Access instance of a class Pavel_47 5 2,091 Nov-19-2021, 10:05 AM
Last Post: Gribouillis
  Class-Aggregation and creating a list/dictionary IoannisDem 1 1,921 Oct-03-2021, 05:16 PM
Last Post: Yoriz
  Class Instance angus1964 4 2,448 Jun-22-2021, 08:50 AM
Last Post: angus1964
  Calls to Attributes of a Class SKarimi 3 3,388 Apr-22-2021, 04:18 PM
Last Post: SKarimi
  apendng to a list within a class gr3yali3n 4 2,345 Feb-16-2021, 06:30 AM
Last Post: buran
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 2,330 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020