Earlier quoted context omitted.
I've never understood this complaint. Whitespace is included when you copy something. What's the problem? Admittedly it is mildly annoying when someone decides to use some random number of spaces for indentation, and you have to fix it to make it match the rest of your code (my preferred editor, Geany, has a feature for this). We should all just use tabs. But "very hard"?
The web collapses whitespace so if the code is not in tags you are stuck. This is quite often a case where comment systems were not intended to share code.
Why People Should Learn Python
171–180 of 329 posts
Re: Why People Should Learn Python
#172Earlier quoted context omitted.
What do you guys mean by dependency locking? What I do with pip is add a requirements.txt with things like: Django~=1.10.0 And it keeps the env autoupdated with the latest patch revision but not the latest minor revision. pip-tools doesn't seem to do much related to that, no?
The problem with that is that you no longer have reproducible builds. If you checkout a year old commit and built deployment artifacts with it you want the resulting artifact the be the same as when it was created. This is what you get with Bundler and the Gemfile/Gemfile.lock split You put gem 'rails', '~> 4.2.7' in your Gemfile and when you run `bundler install` the exact version of rails you ended up resolving wit…
If I check out an old commit I can look up docker image version in the source control, download exactly the docker image that was running at that time and start shell in this image. Inside the image I can run "pip freeze" to check exact version of each package that was running at that time. I can then update the old Dockerfile with those specific versions by adding the "==x.y.z" e.g. "pip install oauth2client==3.0.0" in the pip install to reproduce the old build.
Additional benefit is that such scheme works for system packages, or for any other language libraries I can think of.
Re: Why People Should Learn Python
#173Earlier quoted context omitted.
8. Significant whitespace. Not only is it a constant minor inconvenience when editing the program, it makes it very hard to cut-and-paste code fragments on the web.
I've never understood this complaint. Whitespace is included when you copy something. What's the problem? Admittedly it is mildly annoying when someone decides to use some random number of spaces for indentation, and you have to fix it to make it match the rest of your code (my preferred editor, Geany, has a feature for this). We should all just use tabs. But "very hard"?
In addition to the points posted in a parallel thread, selecting and copying leading whitespace reliably is more difficult than just getting the printable characters. Also: it's not something that anyone has any cause to do outside of copying Python text.
Re: Why People Should Learn Python
#174Earlier quoted context omitted.
just to chime in on this, modern PHP is nothing like what people remember from the pre ROR days, i still use it to this day and the major frameworks and libs are really well written to the point i feel some are even over engineered and almost looking like Java (just take a look at the latest Guzzle PHP Library)
As my PHP fluent colleague said to me - don't bother learning PHP or you will end up having to fix (our) Wordpress sites and thats a nightmare. We have a Python application, and while its not written well, the PHP sites we have seem to be a fair bit worse even the ones not done in Wordpress.
Luckily I'm currently working with a PHP7 app, so all is good, but my next app will likely not be PHP at all.
Re: Why People Should Learn Python
#175Is it just my feeling or are there languages which are preferred on HN? Indicators for languages which are liked by the HN community: - Positive stories get many upvotes and are instantly at the top of HN - Most comments are positive - Frequent coverage on HN about the language Indicators for languages which are not liked by the HN community: - Rants get many upvotes and are instantly at the top of HN - Most comments…
Re: Why People Should Learn Python
#176Re: Why People Should Learn Python
#177I switched to writing python as my main backend/scripting language with my new job. Previously I was using Ruby for most of this stuff with some Go. I must say that so far Python has been a vastly inferior experience for me. The languages are fairly similar all though I prefer the more talkative/english style of ruby and the use of functions over list and dict comprehension. The thing that really stands out to me tho…
Re: Why People Should Learn Python
#178> Another thing is strict typing and debugging: since Python is an interpreted language, finding bugs wasn’t as easy Wait, what? How is its interpreter remotely relevant to its semantics? > if you have a syntax error in C, the program will simply not compile, on the other hand, in interpreted languages, the problem might go unnoticed for quite some time Hang on--Python allows you to run code that has syntax errors? I…
To my knowledge syntax within a file is completely checked when that file is loaded. I think the OP referred more to errors in method and other reference names.
#!/usr/bin/python
import time
time.sleep(5)
fdafadsfadsf
It'll take 5 seconds to crash with a "NameError: name 'fdafadsfadsf' is not defined". Likewise, if you do this: #!/usr/bin/python
import time
x = 1
time.sleep(5)
print "x is "+x
It'll take 5 seconds to crash with "TypeError: cannot concatenate 'str' and 'int' objects"In a language like Java, these would be syntax errors, and they'd be picked up at compile time as they're illegal in Java's syntax.
I assume they're legal in Python's syntax, because for all the syntax checker knows, time.sleep() might define fdafadsfadsf and convert x into a string. So they're runtime errors in Python.
Of course, Java still has runtime exceptions - null pointer exceptions, for example.
Re: Why People Should Learn Python
#179Earlier quoted context omitted.
I find chained enumerator / block style code much easier to write and understand than list / dict comprehensions too. It's probably the single biggest thing that I don't like about Python; lambdas are simply too awkward, but lambdas + monadic transformations are probably my primary mental abstractions for writing software these days.
Could you give an example of that?
Re: Why People Should Learn Python
#180As the author mentioned Python is good for small stuff. If you are building a huge system where the jobs are spread between a dozen of people things could easily get out of control and you could end up in the dirt.