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
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
Using Django as a layer between programs and database (a.k.a help a newbie please)

Hello,

At my new job in a small company my employer wants me to create a Django API interface between a manager program (C#) and a MySQL database. Previously the manager communicated directly with the database, and the authentication was only handled by the manager (not that safe). My employer demands that the API uses Django's built-in models and views as much as possible and communication is done via HTTPS.

I have build a few models and for them a few FBVs, so that when I send POST/GET requests I get new data in the database or receive information in JSON form to the manager. User credentials are sent along with the requests with base64 encoding and validated in the views, so that each user handles only their own data.

I have several kind of wide questions/problems I haven't found advice for online, so here goes:

**1. How should I organize my views?** It seems I'm going to need a lot of views to achieve the same functionality as before, so how should I organize them? I will need inserts/updates, lists etc. for a great many models. I haven't seen many examples of people using views this way (not looking at the website at this point).

**2. Any useful tools?** Are there any tools that are useful in doing this, basically making queries indirectly through Django? From what I have found online, I don't want to use raw SQL queries for safety reasons.

**3. Benefits/drawbacks of Django?** Any reasons why Django is even good/bad for what I'm trying to do? I understand that later on when there is a need for a browser based web application this is very useful, but for now I'm just trying to wrap my head around this task.

I'm sorry that my questions are vague, I haven't necessarily thought everything through all the way, as I'm quite new to this type of programming and especially database/code design. Any help you can offer would be very much appreciated!

/r/django
https://redd.it/5lzowf
How do I increment the instance variable for an employee object when an object of a different class is created?

Hi all, I am working on a web-app which to be used by employees to issue "kudos points", which are arbitarily awarded points with an award reason, an award date, and information about who awarded them and who was awarded a point.

I have in my app/models.py two classes, the first being employees:

class Kiemp(models.Model):
emp_id = models.IntegerField()
emp_first = models.CharField(max_length = 100)
emp_last = models.CharField(max_length = 100)
emp_admin = models.CharField(max_length = 1)
emp_kpoints = models.IntegerField(default = 0)
def __str__(self):
fullname = self.emp_first + " " + self.emp_last
return fullname

And my Kudos point class:

class Kudospoint(models.Model):
awarded_to = models.ForeignKey(Kiemp, related_name = 'awarded_to')
awarded_by = models.ForeignKey(Kiemp, related_name = 'awarded_by')
awarded_reason = models.CharField(max_length = 500)
awarded_date = models.DateTimeField(auto_now = False, auto_now_add = True)
def __str__(self):
return "{} was awarded a kudos point by {} for: '{}' on date: {}".format(self.awarded_to, self.awarded_by, self.awarded_reason, self.awarded_date)

I would like it to be that whenever a Kudospoint object is created, the employee it is awarded to has their emp_kpoints incremented. I am not sure how to go about doing this using Django's ORM: should this logic be in the models file in the first place? How should I implement this?




/r/djangolearning
https://redd.it/5m5ddb