Want to see more threads and images? Ask Bernd!
Bernd Wed, 26 Feb 2025 23:16:46 GMT No. 25519253 [Kohl] [Report thread]
python
def func(arg, kwarg = None):
    if kwarg is None:
        kwarg = {}
Humiliation ritual.
Total posts: 23, files: 0 (Thread is alive)
Bernd Wed, 26 Feb 2025 23:21:00 GMT No. 25519286 >>25519339
You couldn't write 3 lines without breaking PEP8. Aren't you ashamed?
Bernd Wed, 26 Feb 2025 23:21:47 GMT No. 25519293
>pytranny not my problem
Bernd Wed, 26 Feb 2025 23:26:01 GMT No. 25519339
>>25519286 That shit is for midwits with poor taste.
Bernd Wed, 26 Feb 2025 23:32:16 GMT No. 25519384 >>25521287
I dont get it
Bernd Wed, 26 Feb 2025 23:34:11 GMT No. 25519396
Did you mean: >def func(*args, **kwargs):
Bernd Thu, 27 Feb 2025 07:07:14 GMT No. 25521287 >>25521345
Text hidden
Bernd Thu, 27 Feb 2025 07:16:13 GMT No. 25521318
def func(*args, **kwargs): if "OP" in kwargs: if kwargs["OP"] == "onion": raise ValueError("Hang all pedos")
Bernd Thu, 27 Feb 2025 07:17:15 GMT No. 25521321 >>25521333
>>def func(*args, **kwargs): Do I look like I know what a kwarg is?
Bernd Thu, 27 Feb 2025 07:21:37 GMT No. 25521333
>>25521321 I guess a keyword argument.
Bernd Thu, 27 Feb 2025 07:25:17 GMT No. 25521345 >>25521356 >>25521365
>>25521287 Learn what pass by value and pass by reference are. Learn how python passes arguments. Mutable types as default values are not okay in case of python. Also, def func(derp=dict()):
Bernd Thu, 27 Feb 2025 07:29:38 GMT No. 25521356 (removed)
>>25521345 >def func(derp=dict()): Doesn't work either as `dict()` is called at function declaration. This is equivalent to the example I posted in OP.
Bernd Thu, 27 Feb 2025 07:32:55 GMT No. 25521365 >>25521467
>>25521345 >def func(derp=dict()): Doesn't work either as `dict()` is called at function declaration. This is equivalent to `func(derp={})`.
Bernd Thu, 27 Feb 2025 08:13:55 GMT No. 25521467
>>25521365 That's what I've meant to say, it would have the same effect
Bernd Thu, 27 Feb 2025 08:15:36 GMT No. 25521483 >>25521505 >>25522094
Passing default empty list or dict is shit design anyways, so it doesn't bother me even an inch, because I don't write this type of shit code
Bernd Thu, 27 Feb 2025 08:23:34 GMT No. 25521505
>>25521483 Things happen. Especially if someone did a doo-doo into some corporate lib and it's not handled with tests.
Bernd Thu, 27 Feb 2025 10:14:03 GMT No. 25522020
>By definition, immutable objects such as numbers, strings, tuples, and None, are safe from change. Changes to mutable objects such as dictionaries, lists, and class instances can lead to confusion. So it's a very special case for containers someone would say this goes against the principle of least surprise
Bernd Thu, 27 Feb 2025 10:15:22 GMT No. 25522027 >>25522045
Not a problem in Ruby.
@list = []
def func(a={})
    @list << a
end
func
func
puts (@list[0].equal? @list[1])
puts (@list[0].equal? @list[0])
Bernd Thu, 27 Feb 2025 10:19:07 GMT No. 25522045 >>25522087
>>25522027 What terrible syntax. Python reads like plain English.
Bernd Thu, 27 Feb 2025 10:30:54 GMT No. 25522087 >>25522098
>>25522045 No, it does not.
Bernd Thu, 27 Feb 2025 10:32:31 GMT No. 25522094
>>25521483 Cope. No other language does this.
Bernd Thu, 27 Feb 2025 10:33:28 GMT No. 25522098 SÄGE! >>25522145
>>25522087 Maybe you should also make a comment about Dlang, fucking sperg.
Bernd Thu, 27 Feb 2025 10:45:53 GMT No. 25522145
>>25522098 How about you make an argument instead? Obviously the way I wrote it wasn't the prettiest but I typed it on my phone from bed.
Bernd Thu, 27 Feb 2025 11:04:41 GMT No. 25522224
Bump
Bernd Thu, 27 Feb 2025 12:19:40 GMT No. 25522588
>>25519253 Kwarg? More like kwab desu
Thread interest score: 4.6 Thread size: 41.47 kB