Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have bits and bobs of code and I'm thinking of getting them in a python module. But I might need a Python package.
I know it has to do mostly with how I want to divide my code.
But I still need to know what is an average length (in lines) of a python module.
Using the following numbers please select small | average | big
1,000 lines of python
10,000 lines
50,000 lines
100,000 lines
1,000,000 lines
Please help.
A module should be the smallest indepently useable unit of code. That's what modules are for: modularity, independence, take only what you need. A package should be a set of modules that functionally belong together to cover a certain problem area, e.g. statistical computations or 3D graphics.
So the number of lines is not really important. Still I think modules of 10000+ lines are rare. But there's no lower bound.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
As we all know in python, there is one type of data - complex . I read the doc and then cannot find the use case, when to use it, and then what's its characters?
a = 20
b = 328
c = complex(a, b)
print(type(c))
Complex data types are used for advanced calculation in Electronics and applied or astrophysics or such type, just like we use complex numbers in the real world.
Complex numbers are used in electronics and electromagnetism. A single complex number puts together two real quantities, making the numbers easier to work with. For example, in electronics, the state of a circuit element is defined by the voltage (V) and the current (I).
In python, some libraries are used these things like:-
SkiDL
PySpice
Numpy
...etc
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have been dipping my feet into programming and originally was making a simple macro in VBA to find a certain combination that sum to a given number when given a list of inputs. I imagined a number of tasks and minutes to do those tasks, and inputted a number of people to divide the minutes approximately equal between them. To give a concrete example, if I had eight tasks and three people, I might have the following variables:
M = [44,39,29,77,102,35,40,59]
N = 3
Avg = sum(M)/N
I want the program to be able to find the set of combinations for each person that sum closest to the average value. For instance in this example, I would like an output of something like:
A = [102, 40], B = [44,39,59], C = [29,77,35]
If anyone can at least lead me in the right direction with regards to this project, I would be grateful. While this began as an aside from a macro for an Excel sheet, I wouldn't mind if I learned more about optimization algorithms in a more suitable language like Python.
Getting each persons work as close as possible to the mean is equivalent to max-min fair allocation problem
It’s essentially an optimization problem — google research did some work on this here
https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45386.pdf
A CS professor wrote a Python module for this https://github.com/anirudhSK/cell-codel/blob/master/schism/utils/max-min-fairness.py
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have a list to iterate through, the first iteration took 3 minutes 40 seconds, result was a bunch of generated images being saves on hard disk. Would it make sense to split the list into 2 or 3 and apply multithreading in this case?
You can't write to a hard disk in parallel, so using Threading/Multiprocessing wouldn't show any time improvements and would most likely add overhead.
If it's python that's slowing you down and not your disk writing speed, then it might be worth looking into the Map function, if you're using Python3.
https://docs.python.org/3/library/functions.html#map
Otherwise you'd need to look at using a faster language like C
https://docs.python.org/2/c-api/index.html
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Perhaps this is not the correct place to ask this question, and part of me thinks that there is no real answer to it, but I'm interested to see what experienced Python users have to say on the subject:
For maximum readability, concision, and utility, what is a range for an optimal length of a Python function? (Assuming that this function will be used in combination with other functions to do something useful.)
I recognize that this is incredibly dependent on the task at hand, but as a Sophomore Comp. Sci. major, one of the most consistent instructions from professors is to write programs that are comprised of short functions so as to break them up into "simple", discrete tasks.
I've done a big of digging, including through the Python style guide, but I haven't come up with a good answer. If there are any experienced Python users that would like to weigh in on this subject, I would appreciate the insight. Thanks.
I'm sure a lot of people have strong opinions about this, but for new programmers a good rule of thumb is to try and keep it below 10-20 lines. A better rule of thumb is that a function should do one thing and do that one thing well. If it becomes really long, it is likely doing more than one thing and can be broken down into several functions.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm wondering if I can extract a sequence of musical notes from a recorded sound using Python.
It is the first time I'm considering using Python for this.
Help would be truly awesome :)
What you would want to do is take your audio samples, convert them into the frequency domain with a Fast Fourier Transform (FFT), find the most powerful frequency in the sample, and convert that frequency into a note.
See FFT for Spectrograms in Python for pointers to libraries to help with the first two items. See http://80.68.92.234/sigproc.html for some sample code to get you started.