What is metasyntactic variable ? I m confushed. Use some example .thnkx | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is metasyntactic variable ? I m confushed. Use some example .thnkx

17th Apr 2017, 12:36 PM
Saikat Das
Saikat Das - avatar
7 Answers
+ 3
Example: If you have an object foo of type bar, then type(foo) will return <class 'bar'>. foo and bar, in this case metasyntactic variables, are just placeholders. If foo is [1,2] then bar is list. Plug that into the sentence above, and you know type([1,2]) is <class 'list'>.
17th Apr 2017, 12:53 PM
Tob
Tob - avatar
+ 2
Do you mean metasyntactic?
17th Apr 2017, 12:46 PM
Tob
Tob - avatar
+ 2
Variables. Take the sentence 2*x is the same as x+x. Here x is a variable, where you can plug in numbers. If x=5, the sentence reads 2*5 is the same as 5+5. foo and bar are also variables, but now you do not plug in numbers, but python objects. Note that they are not variables in the python language, but in the language we use to talk about the python language, a meta-language if you will. Hence the name metasyntactic variables.
17th Apr 2017, 1:14 PM
Tob
Tob - avatar
+ 2
I would not call a python variable a metasyntactic variable, because it is part of the language itself.
17th Apr 2017, 1:45 PM
Tob
Tob - avatar
0
yes.
17th Apr 2017, 12:49 PM
Saikat Das
Saikat Das - avatar
0
i cant get it. what is foo and bar .?
17th Apr 2017, 12:59 PM
Saikat Das
Saikat Das - avatar
0
then may i call all variables as a metasyntactic variables ?
17th Apr 2017, 1:24 PM
Saikat Das
Saikat Das - avatar