Quantcast
Channel: Planet Python
Viewing all 22420 articles
Browse latest View live

Mike Driscoll: Python 101 2nd Edition Kickstarter Ending in Two Days

$
0
0

My Kickstarter for the 2nd Edition of Python 101 is ending in less than two days. If you want a signed copy or to purchase one of my other books for a discount, you should check out the Kickstarter as I have lots of good deals on there.

Python 101 2nd Ed Kickstarter

Also, note that the 2nd Edition of Python 101 is a complete rewrite. This book will have all new content and is on track to be one of my longest books. I think you will really like it if you are a beginner learning Python or someone who has been using Python but would like to improve to the next level.

The post Python 101 2nd Edition Kickstarter Ending in Two Days appeared first on The Mouse Vs. The Python.


Doing Math with Python: Coding Starter Kit Humble Bundle

$
0
0

I am very excited to share that "Doing Math with Python" is part of No Starch Press's Coding Starter Humble Bundle. Of course, you get No Starch Press's other excellent coding books as part of the bundle.

It's on for the next 20 days!

Humble Bundle

Your purchases will help support the No Starch Foundation and Scratch Foundation.

Get the bundle here.

Podcast.__init__: Getting A Handle On Portable C Extensions With hpy

$
0
0
One of the driving factors of Python's success is the ability for developers to integrate with performant languages such as C and C++. The challenge is that the interface for those extensions is specific to the main implementation of the language. This contributes to difficulties in building alternative runtimes that can support important packages such as NumPy. To address this situation a team of developers are working to create the hpy project, a new interface for extension developers that is standardized and provides a uniform target for multiple runtimes. In this episode Antonio Cuni discusses the motivations for creating hpy, how it benefits the whole ecosystem, and ways to contribute to the effort. This is an exciting development that has the potential to unlock a new wave of innovation in the ways that you can run your Python code.

Summary

One of the driving factors of Python’s success is the ability for developers to integrate with performant languages such as C and C++. The challenge is that the interface for those extensions is specific to the main implementation of the language. This contributes to difficulties in building alternative runtimes that can support important packages such as NumPy. To address this situation a team of developers are working to create the hpy project, a new interface for extension developers that is standardized and provides a uniform target for multiple runtimes. In this episode Antonio Cuni discusses the motivations for creating hpy, how it benefits the whole ecosystem, and ways to contribute to the effort. This is an exciting development that has the potential to unlock a new wave of innovation in the ways that you can run your Python code.

Announcements

  • Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.
  • When you’re ready to launch your next app or want to try a project you hear about on the show, you’ll need somewhere to deploy it, so take a look at our friends over at Linode. With 200 Gbit/s private networking, node balancers, a 40 Gbit/s public network, fast object storage, and a brand new managed Kubernetes platform, all controlled by a convenient API you’ve got everything you need to scale up. And for your tasks that need fast computation, such as training machine learning models, they’ve got dedicated CPU and GPU instances. Go to pythonpodcast.com/linode to get a $20 credit and launch a new server in under a minute. And don’t forget to thank them for their continued support of this show!
  • As a developer, maintaining a state of flow is key to your productivity. Don’t let something as simple as the wrong function ruin your day. Kite is the smartest completions engine available for Python, featuring a machine learning model trained by the brightest stars of GitHub. Featuring ranked suggestions sorted by relevance, offering up to full lines of code, and a programming copilot that offers up the documentation you need right when you need it. Get Kite for free today at getkite.com with integrations for top editors, including Atom, VS Code, PyCharm, Spyder, Vim, and Sublime.
  • You listen to this show to learn and stay up to date with the ways that Python is being used, including the latest in machine learning and data analysis. For even more opportunities to meet, listen, and learn from your peers you don’t want to miss out on this year’s conference season. We have partnered with organizations such as O’Reilly Media, Corinium Global Intelligence, ODSC, and Data Council. Upcoming events include the Software Architecture Conference in NYC, Strata Data in San Jose, and PyCon US in Pittsburgh. Go to pythonpodcast.com/conferences to learn more about these and other events, and take advantage of our partner discounts to save money when you register today.
  • Your host as usual is Tobias Macey and today I’m interviewing Antonio Cuni about hpy, a project aiming to reimagine the C API for Python

Interview

  • Introductions
  • How did you get introduced to Python?
  • Can you start by describing what the hpy project is and how it got started?
    • What are the goals for the project?
    • Who else is involved?
  • How much engagement have you had with CPython core contributors or the steering council?
  • Who are the consumers of the current C API for the CPython implementation?
    • What are some of the pain points or shortcomings for those consumers?
    • What impact does that have for users of a given library that leverages C extensions?
  • Can you talk through the structure of the hpy project?
    • What are some of the design challenges that you are facing for determining the external API?
    • What is involved in integrating the hpy interface into alternate runtimes such as PyPy or RustPython?
  • What is the potential or observed performance impact for libraries that currently rely on the existing C API?
  • How has the vision and scope of this project been updated as you have gotten further along in the implementation?
  • What are the downstream impacts that you anticipate in projects such as PyPy and Cython?
  • What have you found to be the most challenging or contentious aspects of implementing hpy so far?
  • What are some of the most interesting/unexpected/useful lessons that you have learned while working on hpy?
  • What do you have planned for the near to medium term for hpy?

Keep In Touch

Picks

Links

The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA

EuroPython: EuroPython 2020 and COVID-19

$
0
0

As you probably already know, the Coronavirus is spreading throughout Europe and we wanted to give you an update on our current plans around on the situation.

We will update this blog post as new information becomes available.

2020-03-12:

The number of cases in Ireland is still low compared to other countries, but the Irish government is already starting to put limited bans on larger indoor events.

Since EuroPython is planned for July 20-26, we are hopeful that the situation will have improved by then and continue the conference planning with the aim of having the conference on the planned date.

We would still like to ask all attendees to take the necessary and recommended hygienic precautions when attending the event and pay close attention to your country’s travel guidelines. If you don’t feel well, please do not attend the conference - instead, please follow the COVID-19 advice of the Irish Health Service. We will refund your ticket.

Should the conference need to be canceled as a result of the official ban still being in effect in July, we will refund all tickets - even after the official refund cut-off date (June 19th). We are in discussion with the venue to explore options in case the conference has to be canceled, which we will share with you soon as we have any update.

Because the situation is very much in flux, we would recommend that you make booking arrangements with an option to cancel the booking closer to the event date.

Resources:

Thanks,

EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/

EuroPython: EuroPython 2020: Going virtual EuroPython 2021: Dublin, Ireland

$
0
0

In our blog post on the COVID-19 last week, we were still hopeful that the situation would improve in time for the event in July. The last few days have shown us that we need to have a more realistic view on how things will develop in the coming months.

Right now, we are at a point in the conference organization where we have invested a lot of time into the preparation of the conference, but have not started ticket sales, entered sponsorship agreements or ordered conference and marketing material.

We also had discussions with the venue and caterer on possible options to address the risk of not being able to hold the event in July due to government regulations preventing indoor gatherings.

EuroPython 2021

In our EuroPython Society Board call last night, we discussed the situation, looked at the options and decided to take the offer of the venue to postpone the in-person conference to next year.

EuroPython 2021 will be held in Dublin, Ireland, from July 26 - August 1.

image

How about a virtual EuroPython 2020 ?

Since we all love EuroPython, the community and good vibes coming from such gatherings, we are now considering turning this year’s EuroPython 2020 conference into a virtual event.

image

For this, we’d like to gather some feedback and have created a form for you to let us know what your thoughts are on such a virtual setup:

EuroPython 2020 going virtual feedback form

If we go for the virtual setup for EuroPython 2020, the dates will likely change a bit, so ticket sales will start a little later. For now, we will leave the EuroPython 2020 Call for Proposals (CfP) open. Please note that those talks will then have to be held from your notebook/desktop without face-to-face audience contact. On the other hand, many more people could join in, since there’s no travel involved. We will aim to make the virtual event as interactive as possible.

Code name: EuroPython Winter Edition

While we’re at it, we’d also like to use the form to gather some feedback on the idea to have a winter EuroPython event, one where we run a BarCamp/Sprint/Hackathon style setup in a smaller setting.

Thanks,

EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/

Holger Krekel: Message to my IT/hacking friends (Mar17)

$
0
0

Some thoughts and advises on March 17 from BB33, a little office and hackerspace in Freiburg in the black forest. Sitting here alone. My 8yo and partner are good, a few streets further, as is her family, for now. My sisters and many other friends are less well but i won’t detail this here. School has ended but my 8yo is totally angry with Covid-19 … is asking if it could be killed by throwing a host of atomic bombs on it … to which my answer is: “nuclear power can not kill covid-19 even it would kill all human life on the planet. But yes, sincerely, i understand your frustration — let’s take a bicicly ride together.”

If you are like me and many of my friends you’ll get a host of demands because suddenly remote learning and working is in so many minds, also minds who have access to money while others are in urgent need. How to react and how to care?

TLDR; care less about work and exams and office work. Covid-19 induces planetary-scale changes and we need to act situational, not blindly bound by rules but with a caring attitude and focused on our neighborhoods, city and regional-level happenings.

How are you today?

How is your family, friends and the many strangers of your physical neighborhood? Can you personally talk to younger and older people to help them navigate and adjust to the new paraonia-normal? This is a time of massive fears and we need to talk with each other, 1:1 and in small groups and with strangers. Find and give emotional backing.

Now i didn’t talk about you yet … because i don’t know you and i’ll probably never get to know you, certainly never fully. I don’t even know myself fully. Each one of us is unique and has a unique situation — some have a sister who just went through intensive care because of lung problems, another has caring duties for someone with dementia or works in a care-home. Yet others have lost relatives in a different country who are experiencing far worse troubles and fear than you are. Use the phone if you can, make a call for those you care for. Don’t be angry with people who are upset and in fear. Relate humanly.

Take Breaks from the digital, repetitively

Take breaks from the digital. There are shitloads of news and now is the time to stop this bad habit of “news binging”, of trying to not miss a thing. You will miss tons of things — the question is: are you aware of and empathic with situations around you, first neighbors around your own living place, then the quarter, the city, the region and other states? You will also get filtered news from friends — try to make sure it’s scientifically rooted info, filter out bullshit before your communicate it to others.

The biggest challenge for most of us is an emotional one and dealing with fears. This will come in waves and be unevenly distributed. You can not constantly care for others, though. Try to establish rhythms of online/offline-ness that are healthy for your emotional state. Help others to re-arrange. Nobody has lived through a crisis at this planetary scale.

Avoid “White knight” syndrome and profit motives

Try to get rid of the “White Knight” syndrome and the feeling of urgency to save the world. This is a deep running emotional arrangement especially with us male folks. And then we want to be applauded and seen as heroes or winners. This approach is dangerous on a planetary scale. Don’t think about platforms and how to promote your project now. On the other hand, onboard those who want to help with your resilience and decentralization and care projects.  Resist urgency, care for yourselves and others.

Question your motivation if you or colleagues now are “out to make a profit” while disregarding the catastrophe unfolding around them. Just because you are physically safe and well-prepped doesn’t mean you’ll have a nice live if people and caring collapses around you. Those “profiteering” people will not be looked on nicely for the times to come.

Stop Community transmissions, soften police shutdowns

It’s not easy for anybody to stop habits and doing what you did just a few days ago. Don’t wait for orders from above before you move. Don’t take it from me but take it from the WHO Executive director who has personally crisis-managed multiple Ebola-outbreaks:

https://twitter.com/ConallMcD/status/1238865202868883461

It doesn’t matter how dangerous Covid-19 really is — we can not wait to first be sure of what is going to happen before we move. You can reasonably assume Covid-19 is deadly for many and you are transmitting it, the young folks who want to party are transmitting it, and people in the bakery next door who cling to their practice of walking into a tight shop situation, are transmitting it. And the logistics people who are bringing your remotely ordered packages, are transmitting it. Stay distant, teach others.

Try to help yourselves and others. All collective grouping and action is now based on social distancing (IOW: on respecting people’s safe spaces and demanding respect). However, the many people who care for the ill, work in critical logistics, operate power plants, telecommunications and water physical infrastructure, fire departments etc. … they all can not avoid to get into contact with others. Some of them are fighting in a war-like situation. Support them however you can. Don’t hoard, but share and help.

You might do a walk with a dear friend — just keep distance. If others don’t manage to do it, including groups of young kids, or people in disarray, or people clinging to their work because of fears and habit … empathize with them, help them to re-arrange. Suggest other community action than drinking and sitting together closely. This is all not only about cleaning your hands but looking out for others (young and old around you, physically) who cling to social practices that help Covid-19 spread.

If we can’t stop community transmission the government will need to do a partial/total police enforced lockdown. This would be a pity because it’s great to be able to walk out alone or with a socially distant yet dear friend, even make some music together etc.

For others like my italian friends it’s already too late, they are locked into their flats. But they sing on the balconies together — there is always a human, caring and playful option left in any crisis situation!

Question your work place and what you can do now

Re-evaluate what remains important or what new importances emerges. A few random takes:

  • support your local infrastructure: health and caring folks, sellers of medicine and food, those who transport away your garbage, homeless people — don’t look at it from the angle of regulations but of actual situations. Can the hotels who lost all tourists be talked to to accommodate homeless people and help them arrange in a socially distant manner?
  • Can hotels and other free facilities be prepared to accommodate refugees? In Europe we need to find a way to help Greece and the refugee situation there — the Merkel Gov promised to fly 1500 unaccompanied children — let’s designate an area where they can be quarantined and cared for. This would be a signal also against the uncaring right wing who will sooner or later try to pin blame on “the people abroad”.  Sidenote: I feel sorry for those folks who currently have to deal with authoritarianism (right or left wing). My best remote advise is: try to ignore and work around, move underneath and in between. Look out for co-operation and not for fights.
  • Covid-19 is pretty egalitarian and doesn’t care very much if you are rich or poor, white, brown, yellow, green or black … male or female. Here it will be crucial to overcome what is called “social darwisnism” because nobody wants to live in a world driven by acceptance and ignorance of old, disadvantaged or fleeing people dying  miserably. Consider helping to free prisoners who are in only for minor things and maybe take them to hotel rooms with a phone. Imagine yourselves in a prison being shut out from relatives and friend visits and calls, in the current situation.
  • Can you talk with city and regional governments folks and see what you can arrange with them? If you find un-cooperative people ignore them, don’t fight them. Save your energy for useful co-operations. Political reckonings can wait.
  • Is your work that you have been doing last week still relevant? Will somebody existentially suffer if you don’t go to the office, don’t preapre for the next deadline? Many of us knew it all along: officing work is overrated, caring work is underrated. There is no need to get theoretical or intellectual anymore about this: just look around and think yourself.
  • “I told you so” attitudes are not helpful yet it’s so hard to get rid of it. Talk about the future and not the past because it is your own choices with the people around you that will shape the futures to come.
  • Don’t fight over principles or rules or schedules. Try to evolve within your own situations and in the situations you find yourself in. Do 1:1 or small-group calls and don’t wait much for orders from above or from the assembly. The “above” has a tendency to try to fixate the past, to secure the future, but the future is already here, yet unevenly distributed on a planetary scale.
  • Move and act and communicate before you can be sure. Don’t wait to be right or for decisions from above before you move. Relax and care for yourself. You are not the only one to be emotionally exhausted.

Some things end, many more are beginning

Take care, stay socially distant, and develop better caring practices.  “Socially distant” can means more proximity as we start to actually look around more carefully. We can get through this as better and more healthy people, on a more livable planet, with more sensible and caring attitudes — if we and the still functioning parts of governments can avert even larger catastrophes than Covid-19 — pending nuclear reactor meltdowns, financial meltdowns, tele-communications outages, larger scale wars. Disaster planning, worst-case preparedness,  caring and moving early … this is the new game. Never forget to rest.

Playing a “profiteering” game with the lifes of people is, most of realize in their faces now, a questionable stance. Cars, planes and global busynesses just hit the wall and we don’t know yet know how we re-arrange the social, the warez, the traffic, the financials, the electrical and other power systems and the caring and critical infrastructure work. A return to the previous known normal will not happen. Accept and embrace.

But let’s please all see that no nuclear reactor goes bust now because we would all otherwise see the current times as “peanuts” compared to what would happen then. Do your nearby nuclear reactor operators have sufficient local agency to shut down their plants or do they need to wait for some OK from a central place that might never come in time? Do you want to find out? Nobody is in this as a spectator who sits back and judges and then votes in an election.  Consumerism must end and evolve to something different. Everybody bodily feels they are a participant now in something that nobody can yet determine what it will become. Trust that there are many others who think and care the same …

The animals and plants and forests are certainly feeling a big change as humans, finally, start to change their habits … The two birds who are nesting high up in a nearby Seqouia in the street where i live, the little animals who suddenly walk around freely at night because the streets are empty … i imagine the ecologies around us to experience the situations as a big relieve and many species are curious what is happening next. So am i and trust that our extinction rebellions are co-operative in nature and become cross-special. Stay safe and breathe. And by all means lough! Joy and joking and playing can help get us through. And Rest. Take care.

PyBites: Productivity Mondays - Tips from Adam Grant

$
0
0

We are longtime fans of the Tim Ferriss' show. I was listening to Adam Grant — The Man Who Does Everything again and there were some awesome nuggets about productivity, motivation and mindset in there:

  1. Seek criticism

    Adam began his career as a professor and he was very nervous. But then he began to improve tremendously seeking ruthless feedback. No cheerleaders, seek honest criticism: how to love criticism.

    Learn about your blank spots. Yes it can be uncomfortable, but as we always say, that's where growth is!

  2. Attention management

    Sometimes I get obsessed about doing task X at hour Y using Parkinson's law to speed things up. Some tasks are hard to measure though and when you're in flow you should just go.

    Bookmarked: Productivity Isn’t About Time Management. It’s About Attention Management and Paul Graham's Maker's Schedule, Manager's Schedule - Paul Graham. Do one thing at a time and batch process the non-deep work stuff.

  3. How to choose projects

    Tim was saying to chose projects that if you fail you still win = acquisition of new skills or rapid development of existing skills + developing long term relationships.

    Further reading: Scott Adam's career advice. A great book on the topic: So Good They Can't Ignore You.

  4. Goals

    Productivity is a means to an end:

    When you feel like you’re not productive, it’s not necessarily because you’re lazy or because you have bad habits, it’s because you’re not working on the right projects and you haven’t found the ones that are intrinsically motivating and meaningful to you.” — Adam Grant

    A great example is email. We always say: "don't do email in the morning", however Adam uses answering email to gain writing momentum.


How will you use productivity as your tool this week?

Stay safe (and at home!)

-- Bob

With so many avenues to pursue in Python it can be tough to know what to do. If you're looking for some direction or want to take your Python code and career to the next level, book a strategy session with us. We can help you!

Gocept Weblog: Zope May sprint goes remote

$
0
0

Earl Zope was inviting to the Zope May sprint, hoping for many volunteers to come. Due to restrictions to prevent spreading of COVID-19 (Corona) this sprint is going to be remote-only. – By now all of the organizers and their families are fine, so you do not have to worry about us.

This remote-only sprint will be an experiment. We already gathered some experience with remote work, communication and planning. But we neither participated at nor organized a remote-only sprint.

We will prepare channels for communication and collaboration for this sprint. Stay tuned for details. Earl Zope will appreciate your help.

As even a remote-only sprint needs preparation, please join via Meetup, so we are able to see, who we can count on to help Earl Zope in Python wonderland.


Python Software Foundation: Débora Azevedo Awarded the PSF Community Service Award for Q4 2019

$
0
0

Débora Azevedo co-founder of PyLadies Brazil and Django Girls Natal organizer, has been awarded the Python Software Foundation Q4 2019 Community Service Award. 

Débora's outstanding contributions to the growth and support of the Python community goes well beyond PyLadies Brazil and Django Girls Natal - as she is actively involved in Python translation work.

In 2018, she translated the Python Software Foundation survey into Potuguese.

It is for these reasons, that the Python Software Foundation is pleased to present Débora with the 2019 Q4 Community Service Award:

RESOLVED, that the Python Software Foundation award the 2019 Q4 Community Service Award to Débora Azevedo in recognition of her work in supporting the wider Python community in Brazil and the PSF generally. She's a co-founder of PyLadies Brazil, leader and organizer for Django Girls Natal, and helped found amd organizes the PyLadies Brazil conference. Débora's also been interested in supporting the wider community. Last year, Débora assisted the PSF by translating a survey into Portuguese. Additionally, she is a regular presenter and attends many community events.

Debora's Introduction to Programming - The Origin Story 


Débora's first introduction to programming was in 2008, as part of an IT technical course. But, it was an upleasant experience, she recalls. Being both young and without access to a computer, her first introduction to programming made the concept unclear and hard to grasp.

Years later, Débora enrolled into a Computer Networks course - so she would not have to code. Unknown to her, the course required her to take three programming classes, all taught in Python. This was a turning poing in her coding journey - as she realised how empowering being able to code could be. One of those moments came when she had to develop a web app using Django for the school library.

From then on, Débora was hooked.

Involvement in the Developer Community - Co-founding PyLadies Brazil


Suprised at the low turnout of female attendees and sometimes, the complete absence of women at local open source community meetups hosted by Potilivre, Débora, Gabriela Calvalcante, Clara Nobre and Katyanna Moura, started the PyLadies Brazil.

They were spurred on by a feeling of belonging, having their technical skills validated, their voices heard and a general desire of building a community of women with the same interest.

Débora took on more responsibility and became a co-founder for the PyLadies Brazil.

On the topic of Women in Tech, Débora believes that one of the most important things Women in Tech can do for other women is for them to step up as role models.

"Being able to tend to other ladies, in an industry, where some women consider themselves unfit, is revolutionary" says Débora.

Mario Sergio, program manager at Open Knowledge Brazil and past president of Associação Python Brazil, who first met Débora in 2014 at the Python Brazil conference in Porto de Galinhas, Permnambuco, speaks on Débora's contributions towards increasing women participation and increasing overall diversity in the Python Brazil community.

"The Python and Django Girls tutorials that Débora organized together with others, were essential for the inclusion of women. The Python Brazil Conference has had an almost fifty percentage female speakers in the last four editions" -  Mario Sergio

On Débora, being a teacher and a mentor? 

Clara Nobre, says Débora drives and inspires ladies in her local community to embrace programming. And to pursue a career in tech. These ladies, whom Débora inspires, had before now, been largely undecided in what career they wanted to pursue.

"Débora is one of the main references in the communtiy to other women. She is also a woman with a background in another area of expertise, which is English Letters. Débora is a teacher! So she can reach so many girls who still don't know what career they intend to pursue, as well as women who are in the area of Information Technology but haven't yet developed the maturity to program" - Clara Nobre

Crowdfunding Campaigns - Sponsoring Women to Attend Python Brazil Conference


In 2016, Débora and the team launched their first crowdfunding campaign to help raise funds to take some women of the PyLadies Brazil to Python Brazil, the largest Python conference in Latin America.

They raised R$5,975 (USD1,190), which was used to sponsor women to the 2016 Python Brazil conference.

In 2017, Débora and the team, again raised R$15,842 (USD3,160), sponsoring fourteen women who had requested for financial aid to participate in the 2017 edition of the Python Brazil conference. This resulted in a peak of forty two percent participation and activities led by PyLadies at the conference.

"In 2018,  we had a total of 26 talks and tutorials, which were given by women. Some of these activities were only possible, thanks to our crowdfunding campaigns, which raised R$11,770 (USD2,347), making participation in a conference like Python Brazil possible for nine women" - Débora

Débora Azevedo - Inspiring Women in Tech in Brazil to believe in themselves


On why she contributes so much to the Python Community?

Débora says

"Together with the PyLadies, the wider Python community can collaborate, working as partners with one goal in common. Having women become active participants and leaders in the Python community is important. It shouldn't be just one group's fight. By joining forces we can go a lot further. Being part of PyLadies Brazil and Django Girls Natal is the way I found to do my little good in the IT world. Teaching, advising and helping more women to believe in themselves and feel like it is possible for them and to feel like they can do it."

The Python Software Foundation congratulates and celebrates the amazing work and contributions of Débora Azevedo, to the Brazilian Python Community and for being a voice in the push for diversity, inclusion and participation of women in the industry.

Real Python: PyGame: A Primer on Game Programming in Python

$
0
0

In this course, you’ll learn about creating games using Python and the library PyGame.

By the end of this course, you’ll be able to:

  • Draw items on your screen
  • Play sound effects and music
  • Handle user input
  • Implement event loops
  • Describe how game programming differs from standard procedural Python programming

This primer assumes you have a basic understanding of writing Python programs, including user-defined functions, imports, loops, and conditionals. You should also be familiar with how to open files on your platform. A basic understanding of object-oriented Python is helpful as well. pygame works with most versions of Python, but Python 3.6 is recommended and used throughout this article.


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

PyCharm: Webinar: “Django and PyCharm Tips and Tricks” with Paul Everitt

$
0
0

PyCharm has long had mature support for Django. Want to learn tips and tricks about Django to learn how to get the most out of PyCharm? In this webinar we go through bite-sized Django tips being added to our PyCharm Guide.

  • Wednesday, March 25th
  • 5:00 – 6:00 PM CET (12:00 – 13:00 PM EDT)
  • Register Now
  • Aimed at developers with basic Django and PyCharm experience

Django with PyCharm Tips and Tricks

We’ll cover tips related to navigation, autocomplete, refactoring, debugging, and more. Each tip will be backed by a PyCharm Guide page with more information about that and related Django tips. Some of this information is also showed in our Django screencast playlist:

Speaking To You

Paul is the PyCharm and WebStorm Developer Advocate at JetBrains. Before that, Paul was a co-founder of Zope Corporation, taking the first open source application server through $14M of funding. Paul has bootstrapped both the Python Software Foundation and the Plone Foundation. Paul was an officer in the US Navy, starting www.navy.mil in 1993.

Catalin George Festila: Python 3.6.9 : My colab tutorials - part 003.

$
0
0
This tutorial refers to a python module named cirq. The documentation of this python module can be found on this website. The development team comes with this intro: Cirq is a software library for writing, manipulating, and optimizing quantum circuits and then running them against quantum computers and simulators. Cirq attempts to expose the details of hardware, instead of abstracting them away,

PyCoder’s Weekly: Issue #412 (March 17, 2020)

$
0
0

#412 – MARCH 17, 2020
View in Browser »

The PyCoder’s Weekly Logo


The Most Critical Python Code Metric

“Code metrics are a popular way to analyse the complexity of our software. For some reason, we are attracted to single-figure summaries of quality, whether it’s lines of code, cyclomatic complexity, or the Pylint score. Personally, I think using these are about as valuable as judging another person based on one of their visible or measurable characteristics.”
STEVE DOWER

Make a 2D Side-Scroller Game With PyGame

In this step-by-step course, you’ll learn how to use PyGame. This library allows you to create games and rich multimedia programs in Python. You’ll learn how to draw items on your screen, implement collision detection, handle user input, and much more.
REAL PYTHONvideo

Top 10 Python Packages for Machine Learning

alt

The field of data science is rapidly growing and relies heavily on Machine Learning; with hundreds of ML libraries, Python has become the language of choice for most engineers. Check out ActiveState’s list of the top 10 ML packages to learn →
ACTIVESTATEsponsor

New Governance Model for the Django Project

The Django core team, the Django Technical Board, and the Board of Directors of the Django Software Foundation have held their deliberations and voted to accept Django Enhancement Proposal (DEP) 10. Learn what the adoption of DEP 10 means for Django now and in the future.
DJANGOPROJECT.COM

Do Not Log

What makes a good log? When should you log something, and when is logging overkill? In this opinion piece, Nikita Sobolev argues that logging isn’t always best-practice in an application and discuss some alternatives that might make better sense from a business perspective.
NIKITA SOBOLEV

Against Service Layers in Django

“[On the] recommendation to add a ‘service layer’ to Django applications. The short version of my opinion on this is: it’s probably not what you want in Django apps.”
JAMES BENNETT

Python Jobs

Senior Python Software Engineer (London, UK)

Tessian

More Python Jobs >>>

Articles & Tutorials

Documentation as a Way to Build Community

Why is it so difficult to write good documentation? Why are documentation authors for projects often invisible? In this article, Melissa Mendonça investigates the answers to these questions and describes a new NumPy Enhancement Proposal that aims to restructure the NumPy documentation, build a documentation team, and diversify the contributor base.
MELISSA MENDONÇA

A Framework for Studying Population Dynamics

“World Wandering Dudes is a simulation framework in which you initiate a ‘world’ which consists of a ‘field’ and a set of ‘creatures’ (dudes). The field has food on it. Each day, the creatures run around gathering the food which they need to survive and reproduce.”
DUSTIN MCINTOSH

Learn the Skills You Need to Land a Job in Data Science, Guaranteed

alt

As a student in Springboard’s Data Science Career Track, you’ll work one-on-one with an expert data science mentor to complete real-world projects, build your portfolio, and gain the skills necessary to get hired. Springboard’s team will work with you from the start to help you land your dream data science role. Learn more →
SPRINGBOARDsponsor

How to Do a Binary Search in Python

Binary search is a classic algorithm in computer science. In this step-by-step tutorial, you’ll learn how to implement this algorithm in Python. You’ll learn how to leverage existing libraries as well as craft your own binary search Python implementation.
REAL PYTHON

Handling Missing Dictionary Keys With defaultdict

Learn how the Python defaultdict type works and how to use it for handling missing keys when you’re working with dictionaries. You’ll also learn how to use a defaultdict to solve problems like grouping or counting the items in a sequence or collection.
REAL PYTHON

Introduction to SQLAlchemy ORM for Django Developers

The Django ORM and SQLAlchemy are two of the most popular Python ORMs, but they have some pretty significant differences. Explore how common actions work in each framework, including transactions, models, queries, and dealing with the N+1 problem.
DENIS OREHOVSKY• Shared by Denis Orehovsky

HTTP Desync Attacks With Python and AWS

“A couple of months ago, I was at work waiting patiently for some documentation to go live about a new type of attacks against modern web applications called HTTP Desync attacks. Here is the story of my findings in gunicorn!”
EMILE FUGULIN

Why Does all() Return True if the Iterable Is Empty?

Does it make sense for all() to return True for an empty list? Is “all unicorns are blue” a true statement? Does shaving your dog contradict the statement “all mammals have fur?” You’ll have to read to find out!
CARL JOHNSONS

The Troublesome Active Record Pattern

“How inappropriate data access patterns massively slow down programs and how the same problems arise with RESTful APIs.”
CAL PATERSON

Profile, Understand & Optimize Code Performance with Blackfire.io

Blackfire is a deterministic profiler, measuring how code consumes resources at run-time. Appealing graphs & UI enable you to find performance bottlenecks & understand the code’s behavior. Works on production, test/staging & development with no overhead.
BLACKFIREsponsor

WebRTC: A Working Example

Learn how to implement a simple video chat application in Python and JavaScript that leverages WebRTC.
PAWEŁ FERTYK

Projects & Code

Events

EuroPython 2020 and COVID-19

EuroPython 2020 is still scheduled for July 20-26 in Dublin, Ireland.
EUROPYTHON.EU

PyData COVID-19 Response

PyData statement on COVID-19 and Spring 2020 PyData events.
NUMFOCUS.ORG

MoscowPythonConf++

March 27 to March 28, 2020
PYTHON.RU

PyCon SK 2020

Rescheduled to September 11–13 2020
PYCON.SK


Happy Pythoning!
This was PyCoder’s Weekly Issue #412.
View in Browser »

alt

[ Subscribe to 🐍 PyCoder’s Weekly 💌 – Get the best Python news, articles, and tutorials delivered to your inbox once a week >> Click here to learn more ]

EuroPython: EuroPython 2020: Going virtual EuroPython 2021: Dublin, Ireland

$
0
0

In our blog post on the COVID-19 last week, we were still hopeful that the situation would improve in time for the event in July. The last few days have shown us that we need to have a more realistic view on how things will develop in the coming months.

Right now, we are at a point in the conference organization where we have invested a lot of time into the preparation of the conference, but have not started ticket sales, entered sponsorship agreements or ordered conference and marketing material.

We also had discussions with the venue and caterer on possible options to address the risk of not being able to hold the event in July due to government regulations preventing indoor gatherings.

EuroPython 2021

In our EuroPython Society Board call last night, we discussed the situation, looked at the options and decided to take the offer of the venue to postpone the in-person conference to next year.

EuroPython 2021 will be held in Dublin, Ireland, from July 26 - August 1.

image

How about a virtual EuroPython 2020 ?

Since we all love EuroPython, the community and good vibes coming from such gatherings, we are now considering turning this year’s EuroPython 2020 conference into a virtual event.

image

For this, we’d like to gather some feedback and have created a form for you to let us know what your thoughts are on such a virtual setup:

EuroPython 2020 going virtual feedback form

If we go for the virtual setup for EuroPython 2020, the dates will likely change a bit, so ticket sales will start a little later. For now, we will leave the EuroPython 2020 Call for Proposals (CfP) open. Please note that those talks will then have to be held from your notebook/desktop without face-to-face audience contact. On the other hand, many more people could join in, since there’s no travel involved. We will aim to make the virtual event as interactive as possible.

Code name: EuroPython Winter Edition

While we’re at it, we’d also like to use the form to gather some feedback on the idea to have a winter EuroPython event, one where we run a BarCamp/Sprint/Hackathon style setup in a smaller setting.

Thanks,

EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/

Erik Marsja: How to get Absolute Value in Python with abs() and Pandas

$
0
0

The post How to get Absolute Value in Python with abs() and Pandas appeared first on Erik Marsja.

In this Python tutorial, we will learn how to get the absolute value in Python. First, we will use the function abs() to do this. In this section, we will go through a couple of examples of how to get the absolute value. Second, we will import data with Pandas and use the abs method to get the absolute values in a Pandas dataframe.

Python Absolute Value Tutorial

Now, before we go on with the examples on how to get the absolute value of a number using Python, we will go quickly into what absolute value is:

What is an absolute value?

Pretty simple; it means how far a value is from zero.

How do I get the absolute value in Python?

This is easy, as long as you have an integer or a float: abs(-33)

<<

Python abs() Function

The Python abs() function is one of the math functions in Python. This function will return the positive absolute value of a specific number or an expression. In the next sections, we will see plenty of examples of how to get the absolute value in Python. First, however, we are going to have a look at the syntax of the abs() function.

Python abs syntax

The syntax of the abs() function in the Python programming language is as shown below:

abs(x)
absolute value in python

Now, x can be any number that we want to find the absolute value for. For instance, if x is positive or negative zero, Pythons abs() function will return positive zero.

If we, however, put in something that is not a number we will get a TypeError (“bad operand type for abs(): ‘str’”.

python absolute value typeerror

How to get Absolute Value in Python with abs() Example 1

The abs function will enable us to find the absolute value of a numeric value. In this how-to get absolute value in Python example, we are going to find the absolute values of different data and display the output.

abs(-33)

Python abs() Example 2

Now, if we have a list of numbers, we cannot use the abs() function as we did in the first example. Note, if we do we get a TypeError, again. Thus, in this example, we are going to use Python list comprehension and the abs() function.

numbers = [-1, -2.1, -3, -444]
[abs(number) for number in numbers]

Note, it is also possible to import the math module and use the fabs() method to get the absolute value of a number in Python. However, when using fabs(), we will get the absolute value as a float:

import math
math.fabs(-33)
absolute value in python

Python get Absolute Values in Python using Pandas

Now, if we want to get absolute values from a dataset we can use Pandas to create a dataframe from a datafile (e.g., CSV). In this Python absolute value example, we are going to find the absolute values for all the records present in a dataframe. First, we will use Python to get absolute values in one column using Pandas abs method. Second, we will do the same but this for two columns in the dataset. Finally, we will get the absolute values for all columns in the Pandas dataframe.

absolute value in Python with Pandas

Now, for this Python absolute value example, we are going to use the CSV data in the image above. If needed, see the post about Pandas read csv method to understand the steps in importing data from a CSV file. Here’s how to do it, with the example file (python_absolute_value.csv):

import pandas as pd

df = pd.read_csv('python_absolute_value.csv')

Now, when we have the data loaded we are ready to get the absolute values using Python Pandas.

Python Pandas Absolute Values Example 1

In the first Python absolute values example using Pandas, we are going to select one column (“D”):

df['D'].abs()
python absolute value

Python Pandas Absolute Values Example 2

Now, in the second absolute values example, we are going to select two columns (“D” and “F”):

df[['D', 'F']].abs()
python absolute value

Now, if needed there’s more information about slicing and indexing Pandas dataframes in that post.

Python Pandas Absolute Values Example 3

Finally, we are going to get the absolute values from all columns in the Pandas dataframe:

df.abs()
Python absolute value

Conclusion: Python Absolute Value

Now, in this post, we learned how to get the absolute value in Python. It was pretty simple, we just used the abs() function. Second, we learned how to do the same task but with data stored on our computers (e.g., from a CSV file).

The post How to get Absolute Value in Python with abs() and Pandas appeared first on Erik Marsja.


PyPy Development: Leysin 2020 Sprint Report

$
0
0
At the end of February ten of us gathered in Leysin, Switzerland to work on
a variety of topics including HPy, PyPy Python 3.7 support and the PyPy
migration to Heptapod.


We had a fun and productive week. The snow was beautiful. There was skiing
and lunch at the top of Berneuse, cooking together, some late nights at
the pub next door, some even later nights coding, and of course the
obligatory cheese fondue outing.

There were a few of us participating in a PyPy sprint for the first time
and a few familiar faces who had attended many sprints. Many different
projects were represented including PyPy, HPy, GraalPython,
Heptapod, and rust-cpython. The atmosphere was relaxed and welcoming, so if
you're thinking of attending the next one -- please do!

Topics worked on:

HPy

HPy is a new project to design and implement a better API for extending
Python in C. If you're unfamiliar with it you can read more about it at
HPy.

A lot of attention was devoted to the Big HPy Design Discussion which
took up two full mornings. So much was decided that this will likely
get its own detailed write-up, but bigger topics included:
  • the HPy GetAttr, SetAttr, GetItem and SetItem methods,
  • HPy_FromVoidP and HPy_AsVoidP for passing HPy handles to C functions
    that pass void* pointers to callbacks,
  • avoiding having va_args as part of the ABI,
  • exception handling,
  • support for creating custom types.
Quite a few things got worked on too:
  • implemented support for writing methods that take keyword arguments with
    HPy_METH_KEYWORDS,
  • implemented HPy_GetAttr, HPy_SetAttr, HPy_GetItem, and HPy_SetItem,
  • started implementing support for adding custom types,
  • started implementing dumping JSON objects in ultrajson-hpy,
  • refactored the PyPy GIL to improve the interaction between HPy and
    PyPy's cpyext,
  • experimented with adding HPy support to rust-cpython.
And there was some discussion of the next steps of the HPy initiative
including writing documentation, setting up websites and funding, and
possibly organising another HPy gathering later in the year.

PyPy

  • Georges gave a presentation on the Heptapod topic and branch workflows
    and showed everyone how to use hg-evolve.
  • Work was done on improving the PyPy CI buildbot post the move to
    heptapod, including a light-weight pre-merge CI and restricting
    when the full CI is run to only branch commits.
  • A lot of work was done improving the -D tests.

Miscellaneous

  • Armin demoed VRSketch and NaN Industries in VR, including an implementation
    of the Game of Life within NaN Industries!
  • Skiing!

Aftermath

Immediately after the sprint large parts of Europe and the world were
hit by the COVID-19 epidemic. It was good to spend time together before
travelling ceased to be a sensible idea and many gatherings were cancelled.

Keep safe out there everyone.

The HPy & PyPy Team & Friends

In joke for those who attended the sprint: Please don't replace this blog post
with its Swedish translation (or indeed a translation to any other language :).

Anarcat: How can I trust this git repository?

$
0
0

Join me in the rabbit hole of git repository verification, and how we could improve it.

Problem statement

As part of my work on automating install procedures at Tor, I ended up doing things like:

git clone REPO
./REPO/bootstrap.sh

... something eerily similar to the infamous curl pipe bash method which I often decry. As a short-term workaround, I relied on the SHA-1 checksum of the repository to make sure I have the right code, by running this both on a "trusted" (ie. "local") repository and the remote, then visually comparing the output:

$ git show-ref master
9f9a9d70dd1f1e84dec69a12ebc536c1f05aed1c refs/heads/master

One problem with this approach is that SHA-1 is now considered as flawed as MD5 so it can't be used as an authentication mechanism anymore. It's also fundamentally difficult to compare hashes for humans.

The other flaw with comparing local and remote checksums is that we assume we trust the local repository. But how can I trust that repository? I can either:

  1. audit all the code present and all the changes done to it after

  2. or trust someone else to do so

The first option here is not practical in most cases. In this specific use case, I have audited the source code -- I'm the author, even -- what I need is to transfer that code over to another server.

(Note that I am replacing those procedures with Fabric, which makes this use case moot for now as the trust path narrows to "trust the SSH server" which I already had anyways. But it's still important for my fellow Tor developers who worry about trusting the git server, especially now that we're moving to GitLab.)

But anyways, in most cases, I do need to trust some other fellow developer I collaborate with. To do this, I would need to trust the entire chain between me and them:

  1. the git client
  2. the operating system
  3. the hardware
  4. the network (HTTPS and the CA cartel, specifically)
  5. then the hosting provider (and that hardware/software stack)
  6. and then backwards all the way back to that other person's computer

I want to shorten that chain as much as possible, make it "peer to peer", so to speak. Concretely, it would eliminate the hosting provider and the network, as attackers.

OpenPGP verification

My first reaction is (perhaps perversely) to "use OpenPGP" for this. I figured that if I sign every commit, then I can just check the latest commit and see if the signature is good.

The first problem here is that this is surprisingly hard. Let's pick some arbitrary commit I did recently:

commit b3c538898b0ed4e31da27fc9ca22cb55e1de0000
Author: Antoine Beaupré <anarcat@debian.org>
Date:   Mon Mar 16 14:37:28 2020 -0400

    fix test autoloading

    pytest only looks for file names matching `test` by default. We inline
    tests inside the source code directly, so hijack that.

diff --git a/fabric_tpa/pytest.ini b/fabric_tpa/pytest.ini
new file mode 100644
index 0000000..71004ea
--- /dev/null
+++ b/fabric_tpa/pytest.ini
@@ -0,0 +1,3 @@
+[pytest]
+# we inline tests directly in the source code
+python_files = *.py

That's the output of git log -p in my local repository. I signed that commit, yet git log is not telling me anything special. To check the signature, I need something special: --show-signature, which looks like this:

commit b3c538898b0ed4e31da27fc9ca22cb55e1de0000
gpg: Signature faite le lun 16 mar 2020 14:37:53 EDT
gpg:                avec la clef RSA 7B164204D096723B019635AB3EA1DDDDB261D97B
gpg: Bonne signature de « Antoine Beaupré <anarcat@orangeseeds.org> » [ultime]
gpg:                 alias « Antoine Beaupré <anarcat@torproject.org> » [ultime]
gpg:                 alias « Antoine Beaupré <anarcat@anarc.at> » [ultime]
gpg:                 alias « Antoine Beaupré <anarcat@koumbit.org> » [ultime]
gpg:                 alias « Antoine Beaupré <anarcat@debian.org> » [ultime]
Author: Antoine Beaupré <anarcat@debian.org>
Date:   Mon Mar 16 14:37:28 2020 -0400

    fix test autoloading

    pytest only looks for file names matching `test` by default. We inline
    tests inside the source code directly, so hijack that.

Can you tell if this is a valid signature? If you speak a little french, maybe you can! But even if you would, you are unlikely to see that output on your own computer. What you would see instead is:

commit b3c538898b0ed4e31da27fc9ca22cb55e1de0000
gpg: Signature made Mon Mar 16 14:37:53 2020 EDT
gpg:                using RSA key 7B164204D096723B019635AB3EA1DDDDB261D97B
gpg: Can't check signature: No public key
Author: Antoine Beaupré <anarcat@debian.org>
Date:   Mon Mar 16 14:37:28 2020 -0400

    fix test autoloading

    pytest only looks for file names matching `test` by default. We inline
    tests inside the source code directly, so hijack that.

Important part: Can't check signature: No public key. No public key. Because of course you would see that. Why would you have my key lying around, unless you're me. Or, to put it another way, why would that server I'm installing from scratch have a copy of my OpenPGP certificate? Because I'm a Debian developer, my key is actually part of the 800 keys in the debian-keyring package, signed by the APT repositories. So I have a trust path.

But that won't work for someone who is not a Debian developer. It will also stop working when my key expires in that repository, as it already has on Debian buster (current stable). So I can't assume I have a trust path there either. One could work with a trusted keyring like we do in the Tor and Debian project, and only work inside that project, that said.

But I still feel uncomfortable with those commands. Both git log and git show will happily succeed (return code 0 in the shell) even though the signature verification failed on the commits. Same with git pull and git merge, which will happily push your branch ahead even if the remote has unsigned or badly signed commits.

To actually verify commits (or tags), you need the git verify-commit (or git verify-tag) command, which seems to do the right thing:

$ LANG=C.UTF-8 git verify-commit b3c538898b0ed4e31da27fc9ca22cb55e1de0000
gpg: Signature made Mon Mar 16 14:37:53 2020 EDT
gpg:                using RSA key 7B164204D096723B019635AB3EA1DDDDB261D97B
gpg: Can't check signature: No public key
[1]$

At least it fails with some error code (1, above). But it's not flexible: I can't use it to verify that a "trusted" developer (say one that is in a trusted keyring) signed a given commit. Also, it is not clear what a failure means. Is a signature by an expired certificate okay? What if the key is signed by some random key in my personal keyring? Why should that be trusted?

Worrying about git and GnuPG

In general, I'm worried about git's implementation of OpenPGP signatures. There has been numerous cases of interoperability problems with GnuPG specifically that led to security, like EFAIL or SigSpoof. It would be surprising if such a vulnerability did not exist in git.

Even if git did everything "just right" (which I have myself found impossible to do when writing code that talks with GnuPG), what does it actually verify? The commit's SHA-1 checksum? The tree's checksum? The entire archive as a zip file? I would bet it signs the commit's SHA-1 sum, but I just don't know, on the top of my head, and neither do git-commit or git-verify-commit say exactly what is happening.

I had an interesting conversation with a fellow Debian developer (dkg) about this and we had to admit those limitations:

<anarcat> i'd like to integrate pgp signing into tor's coding practices more, but so far, my approach has been "sign commits" and the verify step was "TBD"

<dkg> that's the main reason i've been reluctant to sign git commits. i haven't heard anyone offer a better subsequent step. if torproject could outline something useful, then i'd be less averse to the practice.

i'm also pretty sad that git remains stuck on sha1, esp. given the recent demonstrations. all the fancy strong signatures you can make in git won't matter if the underlying git repo gets changed out from under the signature due to sha1's weakness

In other words, even if git implements the arcane GnuPG dialect just so, and would allow us to setup the trust chain just right, and would give us meaningful and workable error messages, it still would fail because it's still stuck in SHA-1. There is work underway to fix that, but in February 2020, Jonathan Corbet described that work as being in a "relatively unstable state", which is hardly something I would like to trust to verify code.

Also, when you clone a fresh new repository, you might get an entirely different repository, with a different root and set of commits. The concept of "validity" of a commit, in itself, is hard to establish in this case, because an hostile server could put you backwards in time, on a different branch, or even on an entirely different repository. Git will warn you about a different repository root with warning: no common commits but that's easy to miss. And complete branch switches, rebases and resets from upstream are hardly more noticeable: only a tiny plus sign (+) instead of a star (*) will tell you that a reset happened, along with a warning (forced update) on the same line. Miss those and your git history can be compromised.

Possible ways forward

I don't consider the current implementation of OpenPGP signatures in git to be sufficient. Maybe, eventually, it will mature away from SHA-1 and the interface will be more reasonable, but I don't see that happening in the short term. So what do we do?

git evtag

The git-evtag extension is a replacement for git tag -s. It's not designed to sign commits (it only verifies tags) but at least it uses a stronger algorithm (SHA-512) to checksum the tree, and will include everything in that tree, including blobs. If that sounds expensive to you, don't worry too much: it takes about 5 seconds to tag the Linux kernel, according to the author.

Unfortunately, that checksum is then signed with GnuPG, in a manner similar to git itself, in that it exposes GnuPG output (which can be confusing) and is likely similarly vulnerable to mis-implementation of the GnuPG dialect as git itself. It also does not allow you to specify a keyring to verify against, so you need to trust GnuPG to make sense of the garbage that lives in your personal keyring (and, trust me, it doesn't).

And besides, git-evtag is fundamentally the same as signed git tags: checksum everything and sign with GnuPG. The difference is it uses SHA-512 instead of SHA-1, but that's something git will eventually fix itself anyways.

kernel patch attestations

The kernel also faces this problem. Linus Torvalds signs the releases with GnuPG, but patches fly all over mailing list without any form of verification apart from clear-text email. So Konstantin Ryabitsev has proposed a new protocol to sign git patches which uses SHA256 to checksum the patch metadata, commit message and the patch itself, and then sign that with GnuPG.

It's unclear to me what this solves, if anything, at all. As dkg argues, it would seem better to add OpenPGP support to git-send-email and teach git tools to recognize that (e.g. git-am) at least if you're going to keep using OpenPGP anyways.

And furthermore, it doesn't resolve the problems associated with verifying a full archive either, as it only attests "patches".

jcat

Unhappy with the current state of affairs, the author of fwupd (Richard Hughes) wrote his own protocol as well, called jcat, which provides signed "catalog files" similar to the ones provided in Microsoft windows.

It consists of a "gzip-compressed JSON catalog files, which can be used to store GPG, PKCS-7 and SHA-256 checksums for each file". So yes, it is yet again another wrapper to GnuPG, probably with all the flaws detailed above, on top of being a niche implementation, disconnected from git.

The Update Framework

One more thing dkg correctly identified is:

<dkg> anarcat: even if you could do exactly what you describe, there are still some interesting wrinkles that i think would be problems for you.

the big one: "git repo's latest commits" is a loophole big enough to drive a truck through. if your adversary controls that repo, then they get to decide which commits to include in the repo. (since every git repo is a view into the same git repo, just some have more commits than others)

In other words, unless you have a repository that has frequent commits (either because of activity or by a bot generating fake commits), you have to rely on the central server to decide what "the latest version" is. This is the kind of problems that binary package distribution systems like APT and TUF solve correctly. Unfortunately, those don't apply to source code distribution, at least not in git form: TUF only deals with "repositories" and binary packages, and APT only deals with binary packages and source tarballs.

That said, there's actually no reason why git could not support the TUF specification. Maybe TUF could be the solution to ensure end-to-end cryptographic integrity of the source code itself. OpenPGP-signed tarballs are nice, and signed git tags can be useful, but from my experience, a lot of OpenPGP (or, more accurately, GnuPG) derived tools are brittle and do not offer clear guarantees, and definitely not to the level that TUF tries to address.

This would require changes on the git servers and clients, but I think it would be worth it.

Other Projects

OpenBSD

There are other tools trying to do parts of what GnuPG is doing, for example minisign and OpenBSD's signify. But they do not integrate with git at all right now. Although I did find a hack] to use signify with git, it's kind of gross...

Golang

Unsurprisingly, this is a problem everyone is trying to solve. Golang is planning on hosting a notary which would leverage a "certificate-transparency-style tamper-proof log" which would be ran by Google (see the spec for details). But that doesn't resolve the "evil server" attack, if we treat Google as an adversary (and we should).

Python

Python had OpenPGP going for a while on PyPI, but it's unclear if it ever did anything at all. Now the plan seems to be to use TUF but my hunch is that the complexity of the specification is keeping that from moving ahead.

Docker

Docker and the container ecosystem has, in theory, moved to TUF in the form of Notary, "a project that allows anyone to have trust over arbitrary collections of data". In practice however, in my somewhat limited experience, setting up TUF and image verification in Docker is far from trivial.

Android and iOS

Even in what is possibly one of the strongest models (at least in terms of user friendliness), mobile phones are surprisingly unclear about those kind of questions. I had to ask if Android had end-to-end authentication and I am still not clear on the answer. I have no idea of what iOS does.

Conclusion

One of the core problems with everything here is the common usability aspect of cryptography, and specifically the usability of verification procedures. We have become pretty good at encryption. The harder part (and a requirement for proper encryption) is verification. It seems that problem still remains unsolved, in terms of usability. Even Signal, widely considered to be a success in terms of adoption and usability, doesn't properly solve that problem, as users regularly ignore "The security number has changed" warnings...

So, even though they deserve a lot of credit in other areas, it seems unlikely that hardcore C hackers (e.g. git and kernel developers) will be able to resolve that problem without at least a little bit of help. And TUF seems like the state of the art specification around here, it would seem wise to start adopting it in the git community as well.

RMOTR: Learn Data Science by Analyzing COVID-19

$
0
0
Note: In light ofthe current situation, RMOTR will provide a 2 week free of charge trial period, to help people improve their programming and data management skills while staying home. Read more in this post.

COVID-19 has hit hard in the past couple of weeks and its impact has been notorious both from a sanitary perspective and an economic one. Plenty has been written about it, especially statistical reports on its exponential growth and the importance of “flattening the curve”.

At RMOTR, we wanted to help raise awareness of the issues associated with the spread of COVID-19 by making a dynamic and interactive analysis of the situation using Python and Data Science.

We’ve made an interactive project that you can fork and follow step by step. You can see the process that Data Scientists follow to analyze the situation and make predictions. Here is a quick summary.

👉 Click this button to fork the project and follow it step by step👈
This project has been created by @yosoymatias, one of our expert Data Scientists on Staff. This is a write up of his work.

Part 1: The Basics of Exploratory Data Analysis and Data Wrangling

We’ll start with the first Notebook, Part 1.ipynb and follow the basic steps of every Data Science project.

Step 1: Reading Data

The first step is getting the data. In this case, we’re using this Github repo by Johns Hopkins University that contains CSV files updated daily.

We’re using a neat Pandas technique of reading the CSV directly from the Github repo, which means we can run our notebooks everyday and it’ll stay up to date:

COVID_CONFIRMED_URL = ‘https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv'
covid_confirmed = pd.read_csv(COVID_CONFIRMED_URL)

Step 2: Data Cleaning

This is the mandatory second step of our project. Here, the data is fairly clean, so there isn’t much more to do. We’ll replace a few country names and fill in blanks.

Step 3 & 4: Analysis and Data Wrangling

In the first stage of analyzing, we’ll start with a worldwide impact analysis of COVID-19. To conduct our analysis, we’ll need to create new columns, create intermediate DataFrames, and re-shape (melt, stack, group) our data. This is usually known as the “Data Wrangling” process.

Proportion of cases that have been active, recovered or died.

We can then plot the evolution of cases over time which shows, as we know, an alarming exponential growth:

Evolution of cases as days pass

As you may know already, it’s hard to see if growth is slowing down when it’s exponential, so we’ll change our y-axis to use a logarithmic scale:

Evolution of cases, logarithmic scale

To continue our analysis, we’ll compare Recovery vs Mortality. To do that, we’ll define a few new columns with “ratio every 100 confirmed cases”.

We see a more encouraging scenario where recovery has sped up and deaths are kept at a constant rate.

Evolution of COVID-19, in a Dynamic Worldwide Map

We’ll finish the first part of our analysis with an interactive map showing the evolution of COVID-19 over time. The Notebook contains a dynamic plot you can play with, which looks like this:

Evolution of cases in an interactive plot

Part 2: More In-depth Analysis

In this second part, we’ll dig deeper into the state of each country. Head now to Part 2.ipynb to follow the process step by step.

We’ll start again by reading the data, cleaning it, and creating a few intermediate DataFrames. You can see where this is going already. 70% of a Data Scientist’s time is spent on “Data Wrangling”.

Analysis of More Affected Countries

We know that China and Italy top the number of cases, as shown in the following charts:

Total of confirmed cases per countryDeaths per country

But can we go deeper? Our role as Data Scientists is to keep pushing past the surface of the data. The number of cases (confirmed, deaths, recovered) per country is publicly known. However, we can go further and create our own derived analysis. For example “mortality per country”, which now shows a different perspective:

Mortality per coutnry

Finally, let’s take a look at the evolution of cases in these countries, in logarithmic scale (you can find a linear scale in the notebook):

Evolution per country, logarithmic scale

<INSERT YOUR COUNTRY> Analysis

The beauty of “programmatic” analysis is that you can change one variable and have a dynamic analysis. For the sake of this post, I’ll use the USA, but you can spin Part 2.ipynb and try with whatever country you call home.

First, we see a worrying “developing state” where there are a lot of “confirmed” cases but less certainty about recovery:

Total cases in the USA (green is recovered, red is deaths)

We can extend it per state:

COVID-19 cases per US State.

Part 3: Forecasting the Evolution of COVID-19

The last part of our project, Part 3.ipynb shows how to implement a simple Linear Regression model to predict the evolution of COVID-19.

The trick to making this regression work understanding that this is not an actual linear process, but an exponential one. We must treat our data accordingly. We can change the y-axis to display our predictions in a linear scale:

Final thoughts

We can’t say much about the accuracy of our predictions for COVID-19, as there are still many unknowns. There are several drugs and vaccines being tested as we write this piece and social isolation seems to be having an impact.

Our objective with this post is to help you understand the process followed by Data Scientists and the structure of a real Data Science project, regarding a very real, current situation.

Hopefully, we’ll soon look back at this analysis and find that our predictions were extremely off and COVID-19 has immensely slowed down. Even better, it remains a memory, or a demo Data Science project.

Stay Focused

If you’d like to use your social distancing time at home to continue exploring Data Science and Python Programming, RMOTR is now offering 2 weeks of use for free.

All new and current users can utilize any course within the platform. To access the content, you must create a free account and then subscribe for the free trial. You may cancel at any time.

Recommendations

If you’re planning on using RMOTR only for the 2 free weeks, we want to make sure you get the most out of your experience. Here are the courses we recommend you jump into, according to your skill level.

Beginners

If you’re brand new to programming, you’ll want to use these 2 weeks to learn the basics of coding. Start with Intro to Programming with Python. Then move on to learning about collections with Python Collections. Finally, take your new skills to the next level with our NumPy course, Intro to Scientific Computing with NumPy.

In the Know

If you have experience with programming, then you’ll want to hit the ground running. To understand the full power of Python for Data Science, check out our online workshop on Machine Learning for Businesses. Of course, you can watch that anytime.

To optimize your free trial, start with Intro to Scientific Computing with NumPy and learn how to process large volumes of data using Python. Follow that course with Intro to Pandas for Data Analysis and take advantage of the visualizations included. From there, any course on our platform will be helpful as you explore what interests you.

We wish you and yours good health and peace. Stay safe, stay sharp, and help each other.


Learn Data Science by Analyzing COVID-19 was originally published in rmotr.com on Medium, where people are continuing the conversation by highlighting and responding to this story.

Fabio Zadrozny: How is frame evaluation used in pydevd?

$
0
0
First some background in frame evaluation:

Since Python 3.6, CPython has a mechanism which allows clients to override how it evaluates frames. This is done by changing PyThreadState.interp.eval_frame to a different C-function (the default being _PyEval_EvalFrameDefault). See: pydevd_frame_evaluator.pyx#L370 in pydevd (note that Cython is used there).

Note that this affects the Python runtime globally, whereas the regular Python tracing function -- set through sys.settrace() -- affects only the current thread (so, some of the caches for frame evaluation in pydevd are thread-local due to that).

How is this used in the debugger?

Well, the debugger doesn't really want to change how Python code is executed, but, there's another interesting side effect of the frame evaluation: it's possible to change the bytecode of the frame right before it's evaluated and CPython will interpret that bytecode instead of the original bytecode of the frame.

So, this works the following way: the frame evaluation function receives a PyFrameObject*, and at that point, the debugger checks the frame for existing breakpoints, if it has a breakpoint, it'll create a new code object which has a programmatic breakpoint (pydevd_frame_evaluator.pyx#L234) and change PyFrameObject.f_code to point to the new code object (pydevd_frame_evaluator.pyx#L358) -- when it reaches the programmatic breakpoint (pydevd_frame_tracing.py#L34), the regular (trace-based) debugger will kick in at that frame. Until that breakpoint is reached, frames are executed at full speed.

But if it runs at full speed, why is my program still running slower when using pydevd with frame evaluation?

Well, frames are executed at full speed, but, the debugger still adds some overhead at function calls (when it decides whether to add the programmatic breakpoint) and it also needs to add an almost no-op trace (pydevd_frame_evaluator.pyx#L95) function to sys.settrace -- which makes function calls slower too (this is needed because otherwise the debugger is not able to switch to the regular tracing by just changing the frame.f_trace as frame.f_trace is only checked when a tracing function is set for some thread through sys.settrace()). There are also some cases where it can't completely skip tracing for a frame even if it doesn't have a breakpoint (for instance, when it needs to break on caught exceptions or if it's stepping in the debugger).

It's interesting to note that even the regular (tracing) debugger on pydevd can run frames at full speed (it evaluates all frames and if a frame doesn't have a breakpoint the tracing for that frame will be skipped), the difference is that if a frame does have a breakpoint, that frame can run at full speed until it reaches the breakpoint in the frame eval mode, whereas in the regular mode each new line tracing event would need to be individually checked for a breakpoint.

If it just changes the bytecode, why use frame eval at all, can't you just change the bytecode of objects at a custom import hook? (which could have the benefit of avoiding the performance penalty of checking the frame on each new frame call)

There are 2 main reasons for that: the 1st is that breakpoints can change and when they change the frame evaluation would need to be completely shut down and only the tracing debugger would be valid from that point onwards (whereas right now, if breakpoints change, the tracing debugger kicks in for all the frames that were currently running but the frame evaluation debugger can still be used for new frames). The 2nd is that it can be hard to consistently do that if not just before frame evaluation (because user code can also change a method code and there are a number of corner cases to change the bytecode for live objects -- think of a function inside a function or decorated functions).

Note that this means that the debugger could probably get away with something simpler than frame evaluation and could potentially be applicable to other Python implementations (say, a different callback just before the frame is evaluated which allows to change the frame code... unfortunately it can't currently be done through the "call" event received by the trace function set by sys.settrace because at that point the frame is already being evaluated with the current code and at that point, even if it's changed, Python won't pick up that change).

That's it, hope you enjoyed pydevd using frame evaluation for debugging purposes 101 ;)





Continuum Analytics Blog: How We’re Responding to COVID-19

$
0
0

To our community of customers, partners, contributors, and friends: We are all facing a dynamic and difficult situation in the face of the COVID-19 pandemic. Our families, friends, customers, employees, and communities are all dramatically…

The post How We’re Responding to COVID-19 appeared first on Anaconda.

Viewing all 22420 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>