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
A website to look for Django function/class names and import paths

I always forget certain function/class import paths and I thought a website could come in handy so I created one: http://dilu.karthus.net/ ^^^The ^^^source ^^^code ^^^is ^^^available ^^^here: ^^^https://github.com/kviktor/dilu

/r/django
https://redd.it/5lulzy
Can't seem to figure out why I keep ending up with an empty dictionary, care to check it out?

Here's some code from a prof who is teaching an online course (it's through a MOOC, so I can't really ask him directly).

import urllib
url = 'http://www.py4inf.com/code/romeo.txt'
fhand=urllib.urlopen(url)

counts = dict()
for line in fhand:
words = line.split()
for word in words:
counts[word] = counts.get(word, 0) + 1

print counts

I expected a dictionary containing something to the effect of 'some_word: # of occurrences of some_word' but I just get an empty dictionary. I'm running Python 2.7 inside a Jupyter notebook if that helps.

Edit: I think I fixed it. I forgot to use counts.iteritems() to print out the words and their counts. Though, I'm still wondering why I can't view the dictionary.

/r/Python
https://redd.it/5lwkzn
What's that Python script that you could use to generate text to speech from a bunch of sound files?

Is anyone aware of a python module that would use as many voice files one feeds it to generate a usable cache of files to use for text to speech conversion? I am fairly certain I came across it here.

/r/Python
https://redd.it/5lwit4
[AF]Flask routes not working

Hi guys, I'm trying to setup my own server for the first time and I'm running Ubuntu Server 15.04 with nginx and gunicorn.
I'm following that tutorial https://realpython.com/blog/python/kickstarting-flask-on-ubuntu-setup-and-deployment/, and everything is all right, but I can't make flask follow my routes. I can even set a different 404 error (that's how I figured flask was running). Can I get some help here?

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.errorhandler(404)
def page_not_found(error):
return 'Rota com problema {}'.format(request.url), 404

@app.route("/")
@app.route("/index")
def index():
return 'Flask is running!'


@app.route('/data')
def names():
data = {"names": ["John", "Jacob", "Julie", "Jennifer"]}
return jsonify(data)


if __name__ == '__main__':
app.run()

There's my app.py.

I can provide other files and so related to the project.

Edit: Did some further testing and it works all right when I use "curl localhost:8000" or "curl localhost:8000/data". The issue is with my server and not flask???

Edit2: it was nginx and not my app, both nginx and flask are really bad at reporting errors and issues, geez. Nginx was redirecting to localhost:8000 and I was testing against localhost:8000/. Just added that extra slash after the host and everything is fine.

/r/flask
https://redd.it/5lsvss
[P] Pre-trained RNN chatbot

Here is a [pre-trained TensorFlow-powered chatbot](https://github.com/pender/chatbot-rnn) that was trained on many gigabytes of Reddit conversations for over 37 days with a Titan X GPU.

The underlying model is a character-based sequence predictor and it uses optional beam search and relevance masking/MMI to formulate its responses. It comes with a python script for interactive chatting.

A sample dialogue transcript (which was not cherry-picked) is included in the github readme.

Also included is a python script to assemble conversations from raw Reddit data, which I hope may be of interest for other similar projects.

/r/MachineLearning
https://redd.it/5lx7px
Help with a simple Python program / just learning

Hello,

I have been working through tutorials and such but am still a newbie at Python. I decided to try writing a simple program from scratch in order to further my learning.

The goal of the program is to take word (text string) as input, count the vowels (I didn't include Y in order to make it simple as why is not always a vowel) and output the number of vowels back to the user. Here is what I have so far:

# Written in Python 2.7
# Attempting to count the vowels within a string and
# output that count to the user.
vowelList = ["a", "e", "i", "o", "u"]
vowelCount = 0

print "Please type in a word."
print "This program will count the number of vowels in that word."
userWord = raw_input("What is your word? ")

wordLength = len(userWord)
print wordLength

for (vowelList) in (userWord):
vowelCount += 1
print vowelCount

Note: what this program actually does is

Return the total length of the word
count each element in the list and return those one by one.

/r/Python
https://redd.it/5lyiuo
Django/DRF with Python 3.6?

I'm starting a new DRF app with Django 1.10 and I want to use Python 3.6. It's not yet listed as a supported version of Python, but has anyone given it a try?

/r/django
https://redd.it/5lzpvb
Releasing my first project and I'd love to have some people try it out! (x-post /r/Python)

Hey everyone! I wanted to share a little project I've worked on for the last few months. It's called [**Lintly**](https://lintly.com). It is a **continuous Python code quality tool** written in Django. I'm officially releasing it as a beta today for public projects on GitHub. At some point I'd like for it to work with private repos, but I want to get some feedback first.

Okay, so here's what Lintly does. It runs `flake8` on your code each time you push to GitHub or open a PR. Then it comments on PRs with violations, and can be setup to send email or Slack notifications. Here are some features that I think are pretty cool:

* **Pull Request reviews:** Lintly will use the new GitHubs PR Reviews to comment with issues on individual lines of a PR. *Heads up:* Due to GitHub's restrictions, you have to invite the bot account [lintly-bot](https://github.com/lintly-bot) to be a collaborator on your repo in order to get this. Otherwise lintly-bot will simply comment on the PR.
* **Issue help:** I wrote up explanations and examples for *each* flake8 violation. So if you've ever wondered what the heck "continuation line under-indented for hanging indent" means, then I'll have examples to help you fix it.
* **Code quality over time:** Lintly keeps track of your project's code quality over time, so you can see if you're making improvements or not.

I would love to have some people try out Lintly on their open source projects. Please [let me know](https://github.com/LintlyCI/Lintly-Issues) if you think of any improvements or notice any bugs while using it.

If you have any interest, I wrote a [blog post](http://blog.lintly.com/2016/01/04/introducing-lintly/) that explains a little more about Lintly.

Thanks for reading. I hope you find it useful!

Grant

Last thing, if you're into Twitter then feel free to follow me ([@gmcconnaughey](https://twitter.com/gmcconnaughey)) or Lintly ([@LintlyCI](https://twitter.com/LintlyCI)). I don't really tweet much, but I'm hoping to start tweeting about updates to Lintly as I go along.

/r/django
https://redd.it/5lzrv5
Have you ever integrated Django & Apache Solr?

What was the reason for doing it?

How did it go?

What guide did you follow?

What was the outcome?

Any gotchas?

Thanks for sharing.



/r/django
https://redd.it/5lyyq5
Django and Wowza server?

I have 2 servers.

Server A = Django + front-end.

Server B = Wowza server.

I need upload video via Django admin and send them into Server B. After that get a player and render it via Django template on a page.

So how can I do this task? Maybe you have better way to do this.

/r/django
https://redd.it/5m1ppl
Can't download a youtube video in Heroku Production (with youtube-dl) probably a path problem

Hi everyone, so, I have this little flask app in production, everything is fine, except the download of an audio song through the youtube-dl lib.

In local everything works as intended, the download, the path and so on. But in production, I just can't download a single thing, so I thinked about that and readed my heroku logs, and I think the problem is the following ;

When I hit the download button, the file is downloaded ON my Heroku server (in my app/ fodler)
instead of the "client" computer, and I don't really know how to fix that, I've searched through google, reddit, stackoverflow etc and nothing about that.

For testing
purposes, I've found a similiar and minimalist app on github (it's not mine, [here is the link](https://github.com/swhh/python_youtube_project)) and the same problem occur, the exact error message is :


2017-01-04T14:05:19.080112+00:00 app[web.1]: Exception on / [POST]
2017-01-04T14:05:19.080122+00:00 app[web.1]: Traceback (most recent call last):
2017-01-04T14:05:19.080124+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/flask/app.py", line 1817, in wsgi_app
2017-01-04T14:05:19.080125+00:00 app[web.1]: response = self.full_dispatch_request()
2017-01-04T14:05:19.080127+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/flask/app.py", line 1477, in full_dispatch_request
2017-01-04T14:05:19.080128+00:00 app[web.1]: rv = self.handle_user_exception(e)
2017-01-04T14:05:19.080128+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/flask/app.py", line 1381, in handle_user_exception
2017-01-04T14:05:19.080129+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
2017-01-04T14:05:19.080130+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
2017-01-04T14:05:19.080131+00:00 app[web.1]: raise value
2017-01-04T14:05:19.080132+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/flask/app.py", line 1475, in full_dispatch_request
2017-01-04T14:05:19.080132+00:00 app[web.1]: rv = self.dispatch_request()
2017-01-04T14:05:19.080133+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/site-packages/flask/app.py", line 1461, in dispatch_request
2017-01-04T14:05:19.080135+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args)
2017-01-04T14:05:19.080135+00:00 app[web.1]: File "/app/app.py", line 76, in hello
2017-01-04T14:05:19.080136+00:00 app[web.1]: with TemporaryDirectory('videos') as temp_dir:
2017-01-04T14:05:19.080137+00:00 app[web.1]: File "/app/app.py", line 25, in __enter__
2017-01-04T14:05:19.080137+00:00 app[web.1]: self.name = tempfile.mkdtemp(dir=self.directory)
2017-01-04T14:05:19.080138+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.5/tempfile.py", line 368, in mkdtemp
2017-01-04T14:05:19.080139+00:00 app[web.1]: _os.mkdir(file, 0o700)
2017-01-04T14:05:19.080143+00:00 app[web.1]: FileNotFoundError: [Errno 2] No such file or directory: 'videos/tmp6_i_oy_z'


So if anyone have an idea about that..I'm kind of lost, I don't find any fix and it's my first time pushing something in production.

Maybe I have to give an IP address to my path for downloading the file on the client address ?

On a side note ; Is it possible to apt get update on Heroku ? I know it's possible to apt-get install through buildpacks, but can I update some packages ?
And sorry for my english. Thanks a lot for your time.


/r/flask
https://redd.it/5m09mk
I built a job board/aggregator only for remote Python jobs

Hi guys,

I just launched https://www.RemotePython.com a few days ago (built in Python of course, with Django). I started the project as I'm a freelance Python developer and only work remotely, and thought it would be nice if there's a site that only lists remote Python jobs as that would save people time from having to check/subscribe to multiple sites.

Right now, I'm doing the job postings manually. I have a list of sites that I check daily. I make sure that the job actually involves Python before posting it as sometimes you'll see postings like "we're a Java shop, but we'd also consider candidates who have experience in Python, etc.", and they get tagged as "python" because it appeared in the text.

I hope some of you will find the site useful and any feedback is appreciated!

/r/Python
https://redd.it/5m3hoy