What is the Python ` symbol [duplicate] - python

This question already has answers here:
What do backticks mean to the Python interpreter? Example: `num`
(3 answers)
Meaning of the backtick character in Python
(2 answers)
Closed 1 year ago.
Lots of old python code I look in has this ` symbol around a lot of stuff, what does it do? Now it is not considered valid syntax, obviously.
And I don't think it is just another string identifier, its sometimes wrapped around functions in the code I'm looking at.
Any help will be appreciated.

Related

Explanation for string behavior ["somestring" "somestring"] being evaluated to ["somestringsomestring"] [duplicate]

This question already has answers here:
Python string literal concatenation
(1 answer)
String concatenation without '+' operator
(6 answers)
Closed 4 months ago.
I'm using python 3.10.4 right now.
I mistakenly wrote ["somestring" "somestring"] without a , separating the strings. Which evaluated to ["somestringsomestring"] without raising an error (which an error raised was my expectation).
And it seems like it was like that for previous versions.
How should I interpret the process of "string" "string" being evaluated to "stringstring"?

function code from the book "Natural Language Processing with Transformers" [duplicate]

This question already has answers here:
Why not python implicit line continuation on period?
(6 answers)
Closed 10 months ago.
I have never seen this repeated dot syntax, and I can't find any pointers to it anywhere.
Is it application of unsqueeze followed by expand followed by float() ?
input_mask_expanded = (attention_mask
.unsqueeze(-1)
.expand(token_embeddings.size())
.float())
It's equivalent to
input_mask_expanded = (attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float())
Just in a more readable form

Python Import Syntax Rules [duplicate]

This question already has answers here:
Python module with a dash, or hyphen (-) in its name
(2 answers)
What is the naming convention in Python for variable and function?
(15 answers)
Closed 11 months ago.
I've been doing some searching but I couldn't find any consensus on the syntax allowed for imports.
I threw an syntax error for this import and was wondering if there was documentation on allowable syntax.
import some-module
# Do stuff.
You can't use hyphen('-') symbol in any names in Python as this is regarded as substraction operator. Use underscore ('_') instead.

F string prefix in python giving a syntax error [duplicate]

This question already has answers here:
f-strings giving SyntaxError?
(7 answers)
Closed 5 years ago.
I have a variable called method, it's value is POST but when I try to run print(f"{method} method is used.") it keeps giving a syntax error at the last double quote and I can't find the reason on why it does this. I am using python 3.5.2.
F-strings were a new feature introduced in Python 3.6, so of course they're not going to work in 3.5.2.

what's the meaning of "[ ]" in python references? [duplicate]

This question already has answers here:
What do square brackets, "[]", mean in function/class documentation?
(4 answers)
Closed 7 years ago.
I'm using python for a long time. but it was always strange to me why In python references, commands are written like this:
del var1[,var2[,var3[....,varN]]]]
I know that if I want to use the above command I should write it in this way:
del var1, var1
I can't understand the meaning of [] is it related to the lists? any help will be appreciated.
Its just showing that these parameters are optional. This is normal style for references.
There is nothing to do with this in python. Just a tutorial explanation.
I bealive, this is taken origin from Usage message

Categories

Resources