Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
copy list into variable
#1
Hi,

I want to fill the variable "__adress" with content:

class MyClass

    def __init__(self,**args):
        for key in argus:
            if key == "adress": 
                __adress = argus[key].copy()
I call it over:
tmpVar = MyClass(adress=["foo","bar"])
Reply
#2
Why not use the simpler
class MyClass:
    def __init__(self, address):
        self.__address = list(address)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy List Not Copying BAbdulBaki 3 574 Aug-19-2023, 02:03 AM
Last Post: perfringo
  Split string using variable found in a list japo85 2 1,235 Jul-11-2022, 08:52 AM
Last Post: japo85
  About list copy. water 3 1,502 Apr-03-2022, 02:42 AM
Last Post: deanhystad
Question Making a copy list in a function RuyCab 1 1,766 Jul-11-2021, 02:06 PM
Last Post: Yoriz
  An IF statement with a List variable dedesssse 3 7,943 Jul-08-2021, 05:58 PM
Last Post: perfringo
  Create variable and list dynamically quest_ 12 4,285 Jan-26-2021, 07:14 PM
Last Post: quest_
Question Matching variable to a list index Gilush 17 5,696 Nov-30-2020, 01:06 AM
Last Post: Larz60+
  Print variable values from a list of variables xnightwingx 3 2,569 Sep-01-2020, 02:56 PM
Last Post: deanhystad
  Multiplication between a list and a variable doug2019 2 2,120 Oct-08-2019, 04:10 AM
Last Post: doug2019
  Sub: Python-3: Better Avoid Naming A Variable As list ? adt 9 3,936 Aug-29-2019, 08:15 AM
Last Post: adt

Forum Jump:

User Panel Messages

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