TOP 5 Most USELESS Code Snippets in Python 👻

preview_player
Показать описание
Here are the top 5 most useless code snippets in #Python. #shorts
Комментарии
Автор

This is just my life story written in python.

ragilmalik
Автор

The first one is common in beginner code. I wouldn't call it outright useless, but more indicative of inexperience. The rest I admit I haven't seen much at all lol

re.liable
Автор

What is logic behind this syntax:
" is_true: bool = True " ??

yashbanait...
Автор

The "if x == True" can be useful to emphasize that the variable is a bool, not just a non-null value.

Ignas_
Автор

try:
pass
except:
pass
finally:
pass

teo
Автор

Here's a fancy one:

while 0: print("<sample text>")
print("Useless!")

idontwantanamethx
Автор

The first one should be written as print(True)

smarf
Автор

for _ in range(1):
print("How about this!!")
break

earthk
Автор

In the first example, simplifying changes the semantics. If the variable contains neither True not False, then neither line would be printed.

vytah
Автор

a=int(input())
if a==1:
print(1)
elif a==2:
print(2)
elif a==3:
print(3)
...

cenkedits
Автор

I find printing null is actually pretty useful for when debugging and I want to put a breakpoint in a tricky place without changing the functionality of the code

cavhaunch
Автор

I went through to shocked and angry and laugh at the same time

zapp
Автор

I’m going to fill my code with these and just confuse my students. Thanks for these

ovi_snipes
Автор

I found printing an empty string useful in one situation in Java. My friend had some code that didn't work properly and asked what's wrong with it. It looked like some code in a loop want executed do I asked him to add a print next to it to see if the execution enters the loop and the code started working, but without it, it didn't. I even tried running it on my computer with different version of Java and it behaved the same. Adding a breakpoint there also made it work. He ended up printing an empty string and adding a comment that it's necessary for the program to work. Fortunately it wasn't production code

PanDiaxik
Автор

"while true:
while false:
"

ItsCOMMANDer_
Автор

The first one is legitimately good advise tho, the other ones are just trolling. There is no way someone would write code like that, ever, because there is no logical pattern you can think in which would ever lead you to that code, unless you specifically wanted to write that exact piece of code just for the sake of writing that exact piece of code.

avananana
Автор

If you ever actually see someone doing 2-5 thinking it's proper production code, you should advise them to change career paths.

Other than the if-else, I've never seen anyone do the other 4 except as proof of concept as the what "break", "range", and "del" do along formatting the "print" output, so they're not useless in those contexts.

grant
Автор

for the first one get rid of the if statement entirely and just do print(is_true)…

matthewyang
Автор

What is a better way of doing
while True:
break

Shamefully, I do this.

moahmadi
Автор

I have never seen anything except the first one

VivekJoshi.