[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: pct_001.png (320 KB, 548x487)
320 KB
320 KB PNG
Gather around, gather around. Come wizards and newbies alike.
ITT we will be sharing advanced and hacky Python code.

Can you tell me what this will print?

class MindBroken(Exception):
pass

def func() -> int:
try:
raise MindBroken('>Anubis mascot')
return 1
except Exception:
return 2
finally:
return 3

print(func())
>>
>>108482559
im guessing 2
>>
>>108482559
Next one. What will this do?

def func():
try:
raise ValueError('Sneed')
finally:
return

print(func())
>>
Next one. What will the result be?

' 1 2  3\t   4\n\n'.split()
>>
>>108482570
Value Error: Sneed
>>
File: 1748293870122532.png (35 KB, 868x367)
35 KB
35 KB PNG
>>108482559
>>
>>108482583
["1", "2", "3", "4"]
>>
sirs this is a great thread so far. i specifically like the exception mind breaking and .split() quiz. python brahim, can u explain why guido forces the user to use the 'nonlocal' keyword for this? seems pointless.
def counter():
c = 0
def f():
nonlocal c
c = c + 1
return c
return f
>>
>>108482563
It printd 3, finally wins

>>108482596
This will print 'None'. Finally gobbles up the exceptions

>>108482621
>he's seething over a warning
>>
>>108482634
Good lad

>>108482649
idk, I have never used nonlocal in why whole life
>>
>>108482649
didnt know this keyword existed
>>
>>108482559
Too verbose.
In my own expressions parser I only need to write:
"Hello World"
>>
>>108482559
java is more elegant than python, which will never be more than a toy
>>
>>108482559
>coding in 2026
Ngmi
>>
>>108482952
>Java
>elegant
gm
>>
>>108482762
O good to know
>>
>>108482559
>python users are brown
sounds about right
>>
>>108485272
4chan commenters are 14yo mentally
>>
Anyone checkout the free threaded python yet?
>>
File: 1751924065465.png (16 KB, 492x475)
16 KB
16 KB PNG
>>108482559
>Java
Dalit coded
>Python
Only for brahmins
>>
>>108482559
>pythonistas are so stupid they don't even understand the meme they are using
not unexpected



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.