Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

More elegant way to check if a string is empty Read here Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing except for a newline.

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here Read Here

More elegant way to check if a string is empty Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing except for a newline.

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here

More elegant way to check if a string is empty Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing except for a newline.

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here

added 12 characters in body
Source Link
Majiick
  • 711
  • 3
  • 14

More elegant way to check if a string is empty Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing anyway.except for a newline.

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here

More elegant way to check if a string is empty Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing anyway. 

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here

More elegant way to check if a string is empty Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing except for a newline.

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here

Source Link
Majiick
  • 711
  • 3
  • 14

More elegant way to check if a string is empty Read here

if not s_string:
 sys.exit()

You don't need a sys.exit(), just let the program exit on its own.

if s_string:
 print(s_string)
# the program will exit here anyway. 

sys.exit() has some side-effects like killing the python interpreter, which might have some undesirable effects. Read here

You don't even need to check if the string is empty

print(s_string) # If string is empty, will print nothing anyway. 

Name s_string just s or string.

It doesn't detract from the readability of the code, and makes it more pretty and easier to type(and read)

Most people tend to prefer double quotes " for string literals Read Here

lang-py

AltStyle によって変換されたページ (->オリジナル) /