As you all may know pip is a python package manager and everyone has worked with it to install python libs.
Some of the commands with pip that you may not know about it:
- freeze: output installed packages in requirements format. (you can grep and search for a specific package):
- list: list installed packages:
- show: Show information about installed packages:
Important note for devops: pip by default install a stable version of the package. If you need to install an unstable version of the package (latest version) use
If you want to manage your custom python repository package versions (RC, Alpha, Beta, Stable, etc) add
The important part is
To see list of
https://pypi.python.org/pypi?%3Aaction=list_classifiers
Now you can give versioning like
To see different classifiers see the link
https://pypi.python.org/pypi/Django
#django #pip #pre_release #freeze #package #python #devops
Some of the commands with pip that you may not know about it:
- freeze: output installed packages in requirements format. (you can grep and search for a specific package):
rply==0.7.4
rsa==3.2.3
sasl==0.2.1
scipy==0.13.0b1
- list: list installed packages:
tcpwatch (1.3.1)
telebot (0.0.3)
thrift (0.9.3)
- show: Show information about installed packages:
$ pip show pandas
Name: pandas
Version: 0.17.0
Summary: Powerful data structures for data analysis, time series,and statistics
Home-page: http://pandas.pydata.org
Author: The PyData Development Team
Author-email: pydata@googlegroups.com
License: BSD
Location: /Library/Python/2.7/site-packages
Requires: numpy, python-dateutil, pytz
Important note for devops: pip by default install a stable version of the package. If you need to install an unstable version of the package (latest version) use
--pre
flag to install pre-release package.If you want to manage your custom python repository package versions (RC, Alpha, Beta, Stable, etc) add
classifiers
to your setup.py script like below:setup(...,
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Python Software Foundation License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Topic :: Communications :: Email',
'Topic :: Office/Business',
'Topic :: Software Development :: Bug Tracking',
],
)
The important part is
Development Status :: 4 - Beta
, which for stable release you would use Development Status :: 5 - Production/Stable
.To see list of
pypi
Development Status values read from the below link:https://pypi.python.org/pypi?%3Aaction=list_classifiers
Now you can give versioning like
Django 2.0b1
(for pre release) and Django 1.11.6
for stable release.To see different classifiers see the link
Django
link below to learn more:https://pypi.python.org/pypi/Django
#django #pip #pre_release #freeze #package #python #devops
put a key in dictionary into another key and remove it from dictionary:
Idiots way:
Tech C**P way:
#pop #python #dictionary #code_improvement
Idiots way:
data = {
'username': 'alireza@gmail.com'
}
data['email'] = data['username']
del data['username']
Tech C**P way:
data = {
'username': 'alireza@gmail.com'
}
data['email'] = data.pop('username')
pop
access the data and remove it from data payload. In case username
is not in data, an error will be raised. To prevent such an error give it default value:data['email'] = data.pop('username', 'NO_USERNAME')
#pop #python #dictionary #code_improvement
A Fantastic completely FREE course to implement ONLINE ESHOP using
https://scotch.io/courses/build-an-online-shop-with-vue
vue.js
:https://scotch.io/courses/build-an-online-shop-with-vue
Digitalocean
Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
There is a mgic method in python called contains which should return true if item is in self, false otherwise.
The method signature of contains:
Samples:
BUT DONT USE this magic methods this way, as it should be used in internal class operations.
Membership test operator for this is
Side note: methods which are started by _ (underscore) should not be called directly outside of class scope. They meant for internal class operations.
#python #membership #in #contain #exist
The method signature of contains:
object.__contains__(self, item)
Samples:
>>> 'sample_output'.__contains__('sample')
True
>>> 'sample_output'.__contains__('ASL')
False
BUT DONT USE this magic methods this way, as it should be used in internal class operations.
Membership test operator for this is
in
. In case you want to test membership:>>> 'sample' in 'sample_output'
True
>>> 'ASL' in 'sample_output'
False
Side note: methods which are started by _ (underscore) should not be called directly outside of class scope. They meant for internal class operations.
#python #membership #in #contain #exist
OneSignal - free multiplatform push notification service
Send 100% FREE push notifications to Android, iOS, Web by their completely free SDKs on
OneSignal
. #OneSignal is multiplatform push notification service that you just interact with it using API calls in JSON format. It has a thorough documentation for SDKs and Server API.* BE AWARE THAT use
OneSignal
in case your user's privacy does not matter to you! They have mentioned in their privacy policy that they sell this information!!! All device locations, user email addresses and all the other sensetive data will be collected by OneSignal
.#push_notification #push #ios #android #web #notification #one_signal
It is sometimes tempting to log less in order to let's say improve performance or save disk space, and blah blah blah!
Loggers in python are the last thing to think about when you think about performance. You can place log ratote to use less disk space. From my own experience log as much as you can. Log as every step necessary to make log level verbose. At last in case you think you application is very stable you change log level to info, and all debug logs are ignored.
It took sometimes hours to debug a few modules (in microservice structure) to find the culprit, something that could have been solved by putting more logs.
Log, log and log more...
#python #log #logger #performance
Loggers in python are the last thing to think about when you think about performance. You can place log ratote to use less disk space. From my own experience log as much as you can. Log as every step necessary to make log level verbose. At last in case you think you application is very stable you change log level to info, and all debug logs are ignored.
It took sometimes hours to debug a few modules (in microservice structure) to find the culprit, something that could have been solved by putting more logs.
Log, log and log more...
#python #log #logger #performance
UWSGI - Web server Gateway Interface
-----
uwsgi is a big C application which is used to deploy python applications on server. There is a full documentation of UWSGI in
Reference: http://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html
#python #uwsgi #reference #flask #readthedocs
-----
uwsgi is a big C application which is used to deploy python applications on server. There is a full documentation of UWSGI in
readthedocs
, follow it and master it to handle loads of requests concurrently and use graceful reloading of the app. It is usually put behind a full web server like nginX by proxying.Reference: http://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html
#python #uwsgi #reference #flask #readthedocs
Forwarded from Deleted Account
جلسه ۴۹ گروه کاربران پایتون تهران، پنجشنبه ۱۱ آبان ۱۳۹۶ از ساعت ۱۴:۳۰ تا ۱۶:۰۰ در «شتابدهندهٔ آواتک» به نشانی «تهران، خیابان کارگر شمالی، بالاتر از بزرگراه جلال آل احمد، پردیس دانشکدههای فنّی دانشگاه تهران، دانشکدهٔ مهندسی نفت، طبقهٔ پنجم» برگزار خواهد شد.
در صورتی که داوطلب ارائه فنی هستید موضوع ارائه خود را به میلینگ لیست گروه کاربران پایتون تهران ارسال کنید.
https://mail.python.org/mailman/listinfo/tehpug
یا به بنده پی ام دهید.
در صورتی که داوطلب ارائه فنی هستید موضوع ارائه خود را به میلینگ لیست گروه کاربران پایتون تهران ارسال کنید.
https://mail.python.org/mailman/listinfo/tehpug
یا به بنده پی ام دهید.
PART-1: Basic docker commands
* Let's suppose you have built an image.
Display list of your docker images:
Output:
As you can see image name is
To run the image:
The above command runs the docker image. The newly created processs by
host, and the second port
Now to see list of your containers use
From here you can see the ID of your container which is equal to
ontainer (login into container):
if you want to connect to the stdout of your container use
*** IF you are attached to a container and press ^c afterward, the container will be stopped.
If you want to stop a container:
It prints out container id
#docker #commands #docker_part1 #basic #container #devops
* Let's suppose you have built an image.
Display list of your docker images:
docker images
Output:
REPOSITORY TAG IMAGE ID CREATED SIZE
py_app latest baa470dc5609 3 weeks ago 591MB
As you can see image name is
py_app
.To run the image:
docker run -it -d -p 8085:8084 py_app
The above command runs the docker image. The newly created processs by
docker run
from your py_app
image is called a container
. -d
runs the image as a daemon and print the container id to your console:$ docker run -it -d -p 8085:8084 py_app
d612ffbd9d560158f1c64997f9a8877243cdf4288c11010298df80b10cfaff5e
-p
exposes the port on your docker file to the port on your host machine. The first port 8085
is the port on yourhost, and the second port
8084
is the port on your docker file.Now to see list of your containers use
docker ps
:docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d612ffbd9d56 py_app "python app.py" 10 minutes ago Up 10 minutes goofy_hopper
From here you can see the ID of your container which is equal to
d612ffbd9d56
. IF you want to have a shell on your container (login into container):
docker exec -it d612ffbd9d56 bash
root@moby:/app#
if you want to connect to the stdout of your container use
attach
, it does not necessary give you a shell:docker attach d612ffbd9d56
*** IF you are attached to a container and press ^c afterward, the container will be stopped.
If you want to stop a container:
$ docker stop d612ffbd9d56
d612ffbd9d56
It prints out container id
d612ffbd9d56
and stop the container. If you enter docker ps
you should not see the container.#docker #commands #docker_part1 #basic #container #devops
What curriculum you are interested in? From now on we will focus more on the specific topics.
Django – 19
👍👍👍👍👍👍👍 58%
Devops (Docker,...) – 7
👍👍👍 21%
Microservice architecture, implementation – 4
👍 12%
Flask – 2
👍 6%
ReactJS – 1
▫️ 3%
👥 33 people voted so far.
Django – 19
👍👍👍👍👍👍👍 58%
Devops (Docker,...) – 7
👍👍👍 21%
Microservice architecture, implementation – 4
👍 12%
Flask – 2
👍 6%
ReactJS – 1
▫️ 3%
👥 33 people voted so far.