djangoproject
154 subscribers
2 videos
8 files
550 links
connect with us:
@XtakjoyX
Download Telegram
https://github.com/4Catalyzer/pykubectl

A python bridge to kubectl providing additional functionalities useful for CD and #automation.

#machine_learning
https://github.com/pytorch/pytorch

#PyTorch doesn't only port #Torch to Python, but adds many other conveniences, such as #GPU acceleration and a library that allows multiprocessing to be done with shared memory (for partitioning jobs across multiple cores). Best of all, it can provide GPU-powered replacements for some of the unaccelerated functions in #NumPy.

#machine_learning
https://realpython.com/blog/python/getting-started-with-django-channels/#.WLWLY9_IJ0s.linkedin

In this tutorial, we will use #Django_Channels to create a real-time application that updates a list of users as they log in and out.

Django Channels Logo

With #WebSockets (via Django Channels) managing the communication between the client and the server, whenever a user is authenticated, an event will be broadcasted to every other connected user. Each user’s screen will change automatically, without them having to reload their browsers.
http://pybit.es/codechallenge11.html

Inspired by David Beazley's #Generator Tricks for Systems Programmers we ask you to turn the following unix #pipeline into Python code using generators. To get a bunch of .py files you can use our challenges repo you cloned. Or use a project of your own.

Note that in our experience one subprocess is not necessarily one generator, for example 'sort|uniq|sort' can be easily combined into one, as well as 'grep|sed'. See our template if you need guidance.
https://github.com/Miserlou/Zappa#about

Zappa makes it super easy to build and deploy all Python #WSGI applications on #AWS Lambda + #API Gateway. Think of it as "#serverless" #web hosting for your Python apps. That means infinite scaling, zero downtime, zero maintenance - and at a fraction of the cost of your current deployments!

If you've got a Python web app (including Django and Flask apps), it's as easy as:

$ pip install zappa
$ zappa init
$ zappa deploy

and now you're server-less! Wow!

What do you mean "serverless"?

Okay, so there still is a server - but it only has a 40 millisecond life cycle! Serverless in this case means "without any permanent infrastructure."
http://techioz.com/lambda-function-in-python/

#lambda function is defined using lambda keyword. It’s an anonymous function without name.

#python #learn
http://docs.python-guide.org/en/latest/

Greetings, Earthling! Welcome to The Hitchhiker’s Guide to Python.

This is a living, breathing guide. If you’d like to contribute, fork us on GitHub!

This handcrafted guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a daily basis.

This guide is opinionated in a way that is almost, but not quite, entirely unlike Python’s official documentation. You won’t find a list of every #Python web framework available here. Rather, you’ll find a nice concise list of highly recommended options.

#learn
https://realpython.com/blog/python/introduction-to-mongodb-and-python/#.WMfv6BURLc4.linkedin

#Python is a powerful programming language used for many different types of applications within the development community. Many know it as a flexible language that can handle just about any #task. So, what if our complex Python application needs a #database that’s just as flexible as the language itself? This is where #NoSQL, and specifically #MongoDB, come in to play.
http://www.drdobbs.com/open-source/the-new-asyncio-in-python-34-servers-pro/240168408

In a previous article on the new #asyncio module introduced in Python 3.4, I explained simple use of event loop functions that register, execute, and delay or cancel calls. In this article, I demonstrate more-advanced examples that explore asyncio's support for server and client programming, #protocols, and #transports.

#learn
http://stackoverflow.com/questions/29819151/what-should-i-decorate-with-asyncio-coroutine-for-async-operations

If you have a function that needs to use yield from to call a #coroutine, you should #decorate it with asyncio.coroutine. Also note that coroutines are often (not always) "viral". As soon as you add yield from to a function it becomes a coroutine, and additionally any function that calls that coroutine usually (though not always) needs to be come a coroutine, too.
http://calebmadrigal.com/calling-sync-code-from-asyncio/


Calling synchronous code from asyncio

Mon 25 May 2015

I recently needed to call some #synchronous code from #asyncio. Thankfully, asyncio provides the #run_in_executor function, which runs the specified function in a different thread. Here is an example of using it:

#learn
https://pymotw.com/3/asyncio/executors.html

Combining Coroutines with Threads and Processes

A lot of existing libraries are not ready to be used with #asyncio natively. They may block, or depend on concurrency features not available through the module. It is still possible to use those libraries in an application based on asyncio by using an #executor from #concurrent.futures to run the code either in a separate thread or a separate process.

#Threads

The #run_in_executor() method of the event loop takes an executor instance, a regular callable to invoke, and any arguments to be passed to the callable. It returns a Future that can be used to wait for the function to finish its work and return something. If no executor is passed in, a #ThreadPoolExecutor is created. This example explicitly creates an executor to limit the number of worker threads it will have available.

#Processes

A ProcessPoolExecutor works in much the same way, creating a set of worker #processes instead of threads. Using separate processes requires more system resources, but for computationally-intensive operations it can make sense to run a separate task on each CPU core.

#learn
https://see.stanford.edu/Course/CS229

This course provides a broad introduction to #machine_learning and #statistical_pattern_recognition.

Topics include: supervised learning (generative/discriminative learning, parametric/non-parametric learning, neural networks, support vector machines); unsupervised learning (clustering, dimensionality reduction, kernel methods); learning theory (bias/variance tradeoffs; VC theory; large margins); reinforcement learning and adaptive control.
The course will also discuss recent applications of machine learning, such as to robotic control, data mining, autonomous navigation, bioinformatics, speech recognition, and text and web data processing.
Students are expected to have the following background:
http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/

The asynchronous programming topic is difficult to cover. These days, it's not just about one thing, and I'm mostly an outsider to it. However, because I deal a lot with relational databases and the Python stack's interaction with them, I have to field a lot of questions and issues regarding #asynchronous_IO and #database programming, both specific to #SQLAlchemy as well as towards #Openstack.

#asyncio
http://aiomysql.readthedocs.io/en/latest/sa.html

aiomysql.sa — support for SQLAlchemy functional SQL layer

sqlalchemy support ported from #aiopg, so #api should be very familiar for aiopg user.

While core API provides a core support for access to #MySQL #database, manipulations with raw SQL strings too annoying.

Fortunately we can use excellent SQLAlchemy Core as SQL query builder.

So you can execute SQL #query built by tbl.insert().values(val='abc') or tbl.select() expressions.

#sqlalchemy has rich and very powerful set of SQL construction functions, please read tutorial for full list of available operations.

Also we provide SQL transactions support. Please take a look on SAConnection.begin() method and family.
# How to merge two #dicts
# in Python 3.5+

»> x = {'a': 1, 'b': 2}
»> y = {'b': 3, 'c': 4}

»> z = {**x, **y}
»> z
{'c': 4, 'a': 1, 'b': 3}

# In Python 2.x you could
# use this:
»> z = dict(x, **y)
»> z
{'a': 1, 'c': 4, 'b': 3}
https://www.djangoproject.com/weblog/2017/apr/04/django-111-released/

The #Django team is happy to announce the release of Django 1.11.

This version has been designated as a long-term support (#LTS) release, which means that security and data loss fixes will be applied for at least the next three years. It will also receive fixes for crashing bugs, major functionality bugs in newly-introduced features, and regressions from older versions of Django for the next eight months until December 2017.
http://aiohttp.readthedocs.io/en/stable/web.html#aiohttp-web-websockets

In order to implement a #web_server, first create a #request handler.

A request handler is a coroutine or regular function that accepts a Request instance as its only parameter and returns a Response instance:
#aiohttp #asyncio

from aiohttp import web

async def hello(request):
return web.Response(text="Hello, world")

Next, create an Application instance and register the request handler with the application’s #router on a particular HTTP method and path: