Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
148 variations of this code and codewars chose to put the one with the import inside the function on display.
strip() removes only first space
(WUB)+ replace all inline WUB with one space
pay attention to the + in the regex
Yes, especially if the function was called in a loop!
Please don't
strip won't delete all the spaces>
Hey, I like this. I'm still learning about re, and had no idea there was a .sub method. Thanks for this!
In fact, you can use __import__ to simplify the code
Ah...that makes sense, it would be pretty bad from a performance standpoint to delete and completely reload an entire module. Thanks!
From my understanding, access is restricted to the scope it was imported in. However, should you decide to import it again in a different scope (or the same scope, on a different invocation), you don't actually load the module again, you just get its reference.
More info:
http://stackoverflow.com/questions/3106089/python-import-scope
http://stackoverflow.com/questions/3095071/in-python-what-happens-when-you-import-inside-of-a-function
If a module is imported inside a function, is access to it only restricted within the function's scope, or is it still globally accessible?