question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we really need to add every color to locals()?

See original GitHub issue

Currently, constants.py is adding every color inside COLOR_MAP to the locals() dictionary. This is usually frowned upon in Python in general.

If we want to keep exposing all colors to the end user without any namespace access (like manim.colors.RED or some such), then we can carefully import all colors inside __init__.py. This could be done for the purpose of backward compatibility.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
leotrscommented, Jul 10, 2020

I still think we should move all colors to something like manim.colors, and turn them all into Colour instances too. We can easily do this in a backwards-compatible way.

0reactions
leotrscommented, Oct 8, 2020

#488 implements this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why add key in locals actually create variable? - Stack Overflow
So something like locals()['a'] = 'hello' actually creates a new global variable a , and that's perfectly fine in Python, because global ...
Read more >
Make Sense of Your Variables at a Glance with Semantic ...
PyCharm uses semantic highlighting to assign a different color to each parameter and local variable: the “namespaces” parameter is now a certain ...
Read more >
Theming With Variables: Globals and Locals - CSS-Tricks
You 'll notice that we are defining locally-scoped variables with global variables. This is key for the system to work since it allows...
Read more >
Python locals() - Finxter
Python's locals() function returns a dictionary of name --> object mappings. The names are the ones defined in the current local scope, i.e.,...
Read more >
Locally Scoped CSS Variables: What, How, and ... - Una Kravets
We Can Do Better with Local Scope​​ This is a great way to set global variables, but isn't a necessity. CSS variables don't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found