Why doesn't this if statement execute?

I am trying to make a word guessing game. Everything works except for the last if statement part. If the user guesses the name correctly, it doesn't print "Won!". However, if not, else statement executes and it does print "Lost!". Why is that? I chec...
more »

2017-01-11 18:01 (1) Answers

pip install Django on python3.6

If I run pip install Django I get Requirement already satisfied: Django in /usr/local/lib/python2.7/dist-packages I'd like to use python3.6 instead (which is already installed in /usr/bin/python3.6). What's the correct pip syntax to install t...
more »

2017-01-11 11:01 (5) Answers

XOR on contiguous subarrays of an array

From an array, I need to find the value obtained by XOR-ing the contiguous subarrays, following by XOR-ing the values thus obtained. INPUT One line containing integers that are elements of the array. e.g. [1,2,3] OUTPUT Print the answer correspo...
more »

2017-01-11 10:01 (1) Answers

add link to Actions in Django Admin

In Django admin I have a print button that sends information to the template. I want to add to the Action dropdown link where I checkboxes select the desired entries and in Action dropdown choose Print. But when I added a link to the Aсtion dropdo...
more »

2017-01-11 08:01 (1) Answers

Parsing XML values with xml.etree

probably a very simple question - but I'm a python/xml newbie and cant seem to find an answer that works for me. I am trying to parse xml values and from an xml reponse as follows #!/usr/bin/python3 from xml.etree import cElementTree as ET xmlstr...
more »

2017-01-06 19:01 (3) Answers

Python 3 code - Rounding integers

I am trying to round numbers up in python 3. In my existing code, the number either round up to the nearest 10 or down. For example, 67 goes to 70 and 64 goes to 60. I would like the number to always round up to the nearest multiple of 10, so that 67...
more »

2017-01-04 23:01 (1) Answers

Calculating percentile from django queryset

Let's say I have a django queryset of objects User. Each User has an average_score. How can I determine the user's percentile (top 10%, top 20%, etc) based on the average_score? If I were able to sort the queryset, I could theoretically take the ind...
more »

2017-01-02 04:01 (2) Answers

Permissions to append to a file in python?

I am having trouble understanding why I am unable to append to a file in python3 (3.2.3). I create these files in a shared folder but I am unable to append to them. There are no issues with files in my home folder. The shared folder permissions are: ...
more »

2017-01-02 04:01 (0) Answers

What is "..." in python?

I saw this ellipsis / three dot operator in aiohttp: if debug is ...: debug = loop.get_debug() What is it called, and what does it do? Is it some sort of destructuring, or spread operator? And how does it differ from **some_kwargs a...
more »

2017-01-01 22:01 (0) Answers

How to use type hints in python 3.6?

I noticed python 3.5 and python 3.6 added a lot of features about static type checking, so I tried with the following code(in python 3.6, stable version). from typing import List a: List[str] = [] a.append('a') a.append(1) print(a) What surprised...
more »

2016-12-28 07:12 (3) Answers

Incremented CharField

is there any possibility to define a Field which gets incremented, but starts with a letter? So the values should be like: S123, S124, S125. I' d like to use the id field for it, but some reason i' d like to have it as a CharField. As a workaround ...
more »

2016-12-27 15:12 (1) Answers

Multiple 'for' loops in dictionary generator

In this Python documentation the following is used as an example of a generator expression: dict((fn(i+1), code) for i, code in enumerate('FGHJKMNQUVXZ') for fn in (int, str)) >> {1: 'F', '1': 'F', 2: 'G', '2': 'G', 3: 'H', '3': 'H', ...
more »

2016-12-27 07:12 (5) Answers

Unresolved Import QtGui in Eclipse

I'm importing QtGui in Eclipse. i.e. from PyQt4 import QtGui It is giving me error Unresolved Import QtGui. I'm unable to resolve this issue. Please give me solition to this problem. ...
more »

2016-12-27 06:12 (2) Answers

Align numbers in sublist

I have a set of numbers that I want to align considering the comma: 10 3 200 4000,222 3 1,5 200,21 0,3 2 30000 4,5 1 mylist = [['10', '3', '', ''], ['200', '4000,222', '3', '1,5'], ...
more »

2016-12-25 22:12 (3) Answers

Python3 regex string formatting

I try get formatting string using python3 regex - re My input: {'factorial.2.0.0.zip', 'Microsoft ASP.NET Web API 2.2 Client Libraries 5.2.3.zip', 'Newtonsoft.Json.9.0.1.zip'} I try get only name and only version for packages, like that: fac...
more »

2016-12-25 17:12 (1) Answers

File size limit for read()?

I'm running into a problem while trying to load large files using Python 3.5. Using read() with no arguments sometimes gave an OSError: Invalid argument. I then tried reading only part of the file and it seemed to work fine. I've determined that it s...
more »

2016-12-24 18:12 (1) Answers

Manually changing the sound output device on linux

If you haven't heard of SoundSwitch, its an app for windows that allows you to switch sound output/input devices with a keyboard shortcut. I've made a similar app for linux, but I cant get it to work properly. The majority of the app is done, and if ...
more »

2016-12-22 21:12 (2) Answers