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;
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
|
show 2 more comments
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
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
|
show 2 more comments
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
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
python-3.x
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
|
show 2 more comments
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
|
show 2 more comments
3 Answers
3
active
oldest
votes
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.
add a comment |
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?
add a comment |
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
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 23 at 7:37
DYZDYZ
29k62352
29k62352
add a comment |
add a comment |
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?
add a comment |
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?
add a comment |
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?
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?
answered Mar 23 at 7:42
Matthijs990Matthijs990
15812
15812
add a comment |
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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