Data dodania Pytanie
2018-02-15 15:02 `del` on a package has some kind of memory »
del seems to have some memory which puzzles me. See the following: In [1]: import math In [2]: math.cos(0) Out[2]: 1.0 In [3]: del math.cos In [4]...
(3) odpowiedzi
2018-02-15 15:02 Obtaining an output from a function of a module writen in python2 to use it in a script written in python3 »
I have two scripts scriptpy2.py and scriptpy3.py. scriptpy2.py is a module written in python 2.7, whereas my main code scriptpy3.py is written in pyth...
(0) odpowiedzi
2018-02-15 07:02 psycopg2 ProgrammingError - Parameters with Hyphens »
sql = 'select "productID" from "Barneys_Output" where "designerID" = %s' %self.id db = self.cursor.execute(sql) self.id is something like N-1f27va5 ...
(1) odpowiedzi
2018-02-14 23:02 Difference between + and += with python lists »
I've been toying a bit with python lists and I find the following a bit strange. list = ["test"] list + "test1" Traceback (most recent call last): ...
(0) odpowiedzi
2018-02-13 23:02 How can we get the default behavior of __repr__()? »
If a someone writes a class in python, and fails to specify their own __repr__() method, then a default one is provided for them. However, suppose we ...
(3) odpowiedzi
2018-02-12 09:02 unzip a dictionary of coordinates and values »
I wish to populate the values x,y and z, where x are the x coordinates, y the y coordinates and z the associated values for each coordinate, as define...
(4) odpowiedzi
2018-02-11 12:02 Remove duplicates in list without scrambling values, in python? »
How to remove duplicates in a list, but without scrambling the values. The set() command removes duplicates, but then scrambles all the values, I bel...
(0) odpowiedzi
2018-02-11 09:02 How to get all permutations of string as list of strings (instead of list of tuples)? »
The goal was to create a list of all possible combinations of certain letters in a word... Which is fine, except it now ends up as a list of tuples wi...
(3) odpowiedzi
2018-02-10 00:02 What does x in range(...) == y mean in Python 3? »
I just stumbled upon the following line in Python 3. 1 in range(2) == True I was expecting this to be True since 1 in range(2) is True and True == ...
(1) odpowiedzi
2018-02-08 01:02 Finding the odd number out in an array »
I am trying to solve a problem where I'm given an array, such as [0, 0, 1, 1, 2, 2, 6, 6, 9, 10, 10] where all numbers are duplicated twice, excluding...
(8) odpowiedzi
2018-02-06 02:02 Why does chained assignment work this way? »
I found the assignment a = a[1:] = [2] in an article. I tried it in python3 and python2; it all works, but I don't understand how it works. = here i...
(2) odpowiedzi
2018-02-05 07:02 Remove combinations that contains some values before even calculated »
given a list and exclusions elements, is it possible to ignore calculation of combinations that contains these elements ? Example 1 Given l = [1, 2,...
(7) odpowiedzi
2018-02-04 18:02 Prevent backtracking on regex to find non-comment lines (not starting with indented '#') »
I'd like to search for lines that don't start with a pound sign (#) on indented code. Currently, I'm using the regex ^\s*([^\s#].*) with multiline op...
(2) odpowiedzi
2018-02-04 09:02 Most pythonic way to print strings? »
Let's say I have an array and I want to print out its length along with a string. In Java, I would do this: System.out.println("The length of the lis...
(0) odpowiedzi
2018-02-03 22:02 Splitting a List Based on a Substring »
I have the following list: ['1(Reg)', '100', '103', '102', '100', '2(Reg)', '98', '101', '100', '3(Reg)', '96', '99', '98', '4(Reg)', '100', '100', '...
(8) odpowiedzi
2018-02-03 13:02 Can't get images to work in django »
I'm getting a 404 error when trying to serve user uploaded files in local. I've tried a lot of suggestions from the forums but I can't get it to work....
(2) odpowiedzi
2018-02-02 19:02 How can I use Regex to find a string of characters in alphabetical order using Python? »
So I have a challenge I'm working on - find the longest string of alphabetical characters in a string. For example, "abcghiijkyxz" should result in "g...
(5) odpowiedzi
2018-02-01 15:02 How do I split a Very huge string And string without spaces?(python3) »
Firstly I have this long string s = '1MichaelAngelo' How can I get the output as new_s = '1 Michael Angelo' and as a list new_list = [1,'Mi...
(1) odpowiedzi
2018-01-30 22:01 User input in python for exponential »
I am taking an input from the user and the user enters a number? For example the user can enter 25 but the user can also enter 2**32. How do I print t...
(0) odpowiedzi
2018-01-30 20:01 How to keep track of instances of python objects in a reliable way? »
I would like to be able to keep track of instances of geometric Point objects in order to know what names are already "taken" when automatically namin...
(1) odpowiedzi
2018-01-27 15:01 Conditional Django Model Creation »
I am writing a app for django which i am planning to publish. This app requires a Bolean Setting variable CONSUMER_REGISTRATION. Aim of getting this...
(1) odpowiedzi
2018-01-27 14:01 Django 2.0 haystack whoosh update index, rebuild index throw error »
I am using django 2.0 with haystack+whoosh as a search. I configured as it is said in the documentation. Occurred problem is when i run ./manage.py re...
(0) odpowiedzi
2018-01-26 03:01 Changing python version environment inside python script »
I have two python scripts, first one (script1) works with python2 and second one (script2) works with python3. They are two codes that I have not wr...
(1) odpowiedzi
2018-01-26 01:01 How to access the a reverse relation of a reverse relation django »
I am determined to try get all the other users that replied to the same comment as a given reply. I have come up with the following python, however I ...
(3) odpowiedzi
2018-01-25 16:01 [] = (), () = (), and {} = () 'assignments' »
I was surprised to find the following, in Python 3, the first two raise nothing: >>> [] = () >>> () = () >>> {} = () Fil...
(4) odpowiedzi
2018-01-24 21:01 How to open <del>named pipe</del>character device special file for reading and writing in Python »
I have a service running on a Linux box that creates a named pipe character device-special file, and I want to write a Python3 program that communicat...
(3) odpowiedzi
2018-01-24 12:01 Fastest way to generate a random-like unique string with random length in Python 3 »
I know how to create random string, like: ''.join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(N)) However, there should b...
(4) odpowiedzi
2018-01-23 01:01 Returning values of a 'ReturnList' without the key in DjangoRestFramework »
So I have this Serializers class MovieSerializer(serializers.ModelSerializer): class Meta: model = Movie fields = ('name', 'thum...
(1) odpowiedzi
2018-01-22 14:01 Splitting names that include "de", "da", etc. into first, middle, last, etc »
I want to split Brazilian names into parts. However there are names like below where "de", "da" (and others) that are not separate parts and they alwa...
(9) odpowiedzi
2018-01-21 03:01 How to tell if a python module is intended to be python 2 or python 3? »
Python 2 and Python 3 have subtle differences which mean that it is not possible to look at a python module and certainly know, just from automatic co...
(1) odpowiedzi
2018-01-20 20:01 Recursive and random grouping a list »
I'm trying to write a function which creates dichotomously grouped list, f. ex. if my input is as following: [a, b, c, d, e, f, g, h] I want to ...
(2) odpowiedzi
2018-01-20 16:01 What is an interoperable static analysis and testing toolset for a Python 3.x scripted build? »
A scripted build for a new project shall enforce consistency by applying a compatible stack with the following collective attributes: Compatible wit...
(0) odpowiedzi
2018-01-20 14:01 store infinity in postgres json via django »
I have a list of tuples like below - [(float.inf, 1.0), (270, 0.9002), (0, 0.0)] I am looking for a simple serializer/deserializer that helps me sto...
(1) odpowiedzi
2018-01-18 15:01 What is this odd Python colon behavior doing? »
I am using Python 3.6.1, and I have come across something very strange. I had a simple dictionary assignment typo that took me a long time to find. c...
(1) odpowiedzi
2018-01-17 23:01 FORMVIEW and GET »
I am trying to clean a FORMVIEW with very little success. I have the following form: FORMS... class BookRequestNumberSearch(forms.Form): q = forms...
(1) odpowiedzi