Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
26,793,585
2014-11-07T03:30:00.000
1
0
0
0
python,cluster-analysis,k-means
26,793,992
3
true
0
0
K-means clustering attempts to minimize sum of distances between each point and a centroid of a cluster each point belongs to. Therefore, if 90% of your points are close together the sum of distances between those points and the cluster centroid is fairly small, Therefore, the k-means solving algorithm puts a centroid ...
3
0
1
I use the k-means algorithm to clustering set of documents. (parameters are - number of clusters=8, number of runs for different centroids =10) The number of documents are 5800 Surprisingly the result for the clustering is 90% of documents belong to cluster - 7 (final cluster) 9% of documents belong to cluster - 0 (...
What can be the reasons for 90% of samples belong to one cluster when there is 8 clusters?
1.2
0
0
272
26,795,535
2014-11-07T06:39:00.000
11
0
0
0
python,scikit-learn,k-means
36,050,176
3
false
0
0
One correction to the @snarly's answer. after performing d = km.transform(X)[:, j], d has elements of distances to centroid(j), not similarities. so in order to give closest top 50 indices, you should remove '-1', i.e., ind = np.argsort(d)[::][:50] (normally, d has sorted score of distance in ascending order.) Also, ...
1
10
1
I have fitted a k-means algorithm on 5000+ samples using the python scikit-learn library. I want to have the 50 samples closest to a cluster center as an output. How do I perform this task?
Output 50 samples closest to each cluster center using scikit-learn.k-means library
1
0
0
9,095
26,800,566
2014-11-07T11:47:00.000
0
0
0
0
android,python,django,architecture,django-rest-framework
26,801,669
1
false
1
0
I don't use Django but I am currently using Angular with Flask as my REST backend. I think the hybrid approach is useful if your app benefits from caching rendered content. An example would be something like a blogging site where you may store Markdown but render HTML and thus the content is largely unchanging. If this...
1
0
0
I'm starting a new side project in order to learn some new technologies and I have several doubts about the architecture I should use. My idea is developing an app both for web and for mobile (Android app mainly), so I think I need to implement the following: REST API service (with django-rest-framework). Web applicat...
Web application + Mobile App Python/Django architecture
0
0
0
2,645
26,801,277
2014-11-07T12:29:00.000
0
0
0
0
python,mapnik,geotiff
27,091,092
1
false
0
1
You can either generate a big tiff file from the original tiffs with gdal_merge.py (you can find it in the python-gdal package on Debian or Ubuntu) or create a virtual file that mixes them all with gdal_merge-vrt. This second option saves space but probably is slower.
1
0
0
I have a local directory full of geotiff files which make up a map of the UK. I'm using mapnik to render different images at various locations in the UK. I'm wondering what is the best way to approach this? I can create a single RasterSymbolizer then loop through the tiff directory and add each tiff as a seperate lay...
mapnik and local tiff tiles
0
0
0
636
26,812,282
2014-11-08T00:25:00.000
2
0
1
0
python
26,812,299
4
false
0
0
os.path.expanduser will help you
1
0
0
I am trying to read a file in another directory. My current script is in path/to/dir. However, I want to read a file in ~/. I'm not sure how to do this. I tried f = open("~/.file") but I am getting an error IOError: [Errno 2] No such file or directory: '~/.file'
Reading a file in home directory from another directory
0.099668
0
0
134
26,813,652
2014-11-08T04:12:00.000
1
0
0
0
python,sockets,chat,distributed
26,814,280
1
false
0
0
I don't think that threading is an issue here. You can design a solution with or without it. In short, your servers are not really different from your clients. They connect to other servers and send text/data to them. The only thing you have to handle specifically is the re-broadcasting of the clients chats. This is pa...
1
1
0
I have created a simple chat program in python that allows many clients to connect to a single server. I now want to create a two server model, still with many clients, so that the clients will be able to connect to either server. Then when a client sends a message to server1 it will broadcast to all its connected cl...
Distributed Local Chat Servers
0.197375
0
1
379
26,815,360
2014-11-08T08:45:00.000
1
0
1
0
python,macos,kivy,pyinstaller
28,491,679
3
false
0
1
If using PyQt, I can easily achieve this. But as I am using Kivy, it seems like I have to resort to other ways I don't see why you can't just use the PyQt method. Create a separate file that runs the icon that is called by your main Kivy app. Like PyQt I am sure that Kivy has an exit function that you could overrid...
1
3
0
To achieve sense of nativeness in my Pyinstaller packaged Kivy Python application, I would like to create menu item in OSX menu bar. If using PyQt, I can easily achieve this. But as I am using Kivy, it seems like I have to resort to other ways. Any suggestion? I guess it will be in the range of PyObjc or AppleScript. N...
How to create menu item in OSX Menubar using Pyinstaller packaged Kivy Python application?
0.066568
0
0
1,781
26,818,798
2014-11-08T15:36:00.000
1
0
1
0
python,multithreading,plugins
26,818,915
1
false
0
0
Threads share memory with the primary process and each other. For example you can have a list that is available to all threads. An item appended to a list can be seen by other threads. But you have to be careful. You have to understand which operations on data structures are thread safe and which are not. What happens ...
1
0
0
I'm trying to implement a plugin architecture in Python. I've started writing it using the Threading module where each plugin is a thread which I invoke using the Thread.start() method (since all plugins subclass BasePlugin which subclasses Thread). However I've just come across the multiprocessing module. I'm currentl...
Multiprocessing or Multithreading for plugin architecture in Python
0.197375
0
0
321
26,819,350
2014-11-08T16:28:00.000
1
0
1
0
python,linux,pip
26,826,502
1
true
0
0
The error message says that there is no package available, which matches the version string. This refers to the version string of your Python package on PyPI. Make sure that the version string you provide in your setup.py file of your project matches the version you're releasing. Then you run python setup.py sdist uplo...
1
0
0
I have a Django app published on github, which I also mirror on PyPi to make installation easy. It's been at version 1.3 for a year, but 12 hours ago I bumped it to a new version 1.4 on PyPi. I hid version 1.3 on PyPi and made sure all references are to the new version. But pip install my-package still pulls down vers...
pip not getting current version
1.2
0
0
841
26,828,181
2014-11-09T12:30:00.000
1
0
1
1
python,multithreading,twisted,reactor
27,050,242
2
false
0
0
But it seems that it's now impossible to block the main program, I'm not a Python guy but have done this in the context of Boost. Asio. You're correct—your callbacks need to execute quickly and return control to the main reactor. The idea is to only use asynchronous calls in your callbacks. For example, you wouldn't u...
2
2
0
I've been reading about the reactor design pattern, specifically in the context of the Python Twisted networking framework. My simple understanding of the reactor design is that there is a single thread that will sit and wait until one or more I/O sources (or file descriptors) become available, and then it will synchro...
reactor design pattern in a single thread vs multiple threads
0.099668
0
0
1,368
26,828,181
2014-11-09T12:30:00.000
3
0
1
1
python,multithreading,twisted,reactor
26,829,543
2
true
0
0
What are the pros and cons of this, compared to asynchronously looping through each source as they appear, i.e. launching a separate thread for each source. What you're describing is basically what happens in a multithreaded program that uses blocking I/O APIs. In this case, the "reactor" moves into the kernel and th...
2
2
0
I've been reading about the reactor design pattern, specifically in the context of the Python Twisted networking framework. My simple understanding of the reactor design is that there is a single thread that will sit and wait until one or more I/O sources (or file descriptors) become available, and then it will synchro...
reactor design pattern in a single thread vs multiple threads
1.2
0
0
1,368
26,831,593
2014-11-09T18:20:00.000
0
0
0
0
python,numpy,wxpython
26,832,062
1
true
0
1
You can use pyqt or pyside, but I would recommend pyqtgraph which is excellent for this sort of thing. You can build your ui in pyside and use pyqtgraph to manage image output
1
0
0
guys, I am trying to find a python GUI library that can show and process 16bit greyscale image easily. I need to modify pixels. I have tried wxpython. It can show the images. But when I tried to convert a numpy array with single channel 16bit data to a string and loaded it in wxImage, it showed me that invalid buffer s...
Python GUI library to show 16bit greyscale image
1.2
0
0
377
26,832,106
2014-11-09T19:06:00.000
0
0
1
0
python,selenium,ide,installation,package-managers
26,832,348
1
false
0
0
In Pycharm you need to source the directory that contains the package Selenium. In your project browser right-click a directory and select Mark directory as > source eg: /path/to/py/packages/Selenium/ You need to source the "packages" directory.
1
0
0
let me explain the problem: I have pyCharm, SublimeText, CodeRunner, and IPython Notebook. I've been exploring each one to see which i like best. Turns out to be PyCharm. Here's the problem - CodeRunner recognizes the package for "Selenium", and gladly imports the module. However, when I use pyCharm and iPython noteboo...
Import Error Python Varies by IDE
0
0
1
220
26,832,156
2014-11-09T19:11:00.000
2
0
1
0
python,compilation,jython
26,910,114
1
true
0
0
Most of my code works fine on both Python and Jython. I often use databases (Oracle, PostgreSQL and Informix), so I have different "connector" for Jython (which uses JDBC) and for Python (various libraries). There are some little bugs in Jython 2.5.3 I use like parsing date with %f, but most of libraries I use just wor...
1
2
0
Can I use my working Python code as Jython? Are there any differencies? The point is that I have code in Python, but I want to divide the code into, at least, 2 parallel running processes to improve speed of my program. This can be done using Python because of Global Interpreter Lock. So my idea is to get whole code an...
Use Jython compiler to compile Python 2.7 code
1.2
0
0
237
26,837,247
2014-11-10T05:19:00.000
1
0
1
0
python,pythonw
26,837,294
3
true
0
0
create your own print function, say out, and then change all prints to out. the out method can then be changed once to output to console or to a file.
1
2
0
I have a python script (.py) which runs normally on the console. When I try running the script using pythonw by changing the extension to (.pyw), it stopped working. My guess is that the print statements are causing pythonw to die based on results returned from Google Search. Is there a convenient way to disable the pr...
How to disable print statements conveniently so that pythonw can run?
1.2
0
0
2,132
26,837,554
2014-11-10T05:49:00.000
0
0
1
0
python
26,847,891
3
false
0
0
The modular and extensible solution is to put YamlParser in its own source file, and simply put the import yaml statement at the beginning. Any code which tries to import this code will fail if the required module yaml is missing.
1
1
0
I have classes in a Python project that depend on an external packages. I would like these classes to be created only if their dependencies are available. For example, how can I have a class YamlParser which only exists if yaml can be imported?
create a class only if a package is available on the system
0
0
0
78
26,839,710
2014-11-10T08:38:00.000
1
0
1
0
javascript,php,python,date,datetime
26,848,970
3
false
0
0
You could take a page from the astronomy people. Sky maps they account for long period precession of Earth's spin by establishing epochs. (The sky is different if you're looking now vs 10,000 BC.) Create a new class that has an "epoch" number and a facade pattern of your current date class. The new class contains two p...
1
9
0
I need a way to serialize and unserialize dates that are potentially far away in the past, for instance -10000 I first look at ISO8601, but it does not seem to support years with more than four digits. (Or at least, python libraries I tried don't.) The different solutions I can think of: change the year before seriali...
Storing dates with more-than-4-digits years
0.066568
0
0
425
26,840,413
2014-11-10T09:24:00.000
0
0
1
0
python,object,sortedlist
26,840,751
4
false
0
0
You can decrease amount of sorts by: Introducing special variable that will show you if your list is sorted AND Sort list when you need to get data from it if your special variable tells you that your list has been modified. Modification for your special variable should be performed on inserting new data.
1
10
0
I implemented an object with a numerical attribute. I want to keep a list of those objects sorted according to that attribute, without need to run a sort method at each insertion. I took a look to bisect module, but I do not know if I can use it also with an object. What is the best way to do that?
Insert a custom object in a sorted list
0
0
0
6,716
26,846,895
2014-11-10T15:15:00.000
0
0
1
0
python,python-unittest
26,847,160
2
false
0
0
You should use assertNotEqual to test that two sequences are unequal. The main feature of sequence related assertions is their ability to compute the difference between subjects upon failure.
1
4
0
There are functions: assertSequenceEqual, assertListEqual and assertTupleEqual in unittest module. But how can I achive the opposite behavior? How can I assert that lists are unequal?
assertListEqual negation (opposite)
0
0
0
1,351
26,847,130
2014-11-10T15:27:00.000
1
0
0
1
python,multithreading,subprocess
26,847,231
1
true
0
0
Maybe this is a silly question, and you've probably done this already, but are you sure simply sending the "\n" to the process won't work? I would say it's likely that selftest.exe doesn't actually read the [ENTER] until it's done. That, of course, depends on how the programs reads the enter. You may also try sending S...
1
1
0
I am trying to automate the running of a program called selftest.exe, which when it is done, asks the user to press [ENTER] to exit. Thus, calling this process through subprocess.Popen does not work, since it hangs forever until the user presses [ENTER], which he never will. Whilst I don't think it would be reasonably ...
Interaction with a subprocess
1.2
0
0
76
26,847,210
2014-11-10T15:32:00.000
1
0
1
0
python,django,macos,pycharm
26,851,321
2
true
1
0
Thanks guys, just tried again and got an "install django" option which fixed it. Don't know why that showed up now but not before.
2
0
0
I'm trying to create a new django project in Pycharm and I'm getting an error "No Django Support Installed in Selected Interpreter". After getting the message the first time I installed django, but the message persists. I have three versions of python installed: 2.5, 2.6 and 2.7, and I get the same message with all thr...
Pycharm doesn't recognize Django installation
1.2
0
0
2,279
26,847,210
2014-11-10T15:32:00.000
0
0
1
0
python,django,macos,pycharm
58,051,603
2
false
1
0
go to file/setting/Project:"name project" there you should add your interpreter that you want use for your project
2
0
0
I'm trying to create a new django project in Pycharm and I'm getting an error "No Django Support Installed in Selected Interpreter". After getting the message the first time I installed django, but the message persists. I have three versions of python installed: 2.5, 2.6 and 2.7, and I get the same message with all thr...
Pycharm doesn't recognize Django installation
0
0
0
2,279
26,848,219
2014-11-10T16:21:00.000
1
0
1
0
python,integer
26,848,318
1
false
0
0
If you have a list of numbers that need to be stored, you could use array.array('l') or array.array('L'). You may also use ctypes.c_int(), ctypes.c_uint(), ctypes.c_long(), or ctypes.c_ulong() to store numbers in four bytes.
1
1
0
So, what I understand is that in a 64 bit system, a number declared in python takes 64 bits. Is it possible to make it 32 bit, for memory reduction purposes?
How can I force a number in python to take 32 bits instead of 64 bits
0.197375
0
0
798
26,848,683
2014-11-10T16:44:00.000
0
0
1
0
python,sockets,socketserver
26,849,719
1
true
0
0
SocketServer will work for you. You create one SocketServer per port you want to listen on. Your choice is whether you have one listener that handles the client/server connection plus per file connections (you'd need some sort of header to tell the difference) or two listeners that separate client/server connection and...
1
0
0
I've come to the realization where I need to change my design for a file synchronization program I am writing. Currently, my program goes as follows: 1) client connects to server (and is verified) 2) if the client is verified, create a thread and begin a loop using the socket the client connected with 3) if a file on t...
Can I use the Python SocketServer class for this implementation?
1.2
0
1
158
26,848,795
2014-11-10T16:50:00.000
2
0
1
0
python,return,main
26,849,025
2
true
0
0
Everything Daniel said is true, but additionally if you want to know the process' exit code, it will by default be 0 unless an uncaught exception is thrown in which case it will be non-zero. You can modify the exit code directly by invoking sys.exit.
2
2
0
I'm helping in a project of my course in the college and we have a script that depends of the return value of the main function of one of its modules (by main function, I mean the "main()"). But in that function, no value is returned either the code has done successfully what it was supposed to be done, or not. So, if ...
What's the standard return value of a main function in Python?
1.2
0
0
6,301
26,848,795
2014-11-10T16:50:00.000
9
0
1
0
python,return,main
26,848,873
2
false
0
0
You've already made a false assumption from the start, which is that there is necessarily a main function at all. There isn't: Python doesn't need one, and doesn't call one automatically if it's there. Rather, all Python modules are executed from top to bottom; if the only thing at module level is a call to main(), the...
2
2
0
I'm helping in a project of my course in the college and we have a script that depends of the return value of the main function of one of its modules (by main function, I mean the "main()"). But in that function, no value is returned either the code has done successfully what it was supposed to be done, or not. So, if ...
What's the standard return value of a main function in Python?
1
0
0
6,301
26,849,501
2014-11-10T17:32:00.000
12
1
0
0
python,reddit,praw
26,850,897
1
false
0
0
Found it - for anyone who had trouble with this, just use author_flair_text
1
4
0
I'm trying to using PRAW to organize all comments by users active in /r/nba based on their flair. Is there a good way get a user's flair if I have the username? My end goal is to perform some text analysis on user comments grouped by NBA fandom. thanks!
PRAW: Get User's Flair
1
0
0
1,053
26,849,884
2014-11-10T17:54:00.000
1
0
0
0
javascript,python,rest
26,850,033
2
false
1
0
If I understand what you're trying to do, you might be looking for something like jQuery. It's a subtle JS framework that will make it easier to talk to your Django API, especially using Ajax and JSON.
1
0
0
We are thinking to move away from Django and separate the backend and frontend. The backend is straight forward as I have done it plenty of times by exposing it as a Python RESTful API. Whats new to me is the thin client part. Theoretically I could just write HTML and plain javascript to talk to the API. Is there a ma...
How to move from Django to REST-API/Thin Client?
0.099668
0
1
146
26,851,328
2014-11-10T19:22:00.000
0
1
0
0
python,cbmc
53,566,093
2
false
0
0
CBMC can also produce JSON output using --json-ui since version 5.5, which is more compact than the XML output. Also note that you can suppress certain messages by adjusting the verbosity level using --verbosity <some number between 0 and 10>.
1
1
0
Is there a way that I can call CBMC from Python or is there any wrapper or API for it available? My Problem is the following. I want to create a C function automatically in Python (this works quite well) and sent them to CBMC from Python for checking and get feedback if the function is OK or not.
CBMC call from Python?
0
0
0
169
26,855,274
2014-11-11T00:01:00.000
0
0
1
0
python,utf-8
26,855,540
4
false
0
0
I got the answer: my console needed to be restarted. I use Spyder(from Python x,y) for development and this error occcured, so beware. UPDATE: Spyder console seems to suck, because to get it to work, I had to use string.encode('latin1') and (now here's the catch) OPEN A NEW CONSOLE! If I try to reuse my already open co...
2
0
0
i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me? ->I already tried putting # coding: iso-8859-1 -*- on top, ->using encode like print "nome do seu chápa".encode('iso-8859-1') also doesn't work and even -> using print u"Nâo" doesn't work
python 2.7 - how to print with utf-8 characters?
0
0
0
4,338
26,855,274
2014-11-11T00:01:00.000
0
0
1
0
python,utf-8
26,855,341
4
false
0
0
A more complete response. Strings have two types in Python 2, str and unicode. When using str, you are using bytes so you can write them directly to files like stdout. When using unicode, it has to be serialized or encoded to bytes before writing to files. So, what happens here? print "nome do seu chápa".encode('iso-88...
2
0
0
i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me? ->I already tried putting # coding: iso-8859-1 -*- on top, ->using encode like print "nome do seu chápa".encode('iso-8859-1') also doesn't work and even -> using print u"Nâo" doesn't work
python 2.7 - how to print with utf-8 characters?
0
0
0
4,338
26,856,098
2014-11-11T01:38:00.000
2
0
1
0
python,performance,dictionary,big-o
26,856,247
1
true
0
0
It's not hard to test this out empirically, For cpython the answer is No, it doesn't take longer. Other implementations may recalculate the hash on demand. You'll have to look into it yourself if you're not using cpython If the keys are big and plentiful enough, you may notice effects due to cpu cache and swap though.
1
3
0
If I had a a dictionary with a huge key, would it make lookups significantly slower? What I mean by huge key is : {"THIS IS A HUGE KEY THAT IS VERY LONG1" : 1, "THIS IS A HUGE KEY THAT IS VERY LONG2" : 2} Would a key that is a string of length 300 be significantly slower than a key of length 3? Since lookups for dictio...
dictionary performance based on key length
1.2
0
0
381
26,857,111
2014-11-11T03:45:00.000
7
0
0
0
python,python-2.7,flask
26,857,138
1
true
1
0
Your app.run() function must be app.run(host='0.0.0.0') in order to give access other devices on same network.
1
2
0
I ran a simple flask web application on python on my localhost. The web application is running on 127.0.0.1:8000. But I cannot access it from a remote machine in my network using myHostComputerIPaddress:8000. My host is a windows machine. Please advise.
Python Flask application cannot be accessed by remote computers in network
1.2
0
0
1,120
26,859,236
2014-11-11T06:53:00.000
1
0
0
0
android,python
26,860,181
1
true
1
0
Assuming you will be using a REST-based setup you might want to look into using ssl certificates and use https for verification and signal protection. For a simpler solution, use a pre-shared-key and put it in the header of the request. With that said your setup will only be as safe as your key management. Encryption a...
1
0
0
how to protect request information from 3rd party android apps using server side. Hello, anybody can help, how to identify 3rd party android apps and we protect access from 3rd party
how to protect request information from 3rd party android apps using python
1.2
0
1
39
26,860,604
2014-11-11T08:30:00.000
0
1
0
0
python,unit-testing,testing,python-behave
28,639,457
1
false
0
0
behave is the "test runner". Use the "-o " option to store your results somewhere for whatever format(her) you want to use. NOTE: It is basically the same like py.test.
1
0
0
I need to run my tests (written with Python and Behave) without using console. I prefer to create simple Python script and use some unit test runner. I'm thinking about unittest, but pytest and nose solutions are also welcome:) I couldn't find any hint on behave's homepage.
How to run Python & Behave tests with some unit test framework?
0
0
0
882
26,864,212
2014-11-11T11:49:00.000
0
0
1
0
python,hive,python-module
32,773,202
1
false
0
0
You can put the path to the egg file at the beginning of sys.path so that you can make sure the module you want to import is not masked by others in sys.path.
1
0
0
How do we import modules from egg file in python? I have to import modules from lxml.egg and need to add it as a package to the transform script (in python) for running a map reduce job. I tried adding the egg file to sys.path and then importing it, but it did not work.
How to add egg files and import modules in python?
0
0
0
926
26,866,307
2014-11-11T13:43:00.000
0
0
0
0
python,css,django
26,866,366
3
false
1
0
You can just use menu.2 in your template.
3
0
0
I have a list of values in my view where I want to store some classes name and pass them to the template. Here is the list in the view: menu = ['','disabled','','',''] and my code for the template <li class="{{ menu|slice:"1:2"|first }}"></li>. So far this is the only working code I came with, is there a better way to ...
How to access a given list element in django templates?
0
0
0
983
26,866,307
2014-11-11T13:43:00.000
0
0
0
0
python,css,django
26,866,393
3
false
1
0
An alternative is to get the element[n] that you need in your view, and pass it to the template directly. Generally speaking, It's a better approch to pass to the template the data that you're going to actually use. So why pass a full list to use only one item of it?
3
0
0
I have a list of values in my view where I want to store some classes name and pass them to the template. Here is the list in the view: menu = ['','disabled','','',''] and my code for the template <li class="{{ menu|slice:"1:2"|first }}"></li>. So far this is the only working code I came with, is there a better way to ...
How to access a given list element in django templates?
0
0
0
983
26,866,307
2014-11-11T13:43:00.000
0
0
0
0
python,css,django
26,866,364
3
true
1
0
menu.1 should work if you know the exact index of your list, it could be cleaner and more explicit to do retrieval in your view. context['menu_target'] = menu[1] instead of having a list of empty values and accessing them in your template
3
0
0
I have a list of values in my view where I want to store some classes name and pass them to the template. Here is the list in the view: menu = ['','disabled','','',''] and my code for the template <li class="{{ menu|slice:"1:2"|first }}"></li>. So far this is the only working code I came with, is there a better way to ...
How to access a given list element in django templates?
1.2
0
0
983
26,868,492
2014-11-11T15:34:00.000
0
0
0
0
python,selenium-webdriver,phantomjs
29,312,102
2
true
1
0
Go figure. Problem resolved with a reboot.
1
1
0
Here's just about the simplest open and close you can do with webdriver and phantom: from selenium import webdriver crawler = webdriver.PhantomJS() crawler.set_window_size(1024,768) crawler.get('https://www.google.com/') crawler.quit() On windows (7), every time I run my code to test something out...
Selenium webdriver + PhantomJS processes not closing
1.2
0
1
809
26,869,746
2014-11-11T16:32:00.000
0
0
0
0
android-5.0-lollipop,qpython
26,902,933
1
false
0
1
I think QPython doesn't support PIE yet.
1
1
0
I am getting the following "error: only position independent executables (PIE) are supported." when trying to run scripts. Does QPython run on Android 5.0? Is it an issue with the 64bit version of Lollipop?
QPython on Nexus 9: PIE error
0
0
0
493
26,870,235
2014-11-11T16:58:00.000
0
0
0
0
python,django,django-views
26,870,947
1
false
1
0
The most likely explanation is that you did not remove pages/views.pyc If that file is still present, then Python will load it. Whenever you remove a .py file make sure to remove the .pyc too. The .pyc is the "compiled" version of your .py file.
1
0
0
I have a project in Django. I'm trying to change some logic in /pages/views.py. But my changes are not applied. Then to test I removed /pages/views.py but the pages still work. When I try to delete the /pages/templates/page.html, I get the error, which is as it should be. I don't understand why removing the script does...
Removing the .py file of a Django view does not actually remove the view
0
0
0
85
26,870,317
2014-11-11T17:02:00.000
1
0
1
1
python,multiprocessing,pyside
26,870,615
1
true
0
0
As you are speaking of PySide, I assume you program is a GUI one. In a GUI program all processing must occurs in a worker thread if you want to keep the UI responsive. So yes, the initial script must be start in a thread distinct from main thread (main one is reserved for UI)
1
1
0
I am a bit confused with multiprocessing. I have a video processing script which can be run from the command line or launched from a PySide application using a subprocess call. The script seems to run fine from the command line and basically initializes a pool of workers which each process a separate video file. When ...
How to use threading/multiprocessing to prevent program hanging?
1.2
0
0
78
26,873,898
2014-11-11T20:26:00.000
0
0
0
0
javascript,python,google-maps,apigee,hmacsha1
27,083,574
1
true
1
0
I was able to make it work with Python. My solution is based mostly on Google's example script. I had to make changes to the line to decode the signature in order for it to work on Apigee Edge. Of course, this will only work for those who have a paid Apigee Edge account as the free version does not support Python.
1
1
0
I am trying to generate a valid signature for the google maps API on Apigee edge. I've tried using a javascript callout to no avail. I am able to generate signatures but they don't match what google expects. I suspect it has to do with the encoding of the crypto key. I can't get python scripts to deploy at all (already...
Generate HMAC signature for Google Maps at work API on Apigee Edge
1.2
0
0
490
26,876,438
2014-11-11T23:18:00.000
5
1
1
0
python,multithreading,python-mock,global-state
26,877,363
2
false
0
0
I went ahead and ran a crude experiment using multiprocessing.dummy.Pool on Python 3.4. The experiment mapped a function against range(100) input using the thread pool, and if the input of the function was exactly 10, it patched an inner function to call time.sleep(). If the patch was threadsafe, the results would all ...
2
4
0
I'm trying to determine if Python's mock.patch (unittest.mock.patch in Py3) context manager mutates global state, i.e., if it is thread-safe. For instance: let's imagine one thread patches function bar within function foo with a context manager, and then inside the context manager the interpreter pauses that thread (be...
Does python's `unittest.mock.patch` mutate global state?
0.462117
0
0
2,517
26,876,438
2014-11-11T23:18:00.000
10
1
1
0
python,multithreading,python-mock,global-state
26,877,522
2
true
0
0
mock.patch isn't inherently thread-safe or not thread-safe. It modifies an object. It's really nothing more than an assignment statement at the beginning, and then an undo-ing assignment statement at the end. If the object being patched is accessed by multiple threads, then all the threads will see the change. Typica...
2
4
0
I'm trying to determine if Python's mock.patch (unittest.mock.patch in Py3) context manager mutates global state, i.e., if it is thread-safe. For instance: let's imagine one thread patches function bar within function foo with a context manager, and then inside the context manager the interpreter pauses that thread (be...
Does python's `unittest.mock.patch` mutate global state?
1.2
0
0
2,517
26,879,011
2014-11-12T03:58:00.000
1
0
0
0
django,django-socialauth,python-social-auth
49,575,484
7
false
1
0
i was searching on that and the solution is user.social_auth.exists() it will return True if the user exists in the database else it will return false.
1
7
0
I would like to check if a user is logged in via social authentication or using the django default authentication. something like if user.social_auth = true?
Check if current user is logged in using any django social auth provider
0.028564
0
0
4,806
26,881,673
2014-11-12T07:42:00.000
2
0
1
0
ipython,xshell
26,924,407
1
true
0
0
According to the response from technical support team of XSHELL, it seems xshell does not support interactive shell currently. how can I enter interactive console of iPython in xshell? In cmd of windows, when I type "ipython", it will bring me to the interactive console automatically. However, in xshell, I've tried...
1
1
0
I just begin to use xshell in Windows 7, it looks good, but how can I enter interactive console of iPython in xshell? In cmd of windows, when I type "ipython", it will bring me to the interactive console automatically. However, in xshell, I've tried several command like "ipython", "ipython console", all of them would n...
how to start iPython in xshell
1.2
0
0
262
26,883,774
2014-11-12T09:45:00.000
0
0
0
1
python,rrdtool
27,647,300
1
false
0
0
Unfortunately python-rrdtool package from Ubuntu/Debian is a python 2.x package only. So it will work in python 2.7 and not in python 3.4. If you must use rrdtool in python 3.x then you will have to use some alternative python to rrdtool binding. There are several to choose from if you look at pypi.python.org (which yo...
1
0
0
due to problems when installing rrdtool on windows i decided to switch to Linux to solve many problems. I've installed Lubuntu (that has python 2.7.8 installed by default) and python 3.4.2. Than with packet manager i've installed python-rrdtool. The problem is: from the terminal when i write "python2" and than "import ...
Lubuntu with python 2.7.8 and 3.4.2 import rrdtool
0
0
0
633
26,883,835
2014-11-12T09:49:00.000
1
1
0
0
python,scipy
26,883,907
1
false
0
0
I would take a guess and say your Python doesnt know where you isntalled scipy.io. add the scipy path to PYTHONPATH.
1
1
1
I'm involved in a raspberry pi project and I use python language. I installed scipy, numpy, matplotlib and other libraries correctly. But when I type from scipy.io import wavfile it gives error as "ImportError: No module named scipy.io" I tried to re-install them, but when i type the sudo cord, it says already the ne...
Import error when using scipy.io module
0.197375
0
0
1,955
26,889,459
2014-11-12T14:33:00.000
1
0
1
0
python,garbage-collection
26,889,994
1
true
0
0
It looks like gc.get_objects is what you want. Be careful using DEBUG_LEAK as it implies DEBUG_SAVEALL. DEDUG_SAVEALL causes all unreferenced objects to be saved in gc.garbage rather than freed. This means the number of objects tracked by the garbage collector can only increase. Additionally gc.get_objects does not ret...
1
1
0
I'm currently debugging a memory leak in a Python program. Since none of my objects have a __del__ method, I'm assuming the issue is some sort of global variable that continues to accumulate references to reachable objects. Also, when I run using gc.debug(gc.DEBUG_LEAK), I see a lot of gc: collectable messages, but n...
Get count of reachable live objects
1.2
0
0
492
26,889,799
2014-11-12T14:51:00.000
1
0
0
0
python,selenium,selenium-rc
26,892,369
2
true
0
0
I figure it out :) It seems that wen you remove the test_ from the beginning of the function I can setup function wihtout the browser to be closed
1
3
0
I'm a newbie on selenium and I wrote a little python script using selenium to test some functionalities on our website. But I notice something strange in my code. I have several functions for example : Login to website List item Click on a link etc. But, each time selenium hits the bottom of a function it closes th...
How to prevent Selenium from closing browser after each function?
1.2
0
1
6,289
26,891,117
2014-11-12T15:53:00.000
1
0
0
0
python,plugins,window,sublimetext
26,892,999
1
true
0
1
No , one of the biggest limitation of Sublime Text right now is the ability to create a custom interface or packages/plugins - you have to use the quickPanel list or an input at the bottom of the screen.
1
1
0
When discovering Sublime 3 plugin API I found out the function show_quick_panel() that shows some panel implemented as view. Is there any method to construct a custom view by my own and then add it to the window?
sublime add view to the window
1.2
0
0
61
26,894,623
2014-11-12T19:07:00.000
0
0
0
0
python,sdl,sdl-2,pysdl2
28,871,678
1
false
0
1
Solved this myself by calling sdl2.SDL_PumpEvents() once per loop.
1
0
0
Even after calling sdl2.mouse.SDL_ShowCursor(0), which effectively hides the cursor during runtime, when doing lengthy iterations (for my purposes, loading a large volume of images into RAM), the beachball cursor nonetheless appears. It is critical that this doesn't happen because what I'm writing is an experiment for ...
Pysdl2 on OSX How to prevent beachball cursor during long iteration loops
0
0
0
90
26,894,942
2014-11-12T19:27:00.000
19
0
1
0
python,pycharm
26,895,823
7
false
0
0
The UI doesn't seem to set the configuration files correctly. It is probably a bug. If you edit: <projectdir>/.idea/.name you can set the name there. You will have to restart PyCharm for this to take effect.
6
14
0
In PyCharm, I can refactor the project by right clicking on it in the menu on the left. However, this does not change the name in the blue bar right at the top of the PyCharm window, where it also shows the project path on your machine. Why not?
Renaming PyCharm project does not change name at top of window
1
0
0
8,101
26,894,942
2014-11-12T19:27:00.000
1
0
1
0
python,pycharm
70,691,593
7
false
0
0
In the Project Tool Window (Alt + 1) right click on the project folder -> Refactor -> Rename (Shift + F6). A short menu pops up, where you can choose between Rename directory and Rename project. They are working independently: the first only changes the directory name, and leaves the old project name, the latter only c...
6
14
0
In PyCharm, I can refactor the project by right clicking on it in the menu on the left. However, this does not change the name in the blue bar right at the top of the PyCharm window, where it also shows the project path on your machine. Why not?
Renaming PyCharm project does not change name at top of window
0.028564
0
0
8,101
26,894,942
2014-11-12T19:27:00.000
0
0
1
0
python,pycharm
70,481,345
7
false
0
0
Steps I took, if helpful to someone: Change the name of your project folder. Rename your virtual environment to the new name. (I simply made a copy of my conda env and deleted the old one) Delete the ./.idea folder. Shut down PyCharm. Open your project folder as a new PyCharm project.
6
14
0
In PyCharm, I can refactor the project by right clicking on it in the menu on the left. However, this does not change the name in the blue bar right at the top of the PyCharm window, where it also shows the project path on your machine. Why not?
Renaming PyCharm project does not change name at top of window
0
0
0
8,101
26,894,942
2014-11-12T19:27:00.000
1
0
1
0
python,pycharm
65,572,383
7
false
0
0
I had the same problem and solved it by doing: Edit the name of <projectdir>/.idea/<projectName>.lml to match the project name Change the name of .lml file in the <projectdir>/.idea/modules.xml file. Restart PyCharm
6
14
0
In PyCharm, I can refactor the project by right clicking on it in the menu on the left. However, this does not change the name in the blue bar right at the top of the PyCharm window, where it also shows the project path on your machine. Why not?
Renaming PyCharm project does not change name at top of window
0.028564
0
0
8,101
26,894,942
2014-11-12T19:27:00.000
0
0
1
0
python,pycharm
62,255,970
7
false
0
0
You can also check pycache folder. You can delete it, if it is there, and try again.
6
14
0
In PyCharm, I can refactor the project by right clicking on it in the menu on the left. However, this does not change the name in the blue bar right at the top of the PyCharm window, where it also shows the project path on your machine. Why not?
Renaming PyCharm project does not change name at top of window
0
0
0
8,101
26,894,942
2014-11-12T19:27:00.000
3
0
1
0
python,pycharm
44,685,836
7
false
0
0
I came also across this problem and the solution is much much much much (and many more 'much' ) simpler. The menu at the top right is a menu of the run configurations. Upon renaming the file and if the file has been run/debuged previously, there is a case where the run configuration is not updated. To correct this, e...
6
14
0
In PyCharm, I can refactor the project by right clicking on it in the menu on the left. However, this does not change the name in the blue bar right at the top of the PyCharm window, where it also shows the project path on your machine. Why not?
Renaming PyCharm project does not change name at top of window
0.085505
0
0
8,101
26,897,392
2014-11-12T21:56:00.000
3
0
1
0
python,json,performance,dictionary
26,898,561
3
false
0
0
Use a dict. Unless you've run out of RAM, it's likely the solution you're looking for.
2
1
0
If I have a huge number of strings, would the fastest way to look them up and grab the value be a dictionary? When I mean huge, I mean potentially 2000 strings each of length 500 (JSON). dict1 = {"JSON1": "JSON1", "JSON2": "JSON2", "JSON3": "JSON3", ... } So let's say I am trying to see if JSON2 is in dict1. Would di...
Fast string or JSON look up data structure
0.197375
0
0
112
26,897,392
2014-11-12T21:56:00.000
2
0
1
0
python,json,performance,dictionary
26,898,661
3
true
0
0
In your example, the key and value are both the same string. If you're just wanting to check presence, you don't need to waste the reference to the key. In that case, you can use a set. Otherwise, a dict in RAM is the best you're going to get in Python. If you have something bigger than RAM (doesn't sound like it), t...
2
1
0
If I have a huge number of strings, would the fastest way to look them up and grab the value be a dictionary? When I mean huge, I mean potentially 2000 strings each of length 500 (JSON). dict1 = {"JSON1": "JSON1", "JSON2": "JSON2", "JSON3": "JSON3", ... } So let's say I am trying to see if JSON2 is in dict1. Would di...
Fast string or JSON look up data structure
1.2
0
0
112
26,897,876
2014-11-12T22:27:00.000
0
0
1
0
python,http,asynchronous,stream,protocols
26,914,159
1
true
0
0
reader/writer pair should be enough. While we use own implementation in aiohttp for some, (partially historic) reasons.
1
2
0
I'm writing a neat little async HTTP library for Python that is a ported (yet slightly more robust) version of the standard library's included HTTP utilities. I keep coming back to trying to figure out whether it is necessary to even write a Protocol subclass or just implement a StreamReader/StreamWriter. I have done ...
Are Python's AsyncIO protocols necessary for writing an async HTTP library?
1.2
0
1
137
26,897,922
2014-11-12T22:30:00.000
8
0
0
1
python,parallel-processing,generator
26,898,024
1
true
0
0
I think you may be trying to solve this problem at the wrong level of abstraction. Python generators are inherently stateful, and thus you can't split a generator across processes without some form of synchronization, and that will kill any performance gains that you might achieve through parallelism. I would recommend...
1
2
0
I have a Python generator which pulls in a pretty huge table from a data warehouse. After pulling in the data, I am processing the data using celery in a distributed manner. After testing I realized the the generator is the bottleneck. It can't produce enough tasks for celery workers to work on. This is when I have dec...
Accessing python generators in parallel using multiprocessing module
1.2
0
0
1,768
26,898,410
2014-11-12T23:08:00.000
4
0
0
0
python,machine-learning,nlp,scikit-learn,vectorization
26,904,535
1
true
0
0
Have you tried HashingVectorizer? It's slightly faster (up to 2X if I remember correctly). Next step is to profile the code, strip the features of CountVectorizer or HashingVectorizer that you don't use and rewrite the remaining part in optimized Cython code (after profiling again). Vowpal Wabbit's bare-bone feature pr...
1
3
1
I'm looking for an implementation of n-grams count vectorization that is more efficient than scikit-learn's CountVectorizer. I've identified the CountVectorizer.transform() call as a huge bottleneck in a bit of software, and can dramatically increase model throughput if we're able to make this part of the pipeline mor...
Fastest Count Vectorizer Implementation
1.2
0
0
1,295
26,899,161
2014-11-13T00:16:00.000
0
1
0
0
python,c,interrupt,i2c
67,497,343
2
false
0
0
There are devices that have an interrupt line in addition to I2C lines. For example I have a rotary encoder I2C interface board from duppa.net which has 5 pins - SDA, SCL, +, - and interrupt. The python library that comes with it configures the Raspberry Pi GPIO 4 line as an input edge triggered interrupt and sets up c...
2
2
0
Some background: I have an i2c device (MCP23017), which has 6 switches connected to its GPIO ports. The MCP23017 is connected to a Raspberry Pi via i2c. I'm able to read the state of each of the switches as required. My issue is in regards to interrupts. I'm using the WiringPi2 library for Python, which allows me to in...
Interrupts using i2c and Python
0
0
0
2,183
26,899,161
2014-11-13T00:16:00.000
0
1
0
0
python,c,interrupt,i2c
26,908,484
2
false
0
0
As far as I understand, WiringPiISR library only allows you to configure a Pin to be an interrupt and define its type (ie, edge based or level based). Since you're talking about I2c interrupt, there is no way you can have I2C interrupt as in this case, Your Rpi works as a master device and other connected device(s) as ...
2
2
0
Some background: I have an i2c device (MCP23017), which has 6 switches connected to its GPIO ports. The MCP23017 is connected to a Raspberry Pi via i2c. I'm able to read the state of each of the switches as required. My issue is in regards to interrupts. I'm using the WiringPi2 library for Python, which allows me to in...
Interrupts using i2c and Python
0
0
0
2,183
26,900,849
2014-11-13T03:29:00.000
0
0
0
0
python,django,photologue
26,918,549
1
false
1
0
There was a bug in Photologue 3.1 - the templates required for this feature were missing. Photologue 3.1.1 fixes this :-)
1
1
0
According to the docs, The 'zip upload' functionality has been moved to a custom admin page as of 11/4/2014. This functionality is nowhere to be found, and my galleries upload field in admin disallows uploading zip files.
Photologue zip uploader not working
0
0
0
98
26,901,882
2014-11-13T05:23:00.000
-1
1
0
0
python,cloud,web-crawler,virtual,server
65,263,186
5
false
0
0
If you have a google e-mail account you have an access to google drive and utilities. Choose for colaboratory (or find it in more... options first). This "CoLab" is essentially your python notebook on google drive with full access to your files on your drive, also with access to your GitHub. So, in addition to your loc...
2
23
0
I have a web crawling python script that takes hours to complete, and is infeasible to run in its entirety on my local machine. Is there a convenient way to deploy this to a simple web server? The script basically downloads webpages into text files. How would this be best accomplished? Thanks!
What is the easiest way to run python scripts in a cloud server?
-0.039979
0
1
26,999
26,901,882
2014-11-13T05:23:00.000
1
1
0
0
python,cloud,web-crawler,virtual,server
67,290,539
5
false
0
0
In 2021, Replit.com makes it very easy to write and run Python in the cloud.
2
23
0
I have a web crawling python script that takes hours to complete, and is infeasible to run in its entirety on my local machine. Is there a convenient way to deploy this to a simple web server? The script basically downloads webpages into text files. How would this be best accomplished? Thanks!
What is the easiest way to run python scripts in a cloud server?
0.039979
0
1
26,999
26,906,023
2014-11-13T09:59:00.000
0
0
0
0
python,pygame,panda3d
26,997,383
2
false
0
1
Yes. Both Panda3D and PyGame are Python modules that can be used in any (compatible) Python installation. There is (at least to my awareness) nothing about either library that prevents you from importing other Python modules. Depending on what you're trying to do, though, the answer may be more tricky. For instance,...
1
0
0
I am new to game development and am trying to develop a game with panda3d. Can we directly use Pygame modules along with Panda3d ones?
How to use Panda3d and Pygame together
0
0
0
1,355
26,907,588
2014-11-13T11:13:00.000
0
1
0
1
python,mysql,raspberry-pi,windows-server
26,941,321
1
false
0
0
As long as you know the IP address of the windows machine, you can easily run a server on windows (Apache/MySQL -> PHP). You provide this IP address to the RaspberryPI and it can login and authenticate the same way as on any other server. Basically the WAMP stack will act as an abstraction layer for communication.
1
0
0
In a project me and students are doing, we want to gather temperature and air humidity information in nodes that sends the data to a raspberry pi. That raspberry pi will then send the data to a mysql database, running on windows platform. Some background information about the project: As a project, we are going to des...
How to send data from raspberry pi to windows server?
0
0
0
2,420
26,909,293
2014-11-13T12:49:00.000
1
0
1
0
python,vim
32,551,050
4
false
0
0
This may happen if you are using a different python version in your machine compared to the one vim is compiled in. For eg. If you are in a virtualenv, try deactivating it and then use vim.
3
2
0
Today I encountered a problem about vim: vim: symbol lookup error: vim: undefined symbol: PyUnicodeUCS4_AsEncodedString I didn't install any vim plugins. But I installed some Python projects(Nginx, uwsgi). Seemingly after these installations, vim crushed. Any clues?
vim: symbol lookup error: vim: undefined symbol: PyUnicodeUCS4_AsEncodedString
0.049958
0
0
7,664
26,909,293
2014-11-13T12:49:00.000
2
0
1
0
python,vim
51,603,776
4
false
0
0
This might not directly answer the question, but I had the same problem when loading anaconda and found that invoking vi, instead of vim worked. Since I'm guessing that vi is symlinked to vim because syntax highlighting worked and my ~/.vimrc commands all work as expected. It's a simple and inelegant option, but perhap...
3
2
0
Today I encountered a problem about vim: vim: symbol lookup error: vim: undefined symbol: PyUnicodeUCS4_AsEncodedString I didn't install any vim plugins. But I installed some Python projects(Nginx, uwsgi). Seemingly after these installations, vim crushed. Any clues?
vim: symbol lookup error: vim: undefined symbol: PyUnicodeUCS4_AsEncodedString
0.099668
0
0
7,664
26,909,293
2014-11-13T12:49:00.000
1
0
1
0
python,vim
53,577,753
4
false
0
0
the problem can also occur when you point the library path to another path BY exporting to environment mentioning in .bash.rc . Probably can happen when you are changing the paths for oracle installations. So correct your Paths so that vim would be pointing to the correct lib path
3
2
0
Today I encountered a problem about vim: vim: symbol lookup error: vim: undefined symbol: PyUnicodeUCS4_AsEncodedString I didn't install any vim plugins. But I installed some Python projects(Nginx, uwsgi). Seemingly after these installations, vim crushed. Any clues?
vim: symbol lookup error: vim: undefined symbol: PyUnicodeUCS4_AsEncodedString
0.049958
0
0
7,664
26,909,777
2014-11-13T13:15:00.000
0
1
0
0
python,security,sockets,arduino
26,910,064
1
false
0
0
use stunnel at both ends, so all traffic at both ends goes to localhost that stunnel encrypts and sends to the other end
1
0
0
I'm developing a project in my university where I need to receive some data from a set of an Arduino, a sensor and a CuHead v1.0 Wifi-shield on the other side of the campus. I need to communicate thru sockets to transfer the data from sensor to the server but I need to ensure that no one will also send data thru this ...
How to ensure that no one will access my socket?
0
0
1
34
26,914,533
2014-11-13T17:13:00.000
0
0
1
0
python,class,inheritance
26,916,448
1
false
0
0
UPDATE Final solution was to make a factory function that returns instances of the SubType classes. This factory reads information in parameters passed to it, that determine which SubType class to instantiate. The SubType classes all extend Class A. I had envisioned things backwards, thinking I started with the mos...
1
1
0
Let's say I've got python object A, that is an instance of class A. Every instance of class A has an attribute SubType. I've also got classes SubType_B, SubType_C, and SubType_D, each of which has a method called ingest(). The ingest() method was previously using (self) to get all the parameters it needed, but that s...
Importing methods from Python class into another class instance
0
0
0
115
26,915,644
2014-11-13T18:12:00.000
1
0
0
0
python,protocol-buffers
26,941,801
1
true
0
0
I wouldn't recommend trying to monkey-patch the encoding functions. You will almost certainly break something. What you can do is write an independent function which encodes a protobuf in an arbitrary way via reflection. For an example of this, see the text_format.py module in Protobufs itself. This module encodes and ...
1
0
0
I'm writing a python app that already has the protobuf messages defined. However, we need to use a custom wire format (I believe that's the correct term). How do you (in python) override the base encoding functions? I've looked in encoder.py and that's a maze of nested functors. So what do I need to monkey patch (or w...
how to use custom encoding/decoding with Google Protobuf
1.2
0
0
819
26,917,114
2014-11-13T19:45:00.000
2
0
0
1
python-2.7,google-app-engine,google-cloud-datastore
26,917,183
2
false
1
0
If you need to store each row as a separate entity, it does not matter how you create these entities - you can improve the performance by batching your requests, but it won't affect the costs. The costs depend on how many indexed properties you have in each entity. Make sure that you only index the properties that you ...
1
0
1
I have a 3Gb csv file. I would like to write all of the data to GAE datastore. I have tried reading the file row by row and then posting the data to my app, but I can only create around 1000 new entities before I exceed the free tier and start to incur pretty hefty costs. What is the most efficient / cost effective way...
What is the most efficient way to write 3GB of data to datastore?
0.197375
0
0
102
26,921,629
2014-11-14T01:43:00.000
0
0
0
1
python,mongodb,openshift,bottle
26,922,793
1
false
0
0
Yes. You have to run your own Mongodb server locally or port forward and use the OPENSHIFT Mongodb.
1
0
0
I have a bottle+mongo application running in openshift. when I git-clone the application to my local computer neither the database nor the env-variables get download on my computer --just the python files. Should I have to mimic the mongo part in my local computer to developed locally? Or I missing something here.
openshift python mongodb local
0
1
0
47
26,923,372
2014-11-14T05:15:00.000
0
0
0
0
python,data-mining,orange
28,112,745
1
false
0
0
In my case this error was due to an old version of numpy being installed prior to installing Orange on a windows install. The Orange installer did not upgrade numpy even though for some widgets it requires it (the discretize widget being one of them which then fails to load silently^). Uninstalling numpy and rerunning...
1
0
0
In ORANGE - I found that the Discretize widget is missing in my installation - where do I go to load it?
Missing widget - how do I load one (Discretize)
0
0
0
228
26,939,090
2014-11-14T21:22:00.000
0
0
0
1
python,windows,shell,unix
26,939,339
2
false
0
0
You have to install Unix Bash for Windows, but not sure if it works correctly ... Better solution is install or virtualize some Linux distribution.
1
0
0
I tried using some Unix command using the subprocess module on my Python interpreter installed on a windows 7 OS. However, it errors out saying command not found. It does recognize Windows commands though. Can I somehow use Unix commands in here too? Thanks, Vishal
How to run Unix commands in python installed on a windows machine?
0
0
0
1,284
26,939,410
2014-11-14T21:50:00.000
0
1
0
0
java,python,long-integer,primitive
26,939,554
2
false
1
0
Python stores long integers with unlimited percision, allowing you to store large numbers as long as you have available address space. As for Java, use BigInteger class
1
0
0
Why is Python able to store long-integers of any length were as Java and C only provide 64 bits? If there is a way in Java to do it, please show it.
long-type in Python vs Java & C
0
0
0
1,680
26,939,548
2014-11-14T21:59:00.000
0
0
1
0
python,python-3.x,pyqt4,pycharm
26,940,592
1
true
0
0
Yes its compatible. I'm currently on PyCharm 4.0 (EAP) and it's compatible with all versions of python and associated packages. Its hands down the best product out there for coding with python
1
0
0
I am currently going through the familiar new language, new installation nightmare or fun if you so choose to believe. I need to install PySide 3.2 so as to have support for PY-VISA which states that it only runs on Python 2.6+ and 3.2+. So I'm believing that it will also apply to PySide 3.2 which I am using. (If I'm ...
Does PyCharm 3.4 support PySide 3.2
1.2
0
0
255
26,939,764
2014-11-14T22:15:00.000
-2
0
1
0
python,time-complexity
26,940,683
1
false
0
0
It's O(1), because it just returns an object whose next method returns a different permutation each time it is called. The size of the argument to permutations does not affect the time it takes to create that object.
1
0
0
Can you please tell me what is the complexity of permutations() from the "itertools.permutation" module in python? I am practicing and learning python, and appreciate any help from you.
Complexity of itertools.permutations
-0.379949
0
0
1,603
26,939,980
2014-11-14T22:33:00.000
0
0
0
0
python,python-2.7
26,940,072
2
false
0
0
The function is implemented as a C function in /Modules/posixmodule.c. In particular it's the function posix_getcwd and this is passed back to Python as getcwd.
1
0
0
I thought that I should be able to see the source code of packages that I import in Python from the Python Standard Library. When I opened the os.py file, I didn't see any definition of getcwd(). Why is this so?
Can't find getcwd() function definition in os.py file
0
0
0
458
26,942,476
2014-11-15T04:16:00.000
5
0
1
0
python-2.7,csv,zip
26,942,545
10
false
0
0
Yes. You want the module 'zipfile' You open the zip file itself with zipfile.ZipInfo([filename[, date_time]]) You can then use ZipFile.infolist() to enumerate each file within the zip, and extract it with ZipFile.open(name[, mode[, pwd]])
1
52
1
I'm trying to get data from a zipped csv file. Is there a way to do this without unzipping the whole files? If not, how can I unzip the files and read them efficiently?
Reading csv zipped files in python
0.099668
0
0
70,401
26,942,909
2014-11-15T05:33:00.000
3
0
0
1
python,ubuntu,kivy
26,946,523
1
true
0
1
It sounds like your kv file isn't being loaded. Does it have the correct name, and is in the right directory? You can check the output in the terminal to see whether the file is loaded. Edit: One possibility is case sensitivity - windows is not case sensitive, linux generally is. Make sure the kv filename is all lowerc...
1
1
0
I have a kivy app that uses a kv file, main.py, and a py class that handles the database. Everything works fine in windows. When I run linux (ubuntu) I get a black window with the correct title, but there are no widgets in the window. What do I need to do different to run a kivy app, that was put together and runs win...
Kivy app works on Windows 7 but not on ubuntu
1.2
0
0
268
26,943,368
2014-11-15T06:51:00.000
3
0
1
1
python,google-app-engine,webapp2
26,952,993
1
false
1
0
Using Methods Each handler class has methods with names like get and post, after the HTTP methods GET and POST etc. Those methods are functions that handle requests. Each request to your server will be routed to a request handler object, which is a new instance of some request handler class. So, a request handler insta...
1
0
0
I'm a beginner and am wondering why we use self.response.out.write instead of print, and why we use classes, instead of functions, for the request handlers in the first place. Are there any special reasons?
Why does GAE use classes and self.response.out.write over functions and print?
0.53705
0
0
733
26,943,847
2014-11-15T08:01:00.000
9
0
0
0
python,html,selenium,selenium-webdriver
26,947,299
3
false
1
0
You can use webElement.isEnabled() and webElement.isDisplayed() methods before performing any operation on the input field... I hope this will solve you problem... Else, you can also put a loop to check above 2 conditions and if those are true you can specify the input text and again you can find the same element and y...
1
20
0
I'm able to verify whether or not an element exists and whether or not it is displayed, but can't seem to find a way to see whether it is 'clickable' (Not talking about disabled). Problem is that often when filling a webform, the element i want may be overlayed with a div while it loads. The div itself is rather hard t...
Check whether element is clickable in selenium
1
0
1
53,151
26,948,469
2014-11-15T17:16:00.000
0
0
1
0
python,django,pycharm
27,120,852
1
false
1
0
(Using PyCharm 4.0) Go to Tools --> Deployment --> and either select an existing server connection or create a new one. Under the Mappings tab, you can associate a local path with a remote path. I keep my Django project folder mapped to the one on the server. Once you hit OK, go back to Tools --> Deployment, and you ...
1
1
0
I have an existing django project on an AWS instance. I have copied my Python files to my local machine. PyCharm is configured to use the Python interpreter on the remote machine. The django file references are, naturally, not resolved by PyCharm, since the django files are not on the local machine. Is the usual pro...
With PyCharm, how do I reference django files when using remote AWS interpreter?
0
0
0
215
26,949,755
2014-11-15T19:23:00.000
4
0
0
0
python,class,pandas
55,484,853
2
false
0
0
I would think you could create the dataframe in the first instance with a = MyClass(my_dataframe) and then just make a copy b = a.copy() Then b is independent of a
1
11
1
I would like to create a class from a pandas dataframe that is created from csv. Is the best way to do it, by using a @staticmethod? so that I do not have to read in dataframe separately for each object
Pass pandas dataframe into class
0.379949
0
0
37,394
26,951,213
2014-11-15T22:00:00.000
0
0
0
0
python,matplotlib
52,963,075
1
false
0
0
Actually it's not invalid. pcolor and pcolormesh are certainly interpolating! Use pcolor to plot a 4x4 matrix and you will get a 3x3 output. pcolor is not plotting each matrix entry, but each "output value" is an interpolation of the four surrounding values of the original matrix. And there is no way to turn this off.
1
4
0
I've noticed pcolormesh by default interpolates/smoothes the raw data. How do I turn this off?
How to turn off interpolation in pcolormesh()?
0
0
0
2,621
26,952,168
2014-11-15T23:52:00.000
1
1
0
0
python
26,955,746
1
false
0
0
Ok, so I found the answer! The problem is that if the registred application is set to web application in the google developer console settings, this is the error message you will get. To solve this I just changed the type to desktop application instead.
1
1
0
I am running a python script on my raspberry pi, via ssh. I use the google oauth library to fetch events from google calendar, but I have problems with the authentication. When I run the program on my main computer (which has a GUI and a web browser), it works as expected, but not on my Pi. I am running the program wit...
Redirect error when using google oauth and the flag --noauth_local_webserver
0.197375
0
1
1,538
26,953,276
2014-11-16T03:01:00.000
0
0
0
0
python,multithreading,api,httprequest,bitcoin
27,347,087
1
false
0
0
Yes. Use threading for concurrent network requests. If you do computations on the response you will be bound by the GIL (Global Interpreter Lock) in which case you can start other processes to do the computations on the data using the multiprocessing library. Requests lib supports threading and Doug Hellemans "Python M...
1
2
0
I am trying to get different JSON from bitcoin market RESTful API. Here is the problem: I can only send my single GET request to API one by one, so that I cannot get all the data from all the bitcoin market at the same time. Is there a way to use Python thread(each thread send GET request using different client ports)...
Send Multiple GET Requests to Server:80 port Simultaneously
0
0
1
704
26,954,341
2014-11-16T06:03:00.000
1
1
1
0
python
26,954,400
2
false
0
0
# followed by anything is a comment; so far as Python itself is concerned, that's it. Unix, on the other hand, will parse out the /usr/bin/python so that it knows how to run your code.
1
6
0
I could add #! /usr/bin/python in the beginning of python script and add this script to PATH in order to run it as a command. But could anyone explain to me what does '#' and '!' mean separately in python and what other language has this mechanism? Thanks
the meaning of #! in python separately
0.099668
0
0
3,978
26,955,485
2014-11-16T09:23:00.000
1
0
1
0
python,list,module
26,955,584
2
true
0
0
The way, to write a storage module seems correct. But without knowing the details, I can only suggest some good practices, with might be not suitable for your case. Static objects, like tiles should be loaded/created only at one place. The access to these objects should happen over a definite interface implemented in o...
1
1
0
In a nutshell: Is it possible and in good practice to have a list in one module be accessed and modified from several others or it better be restructured to be used in only the one in which they were created? I am writing a game and as it got above 1500 lines, i thought it would be high time to restructure it into modu...
Python - Accessing and modifying a list from several modules
1.2
0
0
66
26,955,646
2014-11-16T09:45:00.000
0
0
0
0
python,scikit-learn,dbscan,metric
26,963,180
1
true
0
0
Have you tried metric="precomputed"? Then pass the distance matrix to the DBSCAN.fit function instead of the data. From the documentation: X array [n_samples, n_samples] or [n_samples, n_features] : Array of distances between samples, or a feature array. The array is treated as a feature array unless the metric is giv...
1
1
1
I have a set of data distributed on a sphere and I am trying to understand what metrics must be given to the function DBSCAN distributed by scikit-learn. It cannot be the Euclidean metrics, because the metric the points are distributed with is not Euclidean. Is there, in the sklearn packet, a metric implemented for suc...
How to use sklearn's DBSCAN with a spherical metric?
1.2
0
0
816
26,957,894
2014-11-16T14:15:00.000
5
0
0
1
python,linux,opencv,apt-get
26,958,046
1
true
0
0
Of course, it's much easier to use the apt-get variant. Some drawbacks are, that you might not get the most recent version hence the apt-get package isn't updated as fast as the sources are. Furthermore you'll have a higher level of control according to modules that are going to be installed and the compile parameters,...
1
0
0
I'm working with OpenCV using Python on Linux. I always installed OpenCV building the the Source with make. As you know there are many guides online which all say pretty much the same things. Now i found some guys which say to install OpenCV using apt-get with the command sudo apt-get install python-opencv Which are ...
Install OpenCV for python building the source or with apt-get?
1.2
0
0
872
26,958,759
2014-11-16T15:45:00.000
2
0
1
0
python,matplotlib,duck-typing,isinstance
26,958,901
2
false
0
0
Why not write two separate functions, one that treats its input as a color map, and another that treats its input as a color? This would be the simplest way to deal with the problem, and would both avoid surprises, and leave you room to expand functionality in the future.
1
1
1
I'm writing an interface to matplotlib, which requires that lists of floats are treated as corresponding to a colour map, but other types of input are treated as specifying a particular colour. To do this, I planned to use matplotlib.colors.colorConverter, which is an instance of a class that converts the other types o...
Using isinstance() versus duck typing
0.197375
0
0
888