Python Revisited 2024: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Created page with "=Introduction= A quick revisit to python to maybe improve/refresh my own knowledge. =Project Creation (Poetry)= Guess most folks know about this and knowing IT, some people will hate it, and some will love it. Coming fresh out of NodeJS and React/Nextjs, this seemed a good idea to me. I am starting to feel with AI, that technologies are going to be changing quickly and being able to get going quickly is useful. This looked easy but when I tried it, it was harder. Here g..."
 
Line 2: Line 2:
A quick revisit to python to maybe improve/refresh my own knowledge.  
A quick revisit to python to maybe improve/refresh my own knowledge.  
=Project Creation (Poetry)=
=Project Creation (Poetry)=
Guess most folks know about this and knowing IT, some people will hate it, and some will love it. Coming fresh out of NodeJS and React/Nextjs, this seemed a good idea to me. I am starting to feel with AI, that technologies are going to be changing quickly and being able to get going quickly is useful. This looked easy but when I tried it, it was harder. Here goes
Guess most folks know about this and knowing IT, some people will hate it, and some will love it. Coming fresh out of NodeJS and React/Nextjs, this seemed a good idea to me. I am starting to feel with AI, that technologies are going to be changing quickly and being able to get going quickly is useful. This looked easy but when I tried it, it was harder.  
Here goes
==Make a Project==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
poetry new my-project
</syntaxhighlight>
==Make a Fask App==
Now lets make a Flask app. We will start by putting the code in src/app
<syntaxhighlight lang="bash">
cd my-project
mkdir -p src/app
touch src/app/__init__.py
touch src/app/__main__.py
cd my-project
</syntaxhighlight>
==Modify the pyproject.toml==
The main thing is to change the packages line. I had a bit of trouble getting pylance to find my packages because, maybe, I did not poetry install after this. See below.
<syntaxhighlight lang="toml">
[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
authors = ["Bill Wiseman <bw@bibble.co.nz>"]
readme = "README.md"
packages = [{ include = "app", from = "src" }]
[tool.poetry.dependencies]
python = "^3.12"
[tool.poetry.group.dev.dependencies]


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
</syntaxhighlight>
</syntaxhighlight>

Revision as of 02:10, 27 October 2024

Introduction

A quick revisit to python to maybe improve/refresh my own knowledge.

Project Creation (Poetry)

Guess most folks know about this and knowing IT, some people will hate it, and some will love it. Coming fresh out of NodeJS and React/Nextjs, this seemed a good idea to me. I am starting to feel with AI, that technologies are going to be changing quickly and being able to get going quickly is useful. This looked easy but when I tried it, it was harder. Here goes

Make a Project

poetry new my-project

Make a Fask App

Now lets make a Flask app. We will start by putting the code in src/app

cd my-project
mkdir -p src/app
touch src/app/__init__.py
touch src/app/__main__.py
cd my-project

Modify the pyproject.toml

The main thing is to change the packages line. I had a bit of trouble getting pylance to find my packages because, maybe, I did not poetry install after this. See below.

[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
authors = ["Bill Wiseman <bw@bibble.co.nz>"]
readme = "README.md"

packages = [{ include = "app", from = "src" }]

[tool.poetry.dependencies]
python = "^3.12"

[tool.poetry.group.dev.dependencies]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"