- Open termnal
CTRL+ALT+T
- Update the packages list:
sudo apt update
- Install Python3 :
sudo apt-get install python3
- Create a folder on computer to use for Python programs, such as
~/pythonpractice
- Type
cd ~/pythonpractice
to change directory to your pythonpractice folder. - Open text editor and create the python file for example:
nano hello.py
orgedit hello.py
and save program in that folder. - Make sure the first line of file has, add #! and the path of the Python interpreter
#!/usr/bin/env python
. - Make the script executable by
chmod +x <filename>.py
. - And run it as
./<filename>.py
.For example:./hello.py
. python <filename>.py
for Python 2.xpython3 <filename>.py
for Python 3.x
-
First install this :
pip3 install virtualenv
-
Open a folder and go to inside it. And create an envirenoment inside of your folder:
virtualenv env
-
Activate the environment (for GNU/Linux and Mac):
source env/bin/activate
(for Windows) :\env\Scripts\activate.bat
-
When your virtual env is active create requirement file for dependencies:
pip freeze > requirements.txt
-
See the txt file :
cat requirements.txt
-
İnstall the all necessary packages :
pip install -r requirements.txt
Basics Intermediate Advanced - variables,numbers,strings,lists - exceptions handling - multithreading - dictionary , tuple - classes , objects - multiprocessing - if,for control blocks - inheritance - multiprocessing lock & pool - functions - generators - unit tests:pytest - read,write files - list/dict comprehensions - context managers - modules - sets,command line argparse - ...... - ....... - ....... - ......
- Install Flask :
pip3 install Flask
- Import :
from flask import Flask
- install SQLAlchemy the Database Toolkit for Python:
pip3 install flask-sqlalchemy
- Import :
from flask_sqlalchemy import SQLAlchemy
Project layout should look like this:
Project_name/
├── templates/
│ └── base.html
└── static/
│ └── style.css
-https://flask.palletsprojects.com/en/1.1.x/tutorial/layout/
- Import :
import pdb;
- Insert the following code at the location where you want to break into the debugger:
pdb.set_trace()
- iterate over files in that directory - from 0 to N. frame!!!!for filename in os.listdir(directory):
import os
import re
directory = '/images' # assign directory
for data_file in sorted(os.listdir(directory), key=lambda x:float(re.findall("(\d+)",x)[0])):
print(data_file)