Tom Roche
Shared posts
ReincarNathan
Tom Rocheexcellent like last year/series: hoping for more @ https://www.bbc.co.uk/programmes/m0002824
Stack Abuse: Managing Python Environments with direnv and pyenv
Tom RocheBrief howto on using direnv and pyenv to automate virtualenv
Introduction
As Python developers, most of us are familiar with Virtual Environments. One of the first things we do when working on a new project is to create an environment. We commonly use virtualenv or venv exactly for that purpose.
Each project we work on uses different packages and may even be compatible with only one Python version.
Doing something repeatedly warrants automation. In this article, we'll see how direnv and pyenv can help us do that.
As a side note, some modern IDEs already automated these steps. For example, PyCharm will create the Virtual environment when initializing a project:

Although automating all these steps is a great win if we use IDEs that support such functionalities, a more generic solution should be IDE-agnostic.
The Problems of virtualenv
Imagine we found a project on GitHub and we would like to play around with it. Pyweather is a simple script that requests the extended weather forecast for our location and prints it on the terminal.
These are the steps we take in order to try the script on our machine:
$ git clone https://github.com/lcofre/pyweather.git
$ cd pyweather
Then we create the virtual environment and install the packages the script uses:
$ virtualenv --python=python3 env
$ source env/bin/activate
(env) $ pip install requirements.txt
And only then, we can execute the script:
(env) $ ./pyweather.py
We created a virtual environment and saved it in the root folder of our project. While being on that folder we had to activate the environment with the source command.
When we finish working, we need to leave the Virtual Environment by executing deactivate:
(env) $ deactivate
All those steps are our responsibility. How many times we may have forgotten to activate an environment and installed a package globally!
Let's see how direnv helps us automate this.
direnv
direnv was made mainly to load environment variables, depending on the current directory and has an extension for many shells.
In this example, we'll be using using bash, but direnv supports many other shells as well. And what's more important for us, it allows us to manage Python Virtual Environments.
To install it we'll run the bash installer they provide. We could use the package manager of our distribution, but the bash installer will ensure we install the latest version available:
$ curl -sfL https://direnv.net/install.sh | bash
Now we need to hook direnv to bash. We'll edit ~/.bashrc and then reload it:
$ echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
$ source ~/.bashrc
This way direnv will link itself to the shell and will be executed always before each prompt. We will never notice it's working on the background.
direnv will check if something needs to be loaded on the current folder. It checks the existence of a file named .envrc, with instructions on what should be loaded.
To load Python Virtual Environments we run the layout command, followed by the Python version:
$ echo 'layout python' > .envrc
Or if we want to use Python 3:
$ echo 'layout python3' > .envrc
Running these will tell direnv to look for a python or python3 executable on the path.
As soon as we create the .envrc file we'll be warned that we need to allow direnv to access that folder. Let's do that right now:
$ direnv allow
direnv: loading .envrc
...
New python executable in /home/myuser/untitled/.direnv/python-3.6.9/bin/python3
...
Installing setuptools, pkg_resources, pip, wheel...direnv:
done.
direnv: export +VIRTUAL_ENV ~PATH
As we can see in the output, the Virtual Environment was immediately created. The prompt is not modified though, so we won't see the name of the environment written at the beginning.
Now we can install the packages we need as we did on the environment we created in the previous section:
$ pip install -r requirements.txt
direnv will silently activate the environment in the background. Whenever we move out of the directory, the environment will be deactivated:
$ cd ..
direnv: unloading
If we can use any Python version that is installed on the system, direnv is all we need.
Let's suppose now that our pyweather script requires a very specific version though.
pyenv
pyenv is a version management utility for Python. It allows, among other things, to change Python versions on a per-project basis. direnv provides support for it since version 2.21.0, so together they can give us a higher level of control on the version we use in our environment.
Let's start by installing pyenv:
$ curl -L https://pyenv.run | bash
And then ensuring it will always be accessible to our terminal:
$ echo 'export PATH="~/.pyenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
$ source ~/.bashrc
Now let's suppose our pyweather script requires a very specific Python version, 3.6.2.
First, we need to install that version of Python:
$ pyenv install 3.6.2
And now we can configure our project to use the specific version:
$ echo 'layout pyenv 3.6.2' > .envrc
$ direnv allow
We can confirm all works as expected by checking the Python version in the environment:
$ python --version
Python 3.6.2
If we ever need to change the Python version, it will be enough for us to change the layout in the .envrc file.
Thanks to both utilities we can change the layout to any Python version, and our virtual environment will be updated right away.
Another advantage of using both direnv and pyenv is that we can version our .envrc file in our project repository.
That way all contributors will be able to configure their environment as intended by the project, as long as they install the utilities and Python version needed.
Conclusion
Virtual Environments are in a way detached from the Python development workflow. We need to remember to configure and activate it before working with our project. Thanks to direnv and pyenv we can automate all this, and entering the project folder will do all the work for us in the background.
Installation of both utilities is not straightforward, but after being done once we will save ourselves a lot of time. We will also always have the certainty that we are working with the right virtual environment and Python version.
Everything you ever wanted to know about the Cuban Missile Crisis, but were afraid to ask
Tom RocheNot quite as establishment-liberal as expected: pro-JFK, but very good pushback on RFK, esp his outright lies and the fake history that is "Thirteen Days"
In the latest of our series tackling the big questions on major historical topics, historian Mark White responds to listener queries and popular search enquiries about the Cold War nuclear confrontation between the US and the USSR. Historyextra.com/podcast
See acast.com/privacy for privacy and opt-out information.
The Anglo-Saxon Chronicles
Tom RocheVERY EXCELLENT
Historian Pauline Stafford shares the latest research and thinking on some of the most important historical sources from Early Medieval England. Historyextra.com/podcast
See acast.com/privacy for privacy and opt-out information.
Behind the News, 7/9/20
Tom Roche[Erin Thompson @ CUNY](https://www.jjay.cuny.edu/faculty/erin-thompson) on [art crime](https://www.artcrimeprof.com/) and the history of toppling statues • [Jennifer Cohen @ Miami U Ohio and U Witwatersrand](https://jecohen.wordpress.com/) on gendering the health and economic crises
David Abulafia on The Boundless Sea
Tom Rocheexclusive/longer version @ https://www.historyextra.com/period/medieval/david-abulafia-wolfson-history-prize-winner-on-the-boundless-sea/
Historian David Abulafia discusses his latest book, The Boundless Sea: A Human History of the Oceans, which was recently declared the winner of the prestigious Wolfson History Prize. Our conversation focuses in particular on the maritime history of the medieval era. Historyextra.com/podcast
See acast.com/privacy for privacy and opt-out information.
Combating the Political Power of the Rich: Wealth Taxes and Seattle Election Vouchers
Tom Rochepullquotes:
> [Us] rich do have a hugely disproportionate amount of political power, and we should be upset about this, but the fact is that we cannot plausibly hope to balance the scales by reducing their wealth, or at least not any time in the foreseeable future. There is an alternative route, which is both simple and already in practice: the [Seattle Democracy Voucher](https://www.seattle.gov/democracyvoucher/about-the-program) program.
...
> [We can use similar mechanisms] to support the media as well. Suppose that every adult had a $100 a year fully refundable tax credit to be used to support the creative worker or organization of their choice. This could include individual reporters, writers, musicians, singers, or any type of creative worker, or alternatively they could support an organization, such as a newspaper, a publisher, a movie production company or any other organization that supports creative work.
> There are two reasons for including creative workers more generally and not just journalists and news outlets in the list of potential beneficiaries. The first is that they have also seen plunges in revenue as a result of the Internet. The amount of spending for recorded music in particular has dropped by close to 90 percent over the last two decades. It is important to set up a new source of revenue to support creative workers.
> The other reason for extending eligibility beyond news media is that we don’t want the government to be in the business of deciding what qualifies as news. If a news outlet were to include opinion pieces or satire on political events, would the government allow it to get money designated for news reporting? If we draw the lines broadly, this should not be an issue. There will always be issues of outright fraud, which must be policed, but these should be far removed from anything resembling judgements about what constitutes proper news reporting and commentary.
...
> [a locality with a creative-worker voucher] could set itself up as an artistic mecca with this sort of system. It could just include a requirement that to be eligible to receive money through the voucher system, a person had to be physically present for at least nine months a year. This would attract musicians, singers, writers, and other creative workers, since they would want to be eligible for this pool of money. Furthermore, to make additional money and to increase the likelihood that residents would support them, they would want to perform their music, or offer workshops, or engage in other activities that would make them known to the community. These activities would also attract tourists from around the country.
I have written many times that I thought the focus on wealth inequality, as opposed to income inequality, was misplaced. There are many practical, political, and legal problems associated with taxing wealth that are considerably smaller when we talk about altering the economic structures that redistribute so much income upward.
But beyond the issue of whether inequalities of income or wealth are more easily tackled, there is also a very strange argument for focusing on wealth that is based on its impact on political power. The argument is that people like the Koch brothers or Mark Zuckerberg can gain enormous political power as a result of their immense wealth. Therefore, if we believe in democracy, we have to bring such outsized fortunes down to earth.
It is certainly true that the rich and very rich enjoy enormous political power under our current system, but it does not follow that attacking their wealth is the most effective way to restore a more functional democracy. To see this point, just imagine the most optimistic plausible scenario.
Let’s say that we get progressives in the presidency, a progressive majority in Congress, and can either get a sympathetic Supreme Court or find a workaround with a hostile court. Maybe in that scenario, we can get a wealth tax in place in eight to ten years. Then let’s say the tax has been in operation for ten years. Again, being optimistic but at least somewhat realistic, perhaps after ten years, we will have downsized the big fortunes, like those held by Koch and Zuckerberg, by 50 percent.
So, in this optimistic scenario, twenty years from now, Jeff Bezos will still have $80 billion, Bill Gates will have $50 billion, and Mark Zuckerberg will have $40 billion. Will the United States then have a functioning democracy, with everyone getting a more or less equal voice?
The point here is that the rich do have a hugely disproportionate amount of political power, and we should be upset about this, but the fact is that we cannot plausibly hope to balance the scales by reducing their wealth, or at least not any time in the foreseeable future. There is an alternative route, which is both simple and already in practice: the Seattle Democracy Voucher program.
This program gives Seattle residents four vouchers, worth $25 each, to be given to the candidate(s) of their choice. To be eligible to receive a voucher, a candidate must accept limits on both overall spending and the amount of money that they can get from any individual donor. This system has allowed many candidates to run competitive campaigns, without relying at all on getting the support of rich people.[1]
This sort of system of campaign finance focused on giving low and middle-income people a voice, will not necessarily be able to the match the millions or tens of millions that the very rich can shower on their favored candidates, but it is adequate to ensure that candidates appealing to the non-rich can get their arguments out. And, there is sufficient research to show that, while candidates need a certain amount of money to be competitive, the biggest spending candidate does not always win.
This raising of the voice of the bottom approach can be applied elsewhere, including to the media and creative work more generally. A major problem for those of us concerned about the future of democracy is the collapse of traditional newspapers and other print media. The Internet, and the rise of Facebook and Google, have deprived them of the advertising revenue they depended upon to survive. As a result, hundreds of newspapers have gone out of business in the last quarter-century, and even most of those that survive have hugely cut back on their staff of reporters.
The few outlets that still maintain a large staff of reporters, such as the New York Times and Washington Post, depend on the goodwill of rich people who are prepared to lose money or at least get well below market returns on the money they have invested in their papers. While it is great that some of the very rich are committed to helping maintain a vibrant press, this is not a viable long-term mechanism.
We can pick up on the Seattle democracy voucher approach to support the media as well. Suppose that every adult had a $100 a year fully refundable tax credit to be used to support the creative worker or organization of their choice. This could include individual reporters, writers, musicians, singers, or any type of creative worker, or alternatively they could support an organization, such as a newspaper, a publisher, a movie production company, or any other organization that supports creative work.
There are two reasons for including creative workers more generally and not just journalists and news outlets in the list of potential beneficiaries. The first is that they have also seen plunges in revenue as a result of the Internet. The amount of spending on recorded music, in particular, has dropped by close to 90 percent over the last two decades. It is important to set up a new source of revenue to support creative workers.
The other reason for extending eligibility beyond news media is that we don’t want the government to be in the business of deciding what qualifies as news. If a news outlet were to include opinion pieces or satire on political events, would the government allow it to get money designated for news reporting? If we draw the lines broadly, this should not be an issue. There will always be issues of outright fraud, which must be policed, but these should be far removed from anything resembling judgments about what constitutes proper news reporting and commentary.
The $100 figure is arbitrary, but even this modest sum could provide more than $20 billion a year to support creative work.[2] At a pay rate of $80,000 a year, this could support 250,000 journalists and other creative workers. It is also important to realize that this system does not preclude other mechanisms for raising revenue.
For example, newspapers can still sell print copies and get ads, as they do today. The big difference would be that this would not be their primary mode of raising revenue. Musicians, writers, and creative workers could still earn money from other sources, such as live performances or conducting workshops. So, the money they receive through this tax credit system would not be the sole support for newspapers and other creative work, but it would provide an enormously important supplement that could maintain a vibrant news media and creative sector that did not depend on the goodwill of a small number of very wealthy people.
Going Local
Another tremendously important aspect of this tax credit route is that it can be implemented at the state or even local level, as demonstrated by the Seattle democracy voucher program. The ability to start a measure like this at the state or local level is tremendously important given the improbability of major action addressing the unequal distribution of political power at the national level.
As a practical matter, it would be a relatively simple thing for a state or city to give each of its adult residents a voucher of $100 to support journalism and other creative work. To avoid freeloading by residents of other states or cities, it can even put up paywalls, as most newspapers do now. That way, if people in Chicago, or the state of Illinois, were prepared to use their vouchers to support a high-quality newspaper like the New York Times, they would be able to get free access themselves, but people elsewhere in the United States would have to pay, just as they do now for the New York Times.
On the creative worker side, a state or city going this route could set itself up as an artistic mecca with this sort of system. It could just include a requirement that to be eligible to receive money through the voucher system, a person had to be physically present for at least nine months a year. This would attract musicians, singers, writers, and other creative workers since they would want to be eligible for this pool of money. Furthermore, to make additional money and to increase the likelihood that residents would support them, they would want to perform their music, or offer workshops, or engage in other activities that would make them known to the community. These activities would also attract tourists from around the country.
The key point here is of course to establish an alternative mechanism for supporting independent media. If this can be done successfully in a city or state, it is likely to be emulated by others. Ideally, it would be adopted nationally, but even if just a small number of cities and states went this route it can provide a substantial measure of support that does not currently exist.
In any case, even a single city would be a big step forward. We can sit around and wait for the gods to make things work out to our liking so that there is a radical downward redistribution from the very rich to everyone else or we can take simple steps that will actually have an impact. We know liberal funders much prefer the former route, but anyone who actually gives a damn about inequality better be looking for things we can do now.
[1] There are comparable systems that amplify the voice of people with less money, such as the “super-match” system that New York City has in place for local elections. Under this system, small donations can be matched up to eight to one for candidates that limit their spending and large contributions and meet other criteria. The advantage of the Seattle system is that the vouchers can give a voice even to people who may find a small contribution to be a substantial burden.
[2] I would require a trade-off to be eligible for this money that the recipients could not also get copyright protection for their work. The government supports you once, not twice. If you take the money, then your work is in the public domain and can be freely reproduced and transferred. We want people to have access to the material that the government has paid for. I discuss the mechanics of this sort of system in more detail in chapter 5 of Rigged [it’s free].
The post Combating the Political Power of the Rich: Wealth Taxes and Seattle Election Vouchers appeared first on Center for Economic and Policy Research.
When Washington (Almost) Went Socialist: Seattle’s General Strike of 1919
Mike Davis on Covid-19, Street Uprisings & the Failure of Government
A History of Corporate Looting 1787 to Now
Tom Rochealas, waaay too much rant and almost no history: https://kpfa.org/episode/letters-and-politics-june-15-2020/
Dig: Mike Davis on Prisoners of the American Dream
Tom Rocheexcellent review of US labor history and its connection to US politics
Mike Davis on his classic book about why the US has long lacked strong socialist and labor politics. One recurrent answer: racism.
Read Dan's essay on the moment: jacobinmag.com/2020/06/donald-trump-war-american-democracy-riots-coronavirus
Not in the mood for a long, complex Dig interview? Check out Antibody, which is like commie This American Life: thedigradio.com/antibody
Support this podcast at Patreon.com/TheDig
"White Fragility," Plus Adolph Reed on Identity Politics
Tom Rocheall excellent: the '4 news food groups' opening, middle discussion on Taibbi's recent "White Fragility" piece, and the Reed interview
Matt and Katie discuss Matt's review of "White Fragility," Professor Adolph Reed joins to discuss identity politics
Learn more about your ad choices. Visit podcastchoices.com/adchoices
In ‘Russian Bounty’ Story, Evidence-Free Claims From Nameless Spies Became Fact Overnight
Tom Rocheexcellent esp pointers to problems (generally, as well as specifically in this story) with unnamed sources

The New York Times (6/26/20) front-paged what “intelligence says”—while offering very little explanation of why they say they believe it, or why we should believe them.
Based upon a bombshell New York Times report (6/26/20), virtually the entire media landscape has been engulfed in the allegations that Russia is paying Taliban fighters bounties to kill US soldiers.
The Washington Post (6/27/20) and the Wall Street Journal (6/27/20) soon published similar stories, based on the same intelligence officials who refused to give their names, and did not appear to share any data or documents with the news organizations. “The Wall Street Journal and the Washington Post have confirmed our reporting,” tweeted the Times article’s lead author, Charlie Savage. The Post’s John Hudson seemed to back him up: “We have confirmed the New York Times scoop: A Russian military spy unit offered bounties to Taliban-linked militants to attack coalition forces in Afghanistan,” he responded.
Yet these statements were categorically untrue. The Times stressed how unsure they were about the allegations, using qualifying language throughout, such as “it was not clear” and “greater uncertainty.” And Hudson’s own article uses the phrase “if confirmed” in relation to the bounty claims, explicitly conceding they are not confirmed.
Despite the fact that the anonymous accusations were far from proven, and that both the Post and Journal included categorical denials from all those involved, including the White House, the Taliban and Moscow, much of corporate media treated the story as an established fact from the outset. “This is jaw-dropping,” fumed MSNBC host Rachel Maddow (6/26/20) about the “sickening” news. She throws in an “if this Times report is correct” before going on to treat is as “confirmed” information:
You know from this reporting in the New York Times, which has since been confirmed by the Wall Street Journal, that not only does the president know that Russia was paying for American soldiers’ deaths, paying rewards for Americans dead…his response to that is nothing except a friendly call.
CNN (6/26/20) ran the headline “Russia Offered Bounties to Afghan Militants to Kill US Troops,” while the Guardian (6/27/20) went with a British variant, “Russia Offered Bounty to Kill UK Soldiers”—in both cases presenting the allegations as facts.
‘Officials Said’
This would be troublesome enough, but there are a number of reasons to be skeptical of the veracity of the claims. Firstly, the Times, Post and Journal’s reports are all based on fundamentally untrustworthy actors who refuse to go on the record. Here is a list of all the sources mentioned in the Times report:
- “According to officials briefed on the matter”
- “Officials said”
- “Officials said”
- “Officials said”
- “Said Dmitry Peskov, the press secretary for President Vladimir V. Putin”
- “Zabihullah Mujahid, a spokesman for the Taliban, denied”
- “The officials spoke”
- “Russian government officials have dismissed such claims”
- “Gen. John W. Nicholson Jr., the commander of American forces in Afghanistan at the time, said”
- “Officials were said to be confident”
- “Some officials have theorized”
- “Officials have also suggested”
- “The officials briefed on the matter said”
- “Western intelligence officials say”
- “American intelligence officials say”
- “American officials say”
- “Officials briefed on its operations say”
It is standard journalistic practice to name and check sources. The Society of Professional Journalists’ code of ethics insists that “reporters should use every possible avenue to confirm and attribute information before relying on unnamed sources,” and that we must “always question sources’ motives before promising anonymity,” because too many “provide information only when it benefits them.”
Without a name to go with the source, there are no consequences for sources (or journalists, for that matter) lying and spreading malicious rumors. Using an anonymous source is implicitly asking readers to trust a reporter’s judgment and credibility. The practice is less important with minor details in a story (e.g. “a city nurse said three people had been injured”), but grows exponentially more vital when the source is the basis for the article, and when there are massive consequences in publishing the story. That is why it should be reserved for whistleblowers or others facing serious harm if caught. The Times’ own guidelines on integrity strongly discourages the practice; “There is nothing more toxic to responsible journalism than an anonymous source,” wrote the paper’s public editor (New York Times, 5/30/04).
Allowing unnamed officials to set the agenda in news is something FAIR has constantly criticized (6/25/14, 3/29/16, 4/26/17), and regularly leads to outlets being burned (FAIR.org, 6/30/17, 12/3/18). Therefore, they should be used only when a reporter is completely confident in their veracity. Considering who the sources were for the Russian bounty scandal (intelligence officials), the story, as it was published, should never have left the drawing board. As we wrote recently (FAIR.org, 2/28/20):
It is the job of the covert security services to lie and manipulate. They are among the least trustworthy groups in the world, journalistically speaking, as part of their profession involves planting fake information. The only group less deserving of blind faith than spies would be anonymous spies.

Janine Jackson (Extra!, 11/11) noted that journalists’ anonymity agreement with official sources “works out swell for powerful people who’d prefer to avoid accountability for what they say, and terribly for citizens for whom that accountability is crucial.”
Unfortunately, reliance on such sources is near ubiquitous at the Times and the Post. In 2011, FAIR (1/11/11) found that virtually every article on Afghanistan appearing in the two outlets over the course of a week featured material from anonymous official US sources.
The information on the Russian bounties appears to have been both minimal and vague, with officials refusing to show any corroborating evidence or the documents they claimed to have, and were unable to link the accusations to any concrete, real-world events. Perhaps more solid information will be provided at a later date, but the fact that what has been presented so far has turned into a major story is bizarre in itself.
The first response of any credible journalist to receiving this tip, given to them by spooks who refused to put their names to it—and who freely admitted, as the Times report notes, that the information was derived from “interrogated” Afghan fighters, in a country were Human Rights Watch (4/17/19) says torture of detainees is “disturbingly high”—should have been to throw the story into the trash bin, at least until the officials agreed to go on the record. That the authors of the Times article share five Pulitzer Prizes between them suggests that this might not have simply been comically irresponsible and shoddy journalism, however, but something more intentional.
Endless War
As the three articles pointed out, the accusations come at a time when the Trump administration is negotiating with the Taliban and has committed to removing all troops from the country by next year (a move that is now being blocked by the House Armed Services Committee because of the bounty scandal). Crucial nuclear weapons limitations treaties are also expiring, with Moscow showing a keen interest in renewing them. But many officials argue the US should start a new atomic arms race, “spending” Russia into “oblivion.”

It’s bad news when the publication that tracks how close we are to the end of the world (Bulletin of the Atomic Scientists, 1/23/20) switches its gauge from minutes to seconds.
Partially in response to the increased tensions between the two nations, the Bulletin of the Atomic Scientists recently moved its famous Doomsday Clock up to 100 seconds to midnight, signalling that they believe the world is closer than it has ever been to Armageddon, even than during the Cuban Missile Crisis. This background should have been a red flag from the outset. It is rare that poor journalism threatens the fate of the planet, but increasing hostility between two nuclear-armed foes might be doing just that.
If the Taliban is indeed being paid to kill American servicemen and women, they are not doing a particularly good job of it. US losses in Afghanistan have slowed greatly, from dozens dying every month during President Obama’s surge to only 22 in the past year. Over 1,700 died under Obama, compared to just a few dozen under Trump.
To anyone concerned about protecting the lives of US troops, the logical answer would be to remove them from Afghanistan, as both Obama and Trump have promised. Yet very few of the countless reports questioned either the wisdom or the legitimacy of the 19-year US occupation of the country.
If the story is true, Russia would be mirroring semi-official US policy with regard to their own troops. In 2016, former acting CIA Director Michael Morell appeared on the Charlie Rose Show (8/8/16), and said it was his job to “make the Russians pay a price” for their role in the Middle East. When Rose asked if that meant killing Russians, he replied: “Yes. Covertly. You don’t tell the world about it. You don’t stand up at the Pentagon and say, ‘We did this.’ But you make sure they know it in Moscow.” Going further back, the US channeled vast amounts of money to the Afghan Mujahideen in the 1980s “to make sure Afghans could do everything possible to kill Russians, as painfully as possible,” in the words of influential Rep. Charlie Wilson.
The Plot Thickens?
Following up on the story, the New York Times published two further viral articles, claiming that Trump had been made aware of the Kremlin plot as early as February (6/29/20) and that Russia had sent large financial transfers to a Taliban-linked account (6/30/20). Yet both these stories suffered from the same deficiencies as the first one, depending on anonymous official sources making relatively unspecific claims while offering no evidence. Indeed, the unnamed “analysts” were only willing to say that the cash transfers were “most likely” part of the bounty scandal the Times had broken four days earlier. Yet the effect was to bolster the veracity of what had come before in many people’s minds.

One source for Business Insider (7/1/20) says ” it was well-known that groups in need of money could work with Russians,” another says “there were many affiliated groups that have maintained ties with Russia,” and the third is someone whose name Business Insider doesn’t know that it communicated with only through Facebook.
Meanwhile, Business Insider (7/1/20) ran a story “confirming” the unfolding bounty scandal, claiming that they had spoken to three Taliban sources who told them Russia and Iran offered them payments. As with the Times, however, the sources were unwilling to put their names to the accusations. Perhaps more comically, Business Insider admitted that it did not even know the name of one of the “Taliban commanders” it cited, communicating to him only via Facebook. If this is how credulous Business Insider is, I know a Nigerian prince who is eager to talk to them about an urgent business proposal.
Independent journalist Caitlin Johnstone (Medium, 6/28/20) suggested that corporate media could not be this obtuse, and that the affair suggested active collaboration between deep state and fourth estate, writing:
All parties involved in spreading this malignant psyop are absolutely vile, but a special disdain should be reserved for the media class who have been entrusted by the public with the essential task of creating an informed populace and holding power to account.
Media like the New York Times and Washington Post pour scorn on Trump administration officials daily, yet appear to display complete reverence to the national security state, treating three-letter agencies’ every utterance as gospel. In the wake of a number of high-profile police lies during the George Floyd protests, the Washington Post (6/30/20) reported that newsrooms across the country are reflecting on their relationship with law enforcement and will no longer accept “police said” as fact. Perhaps they should do the same with intelligence officials.
Jacobin Radio: Robert Brenner on Coronavirus
Tom Rocheexcellent, especially on the US Federal Reserve massive purchasing of corporate bonds
Suzi talks to Robert Brenner, who has just published “Escalating Plunder” in New Left Review 123, about the federal response to the shutdown of the economy in the wake of the coronavirus. The punchline is that the COVID-19 bailout, or Cares Act, not only escalates plunder, it is predation on steroids in a stalled economy in worsening decline. In other words, the bipartisan establishment has concluded that they can only intervene — and call it rescue — by underwriting the rip-off already in motion, bailing out the top 0.1 percent in the face of plunging production, employment, and profits. Brenner calls out predation. We get his analysis.
The Militarization Of Police
Tom Rochehttps://www.npr.org/2020/07/01/885942130/militarization-of-police-means-u-s-protesters-face-weapons-designed-for-war archived @ https://web.archive.org/web/20200702002541/https://www.npr.org/2020/07/01/885942130/militarization-of-police-means-u-s-protesters-face-weapons-designed-for-war
A Doctor Confronts Medical Error
Tom Rochehttps://www.npr.org/sections/health-shots/2020/06/30/885186438/a-doctor-confronts-medical-errors-and-flaws-in-the-system-that-create-mistakes archived @ https://web.archive.org/web/20200701235610/https://www.npr.org/sections/health-shots/2020/06/30/885186438/a-doctor-confronts-medical-errors-and-flaws-in-the-system-that-create-mistakes
Also, Ken Tucker reviews Bob Dylan's new album, 'Rough and Rowdy Ways.'
White Hawk Down: Ken Klippenstein & Julia Salazar on Eliot Engel
Tom Rochegood show, but Katie really should increase file compression--182 MB is waaay huge for audio of this length (~90 min)
William and Cnut: a tale of two conquerors
Tom Rocheinstead of this, get the extended/less-cut version @ https://www.historyextra.com/period/medieval/william-cnut-conquerors-emily-ward-podcast/
Historian Emily Ward, co-editor of a new book on the conquests of 1016 and 1066, explains how the earlier Danish invasion of England is crucial to our understanding of what happened 50 years later. Historyextra.com/podcast
See acast.com/privacy for privacy and opt-out information.
Americas Other Civil War
Prof. Michael Osterholm – Corona Virus Update
Behind the News, 6/25/20
Tom RocheNikhil Pal Singh @ NYU and Quincy Institute on race, class, policing, protest • Michael Kinnucan @ Brooklyn DSA’s electoral committee on left victories in the NYC primary elections
Ned Batchelder: Pickle’s nine flaws
Tom Roche> There are lots of other ways to serialize objects, ranging from plain-old JSON to fancier alternatives like marshmallow, cattrs, protocol buffers, and more.
Python’s pickle module is a very convenient way to serialize and de-serialize objects. It needs no schema, and can handle arbitrary Python objects. But it has problems. This post briefly explains the problems.
Some people will tell you to never use pickle because it’s bad. I won’t go that far. I’ll say, only use pickle if you are OK with its nine flaws:
- Insecure
- Old pickles look like old code
- Implicit
- Over-serializes
- __init__ isn’t called
- Python only
- Unreadable
- Appears to pickle code
- Slow
The flaws
Here is a brief explanation of each flaw, in roughly the order of importance.
Insecure
Pickles can be hand-crafted that will have malicious effects when you unpickle them. As a result, you should never unpickle data that you do not trust.
The insecurity is not because pickles contain code, but because they create objects by calling constructors named in the pickle. Any callable can be used in place of your class name to construct objects. Malicious pickles will use other Python callables as the “constructors.” For example, instead of executing “models.MyObject(17)”, a dangerous pickle might execute “os.system(‘rm -rf /’)”. The unpickler can’t tell the difference between “models.MyObject” and “os.system”. Both are names it can resolve, producing something it can call. The unpickler executes either of them as directed by the pickle.
More details, including an example, are in Supakeen’s post Dangers in Python’s standard library.
Old pickles look like old code
Because pickles store the structure of your objects, when they are unpickled, they have the same structure as when you pickled them. This sounds like a good thing and is exactly what pickle is designed to do. But if your code changes between the time you made the pickle and the time you used it, your objects may not correspond to your code. The objects will still have the structure created by the old code, but they will be running with the new code.
For example, if you’ve added an attribute since the pickle was made, the objects from the pickle won’t have that attribute. Your code will be expecting the attribute, causing problems.
Implicit
The great convenience of pickles is that they will serialize whatever structure your object has. There’s no extra work to create a serialization structure. But that brings problems of its own. Do you really want your datetimes serialized as datetimes? Or as iso8601 strings? You don’t have a choice: they will be datetimes.
Not only don’t you have to specify the serialization form, you can’t specify it.
Over-serializes
Pickles are implicit: they serialize everything in your objects, even data you didn’t want to serialize. For example, you might have an attribute that is a cache of computation that you don’t want serialized. Pickle doesn’t have a convenient way to skip that attribute.
Worse, if your object contains an attribute that can’t be pickled, like an open file object, pickle won’t skip it, it will insist on trying to pickle it, and then throw an exception.
__init__ isn’t called
Pickles store the entire structure of your objects. When the pickle module recreates your objects, it does not call your __init__ method, since the object has already been created.
This can be surprising, since nowhere else do objects come into being without calling __init__. The logic here is that __init__ was already called when the object was first created in the process that made the pickle.
But your __init__ method might perform some essential work, like opening file objects. Your unpickled objects will be in a state that is inconsistent with your __init__ method. Or your __init__ might log information about the object being created. Unpickled objects won’t appear in the log.
Python only
Pickles are specific to Python, and are only usable by other Python programs. This isn’t strictly true, you can find packages for other languages that can use pickles, but they are rare. They will naturally be limited to the cross-language generic list/dict object structures, at which point you might as well just use JSON.
Unreadable
A pickle is a binary data stream (actually instructions for an abstract execution engine.) If you open a pickle as a plain file, you cannot read its contents. The only way to know what is in a pickle is to use the pickle module to load it. This can make debugging difficult, since you might not be able to search your pickle files for data you are interested in:
>>> pickle.dumps([123, 456])
b'\x80\x03]q\x00(K{M\xc8\x01e.'
Appears to pickle code
Functions and classes are first-class objects in Python: you can store them in lists, dicts, attributes, and so on. Pickle will gladly serialize objects that contain callables like functions and classes. But it doesn’t store the code in the pickle, just the name of the function or class.
Pickles are not a way to move or store code, though they can appear to be. When you unpickle your data, the names of the functions are used to find existing code in your running process.
Slow
Compared to other serialization techniques, pickle can be slow as Ben Frederickson demonstrates in Don’t pickle your data.
But but..
Some of these problems can be addressed by adding special methods to your class, like __getstate__ or __reduce__. But once you start down that path, you might as well use another serialization method that doesn’t have these flaws to begin with.
What’s better?
There are lots of other ways to serialize objects, ranging from plain-old JSON to fancier alternatives like marshmallow, cattrs, protocol buffers, and more.
I don’t have a strong recommendation for any one of these. The right answer will depend on the particulars of your problem. It might even be pickle...
emacspeak: Learning Rust: Programming The Pick-Up Sticks Game
Tom Rochenote especially the part about configuring emacs for LSP--that's almost certainly the way to go forward for language IDEs (not, e.g., Semantic)
Learning Rust: The Pick-Up Sticks Game
1 Overview
This directory contains an implementation of the Pick Up Sticks game
described in my paper Thinking Of Mathematics (Section 5).
It's an interesting experience writing it in Rust as I learn the
language. The original implementation described in my paper was
written in 1987 in Fortran-77, and consisted of one single
function. Though that style of programming would be frowned upon today
and is clearly not advisable for programming in the large, it's
interesting to observe that a more structured implementation as seen
in this Rust implementation qrequires a lot more fore-thought with
respect to code organization.
2 Programming Environment
here is a short overview of the programming environment used:
- Emacs 28.0.50 with emacspeak 52.0.
- Package
eglotfor managing the project with an LSP server. - Rust Language Server (RLS) as the LSP server.
- Package
companyfor completion. - Package
yasnippetfor code templates. - Package
rust-modefor Rust editing smarts. - Package
racerfor additional cross-referencing and
documentation support. - Package
cargofor cargo integration from inside Emacs.
In the process of setting up my Rust environment, I also
speech-enabled Emacs packages rust-mode, racer and cargo for Emacspeak.
3 Books
I downloaded The Rust Programming Language (2018) from Bookshare
and it's what I am still using as I write this. Note that this book is
also available in the Rust distribution. The version in the Rust
distribution is a little less usable since it's split into multiple
smaller HTML files with each file repeating a lot of navigational
boiler-plate at the top.
4 Experience Learning Rust
I usually find that I learn a language better if I write some code as
I learn the language.
In this instance, I decided to program the pick-up-sticks game — a
simple game that I programmed in 1987 for the final class project for
CS-101 at IIT-Bombay. Here are the rules of the game:
- This is a two-player game and the game starts with \(n\) sticks.
- The first player can pick at most \(n-1\) sticks.
- Assume a player picks \(k\) sticks. At the subsequent turn, opponent
can pick at most \(2 * k\) sticks. - The player who is able to clean-up the remaining sticks while
adhering to the rules is the winner.
Read Thinking Of Mathematics (Section 5) for a description of an
algorithm that is guaranteed to win.
5 The Implementation
Learning Rust's ownership rules for memory management, and learning to
use references the Rust way were some of the things that were unique
to this learning experience.
Rust has some unique features including declaring lifetimes that are
typically needed in more advanced cases; however in my initial
attempts, not doing things the Rust way caused compile-time errors
that initially guided me toward using and declaring
lifetimes. Eventually, all of those declarations became unnecessary.
More generally, the Rust compiler turns out to be a very good Rust
teacher.
6 Crux Of The Implementation
See module game.rs for the implementation. The core of the
implementation is still a handful of lines to implement the winning
strategy of:
- If the number of sticks at the start is a Fibonacci number, ask
the opponent to play first. - At each turn, force the opponent toward the closest Fibonacci number.
- Do above while respecting the limit rule, i.e. if you pick \(k\)
sticks, the opponent can pick up to \(2k\) sticks, so never pick \(k\)
where \(3k >= n\). - The result of (3) is to subdivide the game into smaller games
when playing with larger values of \(n\) — see the while loop in
methodmy_move.
7 Closing Thoughts
- The computing environment I now have is far more sophisticated
than what I had in 1987. - Today, I have interactive completion, source-code
cross-references, on-the-fly access to documentation, and a fully
accessible book where I can look up things whenever I want. - In 1987, I did most of my thinking and problem-solving in my
dorm-room with no computer to hand. When ready with the solution,
I made a few notes in Braille using a pocket-slate and stylus,
then went to the computer room with a volunteer reader and typed
up the program, with the student volunteer providing high-quality
interactive spoken feedback. - Interestingly, I think it took me less time from memory to
implement the solution in 1987 — perhaps this is time shrinking
with number of years passed. - Either way, the primary take-away is that it pays to analyse a
problem before one actually starts writing code. Writing code is
always fun, and today, even more so given the excellent array of
tools — but unless one focuses on the problem at hand, one can
spend a lot of time sharpening one's pencils as opposed to
writing something useful.
Everything you ever wanted to know about the civil rights movement, but were afraid to ask
Tom Rochevery vanilla
In the latest of our series tackling the big questions on major historical topics, historian Kevin Gaines responds to listener queries and popular search enquiries about the American civil rights movement. Historyextra.com/podcast
See acast.com/privacy for privacy and opt-out information.
Bird Migration
Tom Rochererun
Assessing COVID-19 Risk As The U.S. Reopens
Tom Rochehttps://www.npr.org/2020/06/17/879255417/amid-confusion-about-reopening-an-expert-explains-how-to-assess-covid-risk (archived @ https://web.archive.org/web/20200618010104/https://www.npr.org/2020/06/17/879255417/amid-confusion-about-reopening-an-expert-explains-how-to-assess-covid-risk )
Your Brain, Free Will and the Law
Tom RocheVERY EXCELLENT! Basically "god in the gaps" applied to determinism. Approximate pullquote: free will is only what biology can't yet explain.
Stanford University neuroscientist Robert Sapolsky talks about human behavior, the penal system and the question of free will.
Learn more about your ad choices. Visit megaphone.fm/adchoices