Le 17-10-2026, Richard Kettlewell <inva…@invalid.invalid> a écrit :
> Stéphane CARPENTIER <s…@fiat-linux.fr> writes:
>> Richard Kettlewell <inva…@invalid.invalid> a écrit :
>>> Stéphane CARPENTIER <s…@fiat-linux.fr> writes:
>>>> Like, it's not a typed language but start playing with dictionaries
>>>> without declaring your variables first to see how the claims stand
>>>> before the facts.
>>>
>>> Python is absolutely a typed language. Every object has a type and it
>>> won’t let you use objects in a manner incompatible with their type:
>>>
>>> >>> 0+""
>>> Traceback (most recent call last):
>>> File "<python-input-0>", line 1, in <module>
>>> 0+""
>>> ~^~~
>>> TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>
>> In this case python is a strongly typed language and in other cases
>> it's not that important.
>>
>> With some typed languages, you can't use a variable if you didn't
>> declare it's type before. With python, you don't need to declare
>> integers and strings but you need to declare dictionaries. Why? Don't
>> know.
>
> No special declaration is needed for dicts, you can just write out the
> dict you want.
>
> >>> d={'a': 1, 'b': 2}
> >>> type(d)
> <class 'dict'>
As John said, I'm probably confusing declaring, creating and assigning a
value to a variable. Because when I assigned an empty dictionary to a
variable, all three of them are done at the same time.
The issue wasn't about assigning a new dictionary to a variable, but
adding some values in it. Some methods didn't worked for adding values
if I didn't assign an empty dictionary or an empty list first, before
doing anything on it.
>> With other programming languages I saw, either that works or that
>> doesn't, but I never saw something that stops working when it starts to
>> be more complex. It looks like it's a python specialty.
>
> No, I think the issue here is pretty obviously the attempt to use a tool
> without learning how it works.
I managed to do it with other programming languages. I managed to do it
with python, to. In the end, it worked. But it was more cumbersome with
python. I'm not saying that a programming language should be able to be
used without being learned. I'm saying that it's not an easier language
to use.
--
Si vous avez du temps à perdre :
https://scarpet42.gitlab.io