New answers tagged

3

I'll start off by saying, Hey! Good job! There's a lot of things you got right in this code, including the use of with for file open/close operations and checking the number of command line arguments. Now I'll rip it to shreds. :| First, check out PEP-8, the Python community coding standard. You may find things in there you disagree with, but it's a pretty ...


6

I would group the code in functions and call them from a central main. With how you have it now, simply loading the file into an interactive console will cause all the code to run, which, if the code is long running or causes side-effects, may be less than ideal. Say I wrote a port-scanner, and it takes 2-3 minutes to run. I may not want it to start simply ...


1

I have spent a long time grappling with this problem. I have finally come to the conclusion that it actually is a non-problem! The thing is that once you have pushed the object into a collection you have lost the compile time binding. Type safety is really a compile time issue rather than a runtime issue. My understanding is that when you create a generic ...


3

This seems to so what you want, but is specific to the example and code you gave. There are two pairs of subarrays in arr and two different sets of indices and data to add to the subarrays. So there are four combinations. These get figured out by the values of i, j, and 'k'. Because the data to be added is sparse, I'm going to use scipy.sparse.coo_matrix() ...


Top 50 recent answers are included