Proper usage of UserList and objectsDetecting an undefined object propertyWhat is the most efficient way to deep clone an object in JavaScript?Checking if a key exists in a JavaScript object?Proper way to declare custom exceptions in modern Python?Determine the type of an object?Python class inherits objectConvert JS object to JSON stringFind object by id in an array of JavaScript objectsIterate through object propertiesCheck if a value is an object in JavaScript

Why does Taylor’s series “work”?

Find the area of the rectangle

Would it be fair to use 1d30 (instead of rolling 2d20 and taking the higher die) for advantage rolls?

Why are there five extra turns in tournament Magic?

Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?

Single word that parallels "Recent" when discussing the near future

A latin word for "area of interest"

When the match time is called, does the current turn end immediately?

Usage of the relative pronoun "dont"

refer string as a field API name

What color to choose as "danger" if the main color of my app is red

How come Arya Stark didn't burn in Game of Thrones Season 8 Episode 5

Why is Drogon so much better in battle than Rhaegal and Viserion?

Is there an academic word that means "to split hairs over"?

What is the conversion rate for Sorcery Points to Spell Points?

Would life always name the light from their sun "white"

bash: Counting characters within multiple files

Omit property variable when using object destructuring

What dog breeds survive the apocalypse for generations?

Why does string strummed with finger sound different from the one strummed with pick?

Why did the soldiers of the North disobey Jon?

Is it standard for US-based universities to consider the ethnicity of an applicant during PhD admissions?

Why didn't Daenerys' advisers suggest assassinating Cersei?

How can I fix the label locations on my tikzcd diagram?



Proper usage of UserList and objects


Detecting an undefined object propertyWhat is the most efficient way to deep clone an object in JavaScript?Checking if a key exists in a JavaScript object?Proper way to declare custom exceptions in modern Python?Determine the type of an object?Python class inherits objectConvert JS object to JSON stringFind object by id in an array of JavaScript objectsIterate through object propertiesCheck if a value is an object in JavaScript






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm having a bit of trouble understanding the implementation and usage of UserList's with objects.



To contextualize, I have a Class File, which has the File object, to be opened, read, etc etc, and a Client Object.



In File, I open, and read the Client's file, which has the Client's information line by line.
This way, I read each parameter of the Client, create a Client object, and append the object to a List.



This would be an OK solution, but we are being forced to use an implementation of UserList.



I understand that it's basicly a wrapper (?) for lists of objects.
Basicly, an object that mimics Lists in behaviour, and they are lists of objects.



So far so good.



But for the life of me, I just can't figure out how to properly implement it, and I don't really understand the scarce examples of it's implementation.



It doesn't make sense for me to initialize a UserList everytime I create a Client object, but it also doesn't make sense for me to make the File class, a subclass of UserList, since we have 2 more types of files (Experts and Schedule) that File takes care of.



Therefore, I can only assume that my struture of Classes/Objects isn't correct, so I'm open to suggestions.



main.py



inFileClients = File("2019y01m12clients09h00.txt") # use sys.argv[1:]
inFileClientsHeader, inFileClientsContent = inFileClients.readFileClient()


File.py



def readFileHeader(self, inFile):
#Cut this, only for context
return Header(date, time, scope)

def readFileContentCli(self, inFile):
clientList = []
#Cut this, only for context
clientList.append(Client(name, local, start_date, start_hour, max_price, min_rep, domain, job_dur))

clientList = UserList.__init__(self, clientList)
return clientList



Client.py then only creates an Object with the data received.
So in my mind, UserList already has to be created, and it's only a matter to append the object to that list.










share|improve this question




























    0















    I'm having a bit of trouble understanding the implementation and usage of UserList's with objects.



    To contextualize, I have a Class File, which has the File object, to be opened, read, etc etc, and a Client Object.



    In File, I open, and read the Client's file, which has the Client's information line by line.
    This way, I read each parameter of the Client, create a Client object, and append the object to a List.



    This would be an OK solution, but we are being forced to use an implementation of UserList.



    I understand that it's basicly a wrapper (?) for lists of objects.
    Basicly, an object that mimics Lists in behaviour, and they are lists of objects.



    So far so good.



    But for the life of me, I just can't figure out how to properly implement it, and I don't really understand the scarce examples of it's implementation.



    It doesn't make sense for me to initialize a UserList everytime I create a Client object, but it also doesn't make sense for me to make the File class, a subclass of UserList, since we have 2 more types of files (Experts and Schedule) that File takes care of.



    Therefore, I can only assume that my struture of Classes/Objects isn't correct, so I'm open to suggestions.



    main.py



    inFileClients = File("2019y01m12clients09h00.txt") # use sys.argv[1:]
    inFileClientsHeader, inFileClientsContent = inFileClients.readFileClient()


    File.py



    def readFileHeader(self, inFile):
    #Cut this, only for context
    return Header(date, time, scope)

    def readFileContentCli(self, inFile):
    clientList = []
    #Cut this, only for context
    clientList.append(Client(name, local, start_date, start_hour, max_price, min_rep, domain, job_dur))

    clientList = UserList.__init__(self, clientList)
    return clientList



    Client.py then only creates an Object with the data received.
    So in my mind, UserList already has to be created, and it's only a matter to append the object to that list.










    share|improve this question
























      0












      0








      0








      I'm having a bit of trouble understanding the implementation and usage of UserList's with objects.



      To contextualize, I have a Class File, which has the File object, to be opened, read, etc etc, and a Client Object.



      In File, I open, and read the Client's file, which has the Client's information line by line.
      This way, I read each parameter of the Client, create a Client object, and append the object to a List.



      This would be an OK solution, but we are being forced to use an implementation of UserList.



      I understand that it's basicly a wrapper (?) for lists of objects.
      Basicly, an object that mimics Lists in behaviour, and they are lists of objects.



      So far so good.



      But for the life of me, I just can't figure out how to properly implement it, and I don't really understand the scarce examples of it's implementation.



      It doesn't make sense for me to initialize a UserList everytime I create a Client object, but it also doesn't make sense for me to make the File class, a subclass of UserList, since we have 2 more types of files (Experts and Schedule) that File takes care of.



      Therefore, I can only assume that my struture of Classes/Objects isn't correct, so I'm open to suggestions.



      main.py



      inFileClients = File("2019y01m12clients09h00.txt") # use sys.argv[1:]
      inFileClientsHeader, inFileClientsContent = inFileClients.readFileClient()


      File.py



      def readFileHeader(self, inFile):
      #Cut this, only for context
      return Header(date, time, scope)

      def readFileContentCli(self, inFile):
      clientList = []
      #Cut this, only for context
      clientList.append(Client(name, local, start_date, start_hour, max_price, min_rep, domain, job_dur))

      clientList = UserList.__init__(self, clientList)
      return clientList



      Client.py then only creates an Object with the data received.
      So in my mind, UserList already has to be created, and it's only a matter to append the object to that list.










      share|improve this question














      I'm having a bit of trouble understanding the implementation and usage of UserList's with objects.



      To contextualize, I have a Class File, which has the File object, to be opened, read, etc etc, and a Client Object.



      In File, I open, and read the Client's file, which has the Client's information line by line.
      This way, I read each parameter of the Client, create a Client object, and append the object to a List.



      This would be an OK solution, but we are being forced to use an implementation of UserList.



      I understand that it's basicly a wrapper (?) for lists of objects.
      Basicly, an object that mimics Lists in behaviour, and they are lists of objects.



      So far so good.



      But for the life of me, I just can't figure out how to properly implement it, and I don't really understand the scarce examples of it's implementation.



      It doesn't make sense for me to initialize a UserList everytime I create a Client object, but it also doesn't make sense for me to make the File class, a subclass of UserList, since we have 2 more types of files (Experts and Schedule) that File takes care of.



      Therefore, I can only assume that my struture of Classes/Objects isn't correct, so I'm open to suggestions.



      main.py



      inFileClients = File("2019y01m12clients09h00.txt") # use sys.argv[1:]
      inFileClientsHeader, inFileClientsContent = inFileClients.readFileClient()


      File.py



      def readFileHeader(self, inFile):
      #Cut this, only for context
      return Header(date, time, scope)

      def readFileContentCli(self, inFile):
      clientList = []
      #Cut this, only for context
      clientList.append(Client(name, local, start_date, start_hour, max_price, min_rep, domain, job_dur))

      clientList = UserList.__init__(self, clientList)
      return clientList



      Client.py then only creates an Object with the data received.
      So in my mind, UserList already has to be created, and it's only a matter to append the object to that list.







      python list object methods






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 16:19









      Miguel AlmeidaMiguel Almeida

      41




      41






















          1 Answer
          1






          active

          oldest

          votes


















          0














          As you said UserList is a wrapper on the default python list. It was created to provide base class for list like custom classes. More in the docs.



          So UserList acts like a default List object. To create it don’t directly use init method but create it with constructor



          my_list = UserList()



          Then you can append and pop data as with usual list.



          my_list.append(x)
          my_list.remove(x)


          The real list under hood that keeps data is available by



          my_list.data


          In your example possibly you want to achieve something like container for Clients.



          from collections import UserList

          class ClientList(UserList):
          '''
          your implemented client list
          class that contains some
          methods on list
          '''
          pass





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315812%2fproper-usage-of-userlist-and-objects%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            As you said UserList is a wrapper on the default python list. It was created to provide base class for list like custom classes. More in the docs.



            So UserList acts like a default List object. To create it don’t directly use init method but create it with constructor



            my_list = UserList()



            Then you can append and pop data as with usual list.



            my_list.append(x)
            my_list.remove(x)


            The real list under hood that keeps data is available by



            my_list.data


            In your example possibly you want to achieve something like container for Clients.



            from collections import UserList

            class ClientList(UserList):
            '''
            your implemented client list
            class that contains some
            methods on list
            '''
            pass





            share|improve this answer





























              0














              As you said UserList is a wrapper on the default python list. It was created to provide base class for list like custom classes. More in the docs.



              So UserList acts like a default List object. To create it don’t directly use init method but create it with constructor



              my_list = UserList()



              Then you can append and pop data as with usual list.



              my_list.append(x)
              my_list.remove(x)


              The real list under hood that keeps data is available by



              my_list.data


              In your example possibly you want to achieve something like container for Clients.



              from collections import UserList

              class ClientList(UserList):
              '''
              your implemented client list
              class that contains some
              methods on list
              '''
              pass





              share|improve this answer



























                0












                0








                0







                As you said UserList is a wrapper on the default python list. It was created to provide base class for list like custom classes. More in the docs.



                So UserList acts like a default List object. To create it don’t directly use init method but create it with constructor



                my_list = UserList()



                Then you can append and pop data as with usual list.



                my_list.append(x)
                my_list.remove(x)


                The real list under hood that keeps data is available by



                my_list.data


                In your example possibly you want to achieve something like container for Clients.



                from collections import UserList

                class ClientList(UserList):
                '''
                your implemented client list
                class that contains some
                methods on list
                '''
                pass





                share|improve this answer















                As you said UserList is a wrapper on the default python list. It was created to provide base class for list like custom classes. More in the docs.



                So UserList acts like a default List object. To create it don’t directly use init method but create it with constructor



                my_list = UserList()



                Then you can append and pop data as with usual list.



                my_list.append(x)
                my_list.remove(x)


                The real list under hood that keeps data is available by



                my_list.data


                In your example possibly you want to achieve something like container for Clients.



                from collections import UserList

                class ClientList(UserList):
                '''
                your implemented client list
                class that contains some
                methods on list
                '''
                pass






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 23 at 17:12

























                answered Mar 23 at 16:53









                Konrad SitarzKonrad Sitarz

                622217




                622217





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315812%2fproper-usage-of-userlist-and-objects%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해