Using classname as a variable nameBest way to do parent child relationship in Python 3 with circular dependenciesDo I have to claim variables as global to use them outside of a class?Is passing self to a method call in class consider as circular dependencyCalling a name variable in a message.pyHow to check if file object is random accessHow to implement a custom sorting algorithm to accept any type in python?AttributeError: module 'asyncio' has no attribute 'coroutine' (Python 3.6.4)Creating a variable from one class to anotherCreating new variable name from existing variable names in PythonDelete First Node From Python Linked List

Why doesn't increasing the temperature of something like wood or paper set them on fire?

What does “two-bit (jerk)” mean?

Can a player choose to add detail and flavor to their character's spells and abilities?

Explaining intravenous drug abuse to a small child

How is it believable that Euron could so easily pull off this ambush?

Appropriate age to involve kids in life changing decisions

What calendar would the Saturn nation use?

When does WordPress.org notify sites of new version?

An adjective or a noun to describe a very small apartment / house etc

How can I finally understand the confusing modal verb "мочь"?

Why is the episode called "The Last of the Starks"?

Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?

What is the Ancient One's mistake?

What is more safe for browsing the web: PC or smartphone?

Splitting polygons and dividing attribute value proportionally using ArcGIS Pro?

My parents are Afghan

Can anyone identify this unknown 1988 PC card from The Palantir Corporation?

Why is the blank symbol not considered part of the input alphabet of a Turing machine?

What happens when the drag force exceeds the weight of an object falling into earth?

How could a humanoid creature completely form within the span of 24 hours?

Why is there a cap on 401k contributions?

While drilling into kitchen wall, hit a wire - any advice?

TikZ/PGF draw algorithm

Did any early RISC OS precursor run on the BBC Micro?



Using classname as a variable name


Best way to do parent child relationship in Python 3 with circular dependenciesDo I have to claim variables as global to use them outside of a class?Is passing self to a method call in class consider as circular dependencyCalling a name variable in a message.pyHow to check if file object is random accessHow to implement a custom sorting algorithm to accept any type in python?AttributeError: module 'asyncio' has no attribute 'coroutine' (Python 3.6.4)Creating a variable from one class to anotherCreating new variable name from existing variable names in PythonDelete First Node From Python Linked List






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








0















I'm doing data structures and algorithms course. And in the implementation of the list they use the inbuilt class name list as their variable name. My question is how it affects the code.



Class Singlelinkedlist():
def __init__(self):
pass
def create_list():
pass
list = Singlelinkedlist()
list.create_list()









share|improve this question
























  • It would help avoid misunderstandings if you edited the question and posted some code.

    – Mark Meyer
    Mar 23 at 6:29












  • I tried to add but I need atleast 10 reputations to add images

    – Surya
    Mar 23 at 6:38






  • 1





    That's because you are not supposed to add images of code. You type code directly into the question. If you indent 4 spaces it will format it as code. Ideally you would make a small example that shows the problem you are having without a bunch of extra code not relevant to the problem.

    – Mark Meyer
    Mar 23 at 6:42







  • 1





    I edited it -- you need to add spaces in front of every line. If you look at the edit, you can see how it works.

    – Mark Meyer
    Mar 23 at 6:55






  • 1





    It’s not a good idea to shadow the built in names. The code will still work but might cause hard to debug issues down the track if you make a habit of it.

    – SuperShoot
    Mar 23 at 6:58

















0















I'm doing data structures and algorithms course. And in the implementation of the list they use the inbuilt class name list as their variable name. My question is how it affects the code.



Class Singlelinkedlist():
def __init__(self):
pass
def create_list():
pass
list = Singlelinkedlist()
list.create_list()









share|improve this question
























  • It would help avoid misunderstandings if you edited the question and posted some code.

    – Mark Meyer
    Mar 23 at 6:29












  • I tried to add but I need atleast 10 reputations to add images

    – Surya
    Mar 23 at 6:38






  • 1





    That's because you are not supposed to add images of code. You type code directly into the question. If you indent 4 spaces it will format it as code. Ideally you would make a small example that shows the problem you are having without a bunch of extra code not relevant to the problem.

    – Mark Meyer
    Mar 23 at 6:42







  • 1





    I edited it -- you need to add spaces in front of every line. If you look at the edit, you can see how it works.

    – Mark Meyer
    Mar 23 at 6:55






  • 1





    It’s not a good idea to shadow the built in names. The code will still work but might cause hard to debug issues down the track if you make a habit of it.

    – SuperShoot
    Mar 23 at 6:58













0












0








0








I'm doing data structures and algorithms course. And in the implementation of the list they use the inbuilt class name list as their variable name. My question is how it affects the code.



Class Singlelinkedlist():
def __init__(self):
pass
def create_list():
pass
list = Singlelinkedlist()
list.create_list()









share|improve this question
















I'm doing data structures and algorithms course. And in the implementation of the list they use the inbuilt class name list as their variable name. My question is how it affects the code.



Class Singlelinkedlist():
def __init__(self):
pass
def create_list():
pass
list = Singlelinkedlist()
list.create_list()






python-3.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 6:54









Mark Meyer

42.6k33765




42.6k33765










asked Mar 23 at 6:29









SuryaSurya

12




12












  • It would help avoid misunderstandings if you edited the question and posted some code.

    – Mark Meyer
    Mar 23 at 6:29












  • I tried to add but I need atleast 10 reputations to add images

    – Surya
    Mar 23 at 6:38






  • 1





    That's because you are not supposed to add images of code. You type code directly into the question. If you indent 4 spaces it will format it as code. Ideally you would make a small example that shows the problem you are having without a bunch of extra code not relevant to the problem.

    – Mark Meyer
    Mar 23 at 6:42







  • 1





    I edited it -- you need to add spaces in front of every line. If you look at the edit, you can see how it works.

    – Mark Meyer
    Mar 23 at 6:55






  • 1





    It’s not a good idea to shadow the built in names. The code will still work but might cause hard to debug issues down the track if you make a habit of it.

    – SuperShoot
    Mar 23 at 6:58

















  • It would help avoid misunderstandings if you edited the question and posted some code.

    – Mark Meyer
    Mar 23 at 6:29












  • I tried to add but I need atleast 10 reputations to add images

    – Surya
    Mar 23 at 6:38






  • 1





    That's because you are not supposed to add images of code. You type code directly into the question. If you indent 4 spaces it will format it as code. Ideally you would make a small example that shows the problem you are having without a bunch of extra code not relevant to the problem.

    – Mark Meyer
    Mar 23 at 6:42







  • 1





    I edited it -- you need to add spaces in front of every line. If you look at the edit, you can see how it works.

    – Mark Meyer
    Mar 23 at 6:55






  • 1





    It’s not a good idea to shadow the built in names. The code will still work but might cause hard to debug issues down the track if you make a habit of it.

    – SuperShoot
    Mar 23 at 6:58
















It would help avoid misunderstandings if you edited the question and posted some code.

– Mark Meyer
Mar 23 at 6:29






It would help avoid misunderstandings if you edited the question and posted some code.

– Mark Meyer
Mar 23 at 6:29














I tried to add but I need atleast 10 reputations to add images

– Surya
Mar 23 at 6:38





I tried to add but I need atleast 10 reputations to add images

– Surya
Mar 23 at 6:38




1




1





That's because you are not supposed to add images of code. You type code directly into the question. If you indent 4 spaces it will format it as code. Ideally you would make a small example that shows the problem you are having without a bunch of extra code not relevant to the problem.

– Mark Meyer
Mar 23 at 6:42






That's because you are not supposed to add images of code. You type code directly into the question. If you indent 4 spaces it will format it as code. Ideally you would make a small example that shows the problem you are having without a bunch of extra code not relevant to the problem.

– Mark Meyer
Mar 23 at 6:42





1




1





I edited it -- you need to add spaces in front of every line. If you look at the edit, you can see how it works.

– Mark Meyer
Mar 23 at 6:55





I edited it -- you need to add spaces in front of every line. If you look at the edit, you can see how it works.

– Mark Meyer
Mar 23 at 6:55




1




1





It’s not a good idea to shadow the built in names. The code will still work but might cause hard to debug issues down the track if you make a habit of it.

– SuperShoot
Mar 23 at 6:58





It’s not a good idea to shadow the built in names. The code will still work but might cause hard to debug issues down the track if you make a habit of it.

– SuperShoot
Mar 23 at 6:58












3 Answers
3






active

oldest

votes


















0














list is one of the most fundamental data types in Python. Function list is a list constructor. Many standard and third-party libraries depend on the existence and correctness of this function. You should never, literally under no circumstances, redefine it. If you want a "list-like" identifier, call it my_list or something else.






share|improve this answer






























    0














    maybe you can try something like this:



    Class list(list):
    def __init__(self):
    pass
    def create_list():
    pass
    my_list = list('999')
    my_list.create_list()


    with this you add your own things to a build in
    maybe is that what you mean?






    share|improve this answer






























      -1














      do you meen something like this:



      #making class
      class test():
      #initing class
      def __init__(self, var):
      #make self.var or if you want to: test(7).var
      self.var = var
      #getting self.var out of the program
      data = test(7).var
      #do your thing here





      share|improve this answer























      • Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

        – Surya
        Mar 23 at 7:18











      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%2f55311223%2fusing-classname-as-a-variable-name%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      list is one of the most fundamental data types in Python. Function list is a list constructor. Many standard and third-party libraries depend on the existence and correctness of this function. You should never, literally under no circumstances, redefine it. If you want a "list-like" identifier, call it my_list or something else.






      share|improve this answer



























        0














        list is one of the most fundamental data types in Python. Function list is a list constructor. Many standard and third-party libraries depend on the existence and correctness of this function. You should never, literally under no circumstances, redefine it. If you want a "list-like" identifier, call it my_list or something else.






        share|improve this answer

























          0












          0








          0







          list is one of the most fundamental data types in Python. Function list is a list constructor. Many standard and third-party libraries depend on the existence and correctness of this function. You should never, literally under no circumstances, redefine it. If you want a "list-like" identifier, call it my_list or something else.






          share|improve this answer













          list is one of the most fundamental data types in Python. Function list is a list constructor. Many standard and third-party libraries depend on the existence and correctness of this function. You should never, literally under no circumstances, redefine it. If you want a "list-like" identifier, call it my_list or something else.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 7:37









          DYZDYZ

          29k62352




          29k62352























              0














              maybe you can try something like this:



              Class list(list):
              def __init__(self):
              pass
              def create_list():
              pass
              my_list = list('999')
              my_list.create_list()


              with this you add your own things to a build in
              maybe is that what you mean?






              share|improve this answer



























                0














                maybe you can try something like this:



                Class list(list):
                def __init__(self):
                pass
                def create_list():
                pass
                my_list = list('999')
                my_list.create_list()


                with this you add your own things to a build in
                maybe is that what you mean?






                share|improve this answer

























                  0












                  0








                  0







                  maybe you can try something like this:



                  Class list(list):
                  def __init__(self):
                  pass
                  def create_list():
                  pass
                  my_list = list('999')
                  my_list.create_list()


                  with this you add your own things to a build in
                  maybe is that what you mean?






                  share|improve this answer













                  maybe you can try something like this:



                  Class list(list):
                  def __init__(self):
                  pass
                  def create_list():
                  pass
                  my_list = list('999')
                  my_list.create_list()


                  with this you add your own things to a build in
                  maybe is that what you mean?







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 23 at 7:42









                  Matthijs990Matthijs990

                  15812




                  15812





















                      -1














                      do you meen something like this:



                      #making class
                      class test():
                      #initing class
                      def __init__(self, var):
                      #make self.var or if you want to: test(7).var
                      self.var = var
                      #getting self.var out of the program
                      data = test(7).var
                      #do your thing here





                      share|improve this answer























                      • Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

                        – Surya
                        Mar 23 at 7:18















                      -1














                      do you meen something like this:



                      #making class
                      class test():
                      #initing class
                      def __init__(self, var):
                      #make self.var or if you want to: test(7).var
                      self.var = var
                      #getting self.var out of the program
                      data = test(7).var
                      #do your thing here





                      share|improve this answer























                      • Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

                        – Surya
                        Mar 23 at 7:18













                      -1












                      -1








                      -1







                      do you meen something like this:



                      #making class
                      class test():
                      #initing class
                      def __init__(self, var):
                      #make self.var or if you want to: test(7).var
                      self.var = var
                      #getting self.var out of the program
                      data = test(7).var
                      #do your thing here





                      share|improve this answer













                      do you meen something like this:



                      #making class
                      class test():
                      #initing class
                      def __init__(self, var):
                      #make self.var or if you want to: test(7).var
                      self.var = var
                      #getting self.var out of the program
                      data = test(7).var
                      #do your thing here






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 23 at 7:00









                      Matthijs990Matthijs990

                      15812




                      15812












                      • Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

                        – Surya
                        Mar 23 at 7:18

















                      • Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

                        – Surya
                        Mar 23 at 7:18
















                      Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

                      – Surya
                      Mar 23 at 7:18





                      Sorry bro I didnt mean this. Mark has edited it again. Look at those codes. I mentioned my question above the code. Thanks for the reply.

                      – Surya
                      Mar 23 at 7:18

















                      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%2f55311223%2fusing-classname-as-a-variable-name%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

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript