Links related to tag python

Documentation Brython - brython


module browser.ajax

Ce module permet d'exécuter des requêtes Ajax.

La syntaxe de l'API Web normalisée peut être utilisée (voir ci-dessous) mais Brython propose une syntaxe plus concise: pour chaque méthode de requête (GET, POST, etc.) le module définit une fonction spécifique.

Méthodes sans corps de données

get(url[, blo...

Datasette Lite: a server-side Python web application running in a browser - simonwillison

Datasette Lite: a server-side Python web application running in a browser

Datasette Lite is a new way to run Datasette: entirely in a browser, taking advantage of the incredible Pyodide project which provides Python compiled to WebAssembly plus a whole suite of useful extras.

You can try it out here:

The initial example loads two databases---the classic fixtures.db used ...

Boring Python: dependency management - b-list

Boring Python: dependency management

This is the first in hopefully a series of posts I intend to write about how to build/manage/deploy/etc. Python applications in as boring a way as possible. So before I go any further, I want to be absolutely clear on what I mean by "boring": I don't mean "reliable" or "bug-free" or "no incidents". ...

Build a URL Shortener With FastAPI and Python – Real Python - realpython

Build a URL Shortener With FastAPI and PythonReal Python

par Real Python, le mercredi 18 mai 2022 16:00

In this tutorial, you’ll build a URL shortener with Python and FastAPI. URLs can be extremely long and not user-friendly. This is where a URL shortener can come in handy. A URL shortener reduces the number of characters in a URL, making it easier to read, remember, and share.

By following this step-by-step project, you’ll build a URL shortener with Python and FastAPI. At the end of this tutorial, you’ll have a fully functional API-driven web app that creates shortened URLs that forward to target URLs.

In this tutorial, you’ll learn how to:

• Create a REST API with FastAPI

• Run a development web server with Uvicorn

• Model an SQLite database

• Investigate the auto-generated API documentation

• Interact with the database with CRUD actions

• Optimize your app by refactoring your code

This URL shortener project is for intermediate Python programmers who want to try out FastAPI and learn about API design, CRUD, and interaction with a database. To follow along, it’ll help if you’re familiar with the basics of handling HTTP requests. If you need a refresher on FastAPI, Using FastAPI to Build Python Web APIs is a great introduction.

Get Source Code: Click here to get access to the source code that you’ll use to build your Python URL shortener with FastAPI.

Demo: Your Python URL Shortener

In this step-by-step project, you’ll build an API to create and manage shortened URLs. The main purpose of this API is to receive a full target URL and return a shortened URL. To try out your API endpoints, you’ll leverage the documentation that FastAPI automatically creates:

When you post a target URL to the URL shortener app, you get a shortened URL and a secret key back. The shortened URL contains a random key that forwards to the target URL. You can use the secret key to see the shortened URL’s statistics or delete the forwarding.

Project Overview

Your URL shortener Python project will provide API endpoints that are capable of receiving different HTTP request types. Each endpoint will perform an action that you’ll specify. Here’s a summary of your URL shortener’s API endpoints:

/admin/{secret_key} DELETE Your secret key Deletes your shortened URL

The Call for Proposals for DjangoCon US 2022 Is Now Open! - djangoproject

The Call for Proposals for DjangoCon US 2022 Is Now Open!

The DjangoCon 2022 organizers are excited to announce that the first in-person DjangoCon since 2019 is now open for talk submissions: call for proposals{.reference .external}! The deadline for submissions is June 10th, 2022 AoE{.reference .external}. As long as it's still June 10th anywhere on earth, you can submit your proposal.

We invite you to submit your proposal no matter your ...

How to Publish an Open-Source Python Package to PyPI – Real Python - realpython

How to Publish an Open-Source Python Package to PyPIReal Python

par Real Python,

le lundi 23 mai 2022 16:00Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: How to Publish Your Own Python Package to PyPI

Python is famous for coming with batteries included, and many sophisticated capabilities are available in the standard library. However, to unlock the full potential of the language, you should also take advantage of the community contributions at PyPI: the Python Packaging Index.

PyPI, typically pronounced pie-pee-eye, is a repository containing several hundred thousand packages. These range from trivial Hello, World implementations to advanced deep learning libraries. In this tutorial, you’ll learn how to upload your own package to PyPI. Publishing your project is easier than it used to be. Yet, there are still a few steps involved.

In this tutorial, you’ll learn how to:

• Prepare your Python package for publication

• Handle versioning of your package

• Build your package and upload it to PyPI

• Understand and use different build systems

Throughout this tutorial, you’ll work with an example project: a reader package that can be used to read Real Python tutorials in your console. You’ll get a quick introduction to the project before going in depth about how to publish this package. Click the link below to access the GitHub repository containing the full source code of reader:

Get Source Code: Click here to get access to the source code for the Real Python Feed Reader that you’ll work with in this tutorial.

Get to Know Python Packaging

Packaging in Python can seem complicated and confusing for both newcomers and seasoned veterans. You’ll find conflicting advice across the Internet, and what was once considered good practice may now be frowned upon.

The main reason for this situation is that Python is a fairly old programming language. Indeed, the first version of Python was released in 1991, before the World Wide Web became available to the general public. Naturally, a modern, web-based system for distribution of packages wasn’t included or even planned for in the earliest versions of Python.

Instead, Python’s packaging ecosystem has evolved organically over the decades as user needs became clear and technology offered new possibilities. The first packaging support came in the fall of 2000, with the distutils library being included in Python 1.6 and 2.0. The Python Packaging Index (PyPI) came online in 2003, originally as a pure index of existing packages, without any hosting capabilities.

Note: PyPI is often referred to as the Python Cheese Shop in reference to Monty Python’s famous Cheese Shop sketch. To this day, redirects to PyPI.

Over the last decade, many initiatives have improved the packaging landscape, bringing it from the Wild West and into a fairly modern and capable system. This is mainly done through Python Enhancement Proposals (PEPs) that are reviewed and implemented by the Python Packaging Authority (PyPA) working group.

The most important documents that define how Python packaging works are the following PEPs:

• PEP 427 describes how wheels should be packaged.

• PEP 440 describes how version numbers should be parsed.

• PEP 508 describes how dependencies should be specified.

• PEP 517 describes how a build backend should work.

• PEP 518 describes how a build system should be specified.

• PEP 621 describes how project metadata should be written.

• PEP 660 describes how editable installs should be performed.

You don’t need to study these technical documents. In this tutorial, you’ll learn how all these specifications come together in practice as you go through the process of publishing your own package.

For a nice overview of the history of Python packaging, check out Thomas Kluyver’s presentation at PyCon UK 2019: Python packaging: How did we get here, and where are we going? You can also find more presentations at the PyPA website.

Create a Small Python Package

In this section, you’ll get to know a small Python package that you can use as an example that can be published to PyPI. If you already have your own package that you’re looking to publish, then feel free to skim this section and join up again at the next section.

The package that you’ll see here is called reader. It can be used both as a library for downloading Real Python tutorials in your own code and as an application for reading tutorials in your console.

Note: The source code as shown and explained in this section is a simplified—but fully functional—version of the Real Python feed reader. Compared to the version currently published on PyPI, this version lacks some error handling and extra options.

First, have a look at the directory structure of reader. The package lives completely inside a directory that can be named anything. In this case, it’s named realpython-reader/. The source code is wrapped inside an src/ directory. This isn’t strictly necessary, but it’s usually a good idea.

Note: The use of an extra src/ directory when structuring packages has been a point of discussion in the Python community for years. In general, a flat directory structure is slightly easier to get started with, but the src/-structure provides several advantages as your project grows.

The inner src/reader/ directory contains all your source code:

├── src/
│   └── reader/
│       ├──
│       ├──
│       ├── config.toml
│       ├──
│       └──
├── tests/
│   ├──
│   └──
└── pyproject.toml

The source code of the package is in an src/ subdirectory together with a configuration file

Welcome to Hypothesis! — Hypothesis 6.46.9 documentation - readthedocs

Welcome to Hypothesis¶

Hypothesisis a Python library for creating unit tests which are simpler to write and more powerful when run, finding edge cases in your code you wouldn't have thought to look for. It is stable, powerful and easy to add to any existing test suite.

It works by letting you write tests that assert that something should be true for every case, not just the ones you happen to t...

copier - readthedocs

CI Checked with mypy Code style: black Documentation Status

A library for rendering project templates.

  • Works with local paths and git URLs.
  • Your project can include any file and Copier can dynamically replace values in any kind of text file.
  • It generates a beautiful output and takes care of not overwrite existing files unless instructed to do so.
  1. Install Python 3.6.1 or newer (3.8 or newer if you're on Windows).
  2. Install Git 2.24 or n...

hacker news avec django