Data dodania Pytanie
2017-06-15 10:06 Django resets connection on some requests »
I stub with problem that when sending some requests to Django sever, it closes connection before time. Here is simple project on Github Here is how...
(2) odpowiedzi
2017-06-15 08:06 Python writelines() and write() huge time difference »
I was working on a script which reading a folder of files(each of size ranging from 20 MB to 100 MB), modifies some data in each line, and writes back...
(3) odpowiedzi
2017-06-15 08:06 Thread1:EXC_BAD_INSTRACTION »
I got an error Thread1:EXC_BAD_INSTRACTION. I am making Swift app and I wanna make a system in my app which upload a image to my Django server. When I...
(2) odpowiedzi
2017-06-15 00:06 factory_boy extract original kwargs »
I'm building a factory with factory_boy that generates a django model. I would like to see what arguments the user inputs inline. My factory itself lo...
(1) odpowiedzi
2017-06-14 23:06 How to do a cumulative "all" »
Setup Consider the numpy array a >>> np.random.seed([3,1415]) >>> a = np.random.choice([True, False], (4, 8)) >>> a array...
(1) odpowiedzi
2017-06-14 15:06 OneToMany Relationship for more generic django apps »
I'm trying to figure out how to genereate a one-to-many relation ship (i.e. a "list of objects for one model to the other) without having to use a for...
(2) odpowiedzi
2017-06-14 14:06 Python - easy way to "comparison" map one array to another »
I have an array a = [1, 2, 3, 4, 5, 6] and b = [1, 3, 5] and I'd like to map a such that for every element in a that's between an element in b it will...
(2) odpowiedzi
2017-06-14 08:06 How to make a dictionary of dictionaries with multiple lists »
There is one index list which will be the key of the parent dictionary: index = [1,2,3] and then multiple lists of which will be the child dicts: ...
(7) odpowiedzi
2017-06-14 08:06 Trying to send value from javascript to python server »
I have multiple input tags, my task is to collect the values entered by the user and send it back to the server. I am using Django as my framework. I ...
(1) odpowiedzi
2017-06-13 22:06 When does __eq__ gets called using hash()? »
As mentioned here, Below code, class Person(object): def __init__(self, name, ssn, address): self.name = name self.ssn = ssn ...
(2) odpowiedzi
2017-06-13 20:06 Filtering Django QuerySet based on ManyToMany relationship existence »
The Models Here is the basic models setup we have. A List has many Items, and an Item can be in many Lists. For a given Item, if any of its Lists ar...
(1) odpowiedzi
2017-06-13 19:06 Django form not saving password when creating user »
I have made a custom form for my django app which allows users to register themselves for the website. This is the form for my django app: class Tea...
(3) odpowiedzi
2017-06-13 17:06 python3: Using ternary operator in map, it will return None »
For python 2.7.13 >>> lst_ = [1] >>> map(lambda x, y: x + y if y else 1, lst_, lst_[1:]) [1] For python 3.6.1 >>> lst_ ...
(1) odpowiedzi
2017-06-13 14:06 Operator overloading in Python: handling different types and order of parameters »
I have a simple class that helps with mathematical operations on vectors (i.e. lists of numbers). My Vector can be multiplied by other instances of Ve...
(2) odpowiedzi
2017-06-13 13:06 Comparing the speed of startswith() .vs. in() »
I was under the impression that startswith has to be faster than in for the simple reason that in has to do more checks (allows for the word being loo...
(3) odpowiedzi
2017-06-12 15:06 Is there a way to list the attributes of a class without instantiating an object? »
In Python 3.5, say I have: class Foo: def __init__(self, bar, barbar): self.bar = bar self.barbar = barbar I want to get the li...
(3) odpowiedzi
2017-06-12 12:06 Convert datetime printed by Django, to a different datetime format »
My web application works with datetime(s) as timestamps, which according to Django's error messages need to be in the following format: YYYY-MM-DD HH:...
(3) odpowiedzi
2017-06-12 12:06 Can I lookup a related field using a Q object in the Django ORM? »
In Django, can I re-use an existing Q object on multiple models, without writing the same filters twice? I was thinking about something along the lin...
(2) odpowiedzi
2017-06-12 11:06 Why the dip in speed increase for generating 400,000,000 random numbers? »
I'm generating around 400,000,000 (400 million) random numbers in parallel on an Intel i7 with 4 cores (8 threads hyperthreaded) on macOS with 8 GB RA...
(0) odpowiedzi
2017-06-12 09:06 PostgreSQL - Psycopg2 - copy_from - Invalid byte sequence for encoding "UTF8": 0x00 »
I want to insert bytes into my PostgreSQL (9.5.7) database column with the type bytea, using the Psycopg2 (2.7.1) copy_from() method. I can insert my...
(2) odpowiedzi
2017-06-12 01:06 Union of 2 sets does not contain all items »
How come when I change the order of the two sets in the unions below, I get different results? set1 = {1, 2, 3} set2 = {True, False} print(set1 | se...
(4) odpowiedzi
2017-06-11 22:06 OpenCV: reading frames from VideoCapture advances the video to bizarrely wrong location »
(I will put a 500 reputation bounty on this question as soon as it's eligible - unless the question got closed.) Problem in one sentence Reading fra...
(3) odpowiedzi
2017-06-11 21:06 Heap sort in descending order - Python »
I am trying to figue out how to make the follwing Code for Heap Sort, in an descending order: def swap(i, j): s...
(0) odpowiedzi
2017-06-11 21:06 Django Modal Not Loading »
Someone asked this same exact question but it did it not help me out. I tried implementing the tips, but my modal was still not loading within my djan...
(0) odpowiedzi
2017-06-11 20:06 Why does naive string concatenation become quadratic above a certain length? »
Building a string through repeated string concatenation is an anti-pattern, but I'm still curious why its performance switches from linear to quadrati...
(3) odpowiedzi
2017-06-11 20:06 Python __slots__ metaclass issue »
I'm currently implementing slotted metaclasses using type(): type(i, (), {'__slots__': tuple(data) I would of course ideally keep with slots as I h...
(1) odpowiedzi
2017-06-11 13:06 Why won't my link navigate to the page that I want upon clicking it? »
In Chrome, I must manually type http://127.0.0.1:8000/music/1/ in order to get to the page that I want. (I want to go to page 1). However, When I ...
(1) odpowiedzi
2017-06-11 09:06 Why isn't the following Python script installing libraries using pip? »
I am trying to automate creating a project in Django with the following script. import os, sys, pip, virtualenv directory = sys.argv[1] if not os.pa...
(1) odpowiedzi
2017-06-11 02:06 pandas rolling apply doesn't do anything »
I have a DataFrame like this: df2 = pd.DataFrame({'date': ['2015-01-01', '2015-01-02', '2015-01-03'], 'value': ['a', 'b', 'a']}) ...
(1) odpowiedzi
2017-06-10 22:06 Why does radix sort have a space complexity of O(k + n)? »
Consider an array with n numbers that has maximum k digits (See Edit). Consider the radix sort program here. The buckets basically is a 2d list of all...
(3) odpowiedzi
2017-06-10 20:06 Pandas DataFrame slow to show shape or dtypes »
I'm very new to python and pandas. Any guidance, comment, and suggestion are appreciated! Here is my issue: it takes couple minutes to return the res...
(0) odpowiedzi
2017-06-10 19:06 Django - POST method in relational database model - table doesn't exist »
I would like to create Object2 for defined user ID in url. GET method in the example shown below works fine, but I can't create POST method. I will be...
(1) odpowiedzi
2017-06-10 16:06 Django - How to map object from another API and send in GET response »
I would like to map object from another API and send in GET response. I'm going to change only id of received object. Let's assume I get data from ano...
(2) odpowiedzi
2017-06-10 13:06 How to write views.py for (status) check in models.py »
How do I select the choice parameter "published" in models from views.py? In models.py, I have given choices the options of [draft,published]. I'm us...
(1) odpowiedzi
2017-06-10 09:06 Python 3: Perfect Alphabetical Order »
The goal of the code attempts to find the longest alphabetical substring within a string. s = 'xyzbcdezzz' longest_string = '' current_string = ''...
(8) odpowiedzi