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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
28,232,551 | 2015-01-30T09:13:00.000 | 5 | 0 | 0 | 0 | python-3.x,scikit-learn,random-forest | 28,232,764 | 1 | false | 0 | 0 | The RandomForestClassifier introduces randomness externally (relative to the individual tree fitting) via bagging as BaggingClassifier does.
However it injects randomness also deep inside the tree construction procedure by sub-sampling the list of features that are candidate for splitting: a new random set of features ... | 1 | 3 | 1 | How is using a BaggingClassifier with baseestimator=RandomForestClassifier differ from a RandomForestClassifier in sklearn? | RandomForestClassifier differ from BaggingClassifier | 0.761594 | 0 | 0 | 668 |
28,233,768 | 2015-01-30T10:24:00.000 | 0 | 0 | 0 | 0 | wpf,xaml,textbox,ironpython | 53,803,083 | 3 | false | 0 | 1 | Following snippet might help you.
XAML :
<Label Content="" HorizontalAlignment="Left" Margin="62,163,0,0" VerticalAlignment="Top" Height="472" Width="880" Foreground="Black" FontSize="18" Background="White" x:Name="label1"/>
IronPython :
def Button_Click1(self, sender, e):
self.label1 = self.FindName('label1')
... | 1 | 0 | 0 | I have an aplication in IronPython where I load my xaml with wpf: "wpf.LoadComponent(....xaml)"
I have a Button and a TextBox in my app and when I push the button, the app start doing a 2 minute work, I need to update the textbox of the aplication during this work.
But I can´t do it. My textBox only update it when the ... | How to update TextBox using wpf, IronPython | 0 | 0 | 0 | 2,205 |
28,234,634 | 2015-01-30T11:11:00.000 | 0 | 0 | 0 | 0 | python,html | 42,434,749 | 1 | false | 1 | 0 | While reading assign text to an variable and the decode it, like if your text is stored under variable Var, then while reading use Var.decode("utf-8"). | 1 | 0 | 0 | Dear friendly python experts,
I am using BeautifulSoup to scrape some html text from a site. This site contains German words, such as "Groß" or "Bär". When I print the html text these characters get translated quite nasty making it too hard to search the html text for the words then.
How can I replace ß to ss, ä to ae... | Python - BeautifulSoup - German characters in html | 0 | 0 | 0 | 580 |
28,238,144 | 2015-01-30T14:35:00.000 | 4 | 0 | 0 | 0 | python,django,postgresql,heroku,django-queryset | 28,395,905 | 1 | true | 1 | 0 | I realized that I was using the django server in my procfile. I accidentally commented out and commited it to heroku instead of using gunicorn. Once I switched to gunicorn on the same heroku plan the issue was resolved.
Using a production level application server really makes a big difference. Also don't code at crazy ... | 1 | 2 | 0 | Recently I've been receiving this error regarding what appears to be an insufficiency in connection slots along with many of these Heroku errors:
H18 - Request Interrupted
H19 - Backend connection timeout
H13 - Connection closed without response
H12 - Request timeout
Error
django.db.utils.OperationalError in /
FATAL:... | Django/Postgres: FATAL: remaining connection slots are reserved for non-replication superuser connections | 1.2 | 1 | 0 | 3,434 |
28,238,830 | 2015-01-30T15:11:00.000 | 0 | 0 | 0 | 0 | python,excel,csv | 28,238,935 | 1 | false | 0 | 0 | Try importing it as a csv file, instead of opening it directly on excel. | 1 | 1 | 1 | I've written a python/webdriver script that scrapes a table online, dumps it into a list and then exports it to a CSV. It does this daily.
When I open the CSV in Excel, it is unformatted, and there are fifteen (comma-delimited) columns of data in each row of column A.
Of course, I then run 'Text to Columns' and get ev... | Retain Excel Settings When Adding New CSV | 0 | 1 | 0 | 24 |
28,246,938 | 2015-01-31T00:48:00.000 | 3 | 0 | 1 | 0 | python,json,function,python-2.7,dictionary | 28,246,986 | 2 | true | 0 | 0 | yes , since python is evaluated left to right like english. the functions will be called left to right.
its slightly shorter
not super pythonic but not aweful either | 1 | 0 | 0 | I'm creating a python application that requires a user to log into a web service. The credentials are passed to the server in a POST request as a json dictionary. In order to avoid unnecessarily saving the password in a variable I figured I would do something like the following:
json.dumps({'username': raw_input('Use... | Using the return value of a function as the value in a dictionary in python | 1.2 | 0 | 0 | 50 |
28,246,973 | 2015-01-31T00:52:00.000 | 6 | 1 | 0 | 0 | python,zeromq,pyzmq | 28,255,012 | 1 | false | 0 | 0 | What is causing the problem?
A default setup of the ZMQ IO-thread - that is responsible for the mode of operations.
I would dare to call it a problem, the more if you invest your time and dive deeper into the excellent ZMQ concept and architecture.
Since early versions of the ZMQ library, there were some important para... | 1 | 4 | 0 | I am sending 20000 messages from a DEALER to a ROUTER using pyzmq.
When I pause 0.0001 seconds between each messages they all arrive but if I send them 10x faster by pausing 0.00001 per message only around half of the messages arrive.
What is causing the problem? | ZMQ DEALER ROUTER loses message at high frequency? | 1 | 0 | 1 | 1,622 |
28,253,855 | 2015-01-31T16:29:00.000 | 0 | 0 | 0 | 0 | python,flask | 28,257,714 | 1 | false | 1 | 0 | you need to configure your firewall on your server/workstation to allow connections on port 5000. setting the ip to 0.0.0.0 allows connections to your machine but only if you have the port open. also, you will need to connect via the ip of your machine and not localhost since localhost will only work from the machine... | 1 | 0 | 0 | I have an apache server setup on a Pi, and i'm trying to learn Flask. I set it up so that The 'view' from the index '/' returns "hello world". then i ran my main program. nothing happens from the browser on the PC i'm SSH'ing from,I just get an error saying , but when i used the Pi directly and went to http:localhost:5... | Flask isn't recognising connections from other clients | 0 | 0 | 0 | 48 |
28,256,891 | 2015-01-31T21:47:00.000 | 6 | 0 | 1 | 1 | python,ubuntu-13.10 | 47,263,684 | 7 | false | 0 | 0 | It's also possible that you may not have run sudo apt-get update. It worked for me. | 1 | 9 | 0 | When i try do the given code below:
"sudo apt-get install virtualenv"
the error given in response to the ubuntu-shell is:
E: Unable to locate package virtualenv | Unable to locate package virtualenv in ubuntu-13 on a virtual-machine | 1 | 0 | 0 | 24,270 |
28,258,468 | 2015-02-01T01:23:00.000 | 1 | 0 | 0 | 0 | python,image-processing,hash | 30,613,008 | 1 | false | 0 | 0 | I found a couple of ways to do this.
I ended up using a Mean Squared Error function that I wrote myself:
def mse(reference, query):
return (((reference).astype("double")-(query).astype("double"))**2).mean()
Until, upon later tinkering I found a function that seemed to do something similar (compare image similarity... | 1 | 2 | 1 | I've been trying to write on a fast (ish) image matching program which doesn't match rotated or scale deformed image, in Python.
The goal is to be able to find small sections of an image that are similar to other images in color features, but dissimilar if rotated or warped.
I found out about perceptual image hashing, ... | Color Perceptual Image Hashing | 0.197375 | 0 | 0 | 852 |
28,259,109 | 2015-02-01T03:23:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,pip,six | 37,877,339 | 3 | false | 0 | 0 | I ran into the same thing, the cause was a left over six.pyo / six.pyc in my PYTHONPATH dir which was imported instead of the installed version. | 2 | 0 | 0 | Got this error when importing matplotlib.pyplot. But I have checked the version of six installed using pip list, and it returns version 1.9.0. And when I checked six.__version__, it returns 1.2.0.
Could any one help me? | Python2.7: ImportError: six 1.3 or later is required; you have 1.2.0 | 0 | 0 | 0 | 4,187 |
28,259,109 | 2015-02-01T03:23:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,pip,six | 32,384,602 | 3 | true | 0 | 0 | There is probably a bug somewhere, but a quick and dirty work around was the following:
pip install six==1.8.0 | 2 | 0 | 0 | Got this error when importing matplotlib.pyplot. But I have checked the version of six installed using pip list, and it returns version 1.9.0. And when I checked six.__version__, it returns 1.2.0.
Could any one help me? | Python2.7: ImportError: six 1.3 or later is required; you have 1.2.0 | 1.2 | 0 | 0 | 4,187 |
28,260,051 | 2015-02-01T06:14:00.000 | 1 | 0 | 0 | 0 | python,graph,networkx | 28,291,575 | 1 | false | 0 | 0 | No.
Sorry. In principle it could be possible to create a GUI which interfaces with networkx (and maybe some people have), but it's not built directly into networkx. | 1 | 0 | 0 | Suppose I have to create a graph with 15 nodes and certain nodes. Instead of feeding the nodes via coding, can the draw the nodes and links using mouse on a figure? Is there any way to do this interactively? | Python : Is there a way to interactively draw a graph in NetworkX? | 0.197375 | 0 | 1 | 105 |
28,261,224 | 2015-02-01T09:18:00.000 | 1 | 0 | 1 | 0 | python,python-imaging-library,homebrew,macports,pillow | 56,184,178 | 3 | false | 0 | 0 | 1-Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.
2-Pillow >= 1.0 no longer supports “import Image”. Please use “from PIL import Image” instead. so be careful with it
3-Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as... | 1 | 5 | 0 | I tried to use Python's Image Module on my Mac (new to mac)and I had trouble setting it up. I have Yosemite and some of the posts that I found online didn't work. I ended up installing Homebrew and I finally got PIL on my computer. However, instead of using import image (which I saw people doing it online), I have to u... | Difference between from PIL import Image and import Image | 0.066568 | 0 | 0 | 4,509 |
28,263,798 | 2015-02-01T14:30:00.000 | 0 | 0 | 1 | 0 | python,passwords | 28,263,882 | 2 | false | 0 | 0 | If you really can't do imports, then do this:
Enter the python directory in your computer, search for the getpass module, open the source code and search for the getpass function/class/whatever, copy-paste It in your code, Done. | 1 | 1 | 0 | I need help with a password issue.
I'm trying to create a simple password program, but the problem I am having is that I cannot replace the input with '*'s without importing anything.
Does anyone have any solutions? | Python. How to replace input with asterisks | 0 | 0 | 0 | 4,262 |
28,266,847 | 2015-02-01T19:28:00.000 | 1 | 0 | 0 | 0 | dealloc,python-c-api | 28,297,671 | 1 | true | 0 | 1 | I believe the problem here was one of reference counting.
PyType_Ready() fills various tp_* fields depending on the bases of your type.
One of these is tp_alloc, which I have set to 0.
Its doc says the refcount is set to 1 and the memory block is zeroed.
Every instance Python creates of this type, a new PyObject get ad... | 1 | 1 | 0 | I am embedding Python in C++.
I have a working C++ Python extension object.
The only thing wrong is that if I set tp_dealloc to a custom function it never gets called.
I would have thought Py_Finalize() would trigger this, or maybe terminating the program. But no.
Could anyone suggest why tp_dealloc isn't getting hit? | tp_dealloc not getting hit upon exit | 1.2 | 0 | 0 | 290 |
28,270,435 | 2015-02-02T02:42:00.000 | 1 | 0 | 1 | 0 | python,matplotlib | 28,270,527 | 1 | false | 0 | 0 | Aha, one needs to use the "extent" argument, as in:
plt.imshow(H, cmap=plt.gray(), extent=[-5, 3, 6, 9]) | 1 | 1 | 1 | I'm displaying an image and want to specify the x and y axis numbering rather than having row and column numbers show up there. Any ideas? | pyplot - Is there a way to explicitly specify the x and y axis numbering? | 0.197375 | 0 | 0 | 31 |
28,270,967 | 2015-02-02T04:06:00.000 | 6 | 0 | 0 | 0 | python,scikit-learn | 28,287,768 | 2 | true | 0 | 0 | Yes, you need to reorder them. Imagine a simpler case, Linear Regression. The algorithm will calculate the weights for each of the features, so for example if feature 1 is unimportant, it will get assigned a close to 0 weight.
If at prediction time the order is different, an important feature will be multiplied by thi... | 1 | 4 | 1 | Just getting started with this library... having some issues (i've read the docs but didn't get clarity) with RandomForestClassifiers
My question is pretty simple, say i have a train data set like
A B C
1 2 3
Where A is the independent variable (y) and B-C are the dependent variables (x). Let's say th... | Scikitlearn - order of fit and predict inputs, does it matter? | 1.2 | 0 | 0 | 2,722 |
28,271,711 | 2015-02-02T05:39:00.000 | 0 | 0 | 0 | 0 | python,sql,orm,flask,sqlalchemy | 28,280,443 | 1 | false | 1 | 0 | No, an ORM is not required, just incredibly convenient. SQLAlchemy will manage connections, pooling, sessions/transactions, and a wide variety of other things for you. It abstracts away the differences between database engines. It tracks relationships between tables in convenient collections. It generally makes wor... | 1 | 2 | 0 | Most of the Flask tutorials and examples I see use an ORM such as SQLAlchemy to handle interfacing with the user database. If you have a general working knowledge of SQL, is this extra level of abstraction, heavy with features, necessary? I am tempted to write a lightweight interface/ORM of my own so I better understan... | Handling user database in flask web app without ORM like SQLAlchemy | 0 | 1 | 0 | 970 |
28,272,226 | 2015-02-02T06:30:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,google-search-api,google-app-engine-python | 29,008,682 | 1 | false | 1 | 0 | There can be two reasons for this :
1 - miles instead of km
2 - conversion numbers (for example 35,322.2 is 35322.2 ? km ? miles ?)
i suggest to check what exactly are the numbers processed when executing distance function, you can programmatically output this data in some logs
Hope it helps | 1 | 0 | 0 | I have implemented GAE's Python Search Api and am trying to query based on distance from given geopoint.
My query string is: "distance(location, geopoint(XXX, YYY)) < ZZZ". However, for some reason on the production server, this query string is returning items where the distance is greater than the ZZZ parameter.
Below... | Google App Engine Python Search Api's Location-based queries (Geosearch) Issues | 0 | 0 | 0 | 248 |
28,274,323 | 2015-02-02T09:15:00.000 | 1 | 0 | 1 | 0 | python,pycharm | 28,274,438 | 2 | true | 0 | 0 | The feature is called "Quick Documentation" and the default shortcut for this is CTRL+Q or ALT+MOUSE BUTTON 2.
As far as I know, there is no way to enable it on-hover (personally, I found this very annoying in Eclipse). | 1 | 0 | 0 | How can I configure Pycharm such that I always have the documentation pop up every time I hover over a method or an class?
For example in eclipse:
If I hover the cursor over a c++ function or a class, I can see the documentation for the same in a small pop up window.
Is there some plugin or setting in Pycharm where ... | Documentation Pop Ups | 1.2 | 0 | 0 | 117 |
28,280,308 | 2015-02-02T14:48:00.000 | 0 | 0 | 1 | 0 | python,debugging,spyder | 36,927,378 | 7 | false | 0 | 0 | One minor extra regarding point 3:
It also seemed to me the debug console frequently froze, doing prints, evaluating, etc, but pressing the stop (Exit debug) button usually got it back to the bottom of the call stack and then I could go back up ('u') to the frame I was debugging in. Worth a try. This might be for a la... | 4 | 82 | 0 | I like Python and I like Spyder but I find debugging with Spyder terrible!
Every time I put a break point, I need to press two buttons: first
the debug and then the continue button (it pauses at first line
automatically) which is annoying.
Moreover, rather than having the standard iPython console with auto completion ... | How do I debug efficiently with Spyder in Python? | 0 | 0 | 0 | 113,747 |
28,280,308 | 2015-02-02T14:48:00.000 | 0 | 0 | 1 | 0 | python,debugging,spyder | 49,370,618 | 7 | false | 0 | 0 | You can use debug shortcut keys like:
Step Over F10
Step Into F11
in tools>preferences>keyboard shortcuts | 4 | 82 | 0 | I like Python and I like Spyder but I find debugging with Spyder terrible!
Every time I put a break point, I need to press two buttons: first
the debug and then the continue button (it pauses at first line
automatically) which is annoying.
Moreover, rather than having the standard iPython console with auto completion ... | How do I debug efficiently with Spyder in Python? | 0 | 0 | 0 | 113,747 |
28,280,308 | 2015-02-02T14:48:00.000 | 61 | 0 | 1 | 0 | python,debugging,spyder | 28,285,708 | 7 | true | 0 | 0 | (Spyder maintainer here) After our 4.2.0 version, released in November 2020, the debugging experience in Spyder is quite good. What we provide now is what people coming from Matlab would expect from a debugger, i.e. something that works like IPython and lets you inspect and plot variables at the current breakpoint or f... | 4 | 82 | 0 | I like Python and I like Spyder but I find debugging with Spyder terrible!
Every time I put a break point, I need to press two buttons: first
the debug and then the continue button (it pauses at first line
automatically) which is annoying.
Moreover, rather than having the standard iPython console with auto completion ... | How do I debug efficiently with Spyder in Python? | 1.2 | 0 | 0 | 113,747 |
28,280,308 | 2015-02-02T14:48:00.000 | 1 | 0 | 1 | 0 | python,debugging,spyder | 39,023,817 | 7 | false | 0 | 0 | Here is how I debug in Spyder in order to avoid freezing the IDE. I do this if I alter the script while in debugging mode.
I close out the current IPython (debugging) console [x]
Open a new one [Menu bar-> Consoles-> Open an IPython Console]
Enter debug mode again [blue play pause button].
Still a bit annoying, but... | 4 | 82 | 0 | I like Python and I like Spyder but I find debugging with Spyder terrible!
Every time I put a break point, I need to press two buttons: first
the debug and then the continue button (it pauses at first line
automatically) which is annoying.
Moreover, rather than having the standard iPython console with auto completion ... | How do I debug efficiently with Spyder in Python? | 0.028564 | 0 | 0 | 113,747 |
28,282,005 | 2015-02-02T16:16:00.000 | 0 | 0 | 0 | 0 | python,tkinter | 28,283,243 | 3 | false | 0 | 1 | I believe you'll want to bind the key to your handler: frame.bind('<Return>', some_handler). | 2 | 1 | 0 | I have created a program in python(Tkinter) which takes username and password as input and a button which, when pressed, goes through a function which checks the username and password and further runs the program. I want that, rather than clicking the button, user presses the 'Enter' key and that does the function of t... | Getting values by pressing 'Enter' key rather than clicking a button | 0 | 0 | 0 | 8,809 |
28,282,005 | 2015-02-02T16:16:00.000 | 0 | 0 | 0 | 0 | python,tkinter | 37,026,723 | 3 | false | 0 | 1 | For me, the normal binding to a function did not work. Probably because I am using it inside a class, I used the Lambda function and it worked. Here's the code:
inp.bind('', lambda _: show()) | 2 | 1 | 0 | I have created a program in python(Tkinter) which takes username and password as input and a button which, when pressed, goes through a function which checks the username and password and further runs the program. I want that, rather than clicking the button, user presses the 'Enter' key and that does the function of t... | Getting values by pressing 'Enter' key rather than clicking a button | 0 | 0 | 0 | 8,809 |
28,282,706 | 2015-02-02T16:54:00.000 | 0 | 0 | 0 | 0 | python,scikit-learn,random-forest | 28,315,175 | 2 | false | 0 | 0 | classifier.predict_proba() returns the class probabilities. The n dimension of the array will vary depending on how many classes there are in the subset you train on | 1 | 3 | 1 | I have a dataset that I split in two for training and testing a random forest classifier with scikit learn.
I have 87 classes and 344 samples. The output of predict_proba is, most of the times, a 3-dimensional array (87, 344, 2) (it's actually a list of 87 numpy.ndarrays of (344, 2) elements).
Sometimes, when I pick ... | Scikit-learn RandomForestClassifier output of predict_proba | 0 | 0 | 0 | 2,825 |
28,292,538 | 2015-02-03T06:15:00.000 | 0 | 0 | 0 | 0 | python,django | 28,293,569 | 3 | false | 1 | 0 | You no need any magic to do singleton-like object in python. Just write module, for example shared.py inside your django project. Put your dictionary initialization here and import it from anywhere. | 2 | 3 | 0 | I have an application and a database. The application initially was written in python without django. What seems to be the problem is that it makes too many connections with the database and that slows it down. What I want to do is load whatever data is going to be used in python dictionary and then share that object w... | Share object between django users | 0 | 0 | 0 | 1,011 |
28,292,538 | 2015-02-03T06:15:00.000 | 1 | 0 | 0 | 0 | python,django | 28,294,419 | 3 | true | 1 | 0 | Contrary to your assertion, Django does not reinitialize on every request. Actually, Django processes last for many requests, and anything defined at module level will be shared across all requests handled by that process. This can often be a cause of thread safety bugs, but in your case is exactly what you want.
Of co... | 2 | 3 | 0 | I have an application and a database. The application initially was written in python without django. What seems to be the problem is that it makes too many connections with the database and that slows it down. What I want to do is load whatever data is going to be used in python dictionary and then share that object w... | Share object between django users | 1.2 | 0 | 0 | 1,011 |
28,292,632 | 2015-02-03T06:23:00.000 | 0 | 1 | 1 | 0 | python,metadata,id3v2,hachoir-parser | 28,557,527 | 1 | true | 0 | 0 | The problem with hachoir-metadata is that they search only "text" field for every ID3 chunk, but write image in "img_data" field not in "text" field.
So, hachoir-metadata can not extract images from metadata because this problem in source code. | 1 | 0 | 0 | I've tried to use hachoir-metadata to work with multimedia files but I can't find how to parse covers in ID3v2 metadata. I see in source code that it know about a lot of covers tags but dose not return any in parser. And I've even tried to use libextractor and python-extractor binding and also didn't find how to fetch ... | Does hachoir metadata or libextractor extract covers from ID3v2 and all another formats? | 1.2 | 0 | 0 | 141 |
28,293,096 | 2015-02-03T06:59:00.000 | 6 | 0 | 0 | 0 | python,mongodb,flask,mongoengine | 28,293,187 | 1 | true | 1 | 0 | It's simple just use :
Request.objects.first() | 1 | 3 | 0 | I have a class with name of Request and I want to get first object of it in mongoengine
I think I can use this :
first get all objects like this visitors = Request.objects.all()and then ss = visitors[0].ip
and then call an attribute of object | get first object in mongoengine | 1.2 | 0 | 0 | 2,821 |
28,295,059 | 2015-02-03T09:08:00.000 | 3 | 0 | 0 | 0 | python,django,forms,post | 28,295,685 | 1 | false | 1 | 0 | Should I use exactly multipart/form-data content-type?
Django supports only multipart/form-data, so you must use that content-type.
Where can I specify enctype? (headers, parameters, etc)
in normal HTML just put enctype="multipart/form-data" as one of parameters of your form element. In HttpRequester it's more co... | 1 | 2 | 0 | I'm trying to send a file via post request to server on localhost. I'm using HttpRequester in Firefox (also tried Postman in Chrome and Tasker on Android) to sumbit request.
The problem is that request.FILES is always empty. But when I try to print request.body it shows some non-human-readable data which particularly i... | Empty request.FILES in Django | 0.53705 | 0 | 1 | 3,002 |
28,308,285 | 2015-02-03T20:38:00.000 | 0 | 0 | 1 | 0 | python,multithreading | 28,308,422 | 2 | false | 0 | 0 | It depends.
If your code is spending most of its time waiting for network operations (likely, in a web scraping application), threading is appropriate. The best way to implement a thread pool is to use concurrent.futures in 3.4. Failing that, you can create a threading.Queue object and write each thread as an infinit... | 1 | 0 | 0 | Since my scaper is running so slow (one page at a time) so I'm trying to use thread to make it work faster. I have a function scrape(website) that take in a website to scrape, so easily I can create each thread and call start() on each of them.
Now I want to implement a num_threads variable that is the number of thread... | Python what is the best way to handle multiple threads | 0 | 0 | 1 | 1,243 |
28,310,338 | 2015-02-03T22:54:00.000 | 1 | 0 | 1 | 0 | python,list,dictionary,set | 28,310,389 | 3 | false | 0 | 0 | As far as efficiency goes, you can't be any more efficient than looping through the list. I would also argue that looping through the list is already a simple process. | 1 | 2 | 0 | For my program, I wish to cleanly check whether any elements in a list is a key in a dictionary. So far, I can only think to loop through the list and checking.
However, is there any way to simplify this process? Is there any way to use sets? Through sets, one can check whether two lists have common elements. | Using set on Dictionary keys | 0.066568 | 0 | 0 | 9,198 |
28,310,782 | 2015-02-03T23:30:00.000 | 0 | 0 | 1 | 0 | python,pygame,pip | 28,639,628 | 1 | false | 0 | 1 | you must not have set the path variable in windows..it's the same mistake that i made..
set the environment variable in windows by doing fallowing steps:
right click 'My Computer'
go to properties
Advanced System Settings
Environment Variables
and set Path there..
if this doesn't help then try another method :
open ... | 1 | 0 | 0 | I've installed Python 2.7.6 (32-bit) on Windows 7 (64-bit). This works fine in Windows Power Shell. I set the PATH to C:\Users\name\Python27\Scripts, and that didn't seem to be a problem either. I then downloaded a pygame install file, pygame-1.9.2a0-cp27-none-win32.whl, from:
http://www.lfd.uci.edu/~gohlke/pythonlibs/... | can't install pygame using pip, Python 2.7.6 on Win7 | 0 | 0 | 0 | 559 |
28,311,063 | 2015-02-03T23:55:00.000 | 6 | 0 | 1 | 0 | python,ipython,nose,pdb | 28,313,669 | 1 | true | 0 | 0 | Most likely nose captures stdout. If you can run it with -s option it should work as expected. You can also use from nose.tools import set_trace; set_trace() to use pdb debugger, it will pass stdout/stdin properly. | 1 | 0 | 0 | I have a fairly basic question. I'm running the nosetests command for my python application's test suite. I want to drop into an interactive debugger. As the tests are run, it hits my IPython.embed() line and freezes, no prompt. Ctrl+C kills it and resumes the tests.
How can I drop into an interactive prompt of some so... | Using iPython with nose? | 1.2 | 0 | 0 | 1,032 |
28,313,984 | 2015-02-04T05:15:00.000 | 0 | 0 | 1 | 0 | python,instance,pickle | 28,314,281 | 2 | false | 0 | 0 | Pickling simply doesnt pickle your classes, pickle only works on data, if you try to pickle a class with built in methods it simply will not work. it will come out glitchy and broken.
source: learning python by Mark Lutz | 1 | 0 | 0 | I have a python class which I can instantiate and then pickle. But then I have a second class, inheriting from the first, whose instances I cannot pickle. Pickle gives me the error "can't pickle instancemethod". Both instances have plenty of methods. So, does anyone have a guess as to why the first class would pick... | When does pickle fail to pickle an instance? | 0 | 0 | 0 | 81 |
28,314,822 | 2015-02-04T06:27:00.000 | 0 | 0 | 1 | 0 | python,multithreading | 28,314,945 | 2 | false | 0 | 0 | A background task should never try to kill a foreground task - it might be doing something important. The background task should pass a status of "Restart Needed" and the foreground task should exit when convenient or after prompting the user. This would be an extension of your current status checking.
In your backgr... | 1 | 0 | 0 | I have a client and server model. The server periodically sends its healthy condition to client. The client has a background thread to take care of it(main thread is doing something else). Once the client notices the server is in a bad status, it will do some clean up work and then kill itself(kill the client process).... | python background thread cannot trigger function registered at atexit.register() | 0 | 0 | 0 | 451 |
28,316,119 | 2015-02-04T07:49:00.000 | 1 | 1 | 0 | 0 | python,regex,unit-testing,python-unittest | 28,316,773 | 1 | true | 0 | 0 | Try to test Rule and ValueSetter each in their own Test. Test that the Rule really does what you think in the 5 cases you describe in your question. Then when you test your ValueSetter just assume that Rule does what you think and set for example message_title, message_content and message_number directly. So you inject... | 1 | 0 | 0 | What will be the best way to test following:
We have a large complex class that we'll call ValueSetter which accepts string, gets some data from it and sets this data to several variables like
message_title, message_content, message_number
To perform this it uses another one class called Rule where are rules for parti... | Test part of complex structure with unittest and mocks | 1.2 | 0 | 0 | 56 |
28,318,105 | 2015-02-04T09:42:00.000 | 0 | 0 | 0 | 0 | django,python-2.7,apache2,mod-wsgi,pyinotify | 28,320,868 | 2 | false | 1 | 0 | You shouldn't prevent spawning multiple processes, because it's good thing, especially on production environment. You should consider using some external tool, separated from django or add check if folder listening is already running (for example monitor persistence of PID file and it's content). | 2 | 1 | 0 | I'm running apache with django and mod_wsgi enabled in 2 different processes.
I read that the second process is a on-change listener for reloading code on change, but for some reason the ready() function of my AppConfig class is being executed twice. This function should only run once.
I understood that running django ... | how to run Apache with mod_wsgi and django in one process only? | 0 | 0 | 0 | 444 |
28,318,105 | 2015-02-04T09:42:00.000 | 2 | 0 | 0 | 0 | django,python-2.7,apache2,mod-wsgi,pyinotify | 28,321,203 | 2 | false | 1 | 0 | No, the second process is not an onchange listener - I don't know where you read that. That happens with the dev server, not with mod_wsgi.
You should not try to prevent Apache from serving multiple processes. If you do, the speed of your site will be massively reduced: it will only be able to serve a single request at... | 2 | 1 | 0 | I'm running apache with django and mod_wsgi enabled in 2 different processes.
I read that the second process is a on-change listener for reloading code on change, but for some reason the ready() function of my AppConfig class is being executed twice. This function should only run once.
I understood that running django ... | how to run Apache with mod_wsgi and django in one process only? | 0.197375 | 0 | 0 | 444 |
28,319,283 | 2015-02-04T10:40:00.000 | 0 | 0 | 1 | 0 | python,import,canopy | 28,319,550 | 1 | true | 0 | 0 | I think I have had this problem before. You should be able to solve it by resetting the python kernel in between edits (there should be an option somewhere in your gui), but I don't know if this is the most efficient way to deal with this annoyance
After googling, I think the option you want is Run menu > Restart kerne... | 1 | 0 | 0 | I have two python script named main.py and track.py. I tried to import track.py in main.py in the way below:
import track
...
And I tried to call a function in track.py in main.py below
a=track.localization()
But when I change the code of track.py, I think it make no result. And I think canopy has import other track.py... | why canopy always import a wrong python file | 1.2 | 0 | 0 | 119 |
28,319,579 | 2015-02-04T10:55:00.000 | 2 | 0 | 0 | 0 | python,selenium-webdriver,phantomjs,headless-browser,ghostdriver | 28,319,699 | 2 | true | 1 | 0 | If you want to bypass ghostdriver, then you can directly write your PhantomJS scripts in JavaScript or CoffeeScript. As far as I know there is no way of doing this with the selenium webdriver except with different threads in the language of your choice (python).
If you are not happy with it, there is CasperJS which has... | 1 | 1 | 0 | I am using PhantomJS via Python through Selenium+Ghostdriver.
I am looking to load several pages simultaneously and to do so, I am looking for an async method to load pages.
From my research, PhantomJS already lives in a separate thread and supports multiple tabs, so I believe the only missing piece of the puzzle is a ... | Opening pages asynchronously in headless browser (PhantomJS) | 1.2 | 0 | 1 | 691 |
28,321,474 | 2015-02-04T12:31:00.000 | 0 | 1 | 0 | 0 | python-3.x,fuzzy-search,fuzzy-comparison | 37,747,215 | 1 | false | 0 | 0 | Jellyfish supports Python 3.3 and 3.4. | 1 | 1 | 0 | fuzzy.c:1635:5: error: too few arguments to function 'PyCode_New'
I am upgrading from python 2.7 to 3.2. I am getting an error in the c-compile of the fuzzy library (that apparently isn't Python 3 compatible).
Any suggestions? Is there an alternative to the NYSIIS encoding?
Thanks | Fuzzy - NYSIIS python 3 | 0 | 0 | 0 | 299 |
28,322,139 | 2015-02-04T13:04:00.000 | 1 | 0 | 1 | 1 | python,linux,debian,pip,dpkg | 28,322,460 | 2 | false | 0 | 0 | You can certainly dump all the packages installed by dpkg, but that's probably not what you want to do - you'll end up getting thounsands of packages unrelated to your software, and possibly breaking the system, if it's a different debian version.
My advice is getting your software to a fresh debian machine and try to ... | 1 | 1 | 0 | I'm shipping a Python app for deployment on Debian servers. Providing a requirements.txt file with a list of all needed Python packages is very convenient when installing the app, especially when accompanied with a Makefile to automatically install from it using pip.
But as you know some Python packages depend on Linux... | What is the Debian equivalent of "requirements.txt" in Python for managing packages? | 0.099668 | 0 | 0 | 1,881 |
28,324,393 | 2015-02-04T14:56:00.000 | 1 | 0 | 0 | 0 | python,qt,pyqt,twisted,twisted.web | 28,327,369 | 1 | false | 1 | 0 | So i figured out that Qt isn't sending the TWISTED_SESSION cookie back with subsequent requests.
all i did was send the cookie along with subsequent requests and it worked fine.
i had to sqitch to python's request to ease things | 1 | 1 | 0 | I am currently authenticating via a RESTful http api that generates a token which is then used for subsequent request.
The api server is written with python twisted and works great
the auth token generation works fine in browsers
When requesting from software written in pyqt
the first request hands over a token to the ... | IQtNetwork.QHttp request credential issue | 0.197375 | 0 | 1 | 49 |
28,326,362 | 2015-02-04T16:25:00.000 | 41 | 1 | 1 | 0 | python,pycharm | 57,497,936 | 3 | false | 0 | 0 | In PyCharm Community 2019.2/2019.3 (and probably other versions), you can simply:
right-click any folder in your project
select "Mark Directory As"
select "Sources Root"
Modules within that folder will now be available for import. Any number of folders can be so marked. | 1 | 102 | 0 | I am new to PyCharm. I have a directory that I use for my PYTHONPATH: c:\test\my\scripts\. In this directory I have some modules I import. It works fine in my Python shell.
How do I add this directory path to PyCharm so I can import what is in that directory? | PyCharm and PYTHONPATH | 1 | 0 | 0 | 100,884 |
28,327,329 | 2015-02-04T17:10:00.000 | 1 | 0 | 1 | 0 | python,inheritance,data-structures,types,multiple-inheritance | 28,327,351 | 1 | true | 0 | 0 | So when we arbitrarily create our own data type class and defining the
specific types of children / data types it will be able to handle, are
we just redefining what python already has implemented?
This just has one short answer: yes. | 1 | 1 | 0 | Apologize if this is a duplicate, tried searching.
I understand that everything in python is a data type, but this is what I'm a bit confused about. So everything is an object, we have the collection class, integer, float, and other classes as children of the parent object class thinking of it as a tree of objects with... | Defining your own python objects and data types | 1.2 | 0 | 0 | 183 |
28,327,779 | 2015-02-04T17:36:00.000 | 0 | 0 | 1 | 0 | python,python-3.x,lighttable | 28,327,929 | 4 | false | 0 | 0 | Hit Ctrl + Space to bring up the control pane. Then start typing Set Syntax and select Set Syntax to Python. Start typing your Python then press Ctrl + Shift + Enter to build and run the program. | 3 | 6 | 0 | I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?
I looked on Google and GitHub and ... | Running Python 3 from Light Table | 0 | 0 | 0 | 4,744 |
28,327,779 | 2015-02-04T17:36:00.000 | 0 | 0 | 1 | 0 | python,python-3.x,lighttable | 28,331,730 | 4 | false | 0 | 0 | I got the same problem. It worked for me after saving the file with a .py extension and then typing Cmd+Enter. | 3 | 6 | 0 | I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?
I looked on Google and GitHub and ... | Running Python 3 from Light Table | 0 | 0 | 0 | 4,744 |
28,327,779 | 2015-02-04T17:36:00.000 | 3 | 0 | 1 | 0 | python,python-3.x,lighttable | 29,534,922 | 4 | true | 0 | 0 | I had the same problem with using a syntax that was only valid on Python3.3.
- Go to Settings:User Behaviour
- add the line (find the real path of your python binary):
[:app :lt.plugins.python/python-exe "/usr/bin/python3.4"]
- Save and test in your lighttable
It worked for me :)
Hope it helps | 3 | 6 | 0 | I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?
I looked on Google and GitHub and ... | Running Python 3 from Light Table | 1.2 | 0 | 0 | 4,744 |
28,329,352 | 2015-02-04T19:04:00.000 | 10 | 0 | 0 | 0 | python,ubuntu-14.04,rethinkdb,rethinkdb-python | 28,330,153 | 1 | true | 0 | 0 | You're almost certainly not losing data, you're just starting RethinkDB without pointing it to the data. Try the following:
Start RethinkDB from the directory that contains the rethinkdb_data directory.
Alternatively, pass the -d flag to RethinkDB to point it to the directory that contains rethinkdb_data. For example,... | 1 | 7 | 0 | I save my data on RethinkDB Database. As long as I dont restart the server, all is well. But when I restart, it gives me an error saying database doesnt exist, although the folder and data does exist in folder rethinkdb_data. What is the problem ? | RethinkDB losing data after restarting server | 1.2 | 1 | 0 | 897 |
28,329,562 | 2015-02-04T19:17:00.000 | 0 | 0 | 0 | 1 | macos,python-3.x | 54,770,045 | 2 | false | 0 | 0 | For Anaconda users who have updated to Mojave, you may be running an outdated/unsigned version of Python.
Simply run conda upgrade conda to update Python to the latest version, which should also be signed, and the problem should go away. If it doesn't, then you may need to contact Anaconda's support to get them to buil... | 1 | 9 | 0 | I am developing a simple python3 server app. I invoke it like this:
python3 bbserver.py
Each time after doing this I get the OSX popup:
Do you want the application “Python.app” to accept incoming network connections?
I've tried making an exception for python3 executable (there is no python3.app) in the firewall and hav... | How to prevent OSX popup for incoming connections for Python app? | 0 | 0 | 0 | 2,455 |
28,329,977 | 2015-02-04T19:40:00.000 | 1 | 1 | 0 | 0 | python,html,xml,parsing,raspberry-pi | 28,361,971 | 2 | false | 0 | 0 | I think there are 3 steps you need to make it work.
Extracting only the data you want from the given XML file.
Using simple template engine to insert the extracted data into a HTML file.
Use a web server to service the file create above.
Step 1) You are already using lxml which is a good library for doing this so I d... | 1 | 2 | 0 | I am doing a digital signage project using Raspberry-Pi. The R-Pi will be connected to HDMI display and to internet. There will be one XML file and one self-designed HTML webpage in R-Pi.The XML file will be frequently updated from remote terminal.
My idea is to parse the XML file using Python (lxml) and pass this pars... | Parse XML file in python and display it in HTML page | 0.099668 | 0 | 1 | 4,898 |
28,333,391 | 2015-02-04T23:13:00.000 | 0 | 0 | 1 | 0 | python-3.x,windows-7,path,conda | 28,354,826 | 1 | false | 0 | 0 | In the Windows cmd shell, use the activate and deactivate commands to change the PATH automatically. For instance, if your environment is called python3, run python3 to "activate" (i.e., add to the PATH) the python3 environment. Use deactivate to remove it. | 1 | 2 | 0 | I've got anaconda installed and was able to create a Python 3.3 environment. I can switch to it and conda info -e shows that I've switched.
However, I'm confused about what to set my PATH variable to. If I hard code it to the exact env then it works, but I thought that the purpose of conda was to be able to switch easi... | Windows 7: What PATH to set to when using Conda | 0 | 0 | 0 | 539 |
28,336,318 | 2015-02-05T04:37:00.000 | 5 | 1 | 1 | 0 | python,c++ | 28,336,386 | 1 | false | 0 | 0 | #include in C and C++ is a textual include. import in Python is very different -- no textual inclusion at all!
Rather, Python's import lets you access names exported by a self-contained, separately implemented module. Some #includes in C or C++ may serve similar roles -- provide access to publicly accessible names fr... | 1 | 2 | 0 | is "import" in python equivalent to "include" in c++?
Can I consider namespaces from c++ the same way I do with python module names? | include in C++ vs import in python | 0.761594 | 0 | 0 | 3,107 |
28,339,778 | 2015-02-05T08:57:00.000 | 1 | 0 | 0 | 1 | google-app-engine,python-2.7,google-app-engine-python | 28,340,241 | 1 | false | 1 | 0 | Your full project path contains two space characters and needs to be quoted, also, a trailing slash might be required i.e.:
C:\Python27\python.exe appcfg.py update "C:\Users\alastair\Desktop\School Files\Proxy Files\mirrorrr-master\mirrorrr-master\" assuming that's where you have your app.yaml file.
In your case it's t... | 1 | 0 | 0 | Ive been working on get a proxy working for when im school, to access sites that i use alot for work but my school dont like.. This is the error it comes up with when i try to upload the files to googles app engine..
C:\Program Files (x86)\Google\google_appengine>"C:\Python27\python.exe" appcfg.p
y update C:\Users\ala... | GoogleAppEngine error directory not found | 0.197375 | 0 | 0 | 95 |
28,340,224 | 2015-02-05T09:21:00.000 | 0 | 0 | 0 | 1 | python,weka | 35,519,213 | 3 | false | 0 | 0 | Before installing weka wrapper for python you are suppose to install the weka itself using sudo apt-get install weka or build from source code and add the path the enviroment variable using export wekahome="your weka path" this will make sure you have the required weka jar file in the directory | 1 | 0 | 0 | The official website shows how weka-wrapper can install on ubuntu 64 bit. I want toknowhow it can be install on ubuntu 32 bit? | How to install python weka wrapper on ubuntu 32 bit? | 0 | 0 | 0 | 359 |
28,340,723 | 2015-02-05T09:46:00.000 | 8 | 0 | 1 | 0 | python,testcase,unit-testing | 28,341,477 | 2 | true | 0 | 0 | Asserting something in your tearDown means that you need to be careful that all the cleaning is done before the actual asserting otherwise the cleaning code may not be called if the assert statement fails and raises.
If the assert is just one line it may be OK to have it in every test methods, if it is more than that h... | 1 | 9 | 0 | I have a TestCase with multiple tests and need to assert a few conditions (the same for every test) at the end of each test. Is it OK to add these assertions to the tearDown() method, or is it a bad habit since they're not "cleaning" anything?
What would be the right way of doing this? | Is it OK to assert in unittest tearDown method? | 1.2 | 0 | 0 | 2,278 |
28,343,666 | 2015-02-05T12:12:00.000 | 2 | 0 | 0 | 0 | python,python-2.7,pip,pymssql | 28,349,658 | 1 | true | 0 | 0 | Looking at the full traceback we see that include_dirs includes /usr/local/include but the header files are in /usr/include which I imagine has to do with the fact python 2.7 is not the system python.
You can change the setup.py script to include /usr/include or copy the files into /usr/local/include | 1 | 1 | 0 | I'm trying to pip install pymssql in my Centos 6.6, but kept on experiencing this error:
_mssql.c:314:22: error: sqlfront.h: No such file or directory
cpp_helpers.h:34:19: error: sybdb.h: No such file or directory
I already installed freetds, freetds-devel, and cython.
Any ideas? Thanks in advance! | Installing pymssql in Centos 6.6 64-bit | 1.2 | 1 | 0 | 2,708 |
28,345,878 | 2015-02-05T13:59:00.000 | 1 | 0 | 0 | 1 | python-2.7,twisted | 28,348,066 | 1 | false | 0 | 0 | There's no need and no way to flush either the read buffer or the write buffer. | 1 | 1 | 0 | I created a simple tcp connection server with Twisted framework. I use the self.transport.write function to write data to the client, but I need to flush the data. Is there a way to do this? In addition, is there a way to flush incoming data? | I used self.transport.write function to write to tcp stream, How to use flush with it? | 0.197375 | 0 | 0 | 74 |
28,352,419 | 2015-02-05T19:29:00.000 | 1 | 1 | 1 | 0 | python,python-3.x,com,win32com | 28,363,049 | 1 | true | 0 | 0 | PumpWaitingMessage will process messages and return as soon as there are no more messages to process.
You can call it in a loop, but you should call MsgWaitForMultipleObjects, or MsgWaitForMultipleObjectsEx, before the next loop iteration.
Avoid calling these functions before the initial loop iteration, as they'll bloc... | 1 | 2 | 0 | I use Python 3.4. I have a program that provide an integration with COM module in Windows, by win32com package. To process messages from this module I use the pythoncom.PumpWaitingMessages() method in the infinite while loop. But python infinite loop makes 100% CPU core load (as shown in Windows Task Manager). The ques... | python win32com "PumpWaitingMessages()" processing | 1.2 | 0 | 0 | 3,020 |
28,353,801 | 2015-02-05T20:54:00.000 | 1 | 0 | 1 | 0 | macos,python-3.x,textmate,anaconda | 29,264,565 | 1 | true | 0 | 0 | I use Anaconda Python 2, and found a couple ways to do this.
First note that the tilde shortcut ( ~ ) doesn't work everywhere, and as you found not in text mate variables. Usually you have to use the full path e.g. /Users/youruserid/Anaconda/bin/
Add the path above to your PATH variable in TextMate
set a TM_PYTHON ... | 1 | 2 | 0 | I have installed Anaconda with Python 3.4. How can I use that version on TextMate?
I tried adding ~/anaconda/bin at the beginning of the PATH variable, but it doesn't work.
When I try to run a program I get Program exited with code #1 after 0.00 seconds and no output. | Can I use Anaconda on TextMate | 1.2 | 0 | 0 | 622 |
28,355,169 | 2015-02-05T22:20:00.000 | 1 | 0 | 0 | 1 | python,debugging,gdb,segmentation-fault,strace | 60,442,126 | 1 | false | 0 | 0 | For those who would have the same problem as I had and find this page:
My CherryPy server.py ran fine on my Win10 system on python3.8 but failed with segmentation fault on my Linux system which had python3.6.1.
Switching to python3.8 on Linux solved my problem. | 1 | 2 | 0 | I am running a custom Python 2.7.3 application on CherryPy in Linux. When I used a service script in /etc/init.d/ to start or stop the service, I encountered a Segmentation Fault (SIGSEGV). Strangely, I did not receive a SIGSEGV if I ran the start or stop command manually from the shell, using "python /path/to/file.py ... | Why did I get a Segmentation Fault in Python when /tmp is mounted with noexec? | 0.197375 | 0 | 0 | 636 |
28,358,379 | 2015-02-06T04:03:00.000 | 3 | 0 | 1 | 0 | python,image,image-processing,python-imaging-library,mask | 63,671,324 | 2 | false | 0 | 0 | You can use the PIL library to mask the images. Add in the alpha parameter to img2, As you can't just paste this image over img1. Otherwise, you won't see what is underneath, you need to add an alpha value.
img2.putalpha(128) #if you put 0 it will be completly transparent, keep image opaque
Then you can mask both the i... | 1 | 2 | 1 | I have some traffic camera images, and I want to extract only the pixels on the road. I have used remote sensing software before where one could specify an operation like
img1 * img2 = img3
where img1 is the original image and img2 is a straight black-and-white mask. Essentially, the white parts of the image would ev... | Is it possible to mask an image in Python Imaging Library (PIL)? | 0.291313 | 0 | 0 | 10,471 |
28,359,414 | 2015-02-06T05:53:00.000 | 1 | 0 | 0 | 0 | python,django,postgresql | 28,382,483 | 1 | true | 1 | 0 | If you are using Linux you just have to add that domain name in /etc/hosts and access it like it is a real domain name. Another solution is to make that domain name to point to 127.0.0.1 while you don't push the changes to production. I'd go with the first idea though. | 1 | 0 | 0 | I have successfully implemented django-tenant-schema in my project. It also creates separate schema for each user after they got registered.Suppose if a customer named 'customer1' is successfully logged in, then he will redirect to "customer1.domainname.com".So please suggest me a solution to test if this is working in... | How to proceed after Implementing django tenant schemas | 1.2 | 0 | 0 | 594 |
28,365,304 | 2015-02-06T11:58:00.000 | 11 | 0 | 1 | 0 | python,declaration,pep8 | 28,365,397 | 1 | true | 0 | 0 | Generally, there is no preferred order. Depending on the program, a order can be needed:
You can decorate classes with functions. Then the decorator function must be defined before the class.
OTOH, you can decorate functions with classes. Then the decorator class must be defined before the function.
You can have class... | 1 | 10 | 0 | Is there any preferred order when declaring multiple functions and classes in the same python file? Should functions or classes be declared first? What are the best practices?
PEP8 does not seems to give any recommendation | Python declaration order: classes or functions first? | 1.2 | 0 | 0 | 4,869 |
28,366,467 | 2015-02-06T13:04:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,pyscripter | 39,312,729 | 2 | false | 0 | 0 | Had this problem myself. Turns out for me it was an issue with 32/64 version mismatch. I had installed a 32 bit version of Python on Windows 8 (64 bit). I then tried installing 64 bit Pyscripter and got this error message. Uninstalled both python and pyscripter, and made sure I installed 64 bit version of python an... | 1 | 1 | 0 | I have already installed Python. But when I open PyScripter. I am getting error. It says:
"Python could not be properly initialized"
I'm using Windows 7 & (desktop). I downloaded Python 2.7.3 Windows Installer from python.org. should I download another version of Python. | Python could not be properly initialized | 0 | 0 | 0 | 5,293 |
28,368,533 | 2015-02-06T14:58:00.000 | 2 | 0 | 0 | 1 | macos,python-2.7,icons,xattr | 39,163,917 | 1 | false | 0 | 0 | Let we have a icon.icns file:
Read the com.apple.ResourceFork extended attribute from the icon file
Set the com.apple.FinderInfo extended attribute with folder icon flag
Create a Icon file (name: Icon\r) inside the target folder
Set extended attributes com.apple.FinderInfo & com.apple.ResourceFork for icon file (name:... | 1 | 3 | 0 | I am trying to write the Code in Python to Change the Icon of a Mac OS X folder using just the Python Script (Without XCODE or any other API).
The procedure is that I have a icon.icns file , I need to change the folder icon to the icon.icns file using the python script. | How to change icon of a MAC OS folder using Python Script and Terminal commands? | 0.379949 | 0 | 0 | 1,414 |
28,376,186 | 2015-02-06T22:50:00.000 | 5 | 0 | 1 | 0 | python,python-3.x | 28,376,254 | 2 | false | 0 | 0 | Convert the strings to set objects.
set(str1).issubset(set(str2))
You can also use this alternative syntax:
set(str1) <= set(str2) | 1 | 0 | 0 | This seems pretty straight-forward but I'm stuck. What I want is to see if a string (str1) contains all the letters that are in a second string (str2). If str1 contains all the letters (in any order, any number of times) then return True. If not, return false.
[Note] Str2 does not necessarily have to have all the lett... | Python: Compare 2 strings and see if they contain the same letters | 0.462117 | 0 | 0 | 1,670 |
28,379,325 | 2015-02-07T06:30:00.000 | 1 | 1 | 0 | 1 | python-3.x,python-import,python-module | 29,157,556 | 1 | true | 0 | 0 | You would be better off to install those modules locally.
Can you create packages of those modules (either using pip or something similar) then you can distribute them to your local box.
Of what I know, there is nothing similar. | 1 | 0 | 0 | How I can use some 'extra' python module which is not located localy but on a remote server? Somthing like using maven dependencies with Java | How to use remote python modules | 1.2 | 0 | 1 | 32 |
28,379,373 | 2015-02-07T06:37:00.000 | 0 | 0 | 1 | 0 | python,function,variables,arguments | 28,380,390 | 2 | false | 0 | 0 | As @Alex Martelli pointed out, you can... but should you? That's the more relevant question, IMO.
I understand the appeal of what you're asking. It seems like it should just be good form because otherwise you'd have to pass the variables everywhere, which of course seems wasteful.
I won't presume to know how far along... | 1 | 1 | 0 | In python is there any way at all to get a function to use a variable and return it without passing it in as an argument? | Use a Variable in a Function Without Passing as an Argument | 0 | 0 | 0 | 6,166 |
28,384,481 | 2015-02-07T16:26:00.000 | 1 | 0 | 1 | 0 | python,arrays,numpy | 53,429,718 | 6 | false | 0 | 0 | Just do the following.
import numpy as np
arr = np.zeros(10)
arr[:3] = 5 | 1 | 1 | 1 | I'm having trouble figuring out how to create a 10x1 numpy array with the number 5 in the first 3 elements and the other 7 elements with the number 0. Any thoughts on how to do this efficiently? | Create a numpy array (10x1) with zeros and fives | 0.033321 | 0 | 0 | 5,701 |
28,388,896 | 2015-02-07T23:46:00.000 | 1 | 0 | 1 | 1 | python | 28,388,912 | 1 | false | 0 | 0 | Okay, first point is that you can't share memory among machines unless you're on a very specialized architecture. (Massively parallel machines, Beowulf clusters, and so on.)
If you mean to share code, then package your code into a real Python package and distribute it with a tool like Chef, Puppet or Docker.
If you mea... | 1 | 2 | 0 | My python process run on different machines. It consists of a manager and many workers. The worker in each machine are multi threaded and needs to update some data such as its status to the manager residing on another machine. I didn't want to use mysql because many other processes are already executing many queries o... | python - How to share files between many computers | 0.197375 | 0 | 0 | 516 |
28,388,976 | 2015-02-07T23:59:00.000 | 2 | 0 | 1 | 0 | python,six | 28,440,063 | 1 | true | 0 | 0 | On some computers where I don't have pip installed I usually do:
Extract the downloaded file
In the command line, where you extracted do python setup.py install
Module should now be installed
You can run python now
In the interactive interpreter do import module_name
If you get no errors, installation was a success | 1 | 2 | 0 | I am running Python 2.7.9 on a Windows 8 machine. I've programmed for a long time (since the 60s), but I'm having trouble figuring out how to install the Six Module. I need a step-by-step set of instructions. Either help here or a suggested website would be helpful to this old man. Thanks! | Installing Python Module Six | 1.2 | 0 | 0 | 8,519 |
28,389,501 | 2015-02-08T01:16:00.000 | 4 | 0 | 1 | 0 | python,numpy,jupyter-notebook,ipython | 56,665,018 | 3 | false | 0 | 0 | I tested learning the same small neural net (1) under Jupyter and (2) running Python under Anaconda prompt (either with exec(open(foo.py).read()) under python or with python foo.py directly under Anaconda prompt).
It takes 107.4 sec or 108.2 sec under Anaconda prompt, and 105.7 sec under Jupyter.
So no, there is no sig... | 3 | 13 | 0 | I am developing a program for simulation (kind of like numerical solver). I am developing it in an ipython notebook. I am wondering if the speed of the code running in the notebook is the same as the speed of the code running from terminal ?
Would browser memory or overhead from notebook and stuff like that makes code ... | Does running IPython/Jupyter Notebook affect the speed of the program? | 0.26052 | 0 | 0 | 22,901 |
28,389,501 | 2015-02-08T01:16:00.000 | 15 | 0 | 1 | 0 | python,numpy,jupyter-notebook,ipython | 28,389,651 | 3 | true | 0 | 0 | One of the things that might slow things a lot would be if you had a lot of print statements in your simulation.
If you run the kernels server and browser on the same machine, assuming your simulation would have used all the cores of your computer, yes using notebook will slow things down. But no more than browsing fa... | 3 | 13 | 0 | I am developing a program for simulation (kind of like numerical solver). I am developing it in an ipython notebook. I am wondering if the speed of the code running in the notebook is the same as the speed of the code running from terminal ?
Would browser memory or overhead from notebook and stuff like that makes code ... | Does running IPython/Jupyter Notebook affect the speed of the program? | 1.2 | 0 | 0 | 22,901 |
28,389,501 | 2015-02-08T01:16:00.000 | 9 | 0 | 1 | 0 | python,numpy,jupyter-notebook,ipython | 48,817,440 | 3 | false | 0 | 0 | I have found that Jupyter is significantly slower than Ipython, whether or not many print statements are used. Nearly all functions suffer decreased performance, but especially if you are analyzing large dataframes or performing complex calculations, I would stick with Ipython. | 3 | 13 | 0 | I am developing a program for simulation (kind of like numerical solver). I am developing it in an ipython notebook. I am wondering if the speed of the code running in the notebook is the same as the speed of the code running from terminal ?
Would browser memory or overhead from notebook and stuff like that makes code ... | Does running IPython/Jupyter Notebook affect the speed of the program? | 1 | 0 | 0 | 22,901 |
28,390,253 | 2015-02-08T03:29:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,web | 28,397,610 | 1 | true | 1 | 0 | The best way is to ping the server while the user is online. Using other methods such as the Channel API with GAE proves to be unreliable since you are not constantly sending a ping message but rather just sending a disconnect message. If the browser crashes, no disconnect message is sent. | 1 | 0 | 0 | I want a way for users to open this webpage, and whenever they are on that page, it updates the server that they are on the page. It should only work when the user is actually looking at the webpage (not inactive, like from switchings tabs). One way to do this which I have implemented is to keep pinging the server sayi... | Webpage ping when active | 1.2 | 0 | 0 | 47 |
28,390,961 | 2015-02-08T05:38:00.000 | 98 | 0 | 1 | 0 | python,virtualenv,pycharm,anaconda,conda | 31,937,300 | 5 | true | 0 | 0 | I know it's late, but I thought it would be nice to clarify things: PyCharm and Conda and pip work well together.
The short answer
Just manage Conda from the command line. PyCharm will automatically notice changes once they happen, just like it does with pip.
The long answer
Create a new Conda environment:
conda creat... | 1 | 78 | 0 | I've got Pycharm 4 running on my Linux (Ubuntu 14.04) machine. In addition to the system python, I've also got Anaconda installed. Getting the two to play nicely together seems to be a bit of a problem... PyCharm provides some interesting integration for virtualenvs and pip, but the Anaconda Python distribution seems... | Using (Ana)conda within PyCharm | 1.2 | 0 | 0 | 132,021 |
28,399,120 | 2015-02-08T20:39:00.000 | 1 | 0 | 0 | 0 | python,django | 28,399,223 | 2 | true | 1 | 0 | No, code speed is not affected by the size of your modules.
Additional imports only affect the memory footprint (a little more memory is needed to hold the extra code objects) and startup speed (more files are loaded from disk when your Django server starts).
However, this doesn't really affect code running speeds; Pyt... | 2 | 0 | 0 | In my Django web app, I have pretty much one large file that contains all my views. This has a ton of imported python libraries that are only used for certain views.
Does this slow my code? Like in python does importing things like python natural language toolkit (nlkt) and threading libraries slow down the code wh... | In a Django web application, would large files or many unnecessary import statements slow down my server? | 1.2 | 0 | 0 | 62 |
28,399,120 | 2015-02-08T20:39:00.000 | 0 | 0 | 0 | 0 | python,django | 28,399,156 | 2 | false | 1 | 0 | Views load only one time, at the moment of start your code | 2 | 0 | 0 | In my Django web app, I have pretty much one large file that contains all my views. This has a ton of imported python libraries that are only used for certain views.
Does this slow my code? Like in python does importing things like python natural language toolkit (nlkt) and threading libraries slow down the code wh... | In a Django web application, would large files or many unnecessary import statements slow down my server? | 0 | 0 | 0 | 62 |
28,400,064 | 2015-02-08T22:23:00.000 | 0 | 0 | 0 | 0 | python,sqlite | 28,400,155 | 1 | true | 0 | 0 | In terms of logical correctness, you should commit every time a set of one or more queries that are supposed to execute atomically (i.e, all of them, or else none of them, execute) is finished.
There is no connection between this logical correctness and any given amount of time between commits. In your vaguely-sketche... | 1 | 0 | 0 | I m building a web crawler and I wanted to save links in a database with informations like type, size, etc.
and actually I don't know when I should commit the database (how often)
in other terms: is it a problem if I commit the database every 0.1 second? | Python sqlite3 correct use of commit | 1.2 | 1 | 0 | 67 |
28,400,972 | 2015-02-09T00:13:00.000 | 6 | 0 | 1 | 0 | python,sympy | 28,444,006 | 3 | true | 0 | 0 | Note that by default in SymPy the base of the natural logarithm is E (capital E). That is, exp(x) is the same as E**x. | 1 | 5 | 0 | I want to print the derivative of e**4*x. I want Python to give me 4*e**4x. Instead, it's giving me 4 times THE VALUE OF E. HOw can I get sympy to display e as the letter constant.
Thanks | How do I use a constant LETTER in sympy? | 1.2 | 0 | 0 | 7,557 |
28,404,878 | 2015-02-09T07:35:00.000 | 7 | 0 | 1 | 1 | python-2.7,windows-server-2008,google-compute-engine | 30,692,067 | 4 | false | 0 | 0 | Install python EXCEPT "pip"
Run the python install msi again and select "change"
Select "pip" and install the pip
It would be works...
I think it is a priority problem into the msi package...the package seems to try to install the pip before installing python.exe. So, pip can not be installed... | 2 | 7 | 0 | I fired up a new Windows google compute engine instance. It's running Windows 2008 R2, service pack 1.
I download and try running the Python .msi installer for version 2.7.9, and it fails with this error:
There is a problem with this Windows Installer package. A program required for this install to complete could no... | Fail to install Python 2.7.9 on a Windows google compute engine instance | 1 | 0 | 0 | 7,533 |
28,404,878 | 2015-02-09T07:35:00.000 | 0 | 0 | 1 | 1 | python-2.7,windows-server-2008,google-compute-engine | 31,103,137 | 4 | false | 0 | 0 | It seems to be a dependency issue, please try to install "Microsoft Visual C++ 2008 SP1 Redistributable Package (x64)" | 2 | 7 | 0 | I fired up a new Windows google compute engine instance. It's running Windows 2008 R2, service pack 1.
I download and try running the Python .msi installer for version 2.7.9, and it fails with this error:
There is a problem with this Windows Installer package. A program required for this install to complete could no... | Fail to install Python 2.7.9 on a Windows google compute engine instance | 0 | 0 | 0 | 7,533 |
28,406,420 | 2015-02-09T09:27:00.000 | 2 | 1 | 1 | 0 | python,python-2.7,python-3.x | 28,406,587 | 3 | false | 0 | 0 | put
C:\Netra_Step_2015\Tests\SVTestcases\Common\shared
in your PYTHONPATH env | 2 | 0 | 0 | When I print sys.path in my code I get the following as output:
['C:\Netra_Step_2015\Tests\SVTestcases', 'C:\Netra_Step_2015\Tests\SVTestcases\TC-Regression', 'C:\Python27\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', etc.]
Now, when I write "import testCaseBase as TCB" where testcaseBase.py is in this path:
C... | ImportError: Module not found but sys.path is showing the file resides under the path | 0.132549 | 0 | 0 | 6,665 |
28,406,420 | 2015-02-09T09:27:00.000 | 0 | 1 | 1 | 0 | python,python-2.7,python-3.x | 52,959,701 | 3 | false | 0 | 0 | Please dont use ~/ in the path . it does not work. Use the full path. | 2 | 0 | 0 | When I print sys.path in my code I get the following as output:
['C:\Netra_Step_2015\Tests\SVTestcases', 'C:\Netra_Step_2015\Tests\SVTestcases\TC-Regression', 'C:\Python27\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', etc.]
Now, when I write "import testCaseBase as TCB" where testcaseBase.py is in this path:
C... | ImportError: Module not found but sys.path is showing the file resides under the path | 0 | 0 | 0 | 6,665 |
28,406,798 | 2015-02-09T09:47:00.000 | 3 | 0 | 0 | 0 | python,ssl,packet,scapy | 28,407,181 | 2 | false | 0 | 0 | You can neither assume that all traffic using port 443 is SSL and also that SSL can only be found on port 443. To detect SSL traffic you might try to look at the first bytes, i.e. a data stream starting with \x16\x03 followed by [\x00-\x03] might be a ClientHello for SSL 3.0 ... TLS 1.2. But of course it might also be ... | 1 | 1 | 0 | How can I recognize SSL packets when I sniff in scapy?
I know that SSL packets are going through port 443, can I assume that all the TCP packets that go through port 443 are SSL packets? | Scapy sniffing SSL | 0.291313 | 0 | 1 | 6,880 |
28,411,082 | 2015-02-09T13:38:00.000 | 0 | 0 | 0 | 1 | python,subprocess,terminate | 28,411,277 | 2 | false | 0 | 0 | So, this is not a question involving code, so you get a general answer, not involving code.
The solution to your problem requires you to keep protocol. This protocol must survive the lifetime of your test processes.
So, there must be some place where you can write to about the state of your tests, and this place must e... | 1 | 0 | 0 | I am trying to automatize some test cases using subprocess_check.call() by calling another python script with an input and output files. I have approx. 10 input files. When I started to test, for example, first and second files were tested successfully but in the third file I got an error and the script was terminated.... | Python subprocess.check_call terminate and start from where it terminated | 0 | 0 | 0 | 58 |
28,413,567 | 2015-02-09T15:44:00.000 | 1 | 1 | 1 | 0 | python,robotframework | 41,825,897 | 2 | false | 1 | 0 | Try to add the following path in environment variable also:
"C:\Python27\Lib\site-packages"
Since this path consists all the third party modules installed on your PC and also verify if robot-framework library is present in this folder. | 2 | 1 | 0 | I'm trying to install Robot Framework, but it keeps giving me an error message during setup that "No Python installation found in the registry." I've tried running the installer as administrator, I've made sure that Python is installed (I've tried both 2.7.2 and 2.7.9), and both C:\Python27 and C:\Python27\Scripts are... | Robot Framework can't find Python | 0.099668 | 0 | 0 | 1,818 |
28,413,567 | 2015-02-09T15:44:00.000 | 0 | 1 | 1 | 0 | python,robotframework | 28,443,946 | 2 | false | 1 | 0 | I faced the same issue.
Install a different bit version of ROBOT framework. In my case, I was first trying to install 64bit version but it said "No Python installation found in the registry."
Then I tried to install the 32bit version of ROBOT framework and it worked.
So there is nothing wrong with your Python versio... | 2 | 1 | 0 | I'm trying to install Robot Framework, but it keeps giving me an error message during setup that "No Python installation found in the registry." I've tried running the installer as administrator, I've made sure that Python is installed (I've tried both 2.7.2 and 2.7.9), and both C:\Python27 and C:\Python27\Scripts are... | Robot Framework can't find Python | 0 | 0 | 0 | 1,818 |
28,415,460 | 2015-02-09T17:17:00.000 | 1 | 0 | 1 | 1 | python,windows,ubuntu,exe | 28,415,565 | 1 | true | 0 | 0 | cx_freeze is another option for freezing cross-platform. | 1 | 0 | 0 | I have been trying to package my python scripts into .exe setup for Windows. Is that any way I can do the same while running Ubuntu? | Packaging python scripts to .exe on Ubuntu | 1.2 | 0 | 0 | 45 |
28,416,182 | 2015-02-09T17:55:00.000 | 3 | 0 | 1 | 1 | python,powershell,path | 28,416,220 | 2 | false | 0 | 0 | Python 2.6.1 is already in your path as demonstrated by item number 2 in your list. On number 3, you're adding Python 2.7 to your path after Python 2.6.1's entry. You need to remove Python 2.6.1 from your environment variable, or at a minimum, set it so that 2.7 is listed first. | 1 | 5 | 0 | I have two Python versions on my machine (Windows Vista), 2.6 (located in C/Program files) and 2.7 (located in C/).
1- I open PowerShell
2- I type python, and it calls python 2.6.1.
3- I want to change the path for Python 2.7, so I type:
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")
4-... | Setting path for Python in PowerShell? | 0.291313 | 0 | 0 | 15,527 |
28,417,806 | 2015-02-09T19:34:00.000 | 1 | 0 | 0 | 0 | python,cassandra,datastax-enterprise | 28,419,293 | 2 | true | 0 | 0 | The details depend on your file format and C* data model but it might look something like this:
Read the file from s3 into an RDD
val rdd = sc.textFile("s3n://mybucket/path/filename.txt.gz")
Manipulate the rdd
Write the rdd to a cassandra table:
rdd.saveToCassandra("test", "kv", SomeColumns("key", "value")) | 1 | 0 | 1 | i Launch cluster spark cassandra with datastax dse in aws cloud. So my dataset storage in S3. But i don't know how transfer data from S3 to my cluster cassandra. Please help me | How import dataset from S3 to cassandra? | 1.2 | 1 | 0 | 1,657 |
28,418,823 | 2015-02-09T20:34:00.000 | 0 | 0 | 0 | 0 | python,theano,softmax | 34,094,065 | 1 | true | 0 | 0 | solved. I had to use T.nnet.categorical_crossentropy since my target variable is an integer vector. | 1 | 1 | 1 | I'm implementing a DNN with Theano. At the last layer of DNN, I'm using a softmax as a nonlinear function from theano.tensor.nnet.softmax
As a lost function i'm using cross entropy from T.nnet.binary_crossentropy
But I get a strange error:
"The following error happened while compiling the node', GpuDnnSoftmaxGrad{tenso... | getting error with softmax and cross entropy in theano | 1.2 | 0 | 0 | 1,358 |
28,419,700 | 2015-02-09T21:26:00.000 | 2 | 0 | 1 | 0 | python,import,module | 28,419,726 | 1 | true | 0 | 0 | Should I always repeat my imports at the head of each module file?
Yes. Every module needs to import what it needs to use.
As two great minds noted in the comments, the actual loading of the module only takes place once. Multiple imports will reuse the already-loaded module, so it won't have any significant performa... | 1 | 0 | 0 | There is a main program importing a module with classes or something usefull that another submodule shall use too. For example:
main.py:
import datetime
datetime.now()
import mod
mod.py:
datetime.today()
When importing 'mod' module python gives an error that 'datetime' is not defined. datetime.today() cant be execu... | make imported modules accessible for further imported modules | 1.2 | 0 | 0 | 68 |
28,419,877 | 2015-02-09T21:37:00.000 | 52 | 0 | 0 | 0 | python,pandas | 57,704,035 | 3 | false | 0 | 0 | Meanwhile, since 0.19.0, there is pandas.Series.is_monotonic_increasing, pandas.Series.is_monotonic_decreasing, and pandas.Series.is_monotonic. | 1 | 33 | 1 | Is there a way to test whether a dataframe is sorted by a given column that's not an index (i.e. is there an equivalent to is_monotonic() for non-index columns) without calling a sort all over again, and without converting a column into an index? | Check whether non-index column sorted in Pandas | 1 | 0 | 0 | 17,253 |
28,422,520 | 2015-02-10T01:19:00.000 | 0 | 0 | 0 | 1 | python,django,macos,pip | 35,575,253 | 2 | false | 1 | 0 | Try adding sudo. sudo pip install Django | 2 | 0 | 0 | I recently installed Python 3.4 on my Mac and now want to install Django using pip. I tried running pip install Django==1.7.4 from the command line and received the following error:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line ... | Mac OSX Trouble Running pip commands | 0 | 0 | 0 | 797 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.