Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
YuleLog - A terminal based Yule Log Fireplace for the Christmas Season. Made with Asciimatics!

I had the idea this morning to make a terminal based fireplace like the ones you see on youtube around this time of year. I looked around and didn't really see anything like it so I figured I'd go ahead with it.

I have always loved Asciimatics and remembered there's an awesome fire effect built in. There was a Christmas example, but it only had floating text.

I then found a photo of a log and converted it with https://picascii.com/ and spent some time tweaking the position a bit till it looked good on different console sizes.

It's up on Pypi so you can

`$ pip install YuleLog`

Not a lot of work at all but I'm pretty happy with the outcome and I hope you all are too :D

tl;dr - YuleLog -

Screenshot: https://github.com/Duroktar/YuleLog/blob/master/yule_log/screenshot.png

Github - https://github.com/Duroktar/YuleLog

Pypi - https://pypi.python.org/pypi

Release page - https://github.com/Duroktar/YuleLog/releases/tag/0.0.1

Love, Peace and Happiness to you all. Merry Christmas!!

edit: WORKS BEST IN FULLSCREEN!

/r/Python
https://redd.it/5k5o9l
Basic Model concept but I can't wrap my head around how to do it... Help, please.

Spending part of the Christmas holiday working on my first big Django project and I've hit a wall. I just can't wrap my head around how to do this so any help would be appreciated.

Custom user account (already made and set up) has a field which is used to reference an external API. Information related to the user (transaction list with details) is pulled from the external API (JSON) and saved to my database. Each user will have multiple transactions and each transaction will have multiple pieces of data associated with it that needs to be saved (to be later presented as a graph).

I can't wrap my head around how to set up the model to get the JSON data into my database. This includes creating the model and saving it.

I realize it's probably an elementary problem but if anyone can just list what I need to do to get this done I'd appreciate it. Most tutorials use data from forms (or blog entries) to illustrate how to save data to a database so I guess I need to know how to process and save data from a non-form outside source.

/r/django
https://redd.it/5k45xh
I implemented a module in python for oversampling skewed datasets. Would love to hear your thoughts on it!

It is an implementation of the ADASYN algorithm (link to paper: bit.ly/22KgAnP) and is designed to work along the scikit-learn API. I ran into the need of an oversampling module that focuses more on examples that are harder to classify, and I said, what the heck... I will implement it on my own. Feel free to use it in your projects and if you find any bugs just open an issue

https://github.com/stavskal/ADASYN

Don't forget to star if you find it useful ;)

/r/pystats
https://redd.it/44r9ye
Supervisord project: Python 2 to 3 porting help needed

Supervisor is a process supervisor used by hundreds of thousands (millions?) of production systems. It is used by people who don't even use Python as their application language.

supervisord is one of the most useful tools to run production systems.. and is more relevant when we look at the Docker world..Where is it is usually run as "init 1".

For us (and a crazy ton of systems people who dont even use python for application code), the "supervisor" incompatibility is a blocker to move to py3.

Unfortunately, I think the maintainers are handicapped by py3 expertise - https://github.com/Supervisor/supervisor/labels/python%203

>Supervisor has some major issues on Python 3. Many of these issues are encoding related as well so merging this one patch doesn't move the needle much. We need someone who has strong experience in Python 2/3 porting and is willing to spend a non-trivial amount of time looking at these bytes/strings issues together.


https://github.com/Supervisor/supervisor/pull/471#issuecomment-267793117

/r/Python
https://redd.it/5k1875
a Py3.6 fizzBuzz oneliner with f-strings

print(*map(lambda i: f"{'Fizz' * (not i%3)}{'Buzz' * (not i%5)}" or i, range(1,101)), sep='\n')



/r/Python
https://redd.it/5k7lnb
How to build an interactive dashboard?

Do any packages exist allowing a dashboard with greater layout flexibility than the notebook allows?

/r/IPython
https://redd.it/4ogcgg
[AF] redirection issues

What I'm trying to do is redirect back to the home page (index.html) after a user has submitted their email. Once they submit their email address on a form located on index.html, they are sent to a thank you page (thanks.html). I'm having problems redirecting them back to index.html

I've already tried the official documentation and looked for help online.
I couldn't get return redirect or url_for to work. And all my html files are located in the template directory so that's no the problem.

here is a link to the code. http://pastebin.com/sMAKUu3d
Thanks for the help!

/r/flask
https://redd.it/5k8mlw
Plotting multiple data series side by side in Bokeh

I'm trying to something that seems like it should be really simple, but I haven't been able to figure it out. I have a pandas dataframe with two columns of data, targets and actuals achieved. I want to plot these two side by side in a Bokeh bar chart. However, I can't seem to figure out how to pass multiple data series to the Bar function. I'd rather not have to re-shape my entire dataframe to work with the Bokeh group function, which seems to require that the data to be plotted is all in one series. Thanks.

/r/IPython
https://redd.it/4oc9fy
Introducing geodjango-tigerleaflet, a django app for displaying US States and Counties on Leaflet maps and navigating through them.

I've written a quick django package to help me split out some functionality related to US Census data (with code borrowed from geodjango-tigerline) and serve it for use on leaflet. It's a pretty niche thing, but offering it on github/pypi in case anybody else can make use of it. Of course, if you want to offer pull requests, make github issues or code review then I certainly won't turn it down.

[geodjango-tigerleaflet github](https://github.com/jlillest/geodjango-tigerleaflet)
[geodjango-tigerleaflet example project github](https://github.com/jlillest/geodjango-tigerleaflet-example)

I'm still learning the package creation process, as well as pypi documentation, so any pointers there are also appreciated. I found the process of creating the example app, package and submitting to pypi very easy using the cookiecutter utility. Many thanks to pydanny!

The overall utility of the package is to offer the state and county shapefiles/geojson files for use in the lightweight GIS toolset of leaflet. The templates provided are mostly to show how to get it up and running, though I'd love to make it more generic and use template tags for some of this. The real utility is the geojson views for providing data directly.

The app requires postgresql with the postgis extension, but if you're doing GIS-type work and need the shapefiles stored in your database then you already understand why this is required. Geodjango is such a great toolset for GIS.

Enjoy!

/r/django
https://redd.it/5k8nke
Plotting a transformed random variable

Let's say I've got a random variable X ~ uniform(-1,1) (is a random number between -1 and 1), and Y=X^2.

Using scipy.stats.uniform I can easily plot X's pdf by doing:

x=numpy.linspace(-4,4,100)
plot(x,uniform.pdf(x))

But I'm not sure how to plot Y's pdf/cdf.

Is there some sort of module that will do what I need?

/r/pystats
https://redd.it/42n7ge