Does GDScript support all python features and how can I get around it?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NerdKnight

So I wanted to remove duplicate nested lists in a list. I tried writing my own function, but GDScript’s “remove()” function isn’t the same as python. So I looked on the internet. I found this handy bit of code:

list(set(tuple(sorted(sub)) for sub in test_list))

But Godot through this error in my face:

ERROR (1,28): Expected "," or ")"

I found out GDScript doesn’t support regular python one-line if and for statements.
I tested it and it works fine in regular python.


I have so many questions:

  • Does GDScript actually have discrepancies or am I just stupid?
  • Where can I find a list of all of them?
  • How do I get around this and remove these duplicate lists?
  • Are the devs working on them?
  • Can I tell them where?
:bust_in_silhouette: Reply From: kidscancode

GDScript is not Python. Don’t let the superficial syntax similarity mislead you, it is a completely different language with different rules, built-in functions, and idioms.

Godot’s Array type is documented here:

This shows what you can do with Arrays, don’t try to copy Python code you find, it’s unlikely to work. For example, the GDScript Array function you’re looking for to remove an element from the array is erase().