python-3.5

How to handle users and roles by app in Django

牧云@^-^@ 提交于 2020-01-16 09:05:31
问题 Hello everyone let me ask something about the admin interface and how can I handle my users by app. Well so sorry I'm nooby first of all. So, I need to create a new app for basically take some quiz so I will need users and these users within my app should have a different role as a student or teacher and so on. The thing is that I don't know if the admin Django interface is just for the DB models or whether I can use it as a security layer in my app. Or otherwise, I should create a buck of

Windows equivalent for spawning and killing separate process group in Python 3?

谁说我不能喝 提交于 2020-01-15 07:29:13
问题 I have a web server that needs to manage a separate multi-process subprocess (i.e. starting it and killing it). For Unix-based systems, the following works fine: # save the pid as `pid` ps = subprocess.Popen(cmd, preexec_fn=os.setsid) # elsewhere: os.killpg(os.getpgid(pid), signal.SIGTERM) I'm doing it this way (with os.setsid ) because otherwise killing the progress group will also kill the web server. On Windows these os functions are not available -- so if I wanted to accomplish something

Tensorflow 0.8 Import and Export output tensors problems

纵饮孤独 提交于 2020-01-14 07:44:12
问题 I am using Tensorflow 0.8 with Python 3. I am trying to train the Neural Network, and the goal is to automatically export/import network states every 50 iteration. The problem is when I export the output tensor at the first iteration, the output tensor name is ['Neg:0', 'Slice:0'] , but when I export the output tensor at the second iteration, the output tensor name is changed as ['import/Neg:0', 'import/Slice:0'] , and importing this output tensor is not working then: ValueError: Specified

How to use pip with python3.5 after upgrade from 3.4?

ε祈祈猫儿з 提交于 2020-01-14 07:32:11
问题 I'm on Ubuntu and I have python2.7, (it came pre-installed) python3.4, (used before today) and python3.5, which I upgraded to today, installed in parallel. They all work fine on their own. However, I want to use pip to install some packages, and I can't figure out how to do this for my 3.5 installation because pip installs for 2.7 and pip3 installs python 3.4 packages. For instance, I have asyncio installed on 3.4, but I can't import it from 3.5. When I do pip3 install aysncio , it tells me

How to use pip with python3.5 after upgrade from 3.4?

时光毁灭记忆、已成空白 提交于 2020-01-14 07:31:11
问题 I'm on Ubuntu and I have python2.7, (it came pre-installed) python3.4, (used before today) and python3.5, which I upgraded to today, installed in parallel. They all work fine on their own. However, I want to use pip to install some packages, and I can't figure out how to do this for my 3.5 installation because pip installs for 2.7 and pip3 installs python 3.4 packages. For instance, I have asyncio installed on 3.4, but I can't import it from 3.5. When I do pip3 install aysncio , it tells me

finding a specific value from list of dictionary in python

ε祈祈猫儿з 提交于 2020-01-13 18:17:30
问题 I have the following data in my list of dictionary: data = [{'I-versicolor': 0, 'Sepal_Length': '7.9', 'I-setosa': 0, 'I-virginica': 1}, {'I-versicolor': 0, 'I-setosa': 1, 'I-virginica': 0, 'Sepal_Width': '4.2'}, {'I-versicolor': 2, 'Petal_Length': '3.5', 'I-setosa': 0, 'I-virginica': 0}, {'I-versicolor': 1.2, 'Petal_Width': '1.2', 'I-setosa': 0, 'I-virginica': 0}] And to get a list based upon a key and value I am using the following: next((item for item in data if item["Sepal_Length"] == "7

How to calculate AUC with tensorflow?

丶灬走出姿态 提交于 2020-01-12 03:38:50
问题 I've built a binary classifier using Tensorflow and now I would like to evaluate the classifier using AUC and accuracy. As far as accuracy is concerned, I can easily do like this: X = tf.placeholder('float', [None, n_input]) y = tf.placeholder('float', [None, n_classes]) pred = mlp(X, weights, biases, dropout_keep_prob) correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) When calculating AUC I use the following:

How to calculate AUC with tensorflow?

廉价感情. 提交于 2020-01-12 03:38:07
问题 I've built a binary classifier using Tensorflow and now I would like to evaluate the classifier using AUC and accuracy. As far as accuracy is concerned, I can easily do like this: X = tf.placeholder('float', [None, n_input]) y = tf.placeholder('float', [None, n_classes]) pred = mlp(X, weights, biases, dropout_keep_prob) correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) When calculating AUC I use the following:

Index CSV to ElasticSearch in Python

谁都会走 提交于 2020-01-12 02:00:31
问题 Looking to index a CSV file to ElasticSearch, without using Logstash. I am using the elasticsearch-dsl high level library. Given a CSV with header for example: name,address,url adam,hills 32,http://rockit.com jane,valleys 23,http://popit.com What will be the best way to index all the data by the fields? Eventually I'm looking to get each row to look like this { "name": "adam", "address": "hills 32", "url": "http://rockit.com" } 回答1: This kind of task is easier with the lower-level

Python 3.5 vs Python 2.7: Modules importing submodules

限于喜欢 提交于 2020-01-11 05:09:05
问题 I have been googling this for the past hours and can't find an equivalent question anywhere. Also the documentation for 2.7 and 3.5 seem identical, so I don't think this behavior is documented. Here is my directory structure: project -- project.py -- api -- __init__.py -- subapi -- __init__.py contents of project/project.py : import api contents of project/api/__init__.py : import subapi If I execute python project.py (using python 2.7) from inside the projects folder, it returns without an