19 settembre, 2019

Visto nel Web - 432

Un protagonista assoluto, visto da tutti in modo molto negativo. Anche se gli dobbiamo tante cose, GNU, Emacs e tutta una vision (dai posso usarla almeno una volta?). È che gli americani sono rigorosi su certe cose, mica come noi che continuamo con Silvio et al. Intanto ecco cosa ho wisto nel Web.


Richard M. Stallman
protagonisti
::: bcantrill ::: Slashdot ::: m__toffanin ::: conservancy ::: dcavedon ::: nmcgovern ::: fsf ::: Slashdot ::: zacchiro ::: zacchiro ::: docfreeride ::: vmbrasseur ::: joshsimmons ::: wonderchook ::: mlemweb ::: ahcohen

Europe's Space Industry Is Working On Reusable Rockets With Environmentally-Friendly Fuel
spazio, esplorazione
::: Slashdot

#Apple ha solo il 15% del mercato degli #smartphone
dispositivi mobili
::: Luca_Gualtieri1

Java EE 'Goes All In' on Open Source with Jakarta EE 8
linguaggi di programmazione | open source
::: Slashdot

Was Advertising in Open Source Software a Useful Experiment?
open source | ad, pubblicità
::: Slashdot

Once upon a time C++ compiler for Unix was $500-$4,000 (that's $1,000-$7,000 in today's money). BYTE from Feb 1991
storia
::: unix_byte

Congratulations to @fairphone for hitting the maximum 10/10 repairability score at @ifixit with their 3rd model. Well deserved after so much hard work. I wish the right to #repair would be a more important topic for of the Free Software movement
hardware | economia, lavoro
::: jaromil

Public service announcement: Dear programmers, NOT LETTING ME CUT/PASTE A PASSWORD MAKES MY ACCOUNT *****LESS***** SECURE. There is a circle of hell reserved for you if you don't allow paste into a password field. Regards, Your Customers
privacy, sicurezza, spionaggio, virus
::: allenholub

The UK now intends to keep #Assange locked up AFTER completing his sentence
politica | Web, Internet
::: GordonDimmack

🔵 Oggi edizione speciale della mia newsletter #Guerredirete con un approfondimento su Hacks, leaks e intelligence: misteri e ambiguità di una guerra ibrida 😎
privacy, sicurezza, spionaggio, virus | politica
::: carolafrediani ::: carolafrediani

Pirati
umorismo
::: AgoristN

#Huawei ha iniziato a vendere alcuni #laptop con #Linux pre-installato
Huawei | Linux
::: sdallagata

The next generation of aircraft will track your bathroom visits
privacy, sicurezza, spionaggio, virus | economia, lavoro
::: business

We are a long way from AI systems that can read the news, re-plan supply chains in response to anticipated events like Brexit or trade disputes, and adapt production tasks to new sources of parts and materials
artificial intelligence
::: fabiochiusi


#France and #Germany agree to block #Facebook's #Libra
blockchain e crypto*
::: mcanducci

Oltre 100.000 opere in openlibrary.org
open source | Wikipedia
::: WikimediaItalia

Released from Prison, Spammer Who Stole 17.5 Million Passwords Apologizes and Reforms
privacy, sicurezza, spionaggio, virus
::: Slashdot

If you're into #bitcoin you should be looking at #DeFi. This shit is as cypherpunk as it gets - upending the financial system using technology
blockchain e crypto*
::: safetyth1rd

Python 2 Sunsets in 107 Days. JPMorgan Isn't Ready
Python
::: Slashdot

LoL! It's a pity that I don't own any pet...
uh! quasi ora di cambiare nome a Simo, Martin e Ty
umorismo
::: TuxmAL

IOS 13 Lock Screen Lets Anyone See Your Address Book
privacy, sicurezza, spionaggio, virus
::: Slashdot

Ex-Google worker fears 'killer robots' could cause mass atrocities
Nolan “has called for all AI killing machines not operated by humans to be banned.
(She) said killer robots not guided by human remote control should be outlawed by the same type of international treaty that bans chemical weapons”
robots, automazione
::: fabiochiusi

This is a must-read thread by a former intelligence worker that definitely does not go the direction you would expect
Edward Snowden
::: Snowden

A scheme to wasm compiler
Scheme | linguaggi di programmazione
::: wilbowma

The Next Energy-Efficient Architecture Revolution: A House Built By Robots
innovazioni, futuro | robots, automazione
::: Slashdot

More public resources could be managed as commons, which means that public assets are owned, managed and distributed for the common good. How about starting with critical immaterial assets, such as our data that we collectively produce? Our data, our future
open source | dati, raccolta
::: francesca_bria


Here's an amazing fact about Numpy. Don't fall into this trap!
Python | bug | (forse)
::: fchollet

FCC Fails, Robocalls (and Complaints) Increase, Along with Number-Hijacking
privacy, sicurezza, spionaggio, virus | web-bot, robocall
::: Slashdot

Online Lenders Publicly Shame Debtors in the Philippines Using Their Facebook Contacts
social media
::: Slashdot

Amazon-owned Whole Foods’ decision to drop health benefits for hundreds of part-time workers reveals how promises to workers like CEO Jeff Bezos’ recent pledge are worthless
protagonisti | economia, lavoro
::: LeslieMac

Linux 5.3 Released
Linux
::: Slashdot

MIT Unveils the World's Most Advance Carbon Nanotube Chip
innovazioni, futuro | hardware
::: Slashdot

Permanent Record by Edward Snowden review – the whistleblower’s memoir
Edward Snowden
::: RadioProzac ::: marcoscan ::: fabiochiusi ::: xor

The art of epicycles
matematica
::: Nereide

La follia dei token "virtuali"​ nel PSD2
privacy, sicurezza, spionaggio, virus | hardware
::: cmnit

La laurea 👩‍🎓 in Italia non vale praticamente un caz 🆘 ma non prendetevela con l’università bensì con quelle PMI che non hanno né margini né voglia di pagare un cent per maggiori professionalità e potenzialità, anzi le temono 🤬
scuola, educazione, cultura | lavoro
::: Forchielli

How long until someone claims the power to predict who a child will become as an adult based on these data points? At a time when the desire for metrics seems boundless, what if developments tracked online could translate into a personal capital score?
social media
::: FrankPasquale

Le soleil se lève sur Nice, laboratoire en France de la Safe City et de la surveillance totale de l'espace urbain. C'est cette ville que nous avons choisi pour lancer un mouvement de résistance à la #Technopolice
privacy, sicurezza, spionaggio, virus
::: laquadrature

la catastrofe dell’immaginazione, in cui siamo talmente immersi da non accorgercene, forse è urgente quanto quella climatica. E se servisse un “digital new deal”, accanto a un “green new deal”?
Web, Internet
::: CBlengio


Is Britain heading for a #GeneralElection? The country's political parties definitely think so -- they've spent £1m, collectively, since June on @Facebook political ads & are harvesting vast amounts of voter data. Welcome to Britain's digital phony war
politica | social media | dati, raccolta
::: markscott82

Which countries reduced their fossil CO₂ emissions the fastest (over a 10 year period), while still maintaining positive economic growth (& outside of economic crises)?
ambiente, ecologia
::: Peters_Glen

🔴🗞️ Quante imposte hanno versato all'@AE_Riscossione 7 "giganti del web" nel 2018? Fate un respiro: appena 37 milioni di euro! Le briciole del #profitshifting societario dal Belpaese
ditte | economia, lavoro
::: MasloMisha

Everywhere your phone travels becomes a part of your #PermanentRecord
privacy, sicurezza, spionaggio, virus
::: Snowden

La #Cina, al fine di sfruttare al meglio l’#intelligenzaartificiale nel settore del delivery, inizierà a costruire circa 15 #hub logistici nazionali già quest’anno
Cina | artificial intelligence
::: GenertecItalia

hmac — Cryptographic Message Signing and Verification
Python
::: pymotw

Serve una legge per la Pa per la trasparenza negli algoritmi - L’appello di Matthias Spielkamp, fondatore di AlgorithmWatch @algorithmwatch
algoritmi, codice | privacy, sicurezza, spionaggio, virus
::: Nova24Tec

Russia Carried Out a 'Stunning' Breach of FBI Communications System, Escalating the Spy Game on US Soil
privacy, sicurezza, spionaggio, virus | politica
::: Slashdot

👶 New Google baby monitor could use #AI to alert parents before infant awakes 💪 inform caregivers up to 10 minutes ahead of them waking
artificial intelligence
::: matthewjmiller7

Mozilla and Creative Commons Want To Reimagine the Internet Without Ads, and They Have $100M To Do It
Web, Internet | ad, pubblicità
::: Slashdot

The doctors who helped Facebook check an anti-abortion video have written in the @washingtonpost about the dangerous impact of the video staying up without the factcheck
disinformazione, fake news, bufale
::: firstdraftnews

Amazon Changed Search Algorithm in Ways That Boost Its Own Products
ditte
::: Slashdot


The function of good software
cit.
::: RichRogersIoT

Cina in Italia, l'analisi di @dlfabbri: Italia non terminale, ma strumento, condotta per arrivare al cuore dell'Europa. A Pula centro d'innovazione Huawei su nuove tecnologie e 5g, Trieste dal punto infrastrutturale è una città ausburgica
Cina | 5G
::: LalaHu9 ::: simopieranni

Robot jokes
umorismo
::: dcavedon

CBS and MIT's 1960 Documentary On AI Is a Gem
storia | artificial intelligence
::: Slashdot

Facebook Advertisers Can Write Their Own Headlines For Shared News Stories
Facebook
::: Slashdot

The Sapporo Dome in Japan can be converted between baseball and soccer with a removable baseball field and a retractable soccer field
tecnologia
::: MachinePix

So this just happened
web-bot, robocall
::: gabro27

Why Facebook’s 'Values' Update Matters
I wrote about why it's worth paying attention to a short, understated blog post from Facebook last week that was actually far more than PR-fluff
Facebook
::: evelyndouek

Here's a text-generating AI that invents a convincing news story based off the link you give it - even a fake one, like with this example, (falsely) announcing Trump's arrest. It's written well enough probably to fool a lot of people. Wild days ahead
artificial intelligence
::: drewharwell

The rule of law prevailed today! Six years after @Snowden's revelations, the High Court of South Africa declared that bulk interceptions practices are unlawful
privacy, sicurezza, spionaggio, virus
::: privacyint

HK riots collateral effects: the launch of the new online banks will be delayed to early 2020. Among the operators with a license #Tencent, #Xiaomi, Ant financial #Alibaba. Effetti collaterali delle proteste, l'autorità monetaria di HK fa slittare il debutto delle banche online
politica | economia, lavoro | Cina
::: ritafatiguso

Il nuovo sottosegretario all’editoria Martella: ”rivolgendosi ai giovani, una fascia della popolazione più facilmente esposta ai pericoli delle fake news”. Temo sia vero l’esatto contrario
disinformazione, fake news, bufale
::: mante

The growing popularity of cosmetic surgery is proving a challenge for facial recognition technology
riconoscimento facciale
::: fabiochiusi


Facebook: "we removed multiple Pages, Groups and accounts that were involved in coordinated inauthentic behavior on Facebook and Instagram. We found two separate, unconnected operations that originated in Iraq and Ukraine"
Facebook
::: fabiochiusi

Tutto Zuck minuto per minuto (sì, titolo cambiato da me, non c'era)
Facebook
::: PaoloBarucca

Nice, emblème de la #Technopolice
privacy, sicurezza, spionaggio, virus
::: Marne_

Rotate a video file by 90 degrees CW
(non provato)
tip, suggerimenti
::: commandlinefu

Setting up a Linux Javascript Dev Environment on Windows
Windows does a lot of things well; setting up development environments isn't always one of them. So I thought I would install Windows and see how close I can get to making it Linuxy...
sistemi operativi | programming, codice, snippet
::: TheLinuxDev

Making the Black Box Speak:Towards a Renegade Aesthetics of Resolution
media
::: mayameme

Google Preps 'Smart Screenshots' Feature To Let You Search With a Screenshot
innovazioni, futuro
::: Slashdot

Square Wants To Be a Bank But Doesn't Want To Be Taxed Like One
economia, lavoro
::: Slashdot

Sono appena caduto in una truffa online
umorismo
::: Dio

The Internet Relies on People Working for Free
open source
::: Slashdot

La France doit donner asile à Edward Snowden
Edward Snowden
::: ahcohen

Remember that time ages ago when Norbert Weiner cautioned that democratic countries will find themselves tempted to turn to automation to deal with threats posed by authoritarian regimes and thus risk becoming more authoritarian themselves?
privacy, sicurezza, spionaggio, virus
::: EvanSelinger


As the classifications of humans by AI systems becomes more invasive and complex, their politics become apparent... Forms of measurement easily — but surreptitiously — turn into moral judgments
riconoscimento facciale
::: AINowInstitute

Ma chi l’avrebbe mai detto! Pensa un po’ che grande novità! 🙄
frodi
::: phretor

HP Printers Try To Send Data Back To HP About Your Devices and What You Print
economia, lavoro
::: Slashdot

Oracle Built a Raspberry Pi Super Computer That Looks like a TARDIS
hardware
::: dcavedon

Firefox is Switching to a Monthly Release Cycle
browser
::: dcavedon

The U.S. national laboratories plan to do big things with the world's biggest chip. For one, it'll help the labs' supercomputers ramp up their AI smarts at blazing speeds
innovazioni, futuro
::: IEEESpectrum

New release of multi-backend Keras: 2.3.0
deep learning
::: fchollet

There are over 6,000 open source repos created by the US Government
open source
::: lisaironcutter

RaspberryPiで使うAdafruit SSD1306 OLEDのCommon Lispライブラリ作った
Lisp
::: fireflower0

hide-and-seek game developed by OpenAI shows that for AI agents, self-play “is enough for the agents to learn surprising behaviors on their own—it’s like children playing with each other”
artificial intelligence | machine learning
::: IEEESpectrum ::: gdb

catastrophic effects of working as a Facebook moderator
"Job has left some ‘addicted’ to extreme material and pushed others to far right"
Facebook
::: fabiochiusi

Elliot Schrage famously took the fall over Facebook's scandal with oppo research firm Definers, creating cover for Sheryl Sandberg. A year after "leaving" the company, he's still there... full-time
Facebook
::: tayhatmaker

Ok, so what should you know about the Facebook's Oversight Board?! What the heck is this thing, where did it come from, and why should you care about the documents they released today?
Facebook
::: Klonick


Facebook Enlists Ray-Ban Maker To Help Develop Secret 'Orion' Smart Glasses
augmented reality
::: Slashdot

This #robot from @FarmWiseLabs uses computer vision and machine learning to provide "personalized care" to every plant it touches
robots, automazione
::: IEEESpectrum

Amazon Music Rolls Out Lossless Streaming Tier
Web, Internet
::: Slashdot

It is great to see the city of Rome joining the Cities Coalition for Digital Rights and leading projects on free software, education, digital democracy & empowerment. Welcome on board!
OK, ma Roma? con la Raggi? dubbioso, assay 🤔: prima vedere metro e cassonetto (& non buca)
tecnologia
::: francesca_bria ::: PoliticaPerJedi

AI Surveillance is Expanding Worldwide
privacy, sicurezza, spionaggio, virus
::: Slashdot

Join the revolution! #UBports #UbuntuTouch
Ubuntu | dispositivi mobili | sistemi operativi
::: UBports

Complexity
cit.
::: RichRogersIoT

Researchers Uncover 125 Vulnerabilities Across 13 Routers and NAS Devices
privacy, sicurezza, spionaggio, virus
::: Slashdot

Facebook Expands Definition of Terrorist Organizations to Limit Extremism
Facebook
::: fabiochiusi

Survival of the Richest - The wealthy are plotting to leave us behind
I think people fail to realize Elon Musk and the Paris Climate Accords were neoliberals last and best effort. Their plan now is going to Mars or build bunkers
protagonisti | politica
::: Lalat1na

Tonight, my kid's teacher presented us a new website
privacy, sicurezza, spionaggio, virus
::: fs0c131y

#criptovalute, Banca centrale cinese sembra voler rallentare #Libra
blockchain e crypto*
::: LalaHu9


Don't fall for fake Ad blockers ⚠ Use Adblock Plus or any other with a known site/company/devs behind 👍
privacy, sicurezza, spionaggio, virus | ad, pubblicità
::: WebReflection

My fav answer of the day is ...
umorismo
::: sanacl

My job market paper "No Rage Against the Machines" is now available on @SSRN. Informing the public about automation's threat to their jobs made them more concerned about workplace automation but did not change their policy preferences
robots, automazione
::: baobaofzhang

A software developer who doesn’t understand composition is like a home builder who doesn’t know about bolts or nails. Building software without awareness of composition is like building a home with duct tape and crazy glue
programming, codice, snippet | linguaggi di programmazione
::: RichRogersIoT

SpaceX is trying to buy an entire village inside its Texas rocket-launch site because it 'did not anticipate' there'd be any 'significant disruption' to residents who live there
spazio, esplorazione
::: CadieThompson ::: emenietti

3 reasons #FacialRecognition must be banned
riconoscimento facciale
::: libertyhq

"In a nutshell, the algorithms 'learn' how to tell the difference between bullies and typical users by weighing certain features as they are shown more examples." This is a bad idea - trolls are a moving target - something AI is terrible at
Twitter
::: Boring_AI

Getting started with JavaParser: analyzing Java Code programmaticall
linguaggi di programmazione
::: ftomasse

How China Unleashed Twitter Trolls to Discredit Hong Kong’s Protesters
This king of in-depth analysis is made possible by the data that Twitter made public. Chinese operations on Facebook and YouTube can't be understood in the same way because neither company released any data, including the accounts or their content
politica | Cina | troll
::: JaneLytv

The closest thing I've seen to something relatively revolutionary is @racketlang in that it's designed specifically to enable you to write your own domain-specific languages. This seems to have been the natural progression of many young languages: evolutions from userland. /3
language Racket | linguaggi di programmazione
::: elazar

Several parallel #antitrust investigations regarding big tech's practices are underway
antitrust
::: juanof9

Crypto-mining Malware Saw New Life Over the Summer as Monero Value Tripled
blockchain e crypto* | frodi
::: Slashdot

Google swallows DeepMind Health
But as of now there are no plans to replace the ethics panel, so there is little clarity on who will oversee the work Google does with the data of NHS patients
artificial intelligence | Google
::: ORARiccardo

18 settembre, 2019

Copia di oggetti in Python


In qualche misura è la continuazione di questo post, anche se il titolo dev'essere completamente differente.

Esaurito il capitolo global ci sono ancora un paio di aspetti che a volte --se non faccio attenzione-- non vanno come --ingenuamente-- mi verrebbe da pensare; anche se... --OK, racconto.

Passando oggetti diversi da numeri a una funzione cosa succede? Devo elencarli nel return? o preoccuparmi del valore originale? Un esempio che chiarisce (dovrebbe, spero).

def func(i, f, ls, dic, st):
    i = i * 2
    f = f * 3
    ls[0] = 'cambio'
    ls[1] = 'qui'
    dic['due'] = 2
    st = st.upper() + ' modificata'
    return i, f, st

# main
i = 4
f = 1.2
ls = [1, 2, 3, 4]
dic = {'uno' : 1}
st = 'stringa'
ir, fr, stm = func(i, f, ls, dic, st)
print(i, f)
print(ir, fr)
print(ls)
print(dic)
print(st)
print(stm)


eseguo e ottengo:

$ py3 obj.py
4 1.2
8 3.5999999999999996
['cambio', 'qui', 3, 4]
{'uno': 1, 'due': 2}
stringa
STRINGA modificata
$


Uh! vediamo in dettaglio:
  • i valori originali delle variabili numeriche (i e f) non cambiano e i valori dell'elaborazione devo elencarli in return e tra quanto ritorna la funzione (ir e fr);
  • la lista (ls) passata alla funzione viene modificata, e ritornata modificata, l'originale è perso;
  • la stessa cosa capita per i dizionari (dic), le tuple, gli array, e altri oggetti (non presenti nell'esempio);
  • le stringhe (che in certi linguaggi sono array, p.es C) si comportano come i numeri.

C'è un altra cosa che a volte... copiare oggetti. Ecco un esempio con le liste:

a = [1, 2, 3]
print(a)
b = a
b[0] = 'X'
print(a)
print(b)


$ py3 cp1.py
[1, 2, 3]
['X', 2, 3]
['X', 2, 3]
$


OOPS! la modifica di b ha modificato a! non quello che mi aspettavo. C'è il modulo copy per questo con due funzioni per copiare. Uso liste per gli esempi, ovviamente vale non solo per loro.

la funzione copy.copy() funziona solo per le liste lineari (non so se il termine è corretto), cosi:

import copy

a = [1, 2, 3]
print(a)
b = copy.copy(a)
b[1] = 'X'
print(a)
print(b)


$ py3 cp2-0.py
[1, 2, 3]
[1, 2, 3]
[1, 'X', 3]
$


ma non per liste dentro la lista:

import copy

a = [1, [2, 'a', 'b'], 3]
print(a)
b = copy.copy(a)
b[1][1] = 'X'
print(a)
print(b)


$ py3 cp2-1.py
[1, [2, 'a', 'b'], 3]
[1, [2, 'X', 'b'], 3]
[1, [2, 'X', 'b'], 3]
$


in questo caso devo ricorrere a copy.deepcopy()

import copy

a = [1, [2, 'a', 'b'], 3]
print(a)
b = copy.deepcopy(a)
b[1][1] = 'X'
print(a)
print(b)


$ py3 cp3.py
[1, [2, 'a', 'b'], 3]
[1, [2, 'a', 'b'], 3]
[1, [2, 'X', 'b'], 3]
$

🔴

17 settembre, 2019

Visibilità (scope) delle variabili - 1


Continuo da qui la serie di post elementari sui linguaggi con visibilità delle variabili lessicale e/o dinamica. Però ormai parlo di un argomento collegato, più personale, probabilmente interessa solo me.

Ah! una cosa in parte OT: mi sono letto i documenti citati in bibliografia da Ming-Ho (non tutti, confesso), avendo tempo ci sono cose interessanti, qualcuna la sapevo, altre meno. Ma il solito problema: il tempo.

Questo post arriva in cascata alla serie ma è diverso, forse sono solo io che ho fatto confusione, voglio chiarirmi un po' meglio come Python e JavaScript considerano le variabili, globali e locali. Un post molto semplice, didascalico, solo per me (probabilmente, come già detto).

Normalmente le variabili (numeriche, vedremo prossimamente che per gli oggetti valgono altre leggi) sono passate come valore alle funzioni e nel chiamante il loro valore non muta. Esempio, in Python:

def f():
    print('f()', x)
    return x

def g(n):
    x = n
    print('g()', n, f())
    return f()

# main
x = 1
print('start x =', x)
print(x, f(), g(2), x, f())
x = 5
print('cambio x =', x)
print(x, f(), g(3), x, f())


$ py3 s-n.py
start x = 1
f() 1
f() 1
g() 2 1
f() 1
f() 1
1 1 1 1 1
cambio x = 5
f() 5
f() 5
g() 3 5
f() 5
f() 5
5 5 5 5 5
$


Stesso comportamento con JavaScript con l'avvertenza di definite con var le variabili locali, altrimenti sono globali:

function f() {
    console.log('f()', x)
    return x
}

function g(n) {
    var x = n
    console.log('g()', n, f())
    return f()
}

// main
x = 1
console.log('start x =', x)
console.log(x, f(), g(2), x, f())
x = 5
console.log('cambio x =', x)
console.log(x, f(), g(3), x, f())


$ node s-n.js
start x = 1
f() 1
f() 1
g() 2 1
f() 1
f() 1
1 1 1 1 1
cambio x = 5
f() 5
f() 5
g() 3 5
f() 5
f() 5
5 5 5 5 5
$


OK, finora tutte le variabili sono locali (in realtà c'è la sola x in g()); Per operare con variabili globali in Python uso l'instruzione global globalmente, cioè esterna alle funzioni. Ma in questo caso il comportamento è diverso da come potrebbe apparire (è un errore!): la x in g() è locale:

global x

def f():
    print('f()', x)
    return x

def g(n):
    x = n
    print('g()', n, f())
    return f()

# main
x = 1
print('start x =', x)
print(x, f(), g(2), x, f())
x = 5
print('cambio x =', x)
print(x, f(), g(3), x, f())


$ py3 s-ge.py
start x = 1
f() 1
f() 1
g() 2 1
f() 1
f() 1
1 1 1 1 1
cambio x = 5
f() 5
f() 5
g() 3 5
f() 5
f() 5
5 5 5 5 5

$

Risulta che il valore di x in g() non ha influenza su f() perché questa è globale e non relativa a g().

Per chiarire uno script ancora più focalizzato

global x
x = 1

def g(n):
    print(x) # <- errore qui, x non è definita
    x = n
    print(x)

#main
g(2)
print(x)


eseguendola si ottiene un errore:

$ py3 gl.py
Traceback (most recent call last):
  File "gl.py", line 10, in <module>
    g(2)
  File "gl.py", line 5, in g
    print(x)
UnboundLocalError: local variable 'x' referenced before assignment
$


commentando la print iniziale in g() risulta come in g() x sia locale:

$ py3 gl.py
2
1
$

In JavaScript, dove le variabili sono globali di default:

function f() {
    console.log('f()', x)
    return x
}

function g(n) {
    x = n // modif qui, x è globale
    console.log('g()', n, f())
    return f()
}

// main
x = 1
console.log('start x =', x)
console.log(x, f(), g(2), x, f())
x = 5
console.log('cambio x =', x)
console.log(x, f(), g(3), x, f())


$ node s-ge.js
start x = 1
f() 1
f() 2
g() 2 2
f() 2
f() 2
1 1 2 2 2
cambio x = 5
f() 5
f() 3
g() 3 3
f() 3
f() 3
5 5 3 3 3

$

OOPS! in questo caso la x in g() determina il valore di f(). Ho cioè un comportamento diverso per i due linguaggi, cosa che almeno per me induce errori se non si presta la dovuta attenzione. (Sì, sono ripetitivo).

Da sempre si usano variabili globali ma per quanto è possibile queste vanno limitate per quanto possibile. La variabile x in g() che voglio globale la dichiaro global all'interno della funzione; la chiamata a g() sarà diversa a quella ad h() dove x è locale. Peraltro diventa importante l'ordine delle chiamate:

def f():
    print('f()', x)
    return x

def g(n):
    global x
    x = n
    print('g()', n, f())
    return f()

def h(n):
    x = n
    print('h()', n, f())
    return f()

# main
x = 1
print('start x =', x)
print(x, f(), g(2), x, f())

x = 5
print('cambio x =', x)
print(x, f(), g(3), x, f())

x = 8
print('cambio x =', x)
print(x, f(), h(4), g(3), x, h(6), f())


$ py3 s-gl.py
start x = 1
f() 1
f() 2
g() 2 2
f() 2
f() 2
1 1 2 2 2
cambio x = 5
f() 5
f() 3
g() 3 3
f() 3
f() 3
5 5 3 3 3
cambio x = 8
f() 8
f() 8
h() 4 8
f() 8
f() 3
g() 3 3
f() 3
f() 3
h() 6 3
f() 3
f() 3
8 8 8 3 3 3 3

$
JavaScript, per quanto precedentemente detto è in questo caso più intuitivo

function f() {
    console.log('f()', x)
    return x
}

function g(n) {
    x = n // modif qui, x è globale
    console.log('g()', n, f())
    return f()
}

function h(n) {
    var x = n // x è locale
    console.log('h()', n, f())
    return f()
}

// main
x = 1
console.log('start x =', x)
console.log(x, f(), g(2), x, f())
x = 5
console.log('cambio x =', x)
console.log(x, f(), g(3), x, f())
x = 8
console.log('cambio x =', x)
console.log(x, f(), h(4), g(3), x, h(6), f())


$ node s-gl.js
start x = 1
f() 1
f() 2
g() 2 2
f() 2
f() 2
1 1 2 2 2
cambio x = 5
f() 5
f() 3
g() 3 3
f() 3
f() 3
5 5 3 3 3
cambio x = 8
f() 8
f() 8
h() 4 8
f() 8
f() 3
g() 3 3
f() 3
f() 3
h() 6 3
f() 3
f() 3
8 8 8 3 3 3 3
$


OK, ma le liste? Uh! per le liste (gli oggetti) questo non vale, come vedremo prossimament, non cambiate canale 🙂
🔴

15 settembre, 2019

Visto nel Web - 431

Ultime novità, o almeno quello che ho wisto nel Web.


being a developer is great, until you find companies like @NetTalent, who harvest your email fuck knows from where and send you scammy email that force you to accept terms you cant even read, so they can spam you more #recruiters #scammersspam
::: vikkio88

Apple's iPhone 11 Pro Is Triggering 'Fear of Holes' Or Trypophobia In Some
hardware
::: Slashdot

Most Android Flashlight Apps Request An Absurd Number of Permissions
applicazioni, programmi
::: Slashdot

Sono sopravvissuto all'aggiornamento 1903. Il bug più grosso però non l'hanno ancora risolto
sistemi operativi | umorismo
::: cobrampi

This page explains it very well now. App need to follow OS configured default. Turn off DoH, Firefox. Now
privacy, sicurezza, spionaggio, virus
::: nixcraft

The papers want Congress to move quickly on passing their safe harbor bill so that they have the leverage to demand more money for their content from Google and Facebook
media
::: fabiochiusi

"How can Facebook avoid charges of 'bias' when the entire nature of editorial decision-making is to privilege one set of views over another?" Facebook is hiring human editors. But Facebook is not an editorial company, and has no idea what it is in for.
Facebook
::: jayrosen_nyu

Everything Google Has Said On The Nofollow Link Attribute Change
privacy, sicurezza, spionaggio, virus
::: Gianlucadfiore

Someone stole my debit card, went and spent $60 at a restaurant and only left a $4 tip. It’s not even your card, and you leave a $4 tip
privacy, sicurezza, spionaggio, virus | umorismo
::: Stremlau5

.@coe Committee on AI to explore feasibility of legal framework for AI based on human rights, democracy & rule of law
artificial intelligence | politica
::: MullerCatelijne

If people don’t start saying nicer things about the new iPhones
umorismo
::: JonyIveParody

so the CJEU has just voided the German #Leistungschutzrecht (on procedural grounds) which was the model for the new press publishers right that was introduced in the #copyright directive
copyright e brevetti | censura
::: communia_eu ::: FixIt_EU

Bel pezzo di @AlessLongo su @Nova24Tec di oggi su #AutomatingSociety e il lavoro di @algorithmwatch per comprendere e regolare il ruolo del decision-making automatico nelle politiche pubbliche
algoritmi, codice | artificial intelligence
::: fabiochiusi


McDonald's Is To Replace Human Workers With Voice-Based Tech In US Drive-Throughs
robots, automazione
::: Slashdot

Facebook disables Netanyahu chatbot over hate speech
odio, razzismo, discriminazioni
::: FT ::: sdallagata ::: fabiochiusi

As the 2020 race heats up, here’s how @nytimes politics reporter @AllMattNYT is preparing for an onslaught of intentional falsehoods
disinformazione, fake news, bufale
::: journalismfest

Recent allegations have "intensified concerns about China exporting its digital surveillance tools to Africa. But Western companies are also selling spyware on the continent"
privacy, sicurezza, spionaggio, virus
::: Samuel_Woodhams

Amazon Will Let Anyone Answer Your Alexa Questions Now
social media
::: Slashdot

A seminal paper on automated #decisionmaking: "Auditing Algorithms : Research Methods for Detecting Discrimination on Internet Platforms"
algoritmi, codice | odio, razzismo, discriminazioni
::: GianlucaSgueo

PC Shipments On The Decline
hardware | economia, lavoro
::: Slashdot

Spotify Wants To Know Where You Live and Will Be Checking In
privacy, sicurezza, spionaggio, virus
::: Slashdot

A radically open approach to developing infrastructure for #OpenScience
open source
::: zacchiro

In the era of Big Data, we’ve come to believe that, with enough information, human behavior is predictable. But number crunching can lead us perilously wrong
dati, raccolta
::: aimeevanrobot

Loot Boxes in Games Are Gambling and Should Be Banned For Kids, Say UK MPs
games
::: Slashdot


Twitter blocks accounts of Raul Castro and Cuban state-run media
censura
::: Reuters

Silicon photonics can send a mind-boggling 1200 gigabits per second on a single color in an optical fiber
innovazioni, futuro
::: jeffhecht

A $30 Device Turns the Cold of Outer Space Into Renewable Energy
da verificare
energia
::: Slashdot ::: Slashdot

L'ultima mossa di #Huawei. Ren Zhengfei a Economist e NYT: Pronti a condividere la tecnologia 5G con aziende Usa (dietro pagamento di fee), affinché possano costruire la loro industria 5G. Ciò garantirebbe equilibrio fra Cina, Usa e Europa. Come risponderà l'amministrazione Trump?
Huawei | 5G
::: LalaHu9

Google collects face data now. Here's what it means and how to opt out
Face Match is a feature on Google's new Nest Hub Max that uses a front-facing camera and always-on facial recognition software to help it identify which household member is currently using it
riconoscimento facciale
::: fabiochiusi

.@Corriere: il vostro reload automatico degli articoli—per gonfiare artificialmente le visite web—è semplicemente insopportabile
media
::: zacchiro

Bitcoin isn't a get rich quick scheme
blockchain e crypto*
::: lopp

How the government is using Siri and Alexa to stop the spread of Census misinformation
social media
::: fabiochiusi

Google One Now Backs Up Texts, 'Original Quality' Photos, and Videos on Android
dati, raccolta | dispositivi mobili
::: Slashdot

Al buio metto il pigiama, per 3 volte mi sono accorto di averlo infilato al contrario
umorismo
::: Dlavolo

Tech is a bastion of liberalism
tecnologia
::: fchollet

Not only is UNIX dead
devo indagarci su
cit.
::: RichRogersIoT

ALMAObs J.C.Roja

Will China's massively-integrated-grid model come to North America? Or will the U.S. "build a wall" keeping the plan at bay?
Cina | energia
::: IEEESpectrum

I've tweeted for many years about how awful Richard "RMS" Stallman is - the pedophilia, the ableism, the misogyny
thread
protagonisti | odio, razzismo, discriminazioni | open source
::: sarahmei ::: mattl ::: blakersdozen ::: MarkCC

CRISPR Gene-Editing May Offer Path To Cure For HIV, First Published Report Shows
innovazioni, futuro
::: Slashdot

Google has adjusted its search algorithms to promote news articles it considers “significant original reporting”, its latest move to support journalism following years of criticism
Google | media
::: rasmus_kleis ::: fabiochiusi

Stare dietro a uno schermo non è la stessa cosa che guardare negli occhi una persona. I commenti sui social rivelano tutta la nostra debolezza emotiva
social media
::: SergioGridelli

How much do engineers make?
U.S. Engineering Salaries Jump; Smartphone Developers Win Big
economia, lavoro | lavoro | tecnologia
::: IEEESpectrum

Roberto Saviano e Edward Snowden: "Lotto perché Internet torni di nuovo libero. Zuckerberg? Si pentirà"
politica | privacy, sicurezza, spionaggio, virus
::: oh_luca

False statements about climate change trip people up
ambiente, ecologia
::: RadioProzac

(Only in China) Huawei Just Started Selling Laptops With A Beautiful Linux OS Pre-Installed
Huawei | Linux
::: dcavedon

Here is the transcript of @TheEconomist's interview with Ren Zhengfei, the 74-year-old boss of Huawei. Near the end, he jokes about retiring soon and becoming my assistant (I took that to mean the former was as improbable as the latter)
Huawei
::: studersc

SpaceX Says It Will Deploy Satellite Broadband Across US Faster Than Expected
spazio, esplorazione | Web, Internet
::: Slashdot


Our new @MakEY_Project paper is open access: "Makerspaces in early childhood education: principles of pedagogy and practice"
scuola, educazione, cultura
::: jackiemarsh

Updating the Values That Inform Our Community Standards
Facebook
::: fbnewsroom

Just priceless. An estimated 20% of genetic research papers contain errors because Excel converted some gene names into calendar dates
applicazioni, programmi
::: LukasSchlogl

if you early return a for/of or a generator loop in Chrome 51 it breaks everything we should all try stop supporting old versions of evergreen browsers nobody uses anyway, 'cause testing all of them to grant results is quite unrealistic, and time consuming 😢
programming, codice, snippet
::: WebReflection

If Occupy Created Bitcoin... Sparkle is the world's first redistributive money
blockchain e crypto*
::: beingMicahWhite

Finance Minister Bruno Le Maire said Libra posed financial risks and could be open to abuse. However, he did not spell out how France could keep Libra out of the 28-member European Union
Facebook | blockchain e crypto*
::: fabiochiusi ::: Slashdot

Finnish Public Broadcasting Company, Yle, (...) is hoping to harness the engagement power of gamification to accelerate awareness and understanding of troll tactics and help more people spot malicious Internet fakes
disinformazione, fake news, bufale
::: fabiochiusi

This story by @a_greenberg - published in 2018 and excerpted from his forthcoming book "Sandworm" (https://bit.ly/2kfXw4K)- reminds us of the crucial importance of #cybersecurity in an increasingly #interconnected world
The Untold Story of NotPetya, the Most Devastating Cyberattack in History
privacy, sicurezza, spionaggio, virus | frodi
::: Nereide

Searching YouTube across 10 languages, the BBC found more than 80 videos containing health misinformation - mainly bogus cancer cures. Ten of the videos found had more than a million views. Many were accompanied by adverts
disinformazione, fake news, bufale
::: Mantzarlis

se non l'avete letto, ve lo raccomando assolutamente: Come i servizi segreti inglesi hanno neutralizzato il giornale progressista leader in UK: #Guardian
politica | censura
::: SMaurizi

Toyota Is Trying To Figure Out How To Make a Car Run Forever
energia
::: Slashdot

zuck, non ci prendi mai
Facebook
::: emenietti


Q&A: How Google Implements Code Coverage at Massive Scale
In our experience, code review is the cornerstone of code health
programming, codice, snippet
::: IEEESpectrum

Los Angeles OKs a Deal For Record-Cheap Solar Power and Battery Storage
energia
::: Slashdot

Oggi Super Mario compie 34 anni
games
::: _mattux_

T-Mobile Has a Secret Setting To Protect Your Account From Hackers That it Refuses To Talk About
dispositivi mobili | privacy, sicurezza, spionaggio, virus
::: Slashdot

Congress Is Investigating Apple's Repair Monopoly
politica | hardware | Apple
::: Slashdot

Regular Expressions are SO EASY!!!!
umorismo
::: garabatokid

Assange pourrait passer le reste de sa vie en prison pour avoir offert à toute la presse à travers @wikileaks les preuves de crimes de guerres des USA en Irak. Les générations futures se souviendront de notre passivité
politica | Web, Internet
::: PaulMoreiraPLTV ::: zacchiro ::: SMaurizi

iPhone 11 Lineup Said To Include Two-Way Charging Hardware, But Software Disabled
Apple
::: Slashdot

Giant Entercom Radio Network Gets Ransomwared
frodi
::: Slashdot

Another blog post, part 8 already: Implementing PEG Features
programming, codice, snippet
::: gvanrossum

Alabama Tracking Students' Locations To Penalize Them For Leaving Games Early
privacy, sicurezza, spionaggio, virus
::: Slashdot

Disney CEO Bob Iger Resigns From Apple Board As Companies Come Into Conflict On Streaming
ditte
::: Slashdot


Volkswagen's Bold Plan To Create a New Car OS
sistemi operativi
::: Slashdot

that feeling when you look in the lens documentation and discover there’s a function that does *exactly* what you want, but it’s also an infix operator with the name <<%= and you know that if you actually use it your coworkers are going to kill you
programming, codice, snippet
::: lexi_lambda

To all the Haskellers who have ever told me that Rust’s success wasn’t heavily based on the success of their community culture, I present this subreddit thread where “community” (or related concepts) is called out >15 times as a reason for its success
linguaggi di programmazione
::: jkachmar

La gente passa le giornate ad immortalare situazioni che non vive per l'ansia di immortalarle. #instagram
cit.
::: Genjuro75

This hovercraft is so awesome!
innovazioni, futuro
::: DigitalTrends

Lol, about that WSJ story on criminals using AI to generate a deepfake-style voice and trick a company into handing over money. The insurance company that made the claim admits it does not have evidence and it could have just been a human impersonating
OK, così suona meglio
artificial intelligence | :fake | frodi
::: josephfcox

Welcome to social paranoia by default: automated plate-reading cameras in every corner, smart video doorbells and -- of course -- a social network where to discuss and report each and every suspicion. Wasn't Silicon Valley supposed to liberate us?
tecnologia | social media
::: fabiochiusi

The onus is on the companies. If they can't protect human rights, they need to enact safeguards. And if it's an industry that can never be in line with human rights, it's up to the state to do what it needs to do
privacy, sicurezza, spionaggio, virus
::: fabiochiusi

House Committee Requests Tech Executives’ Emails in Antitrust Probe
ditte | politica
::: emenietti

Linux Foundation Survey Proves Open-Source Offices Work Better
open source
::: Slashdot

I'm doing my best to divulge how "zero knowledge proofs" work and can be used to implement "attributed bases credentials", see this #tutorial any feedback is very welcome at this stage, as a final 1.0.0 release is approaching #crypto #bitcoin
blockchain e crypto*
::: jaromil


So I get stopped in the hallway as I’m carrying this old computer that I need to copy the files, and one of the chiefs asks: ‘What are you doing with this machine?’ And I look at him frankly and I say: ‘Stealing secrets’
politica | censura
::: Snowden

Lol this is pure gold: “With iOS 13, we’ve included
umorismo
::: fabiochiusi

SimJacker, la vulnerabilità che consente di intercettare tutte le SIM del mondo
bug
::: lucaferrari15

14 Essential Ubuntu Keyboard Shortcuts
Ubuntu
::: dcavedon

It is honestly sad to see the BTC community stray so far from the ethos of "not your keys, not your BTC"
blockchain e crypto*
::: iamDCinvestor

Culture numérique pour milliardaires dégénérés
tecnologia | etica
::: RadioProzac

Google Unveils Code Completion Powered by Machine Learning in Dart SDK
machine learning
::: Slashdot

Day 5 #CryptoCrazy week! “The most significant investment opportunity of a generation," says Investor @Travis_Kling founder of @Ikigai_fund adding “This technology was the most important innovation since the internet”
blockchain e crypto*
::: jchatterleyCNN

What is #Bitcoin
blockchain e crypto*
::: Xentagz

Pare che la maggior parte delle persone decida per il primo
umorismo
::: real_fabristol

Here's my conversation with François Chollet (@fchollet) about Keras, @TensorFlow, deep learning, and the future of AI research & scientific progress in general
artificial intelligence | deep learning
::: lexfridman

Speeding up independent binary searches by interleaving them
programming, codice, snippet
::: lemire