Discovered today that there’s no inbuilt nCr function in any of the popular Python modules. Tried itertools, numpy, sciPy This can’t be true? What am I missing? Seems odd to have write it out using math.factorial or use a helper function. Maybe I’m abnormally lazy.
-
-
You're probably seeing something like https://gist.github.com/DRMacIver/4dbf57071f9517dc767128b1dfd71d7f … ? This is due to shenanigans with how Python's module system works. Modules inside packages aren't available as attributes on the module until you've imported them.
-
Ah ok yes, I’ve run into this before. But it seems to be true for some modules, not others (eg numpy?) Or maybe I’m confused. Importing the misc module, I get a deprecation warning. But scipy.special does the trick nicely.pic.twitter.com/8oEM2Omxg8
-
Yeah the confusing thing about this behaviour is that once you've imported the module anywhere in your program, it becomes available on the package. Sometimes this happens because the module is used internally.
-
The result is there's basically no rhyme or reason as to when it works, it just sometimes happens to, but it will always work if you import the module.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.