News for hackers. Stuff that matters.

jabwork

Re:Hypermodern Python on Thursday May 28, 2020 @01:11PM (#23339772)
Configargparse is a great drop in replacement for argparse that I use to handle bridging env vars with cli flags

https://pypi.org/project/ConfigArgParse/

Re:Want to call C from Python? Use D on Wednesday February 19, 2020 @10:25AM (#22366240)
Have you used pythons cffi and if so how would you differentiate this from that?

Does this work for all revisions of C? iirc cffi works for all of c89 and most of c99

I ran into this same issue with python/SQLAlchemy. It's a connection pool thing
Re:Ask HN: Looking for an Alternative to Jira on Tuesday August 27, 2019 @01:26PM (#20812260)
I spent two years using and then administering two RT servers.

I arrived with effectively no real PERL knowledge but a high level of Linux sysadmin competency

I hugely enjoyed working with the system. It was productive, flexible, and never gave me unexplained errors.

Even scripting on the perl api was an excellent experience.

Moreover the devs were extremely helpful in their irc channel (circa 2014-2016 at least) and walked me through a manual upgrade caused by the previous admin customizing the database schema in an unsafe way

Would highly recommend

Re:Easy Python CLI with Click on Sunday August 18, 2019 @04:19PM (#20732559)
For those of you using argparse I recommend looking at configargparse. A drop in replacement which adds environment variable support (similar to click) and config file support
Re:Why a mock doesn’t work on Monday August 05, 2019 @01:13PM (#20615936)
The os module ships with python, so the function call mocking os.listdir will always succeed even if the code being tested does not use os.listdir

By mocking mymodule.os.listdir you add a requirement that mymodule actually import the os module and take advantage of mock.patch failing loudly if it does not.

Re:Why a mock doesn’t work on Sunday August 04, 2019 @05:57PM (#20609466)
I've wrestled with this problem several times. My conclusion was mocks are just fine, but this is a wart in that there isn't "one way to do it"

For the most part I can get by with one rule: always mock the module.

  with mock.patch('os.listdir'):
will always work, even if it doesn't accomplish what you want.

  with mock.patch('mymodule.os.listdir')
will fail if that module does not explicitly import os and instead does something like from os import listdir (perhaps because a later dev did not realize importing os directly was actually a requirement for the test and changed the code).

The rule is not perfect though. In the above case, the error will actually be

  ImportError: No module named os
This can be fixed with e.g.,

  assert hasattr(module, 'os'), "os module is not explicitly imported"
as a preamble to your test but ... it is not perfect by any means.

EDIT: formatting

For the OPs context (their kids) I expect they'll have a lot of typing too do on school computers
Even Apple had the famous episode of releasing an update that bricked phones with replacement parts that weren't sanctioned. They reversed it after much public outcry.

For less common hardware the situation is just as bad. Agriculture equipment has been a pain point for many to get repaired, as the parts are much harder to find and the limited number of certified repair shops can be pressured to stop servicing equipment deemed end of life by the manufacturer

Re:What Is Windows Lite? It's Microsoft's Chrome OS Killer on Tuesday December 04, 2018 @07:36PM (#18604814)
Drat,I had hoped for another edition of this https://www.litepc.com/

For the uninitiated this basically cranked your ability to uninstall windows components up to 11, allowing you to strip out IE and and get windows humming along quite well on antiquated hardware.

Re:Python's New Package Landscape on Thursday October 18, 2018 @01:37PM (#18250350)
I've never had problems with this when requirements.txt contains package versions

Have you, or are you not using explicit versions supplied by eg pip freeze?

punative damages could exceed that under a lot of conditions
I read this as an assertion the masses are losing interest overall, not switching to a competitor
Re:Ask HN: What do you listen to when you code? on Tuesday July 11, 2017 @07:30PM (#14748957)
Music with minimal words (which I find distracting) but often with vocals. Usually an album at a time e.g.,

Ibiza chill sessions (annual albums) Melody AM The altogether Little dragon (NPR remix)

a lot of electric guitar - Steve Vai, joe satriani

Re:Reasons to Switch from Chrome to Firefox on Wednesday June 28, 2017 @07:28PM (#14659490)
I regularly have 200+ FF tabs open, but FF steadily grows in memory usage.

Normally I have to restart around 3gb due to notably degraded performance (around every 4 days ). Do you use extensions to avoid this?

Re:Why So Many Top Hackers Hail from Russia on Thursday June 22, 2017 @07:39PM (#14616116)
I read this as the culture of cheating teaches analysis of the system (education /testing) and how to identify weak points and exploit them

Then, using the same analytical skills, students are better prepared to analyze other systems (eg security) and pinpoint/exploit their weakness

I still write a variety of things. I've found it improves my ability to recall the things I write

> Some say that because we write slower than we type, it allows for deeper thinking as opposed to faster thinking, which could be beneficial. Since writing takes longer, I tend to mull over what I'm trying to communicate and condense it. This is likely why I remember it better. However ....

> because it's harder to edit one is more careful while writing Absolutely not! Given a half pages written text I would likely have no less than a dozen clear markups where I revised or edited a thought.

I certainly don't want to write everything, or produce professional quality hand-written text, but I find benefit in actually writing things down

Re:Why The Cool Kids Don't Use Erlang on Sunday June 22, 2014 @12:28PM (#7928294)
Unreadable on a 10" tablet - slides are larger than my screen and cannot zoom out (Opera)
For RoR's method_missing give me the docs

For apache configuration, give me the examples!

I really like the use case of helping upstream maintainers decide on method deprecation/adding helper functions. Fantastic idea

Re:Python's dir function is wrong on Thursday September 12, 2013 @10:23AM (#6374187)
Python objects can override __dir__, which is all dir() calls anyway.

It looks like this is all for an autocompletion library. Why not just write jedi.dir (jedir?)

Re:Amazon Career Choice Program on Monday July 23, 2012 @04:20PM (#4282895)
Ostensibly because high demand fields are more likely to get hired and lead successful careers outside of Amazon.

Logistically it also simplifies things because you can respond to "Why can't I pursue education X?" questions with "because the BLS doesn't list them"

Re:PHP Addiction on Friday June 29, 2012 @01:39PM (#4177887)
"... run into some tiny annoyance, do a bit of research ... So you switch ..."

If you pick a solution and run into a tiny annoyance learn to work around it in some way. It is a tiny annoyance.

Best case scenario, learn why it's happening, how you can fix it, and (in a dreamland) submit a patch that fixes this for everyone else in the future.

Worst-case scenario just find a workaround.

Re:A Year with MongoDB on Friday April 13, 2012 @02:41PM (#3838196)
Can you give any sort of indication of the value of a schemaless database and the flexibility it provided as the team fleshed out the data model? Was this a mere convenience over traditional schema migration or something more?
Re:Python Requests: HTTP for Humans on Monday October 10, 2011 @02:21PM (#3095078)
It would appear so. Based off of testimonials and briefly looking at the API I'd say this is primarily aimed at a simple API + fewer "gotchas"

E.g., urllib/urllib2 both support urlopen(url, [data]) if `data` is supplied the request is executed as a POST, if not it is executed as a GET.

Issuing a GET w/ a querystring requires mutating the `url` and omitting `data`. This surprised me at first, and probably a number of others

Re:The Mac Is a Great Dev Box on Friday September 16, 2011 @05:36PM (#3006418)
I had a hard time connecting "development on VMs is a good idea because ..." to "Mac is the ideal VM host OS"

AFAIK everyone agrees that Mac hardware can be gotten cheaper by not buying it inside a Mac. Why not assemble a PC, install a VM, and then run windows-in-windows?

This is all coming from someone who exclusively programs on linux boxes, so maybe I'm missing something?