close
  • chevron_right

    Du code Python dans vos pages HTML

    news.movim.eu / Korben · Thursday, 26 May - 07:00 · 2 minutes

Si vous êtes développeur et que vous aimez mettre du Python partout, dans vos poches, dans vos slips, sur vos tartines le matin, alors pourquoi ne pas en mettre également dans vos pages HTML ?

Et cela est maintenant possible grâce à ce PyScript, un bout de js + css à intégrer à votre code qui vous permettra de créer des applications Python directement au coeur de votre code HTML.

Pour ce faire, copiez ceci dans votre page :

<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script> 

Ensuite, il ne vous reste plus qu’à pondre du Python dans une balise <py-script> comme ceci :

<py-script>print("hello les petits fous")</py-script>

Voici un exemple avec le calcul de Pi pour 3 décimales après la virgule :

<html>
<head>
    <meta charset="UTF-8">
    <title>pytest</title>
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
       <py-script>
def wallis(n):
    pi = 2
    for i in range(1,n):
        pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
    return pi

pi = wallis(100000)
s = f"π est approximativement {pi:.3f}"
print(s)
        </py-script>
</body>
</html>

Bon, je ne vous cache pas que c’est long niveau processing et je ne pense pas que ce sera vraiment utilisable pour de l’application web grand public. Mais c’est rigolo. On peut même utiliser des packages et autres modules, faire des interfaces, et même récupérer des valeurs dans les pages HTML avec la fonction pyscript.write comme ceci :

<html>
<head>
    <meta charset="UTF-8">
    <title>pytest</title>
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<h1 id="pi">xxx</h1>
       <py-script>
def wallis(n):
    pi = 2
    for i in range(1,n):
        pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
    return pi

pi = wallis(100000)
s = f"π est approximativement {pi:.3f}"
pyscript.write('pi', s)
        </py-script>
</body>
</html>

Si cela vous intéresse, vous trouverez tout sur le site de PyScript .

  • Ga chevron_right

    Python: Basic Electronics Control with the Raspberry Pi

    Danie van der Merwe · news.movim.eu / gadgeteerza-tech-blog · Saturday, 7 May - 13:10 · 1 minute

The Raspberry Pi device, beyond just being a low-cost introductory computing tool, also provides a robust electronic controller interface that enables programmatic control of external electronic systems. These systems can be as simple as turning on or off an LED, or as complex as being able to control a robotic arm or other, more elaborate, electronic devices. This Python and embedded programming tutorial will show the reader how to use Raspberry Pi-specific Python libraries to control basic electronic components. Many similar Python tutorials presume extensive knowledge in the use of such components, but this article will not make that presumption. Instead, programmers will be shown a “gentle” introduction into the electronics concepts needed to get this project going, in the hopes that this foundation will encourage the reader to do more experimentation beyond the simple experiment to be presented within this two part programming series.

This article, and the second part of it (follow link from bottom of page in first article), presumes that the reader has a basic understanding of how to navigate the Raspberry Pi OS – namely, how to log in, open a terminal window, and how to use a text editor. It also presumes a basic understanding of the Python programming language and concepts.

See https://www.developer.com/languages/python-raspberry-pi-controls/

#technology #raspberrypi #relays #electronics #python

  • In chevron_right

    JetBrains IDEs connect with Gitpod for cloud-based development

    pubsub.slavino.sk / infoworldcom · Tuesday, 3 May - 20:15 edit

Users of JetBrains IDEs now can do remote development in the cloud via the Gitpod platform.

Through an integration between Gitpod and JetBrains announced April 27, developers can access source code hosted in ephemeral development environments from JetBrains IDEs running in the cloud. Language processing occurs in the Gitpod environment. This is done via an integration between Gitpod and JetBrains Gateway , JetBrains’ remote development application now in a beta stage. Developers can access JetBrains Gateway to get started with linking Gitpod and JetBrains IDEs.

To read this article in full, please click here


Značky: #IntelliJ, #Rozne, #Java, #Python

  • In chevron_right

    Python removes ‘dead batteries’ from standard library

    pubsub.slavino.sk / infoworldcom · Monday, 14 March - 17:22 edit

An initiative to remove outdated and unmaintained modules from Python’s standard library has been approved as Python Enhancement Proposal (PEP) 594 . The modules being pruned are all antiquated, unmaintained, replaced by other modules, or some combination of the above.

There is little chance a modern Python developer will need to rewrite existing apps as a result of these changes. In any case, the modules slated for elimination will not be fully removed until two years from now.

[ Also on InfoWorld: 4 keys to writing modern Python in 2022 ]

Python has long had a “batteries included” philosophy, with the goal of providing a versatile standard library that handles many common development tasks. But criticisms have arisen in the past of how “dead batteries” in the standard library—outdated and hard-to-maintain modules—have outlasted their usefulness and ought to be removed.

To read this article in full, please click here


Značky: #Rozne, #Python

  • Py chevron_right

    How to use httpx, a web client for Python

    pubsub.slavino.sk / pyopensource.com · Wednesday, 2 March - 08:00 edit

The httpx package for Python is a sophisticated web client. Once you install it, you can use it to get data from websites. As usual, the easiest way to install it is with the pip utility:

$ python -m pip install httpx --user

To use it, import it into a Python script, and then use the .get function to fetch data from a web address:


Značky: #Python

  • In chevron_right

    TypeScript usage growing by leads and bounds — report

    pubsub.slavino.sk / infoworldcom · Monday, 21 February - 11:00 edit

Usage of TypeScript, Microsoft’s strongly typed language based on JavaScript , has soared compared to six years ago, according to the “2021 State of JS” survey released February 15.

Asked about their use of “JavaScript flavors,” 69% of survey respondents now use TypeScript, compared to just 21% six years ago. JavaScript flavors were defined as languages that compile to JavaScript. Other JavaScript flavors trailed TypeScript by a large margin; the next was Elm at 2.4%, followed by Flow at 1.7% and CoffeeScript at 1.5%.

To read this article in full, please click here


Značky: #Python, #Rozne, #Java, #JavaScript

  • In chevron_right

    A brief intro to the Pants build system

    pubsub.slavino.sk / infoworldcom · Thursday, 17 February - 11:00 edit

The Pants build system is a polyglot tool with a slew of nice features including full parallelism and remote worker support. Pants has been around for several years, but since version 2.0 runs on a completely rebuilt Rust engine that’s geared for speed.

Pants is on version 2.9 as of this writing, and now includes alpha support for Java and Scala as well as support for Python and Go. Keep reading to get a look at this promising open source build tool.

[ Also on InfoWorld: 4 keys to writing modern Python in 2022 ]

Pants features

There are a few interesting features that make Pants a build system worth considering as an alternative to traditional choices. Here they are with a description.

To read this article in full, please click here


Značky: #Devops, #Python, #Rozne, #Java

  • Py chevron_right

    Customize your shell prompt with Starship

    pubsub.slavino.sk / pyopensource.com · Monday, 7 February - 08:01 edit


Značky: #Python