jazzIIIlove
asked on
pyhton list x = [ ] vs mylist x = [ ]
Hi there;
I am creating lists in python and I am using komodo.
Can someone tell me whether the following are equivalent?
list x = [ ] vs. mylist x = [ ]
The reason is that when I input list, komodo highlights it in orange and when I input mylist, it's simple black.
Any fundamental difference in these?
Regards.
I am creating lists in python and I am using komodo.
Can someone tell me whether the following are equivalent?
list x = [ ] vs. mylist x = [ ]
The reason is that when I input list, komodo highlights it in orange and when I input mylist, it's simple black.
Any fundamental difference in these?
Regards.
ASKER
Ok, sorry for my typo.
So list and mylist are same in this context. Right?
MvH.
So list and mylist are same in this context. Right?
MvH.
Yes. They are both wrong in the context. Syntax highlighting in editors just highlights certain character sequences. It knows the list, and it does not know the mylist. This is the only reason for the different colours.
ASKER
Ok, don't get mad.
list = [ ] and mylist = [ ] are same. Right?
Regards.
list = [ ] and mylist = [ ] are same. Right?
Regards.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hey, this was my 1000. question in EE. :)
Good questions are often better than good answers. The questions make us thinking. When the question is not known, the anwer cannot be found. Also, we often ignore the answers if we do not understand the questions. :)
Open in new window
You can alternatively useOpen in new window
but it is not prefered when creating the empty list.The reason why the list is highlighted is that it is a built-in type in Python (one of the most frequently used containers, used as a list, as a stack, as a queue, as an array). You can try in the interactive mode (wrapped lines by the console):
Open in new window
The mylist is just some identifier. But in Python, you do not tell the data type when creating a variable. Variables are not bound to any type. They are just names given to references. The reference values are not bound to the target type either. They are untyped.