Search found 3 matches

by cookie
Fri Mar 26, 2021 6:02 pm
Forum: General Discussion and Questions
Topic: import module by name
Replies: 2
Views: 1272

Re: import module by name

Perfect, that helped me! Thank you!

For future searchers, here's what it is in generic form:

Code: Select all

module = __import__(moduleName)  # for import_module
class_ = getattr(module, className)  # to import a class in a module by name
by cookie
Fri Mar 26, 2021 3:33 pm
Forum: Programs, Libraries and Tools
Topic: Slice list in neopixel object
Replies: 3
Views: 1952

Re: Slice list in neopixel object

What if you convert the object to a list then do the slice? neopxlList = list(neopxl) neopxlList[1:5] # do stuff to sublist To update the elements in the list, I think you've got to replace them as entire tuples, since tuples are immutable. Then apply your updates to the neopixel object to get the c...
by cookie
Fri Mar 26, 2021 3:22 pm
Forum: General Discussion and Questions
Topic: import module by name
Replies: 2
Views: 1272

import module by name

Hello! I'm working on porting some python code to micropython and I'm stuck on a certain point. I'd like to import a module by its name as string. In python : module = import_module(moduleName) So there's no obvious import_module equivalent in upy that I've found. Do you have any ideas for functions...