0 votes

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?
in Engine by (32 points)

1 Answer

+3 votes
Best answer

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:
https://docs.godotengine.org/en/stable/classes/class_array.html

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().

by (21,537 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.