I have an Auriol. (I don't know for certain, but I like to imagine the brand is named after French rally driver Hubert Auriol.) It has a monochrome face, twelve simple hour demarcations, and two hands.
In its own way(s), that is actually quite a smart watch.
It also uses the file as a module, not a script, which means suddenly relative imports works the root dir and the cwd are the same, and it is added to sys.path.
This prevents a ton of import problems, albeit for the price of more verbose typing, especially since you don't have completion on dotted path.
It is my favorite way of running my projects.
Unfortunalty it means you can't use "-m pdb", and that's a big loss.
Not just relative imports but also (properly formed) absolute imports. For example, if you have a directory my_pkg/ with files mod1.py and mod2.py, then
# In my_pkg/mod2.py
import my_pkg.mod1
will work if you run `python -m my_pkg.mod2` but will fail if you run `python my_pkg/mod2.py`
However, the script syntax does work properly with absolute paths if if you set the enviornment variable `PYTHONPATH=.` (I don't know about relative paths - I don't use those). That would presumably allow pdb to work (but, shame on me, I've never tried it).
I also develop and run projects this way. I really, really enjoy it. It's a very pleasant experience, on both the development side and execution side.
I'm relatively new to Python (used it for ~1 year in 2007/2008, again briefly in 2014 -- which is when I believe I picked this module trick up -- and then didn't touch it again until March of this year). It's made an impression on my team and we're all having a good time developing code this way. I do wonder, though, what other shortcomings might exist with this approach.
There's no magic, only layers. `python -m pdb <args>` runs pdb with the rest of the arguments. pdb handles the second `-m`.
If you have a fancy IDE feature, open a new python file, type "import pdb", use go to definition on pdb to jump to that file in the standard library, and read its main function - it handles -m explicitly :)
Speaking of pdb.. maybe someone knows why pdb has some issues with scope in its REPL that are resolved in VSCode's debugger and PyCharm?
Multiline statements are not accepted, nor things like if/for
Even list comprehensions and lambda expressions have trouble loading local variables defined via the REPL
Are there workarounds? It would reduce the need for using IDEs. People who have experience with Julia and Matlab are very used to a trial and error programming style in a console and bare python does not address this need
Not supporting multi-line statements is just because pdb doesn't bother to parse the statement to work out if it is an incomplete multi-line statement. That could be easily fixed (I have a prototype patch for that using `code.compile_command`).
"The scope of names defined in a class block is limited to the class block; it does not extend to the code blocks of methods - this includes comprehensions and generator expressions since they are implemented using a function scope."
This is a fundamental limitation of `exec`. You can workaround it by only passing a single namespace dictionary to exec instead of passing separate globals and locals, which is what pdb's interact command does[2], but then it's ambiguous how to map changes to that dictionary back to the separate globals and locals dictionaries (pdb's interact command just discards any changes you make to the namespace). This too could be solved, but requires either brittle ast parsing or probably a PEP to add new functionality to exec. I'll file a bug against Python soon.
After triggering pdb by having "breakpoint()" in tour python code and dropping in the debugger you can type "interactive" in the console to enter multiline strings.
-m pdb is post mortem debugging, it drops you in the debugger when it encounters the first unhandled exception. This is much easier than trying to pin point where to put a breakpoint.
I've always been curious how that mechanism works exactly what is it about that invocation technique that satisfies the relative imports? I think it changes the pythonpath somehow right in a way related to the module being ran, something like appending the basedir where the module is saved to the PYTHONPATH?
There are ORM with good pros/cons ratios out there. Python has espacially good ones:
- Django comes with a clunky and poor performing one, but it's very well integrated, super practical, productive and has nice ergonomics.
- Peewee gives you an ORM in a small package, which makes writing those little programs a joy when you don't need anything fancy, but feel lazy.
- SQLAlchemy requires a lot more investment, but is very flexible, generates clean SQL and has extremely correct behavior. It also exposes a lower level query builder for when you don't want the OOP paradigm and wish to express idiomatic SQL behavior, but abstracted away with Python.
This becomes a standard engineering decision, where you analyze the ROI.
I absolutely hated having to deal with SQLAlchemy. It took me days to get through the ugly documentation to a level where I could more or less competently use it, and for what? The code is harder to understand than just writing SQL and the performance is worse. I have yet to learn of a single advantage of ORMs that don't boil down to developers not wanting to deal with SQL.
Currently have to use sqlalchemy on an existing project, and while I am not necessarily disagreeing with you on ORMs or performance, just wanted to add that chatgpt has been able to reduce my time fighting with their documentation by what I estimate of 90+%. To be fair, if I would have written pure sql, I might not have needed chatgpt at all, but i also would have to learn pythons database connector calls for the umpteenth time.
Yeah, the productivity and performance with the Django ORM is amazing. I have trouble using any other web framework now...
The thing people are missing is relations. The most important aspect of your application is how data is related to each other. A good ORM makes that easy.
Hibernate is not that bad. The problem with ORMs in the Java web space is lots of people used them as an 'extreme DRY' solution to link database 'objects' to the front-end which breaks separation of concerns and forces you to use the same model or resort to ugly hacks for further mapping.
In a properly separated application it works fine.
Indeed. Not only are these slaps on the wrist accounted for in initial estimations of the cost of doing business, but then they're just written off and ironically inconsequential. There needs to be real consequences.
If changing the battery is a one hour cheap deal, a lot more people may do it.
And I am very happy about those EU initiatives: this way I know what sites are tracking me and how much. This tells me which sites values annoying me with their banner so they can sell my data.
Have you noticed there is no banner on Hacker news despite the fact that:
- they serve in Europe
- they use cookies
That's because it's not about cookies, and the banner is only for privacy abusers.
Most people don't have a $1000 iphone, which is even more problematic, because if you have a cheaper $3-400 phone, that $99 replacement would be very expensive.
Exactly this! I keep seeing this nonsense that a $70/99 store replacement battery is a great cheap deal.
Yeap, only compared to a brand new phone. When you have a cheap iPhone from 5 years ago and you compare the price of a battery replacement to the actual price of your phone it quickly become obnoxiously expensive.
In the US having a battery replaced at a shop is cheap and you can probably find a place that will do it in less than an hour. There are a few nationwide chains of third-parties that do it, plus numerous independent local repair places.
As far as HN goes it is not clear whether or not they are covered by GDPR. Yes, the site is viewable in Europe and people there can make accounts. But that's not sufficient.
GDPR asserts extraterritorial jurisdiction when you are either (1) offering goods and services in the Union or (2) monitoring the behavior of data subjects in the Union that takes place in the Union.
One of the recitals clarifies that the mere availability of a site to Europeans does not necessarily mean it is offering goods and services in the Union. The site has to envisage serving people in the Union.
The main problem is probably that you will not find a “regular Engineer” knowing this unless they’ve had to deal with scaling issues on a DB (e.g. high IOPS etc).
The knowledge is definitely out there, but almost all articles will be reaching for UUIDs, so this is understandably what most people end up with :/
I have simple watches. They are casio.