by leetrout · 10y ago · 0 comments
I'm running in to that with Go. Go even makes it super easy to break things out in to multiple files transparently and people still just toss everything in one file.
In this specific case, and I am a super pedantic, anal retentive when it comes to python, I really wish more people would use pylint / pyflakes / flake8. Use 4 spaces, order & organize your imports so I can easily see what's third party and what's core and as pointed out organize the code in to modules when it makes sense.
I know PEP-8 (& PEP-257) polarizes people and one of the biggest things I LOVE about Go is `gofmt` & `go vet`. Just follow a community standard so we don't spend so much brain power figuring out so many independent styles & conventions. And if everyone disagrees (pretty much everyone complains about 80 cols width) then it usually ends up coming up in other community discussions and the diversions become common and expected.
Rant over- tl;dr I really love community style / organization guidelines, code organization and linting.
I've heard it phrased thus: "scrolling through one file is easier than jumping around between files", and that fits with my experience.
That said, although I'm not very familiar with Python, this file does have a lot of "verticality" with lines like
t q[2];
h q[2];
h q[0];
h q[1];
...
which I would try to express in a bit more compact form, and I'd think stuff like this could be better written with arrays and/or procedurally generated: self.three_qubits_000=np.kron(self.two_qubits_00,State.zero_state)
self.three_qubits_001=np.kron(self.two_qubits_00,State.one_state)
...Every Python library I read is immediately accessible to me. This hasn't been the case for JavaScript.
It seems odd to allow this and then ask everyone to use 4 spaces.
Using tabs makes your python code (potentially) incompatible with other peoples code, due to a style convention. This seems utterly crazy to me.
Yes, I prefer tabs too, but this tabs/spaces/different number of space feels like if C had the option of using either curly braces or parenthesis for blocks.
What? Every number of spaces always works. Anyway, it's nice to separate style recommendations and syntax.