I have a question about the interpretation of the python code below.
What is the interpretation when only variables are described in the condition of the if statement?
Set the OS environment variable TEST_Prefix to the #incoming_test variable incoming_test_ = os.environ ['TEST_Prefix'] if incoming_test: object_path = (incoming_test + "/" + message_id) else: else: object_path = message_id
I interpreted it as follows,
If incoming_test is "" Set the object_path variable to (incoming_test + "/" + message_id) Otherwise Set message_id in object_path variable
I don't understand the "" part.
I'm sorry for the introductory question, but please teach me.
Answer # 1
8. compound statement — Python 3.9.0 documentation
The if statement evaluates the expressions one by one, continues until true, and selects only the suite of clauses that are true (for the definitions of true: true and false: false, Boolean operations () boolean operation) See section);
6. expression — Python 3.9.0 documentation
In the context of Boolean operations and when expressions are used in control flow statements, the following values are interpreted as false: False, None, number 0 for all types, empty string, empty container (Strings, tuples, lists, dictionaries, sets, frozen sets, etc.). Any other value is interpreted as true.
Answer # 2
Truth value judgment
The object is determined to be true by default. However, the class isbool() If you define a method and it returns False, orlenIf you have defined a () method and it returns 0, it is considered false.
So, roughly speaking, I think it's okay if the value of os.environ ['TEST_Prefix'] is not None and its value (character string) is not empty.
- about writing if statements in dictionaries with python
- python - about repeating for statements
- python 3x - about downloading anaconda
- python - about "" "of" "" select === = "" "
- python, about the fire spread step of forest fire simulation
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- i have a question about basic python problems
- python - about the optimum angle of rotation matrix
- python - about x-axis adjustment in matplotlib
- about processing to exclude the character string group specified from list in python
- python - what i don't understand about yolo9000 (v2)
- about batch change of file name using python
- about the python speedtest code
- about the implementation of combinations in python
- please tell me about the role of python tag = "mychr"
- python - about downloading youtube videos by youtube-dl
- python 3x - please teach about the exchange of information with qthead
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory