Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2014-06-10 08:06:52.630 | Is it possible to calculate the performance testing through selenium with python? | Is it possible to calculate the performance testing through selenium with python?
If it is possible, how should I do it? | Selenium is not the right tool to use for performance testing.
jmeter is a great tool for this. You would be able to see the response for each request. | 0 | false | 1 | 3,237 |
2014-06-11 09:47:14.153 | difference between python set and dict "internally" | Can anybody tell me how the internal implementation of set and dict is different in python? Do they use the same data structure in the background?
++ In theory, one can use dict to achieve set functionality. | These two are use the same datastructure in the backend. e.g in sets you cannot store duplicate values but in dict you can store multople same values and you can turn the dict to sets by changing the behavior of dict | -0.201295 | false | 1 | 3,238 |
2014-06-11 17:59:41.490 | How do I communicate and share data between python and other applications? | At a high level, what I need to do is have a python script that does a few things based on the commands it receives from various applications. At this stage, it's not clear what the application may be. It could be another python program, a MATLAB application, or a LAMP configuration. The commands will be sent rarely, s... | Python has since early stages a very comfortable PyZMQ binding for ZeroMQ.
MATLAB can have the same, a direct ZeroMQ at work for your many-to-many communications.
Let me move in a bit broader view, from a few, but KEY PRINCIPAL POINTS, that are not so common in other software-engineering "products" & "stacks" we meet t... | 0.201295 | false | 1 | 3,239 |
2014-06-12 21:28:00.653 | Using Google App Engine to update files on Google Compute Engine | I am working on a project that involves using an Google App Engine (GAE) server to control one or more Google Compute Engine (GCE) instances. The rest of the project is working well, but I am having a problem with one specific aspect: file management. I want my GAE to edit a file on my GCE instance, and after days of... | You can set an action URL in your form to point to the GCE instance (it can be load-balanced if you have more than one). Then all data will be uploaded directly to the GCE instance, and you don't have to worry about transferring data from your App Engine instance to GCE instance. | 0 | false | 2 | 3,240 |
2014-06-12 21:28:00.653 | Using Google App Engine to update files on Google Compute Engine | I am working on a project that involves using an Google App Engine (GAE) server to control one or more Google Compute Engine (GCE) instances. The rest of the project is working well, but I am having a problem with one specific aspect: file management. I want my GAE to edit a file on my GCE instance, and after days of... | The most straightforward approach seems to be:
A user submit a form on App Engine instance.
App Engine instance makes a POST call to a handler on GCE instance with the new data.
GCE instance updates its own file and processes it. | 0 | false | 2 | 3,240 |
2014-06-14 08:34:53.433 | Python set up a timer for client connection | I'll explain you better my problem.
I've code a simple python server who listening for web client connection.
The server is running but i must add a function and i don't know how resolve this..
I must set up a timer, if the client don't connect every N seconds, I've to log it.
I already looked for set up a timeout bu... | How about using a token that is switched when the client connects? Put it in a while loop and if the token is ever the same non-switched value twice in a row kill the loop and stop listen(). | 0 | false | 1 | 3,241 |
2014-06-14 21:38:32.793 | What's the proper Tornado response for a log in success? | So far I have a pretty basic server (I haven't built in any security features yet, like cookie authentication). What I've got so far is an iOS app where you enter a username and password and those arguments are plugged into a URL and passed to a server. The server checks to see if the username is in the database and th... | You can send your response with either self.write() or self.finish() (the main difference is that with write() you can assemble your response in several pieces, while finish() can only be called once. You also have to call finish() once if you're using asynchronous functions that are not coroutines, but in most cases ... | 1.2 | true | 1 | 3,242 |
2014-06-16 05:54:18.610 | shared object in C# to be used in python script | I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox.
Now i need to pass a shared object to python script as an argument from my app.
what type of shared object should i create so that python script can accept it and run it or in simple words how do i create s... | 5.4. Extending Embedded Python
will help you to access the application object.
In this case both application and python running in single process. | 0.201295 | false | 2 | 3,243 |
2014-06-16 05:54:18.610 | shared object in C# to be used in python script | I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox.
Now i need to pass a shared object to python script as an argument from my app.
what type of shared object should i create so that python script can accept it and run it or in simple words how do i create s... | Since python is running as another process. This is no way for python to access object in c# directly since process isolation.
A way of marshal and un-marshal should be included to communicate between processes.
There are many way to communicate between processes. Share memory, file, TCP and so on. | 0.201295 | false | 2 | 3,243 |
2014-06-16 18:20:15.053 | In python how does the caller of something know if that something would throw an exception or not? | In the Java world, we know that the exceptions are classified into checked vs runtime and whenever something throws a checked exception, the caller of that something will be forced to handle that exception, one way or another. Thus the caller would be well aware of the fact that there is an exception and be prepared/co... | As far as I know Python (6 years) there isn't anything similar to Java's throws keyword in Python. | 0 | false | 2 | 3,244 |
2014-06-16 18:20:15.053 | In python how does the caller of something know if that something would throw an exception or not? | In the Java world, we know that the exceptions are classified into checked vs runtime and whenever something throws a checked exception, the caller of that something will be forced to handle that exception, one way or another. Thus the caller would be well aware of the fact that there is an exception and be prepared/co... | how does the caller of something know if that something would throw an exception or not?
By reading the documentation for that something. | 0 | false | 2 | 3,244 |
2014-06-16 18:44:57.843 | pelican blog define metadata for category index page | I want to organize a blog into multiple categories. For each category index page I want to add some metadata like title, description, meta etc. specific to the category.
Pelican uses folders to split posts into categories but how do I define the metadata for each category? Is it possible to use a metadata file to put i... | You might try adding a key/value dictionary to your Pelican settings file that contains your category metadata, and then access that information from within your theme's index.html template. | 0.673066 | false | 1 | 3,245 |
2014-06-17 18:36:39.027 | Handling Cache with Constant Change of Social Network | Using Python's Django (w/ Rest framework) to create an application similar to Twitter or Instagram.
What's the best way to deal with caching content (JSON data, images, etc.) considering the constantly changing nature of a social network? How to still show updated state a user creates a new post, likes/comments on a po... | One technique is to key the URLs on the content of the media they are referring too. For example if you're hosting images then use the sha hash of the image file in the url /images/<sha>.
You can then set far-future cache expiry headers on those URLs. If the image changes then you also update the URL referring to it,... | 0 | false | 1 | 3,246 |
2014-06-18 07:19:09.497 | How to modify virtualenv to achieve the same effect as --system-site-packages? | How can a virtualenv be modified after it is created so as to achieve the same effect as creating it with virtualenv --system-site-packages? In other words, how to enable accessing any systemwide installed packages in a virtualenv which was originally created with that access disabled? | Delete or rename the file /virtualenv_root/lib/python3.4/no-global-site-packages.txt
OR
Add a symlink between /virtualenv_root/lib/python3.4/site-packages/ and /path/to/desired/site-packages/
Here virtualenv_root is the name of your virtual environment. | 1.2 | true | 1 | 3,247 |
2014-06-18 11:30:20.617 | How can i implement spherical hankel function of the first kind by scipy/numpy or sympy? | I knew that there is no builtin sph_hankel1 in scipy then i want to know that how to implement it in the right way?
Additional: Just show me one correct implementation of sph_hankel1 either using of Scipy or Sympy. | Although it would be nice if there were an existing routine for calculating the spherical Hankel functions (like there is for the ordinary Hankel functions), they are just a (complex) linear combination of the spherical Bessel functions of the first and second kind so can be easily calculated from existing routines. S... | 0.545705 | false | 1 | 3,248 |
2014-06-20 18:15:30.037 | How to package a Mac OS app with Pyinstaller that shows both a console and a GUI? | I'm packaging a GUI app for MacOS with Pyinstaller, using --windowed flag. Is it possible to package it so that it would show a console in addition to the GUI? When I tried to set console=True, the GUI part fails.
In other words, when I start the App from the terminal by typing "open My.App/Contents/MacOS/myapp", then ... | while you create application don't add those options
--windowed and --noconsole | 0 | false | 1 | 3,249 |
2014-06-20 18:22:30.320 | Retrieving AMQP routing key information using pika | New to RabbitMQ and I am trying to determine a way in which to retrieve the routing key information of an AMQP message. Has anyone really tried this before? I am not finding a lot of documentation that explicitly states how to query AMQP using pika (python).
This is what I am trying to do:
basically I have a Consum... | I would like to write the answer down because it this question was before the documentation on google.
def amqmessage(ch, method, properties, body):
channel.basic_consume(amqmessage, queue=queue_name, no_ack=True)
channel.start_consuming()
The routing key can be found with:method.routing_key | 0.673066 | false | 1 | 3,250 |
2014-06-20 22:38:43.390 | python c-api: create bytes using existing buffer without copying | It seems to me the buffer protocol is more for exposing Python buffer to C.
I couldn't find a way to create a bytes object using existing buffer without copying in C.
Basically what I want is to implement something similar to PyBytes_FromStringAndSize() but without copying, and with a callback to free the buffer when t... | The only way to do this is to create a new object with PyBufferProcs* PyTypeObject.tp_as_buffer. I checked cpython source code thoroughly, as of 3.4.1, there is no out-of-box (so to speak) solution. | 0.386912 | false | 1 | 3,251 |
2014-06-22 08:07:51.627 | Python/Flask: Application is running after closing | I'm working on a simple Flask web application. I use Eclipse/Pydev. When I'm working on the app, I have to restart this app very often because of code changes. And that's the problem. When I run the app, I can see the frame on my localhost, which is good. But when I want to close this app, just click on the red square ... | I've had a very similar thing happen to me. I was using CherryPy rather than Flask, but my solution might still work for you. Oftentimes browsers save webpages locally so that they don't have to re-download them every time the website is visited. This is called caching, and although it's very useful for the average web... | 0 | false | 1 | 3,252 |
2014-06-23 13:40:22.613 | How do i get started with Amazon Web Services for this scenario? | I'm used to having a remote server I can use via ssh but I am looking at using Amazon Web Services for a new project to give me better performance and resilience at reduced costs but I'm struggling to understand how to use it.
This is what I want to do:
First-time:
Create a Postgres db
Connect to Amazon Server
Downlo... | First-time:
Create a Postgres db - Depending on size(small or large), might want RDS or Redshift
Connect to Amazon Server - EC2
Download code to server - upload your programs to an S3 bucket
Once a month:
Download large data file to server - Move data to S3, if using redshift data can be loaded directly from s3 to reds... | 1.2 | true | 1 | 3,253 |
2014-06-23 17:17:23.550 | How to get non_field_errors on template when using FormView and ModelForm | I'm using FormView with ModelForm to process a registration form. In case of duplication of email i'm raising ValidationError. But this error message is not available on registration template as non_field_errors.
When i tried to find what is the form.errors in form_invalid method in RegistrationView, its showing the ex... | First of all, We will have to make sure if its a non_field_error or a field error.
Where have you raise ValidationError in the ModelForm you have defined ?
If its raised in def clean() of the Form, then it would be present in non_field_errors and can be accessed via form.non_field_errors in template
If it is raised in... | 1.2 | true | 1 | 3,254 |
2014-06-24 01:18:37.957 | How to use PYTHONPATH to import the whole folder in Python | I am new to python and trying to add a project folder to the PYTHONPATH. I created a .pth file and add my root path of the file in my site-packages folder. However, when I trying to import the .py files in this folder, only those located under the root folder (for example '/sample') can be imported, but those subfolder... | I haven't had occasion to ever use a .pth file. I prefer a two-pronged approach:
Use a shebang which runs env python, so it uses the first python on your path, i.e.:
#!/usr/bin/env python
Use virtualenv to keep separate different environments and group the necessary libraries for any given program/program set togeth... | 1.2 | true | 1 | 3,255 |
2014-06-24 06:59:45.710 | Getting “Error loading MySQLdb module: No module named MySQLdb” in django-cms | I can't connect with mysql and I can't do "python manage.py syncdb" on it
how to connect with mysql in django and django-cms without any error? | This is an error message you get if MySQLdb isn't installed on your computer.
The easiest way to install it would be by entering pip install MySQL-python into your command line. | 0.545705 | false | 1 | 3,256 |
2014-06-24 21:25:53.807 | Define models in Django | I'm new to Django and I'm trying to create a simple app!
I basically want to create something like StackOverflow, I have many User and many Question. I don't know how I should define the relationship between these two Models.
My Requirements:
I want each Question to have a single author User, and a list of User that ... | To do this, I would recommend breaking down each individual relationship. Your relationships seem to be:
Authoring
Following
For authoring, the details are:
Each Question is authored by one User
Each User can author many questions
As such, this is a One-to-Many relationship between the two. The best way to do this ... | 1.2 | true | 1 | 3,257 |
2014-06-25 04:05:18.480 | How to plot text documents in a scatter map? | I'm using scikit to perform text classification and I'm trying to understand where the points lie with respect to my hyperplane to decide how to proceed. But I can't seem to plot the data that comes from the CountVectorizer() function. I used the following function: pl.scatter(X[:, 0], X[:, 1]) and it gives me the erro... | If X is a sparse matrix, you probably need X = X.todense() in order to get access to the data in the correct format. You probably want to check X.shape before doing this though, as if X is very large (but very sparse) it may consume a lot of memory when "densified". | 0 | false | 1 | 3,258 |
2014-06-25 18:39:05.473 | Long integer values in pandas dataframe change when sent to SQLite database using to_sql | I am using pandas to organize and manipulate data I am getting from the twitter API. The 'id' key returns a very long integer (int64) that pandas has no problem handling (i.e. 481496718320496643).
However, when I send to SQL:
df.to_sql('Tweets', conn, flavor='sqlite', if_exists='append', index=False)
I now have tweet ... | I have found the issue -- I am using SQLite Manager (Firefox Plugin) as a SQLite client. For whatever reason, SQLite Manager displays the tweet IDs incorrectly even though they are properly stored (i.e. when I query, I get the desired values). Very strange I must say. I downloaded a different SQLite client to view the ... | 0 | false | 1 | 3,259 |
2014-06-25 20:18:36.997 | Structuring a server for an online multiplayer game | I'm working on an online multiplayer game. I already developed the login servers and database for any persistent storage; both are written in Python and will be hosted with Google's App Engine. (For now.)
I'm relatively comfortable with two languages - Java and Python. I'd like to write the actual gameplay server in on... | "I assume that the majority of gameplay data (e.g. fine player
movements) will need to be sent via UDP connections. I'm unfamiliar
with UDP connections so I really don't know where to begin designing
the server."
UDP can be lower latency, but sometimes, it is far more important that packets aren't dropped in a g... | 1.2 | true | 1 | 3,260 |
2014-06-27 08:03:41.837 | Changing python syntax coloring in eclipse | I am using Eclipse Indigo for python coding.
When I comment something, I want the color of the comment to be blue
how can I achieve?
Thanks | Assuming you use the PyDev plug-in you can access the color settings in the Window/Preferences/PyDev/Editor menu. | 1.2 | true | 1 | 3,261 |
2014-06-27 14:39:34.477 | Choosing "From" field using python win32com outlook | I am trying to automate emails using python. Unfortunately, the network administrators at my work have blocked SMTP relay, so I cannot use that approach to send the emails (they are addressed externally).
I am therefore using win32com to automatically send these emails via outlook. This is working fine except for one t... | If you configured a separate POP3/SMTP account, set the MailItem.SendUsingAccount property to an account from the Namespace.Accounts collection.
If you are sending on behalf of an Exchange user, set the MailItem.SentOnBehalfOfName property | 1.2 | true | 1 | 3,262 |
2014-06-30 13:22:33.253 | How to Get Move From Minimax Algorithm in Tic-Tac-Toe? | So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value.
However, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make?... | Conceptualize the minimax algorithm like a graph, where every vertex is a possible configuration of the board, and every edge from a vertex to its neighbor is a transition/move from one board configuration to the next.
You need to look at the heuristic value of each board state neighboring your current state, then choo... | 0 | false | 3 | 3,263 |
2014-06-30 13:22:33.253 | How to Get Move From Minimax Algorithm in Tic-Tac-Toe? | So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value.
However, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make?... | The simplest way to select your move is to choose your move that has the maximum number of winning positions stemming from that move.
I would, for each node in your search tree (game state) keep a record of possible win states that can be created by the current game state. | 0 | false | 3 | 3,263 |
2014-06-30 13:22:33.253 | How to Get Move From Minimax Algorithm in Tic-Tac-Toe? | So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value.
However, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make?... | In using the MM algorithm, you must have had a way to generate the possible successor boards; each of those was the result of a move. As has been suggested, you can modify your algorithm to include tracking of the move that was used to generate a board (for example, adding it to the definition of a board, or using a s... | 0 | false | 3 | 3,263 |
2014-06-30 19:10:39.740 | How do I terminate a long-running Django request if the XHR gets an abort()? | I initiate a request client-side, then I change my mind and call xhr.abort().
How does Django react to this? Does it terminate the thread somehow? If not, how do I get Django to stop wasting time trying to respond to the aborted request? How do I handle it gracefully? | Just think of the Web as a platform for building easy-to-use, distributed, loosely couple systems, with no guarantee about the availability of resources as 404 status code suggests.
I think that creating tightly coupled solutions such as your idea is going against web principles and usage of REST. xhr.abort() is client... | -0.201295 | false | 2 | 3,264 |
2014-06-30 19:10:39.740 | How do I terminate a long-running Django request if the XHR gets an abort()? | I initiate a request client-side, then I change my mind and call xhr.abort().
How does Django react to this? Does it terminate the thread somehow? If not, how do I get Django to stop wasting time trying to respond to the aborted request? How do I handle it gracefully? | Due to how http works and that you usually got a frontend in front of your django gunicorn app processes (or uswgi etc), your http cancel request is buffered by nginx. The gunicorns don't get a signal, they just finish processing and then output whatever to the http socket. But if that socket is closed it will have an ... | 0.201295 | false | 2 | 3,264 |
2014-07-01 22:25:44.313 | How to correctly nest tables in DynamoDb | I'm attempting to store information from a decompiled file in Dynamo.
I have all of the files stored in s3 however I would like to change some of that.
I have an object id with properties such as a date, etc which I know how to create a table of in dynamo. My issue is that each object also contains images, text files, ... | From what you described, I think you just need to create one table with hashkey. The haskey should be object id. And you will have columns such as "date", "image pointer", "text pointer", etc.
DynamoDB is schema-less so you don't need to create the columns explicitly. When you call getItem the server will return you a ... | 0 | false | 2 | 3,265 |
2014-07-01 22:25:44.313 | How to correctly nest tables in DynamoDb | I'm attempting to store information from a decompiled file in Dynamo.
I have all of the files stored in s3 however I would like to change some of that.
I have an object id with properties such as a date, etc which I know how to create a table of in dynamo. My issue is that each object also contains images, text files, ... | If you stay between the limits of Dynamodb of 64Kb per item.
You can have one item (row) per file.
DynamoDB has String type (for file name, date, etc) and also a StringSet (SS) for list of attributes (for text files, images).
From what you write I assume you are will only save pointers (keys) to binary data in the S3. ... | 1.2 | true | 2 | 3,265 |
2014-07-02 15:48:22.860 | Python 3 Debugging issue | I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain... | pyshell.py file opens during the debugging process when the function that is under review is found in Python's library - for example print() or input(). If you want to bypass this file/process click Over and it will step over this review of the function in Python's library. | 0 | false | 2 | 3,266 |
2014-07-02 15:48:22.860 | Python 3 Debugging issue | I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain... | In Python 3.4, I had the same problem. My tutorial is from Invent with Python by Al Sweigart, chapter 7.
New file editor windows such as pyshell.py and random.pyopen when built-in functions are called, such as input(), print(), random.randint(), etc. Then the STEP button starts stepping through the file it opened.
If y... | 0 | false | 2 | 3,266 |
2014-07-02 16:36:50.627 | How to Combine pyWavelet and openCV for image processing? | I need to do an image processing in python. i want to use wavelet transform as the filterbank. Can anyone suggest me which one library should i use?
I had pywavelet installed, but i don't know how to combine it with opencv. If i use wavedec2 command, it raise ValueError("Expected 2D input data.")
Can anyone help me? | Answer of Navaneeth is correct but with two correction:
1- Opencv read and save the images as BGR not RGB so you should do cv2.COLOR_BGR2GRAY to be exact.
2- Maximum level of _multilevel.py is 7 not 10, so you should do : w2d("test1.png",'db1',7) | 0.986614 | false | 1 | 3,267 |
2014-07-03 08:15:02.340 | How to go back in PyCharm while browsing code like we have a back button in eclipse? | While browsing the code in PyCharm(community edition) how to go back to the previously browsed section? I am looking for eclipse back button type functionality with Pycharm. | Ubuntu 16.04 defines Ctrl + Alt + Left as a workspace switch shortcut
Then it does nothing on Pycharm.
So you have to either disable the Ubuntu shortcut with:
dash
keyboard
shortcuts
navigation
or redefine the PyCharm shortcuts to something else.
Linux distro desktop devs: please make all desktop system wide shortcut... | 0.613357 | false | 1 | 3,268 |
2014-07-03 11:51:31.123 | integrating with existing html page django-page-cms | I have installed django-page-cms successfully i think. Like other cms, it is also for creating new pages. But I already have html pages in my project. How to integrate with that?
They want me to put place holder in html page, like:
{% load pages_tags %}
but I think this will bring the content from the already create... | First you need to create page in admin console. Then add the placeholder in your template
like what tutorial saying
{% get_page "news" as news_page %}
{% for new in news_page.get_children %}
<li>
{{ new.publication_date }}
{% show_content new body %}
{% endfor %} | 1.2 | true | 1 | 3,269 |
2014-07-03 21:48:17.190 | Installing SublimeREPL offline | I'm trying to install SublimeREPL on an offline computer (it has secure data and so can't be Internet-connected). Any ideas for how to do so?
I can copy any installation files to a USB drive, but haven't found any--everywhere I've seen insists on using the Package Manager (which requires connection to function properly... | You could try download and install SublimeREPL using Package Control on a computer with an internet connection and then in Sublime Text go to preferences > Browse packages… where you should find a folder named SublimeREPL. Copy that folder to the same directory on the other computer. That should work. | 1.2 | true | 1 | 3,270 |
2014-07-06 16:54:14.880 | Unistall opencv 2.4.9 and install 3.0.0 | Im using openCV on Ubuntu 14.04, but some of the functions that I require particularly in cv2 library (cv2.drawMatches, cv2.drawMatchesKnn) does not work in 2.4.9. How do I uninstall 2.4.9 and install 3.0.0 from the their git? I know the procedure for installing 3.0.0 but how do I make sure that 2.4.9 get completely re... | The procedure depends on whether or not you built OpenCV from source with CMake, or snatched it from a repository.
From repository
sudo apt-get purge libopencv* will cleanly remove all traces. Substitute libopencv* as appropriate in case you were using an unofficial ppa.
From source
If you still have the files generate... | 1.2 | true | 1 | 3,271 |
2014-07-08 02:16:55.373 | Django - Multiple apps on one webpage? | I've looked all over the net and found no answer.
I'm new to Django. I've done the official tutorial and read many more but unfortunately all of them focus on creating only one application. Since it's not common to have a page as a single app, I would like to ask some Django guru to explain how I can have multiple apps... | A django app doesn't really map to a page, rather, it maps to a function. Apps would be for things like a "polls" app or a "news" app. Each app should have one main model with maybe a couple supporting ones. Like a news app could have a model for articles, with supporting models like authors and media.
If you wanted... | 0.715303 | false | 1 | 3,272 |
2014-07-08 18:52:40.960 | How to use/decompress the file made by img2py | I have used img2py to convert an image into a .py file. But how to use that converted file in pygame. Is there any specific code for it? | The PyEmbeddedImage class has a GetData method (or Data property) that can be used to fetch the raw data of the embedded image, in PNG format. | 0.673066 | false | 1 | 3,273 |
2014-07-09 21:03:02.513 | Python script requires input in command line | I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - "python name_of_script.py" - is seemingly working. However, I'm getting the error: "the following arguments a... | Without reading your code, I guess if
I tried just adding it to the end of my command prompt line, but to no avail.
it means that you need to make your code aware the command line argument. Unless you do some fancy command line processing, for which you need to import optparse or argparse, try:
import sys
# do someth... | 0 | false | 2 | 3,274 |
2014-07-09 21:03:02.513 | Python script requires input in command line | I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - "python name_of_script.py" - is seemingly working. However, I'm getting the error: "the following arguments a... | if you pasted the code here that would help but
the answer you are most likely looking for is commandline arguements.
If I were to guess, in the command line the input would look something like:
python name_of_script.py "c:\thefilepath\totheinputfile" {enter}
{enter} being the actually key pressed on the keyboard and ... | 0 | false | 2 | 3,274 |
2014-07-10 19:00:43.527 | Python Export Program to PDF using Latex format | I have a GUI program in Python which calculates graphs of certain functions. These functions are mathematical like say, cos(theta) etc. At present I save the graphs of these functions and compile them to PDF in Latex and write down the equation manually in Latex.
But now I wish to simplify this process by creating a t... | generate a Latex file.tex with a Python script
f= open("file.tex", 'w')
f.write('\documentclass[12pt]{article}\n')
f.write('\usepackage{multicol}\n')
f.write('\n\begin{document}\n\n')
...
f.write('\end{document}')
f.close()
run pdflatex on the LaTex file from the Python script as a subprocess
subprocess.call('latex fi... | 0.135221 | false | 1 | 3,275 |
2014-07-10 19:32:43.637 | Django Rest Framework--deny access to list but not to retrieve | I'm using Django Rest Framework and I'm having some trouble with permissions. I know how to use has_permission and has_object_permission, but I have a number of cases where someone needs to be able to access retrieve but not list--e.g., a user has access to their own profile, but not to the full list of them. The pro... | One of the arguments to has_permission is view, which has an attribute .action, which is one of the five "LCRUD" actions ("list"/"create"/"retrieve"/"update"/"destroy"). So I think you could use that to check, in has_permission, whether the action being performed is a list or a retrieve, and deny or allow it according... | 0 | false | 1 | 3,276 |
2014-07-12 16:54:00.733 | Can sklearn random forest directly handle categorical features? | Say I have a categorical feature, color, which takes the values
['red', 'blue', 'green', 'orange'],
and I want to use it to predict something in a random forest. If I one-hot encode it (i.e. I change it to four dummy variables), how do I tell sklearn that the four dummy variables are really one variable? Specifically... | You have to make the categorical variable into a series of dummy variables. Yes I know its annoying and seems unnecessary but that is how sklearn works.
if you are using pandas. use pd.get_dummies, it works really well. | 0.996682 | false | 2 | 3,277 |
2014-07-12 16:54:00.733 | Can sklearn random forest directly handle categorical features? | Say I have a categorical feature, color, which takes the values
['red', 'blue', 'green', 'orange'],
and I want to use it to predict something in a random forest. If I one-hot encode it (i.e. I change it to four dummy variables), how do I tell sklearn that the four dummy variables are really one variable? Specifically... | Maybe you can use 1~4 to replace these four color, that is, it is the number rather than the color name in that column. And then the column with number can be used in the models | 0.081452 | false | 2 | 3,277 |
2014-07-13 01:08:33.563 | PySpark Drop Rows | how do you drop rows from an RDD in PySpark? Particularly the first row, since that tends to contain column names in my datasets. From perusing the API, I can't seem to find an easy way to do this. Of course I could do this via Bash / HDFS, but I just want to know if this can be done from within PySpark. | Personally I think just using a filter to get rid of this stuff is the easiest way. But per your comment I have another approach. Glom the RDD so each partition is an array (I'm assuming you have 1 file per partition, and each file has the offending row on top) and then just skip the first element (this is with the sca... | 0.067922 | false | 1 | 3,278 |
2014-07-14 04:13:00.590 | could not save preference file google-apps-engine | Just installed Google Apps Engine and am getting "could not save" errors.
Specifically if I go in to preferences I get
Could not save into preference file
C:\Usera\myname/Google\google_appengine_launcher.ini:No such file or directory.
So some how I have a weird path, would like to know where and how to change this. I ... | I think I have found the answer to my own question.
I have a small app I have written to backup my stuff to Google Drive, this app would appear to have an error in it that does not stop it from running but does cause it to make a file called
C:\Usera\myname\Google
Therefore GAE can not create a directory called C:\U... | 0 | false | 1 | 3,279 |
2014-07-14 11:49:36.947 | In Python, If I split a string up, how do i check if each part of it is an integer | for example if my input was "1 2 3", how do I check if each part is a integer and not anything else and if there was something else, be able to input the string again so its correct otherwise it wont move on | You can split you string to a list using
list1=s.split()
And then check wether each of them is a integer or not. | 0 | false | 1 | 3,280 |
2014-07-14 12:13:22.660 | See when packages were installed / updated using pip | I know how to see installed Python packages using pip, just use pip freeze. But is there any way to see the date and time when package is installed or updated with pip? | pip freeze gives you all the installed packages. Assuming you know the folder:
time.ctime(os.path.getctime(file))
should give you the creation time of a file, i.e. date of when the package has been installed or updated. | 0 | false | 1 | 3,281 |
2014-07-14 13:43:02.750 | Only creating object through factory class in Python - factory class related | C++ programmer here.
In Python, how do you make sure that a particular class (e.g. UsefulClass) can only be created through its related factory class (e.g. FactoryClass)? But, at the same time the public methods of UsefulClass are callable directly?
In C++ this can be easily achieved by making the relevant methods of ... | Don't.
Python is not C++ and using patterns that worked before are silly in Python. In particular, Python is not a "Bondage and Domination" language where phrases like "thereby strictly controlling creation" don't apply.
"If you didn't want to instantiate a UsefulClass then why did you?" — me.
If you can't trust yourse... | -0.265586 | false | 1 | 3,282 |
2014-07-15 22:18:30.117 | How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin? | There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. Even after installing the Python plugin, I don't see that setting anywhere.
Am I missing something obvious? | If you have multiple modules in your project, with different languages, you can set the interpreter in the following way:
File -> Project Structure...
Select Modules in the list on the left
Select the Python module in the list of modules
On the right-hand side, either choose an existing Python SDK from the dropdown li... | 0.240117 | false | 3 | 3,283 |
2014-07-15 22:18:30.117 | How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin? | There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. Even after installing the Python plugin, I don't see that setting anywhere.
Am I missing something obvious? | Follow these steps:
Open Setting (Ctrl + Alt + s)
Click on plugins
Find Browse Repositories and click
Search for "python"
Select Python SDK or pycharm
Restart the IDE
Go to project structure
Select the python SDK in projects or create a new project with python SDK. | 0.16183 | false | 3 | 3,283 |
2014-07-15 22:18:30.117 | How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin? | There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the "Project Interpreter" page. Even after installing the Python plugin, I don't see that setting anywhere.
Am I missing something obvious? | With the Python plugin installed:
Navigate to File > Project Structure.
Under the Project menu for Project SDK, select "New" and
Select "Python SDK", then select "Local".
Provided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives. | 1 | false | 3 | 3,283 |
2014-07-15 23:02:00.583 | Uploading code to server and run automatically | I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically.
I'm working on a project that would require some code to be running 24/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time ... | Here are two approaches to this problem, both of which require shell access to the cloud server.
Write the program to handle the scheduling itself. For example, sleep and wake up every few miliseconds to perform the necessary checks. You would then transfer this file to the server using a tool like scp, login, and st... | 0.201295 | false | 2 | 3,284 |
2014-07-15 23:02:00.583 | Uploading code to server and run automatically | I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically.
I'm working on a project that would require some code to be running 24/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time ... | Took a few days but I finally got a way to work this out. The most practical way to get this working is to use a VPS that runs the script. The confusing part of my code was that each user would activate the script at a different time for themselves. To do this, say at midnight, the VPS runs the python script (using sc... | 0.201295 | false | 2 | 3,284 |
2014-07-16 15:45:04.047 | Python - update configparser between modules | I have terrible doubts regarding python config file approach.
I am creating a program with a GUI (PyQt). The program loads some settings from a .cfg file using the configparser module. And the user can edit these settings from the GUI with the user preferences widget. When the preferences widget is closed the .cfg file... | Updating the state of your application may not be a trivial thing if you are somewhere in the middle. Just an example:
Your app = A car
You launch your app = You start your car
You set in the preferences the variable type_tyre to Winter
Your running app still has type_tyre equals Sommer
You attempt to change tyres whi... | 0 | false | 1 | 3,285 |
2014-07-17 01:51:41.247 | How to find and graph the intersection of 3+ circles with Matplotlib | I'm working on a problem that involves creating a graph which shows the areas of intersection of three or more circles (each circle is the same size). I have many sets of circles, each set containing at least three circles. I need to graph the area common to the interior of each and every circle in the set, if it even ... | Maybe you should try something more analytical? It should not be very difficult:
Find the circle pairs whose distance is less than the sum of their radii; they intersect.
Calculate the intersection angles by simple trigonometry.
Draw a polygon (path) by using a suitably small delta angle in both cases (half of the pol... | 0.386912 | false | 1 | 3,286 |
2014-07-17 06:29:57.650 | What is the benefit of having a whole program contained in a class? | Sometimes, when looking at Python code examples, I'll come across one where the whole program is contained within its own class, and almost every function of the program is actually a method of that class apart from a 'main' function.
Because it's a fairly new concept to me, I can't easily find an example even though I... | A program often has to maintain state and share resources between functions (command line options, dB connection, etc). When that's the case a class is usually a better solution (wrt/ readability, testability and overall maintainability) than having to pass the whole context to every function or (worse) using global st... | 0.201295 | false | 1 | 3,287 |
2014-07-17 13:31:59.097 | Defining priors and marginalizing over priors in pymc | I am going through the tutorial about Monte Carlo Markov Chain process with pymc library. I am also a newbie using pymc and try to establish my own MCMC process. I have faced couple of question that I couldn't find proper answer in pymc tutorial:
First: How could we define priors with pymc and then marginalise over the... | I recommend following the PyMC user's guide. It explicitly shows you how to specify your model (including priors). With MCMC, you end up getting marginals of all posterior values, so you don't need to know how to marginalize over priors.
The Dirichlet is often used as a prior to multinomial probabilities in Bayesian mo... | 0 | false | 1 | 3,288 |
2014-07-17 14:45:10.553 | Google App Engine send batch email | I was wondering how I would go about emailing user emails stored in a python datastore.
Should I create a sort of maintenance page where I can log in as an administrator and then send an email or is there a way for me to execute a python script without needing a handler pointing to a separate webpage so I don't have t... | You can set up a CRON job to run every few minutes and process your email queue. It will require an endpoint where you can send a POST request, but you can use a secret token (like just any random guid) to verify the request is legitimate before you send the email. | 1.2 | true | 1 | 3,289 |
2014-07-17 14:46:30.060 | how to change default values for .columnconfigure() in tkinter? | I have an application made up of Frames, Frames in Frames and Labels in Frames. There is quite a lot of them and I am looking for a way to modify some of the default values.
I am particularly interested in modifying .columnconfigure() since I call .columnconfigure(0, weight=1) on each of the columns, in each frame. Thi... | No, there is no way to change the defaults. You can easily write your own grid function to automatically configure the weight of each column. You could do this by subclassing Frame, for instance. | 1.2 | true | 1 | 3,290 |
2014-07-17 22:43:22.447 | Python: how to access 3.3 if 3.4 is the default? | Running Windows 7. 2.7, 3.3 and 3.4 installed.
I just installed Python 3.3 for a recent project. In the command prompt, python launches 3.4, and py launches 3.3. I can access 3.3 using the 3.3 version of IDLE, but how can I access it via the command prompt?
Is there a shortcut like py that I can use? Do I need to d... | If you want to male a file specifically open with a version you can start the file with #! python3.x the x being the version you want. If you want to be able to right click and edit with that version youll need to do some tweaking in the registry | 0.386912 | false | 1 | 3,291 |
2014-07-18 02:02:56.790 | ipython notebook clear cell output in code | In a iPython notebook, I have a while loop that listens to a Serial port and print the received data in real time.
What I want to achieve to only show the latest received data (i.e only one line showing the most recent data. no scrolling in the cell output area)
What I need(i think) is to clear the old cell output when... | If I am not wrong you mean you just need to clear the output part of a cell, which could be a valid output or some error which you don't what to look anymore. If Yes! just go to top ribbon and select Cell > Current Outputs > Clear | 0.067922 | false | 1 | 3,292 |
2014-07-18 17:02:48.943 | Kivy: how to change window size properties and the difference between click and touch | I have two questions that I can not answer to myself:
How can I change the size of my window, if I do not know the exact size of the phone screen? I.e. my aim is to fit all screen sizes.
Is there any difference between clicking with mouse and touching with fingers in the code? If I write code for clicking, will it wor... | On mobile, your app should automatically fill the phone screen. You don't need to worry about it. On desktop, you can use the --size=WxH option to test a specific screen size, or use the screen module (-m screen:nexus7 for example - run kivy with -m screen to see the available options).
No. All mouse/touchscreen intera... | 1.2 | true | 1 | 3,293 |
2014-07-19 03:20:43.663 | Is it possible to disable IPython from the Eclipse/PyDev console? | The most recent releases of PyDev IDE for Eclipse come with IPython 'embeded' in its interactive console. I'm just wondering if there is a way to disable this option and let PyDev uses a regular python interactive console without uninstalling IPython? I know that if IPython is not installed PyDev will use a regular pyt... | There's currently no option to do that in the UI.
You can do that in a hackish way by manually opening:
plugins\org.python.pydev\pysrc\pydev_ipython_console.py
in your Eclipse installation and uncommenting the 'raise ImportError()' in the top of the file :)
Now, I'm a bit curious on why you'd prefer the PyDev version i... | 0.386912 | false | 1 | 3,294 |
2014-07-21 21:21:13.677 | Produce a PMML file for the Nnet model in python | I have a model(Neural Network) in python which I want to convert into a PMML file . I have tried the following:
1.)py2pmml -> Not able to find the source code for this
2.)in R -> PMML in R works fine but my model is in Python.(Cant run the data in R to generate the same model in R) . Does not work for my dataset.
... | Finally I found my own solution. I wrote my own PMML Parser and scorer . PMML is very much same as XML so its easy to build and retrieve fields accordingly. If anyone needs more information please comment below.
Thanks ,
Raghu. | 0 | false | 1 | 3,295 |
2014-07-21 22:33:18.957 | Autostart on raspberry pi | I have been looking for a few weeks now on how to make a .py file start on startup.
I have had no luck on any of the methods working, does anyone have any ideas.
The file is reasonably small and will need GPIO input from a PIR movement sensor. | Make sure your script runs fine from the command line first.
Also, if you are dealing with the GPIO pins, make sure you are running your script with the proper permissions. I know when I access the GPIO pins on my pi, I need to use root/sudo to access them. | 0 | false | 1 | 3,296 |
2014-07-22 14:47:45.337 | how to establish a session thourghout the selenium webdriver suite by using python in firefox | I want to establish one session at the starting of the suite. That session should be stay for longer time for multiple test cases.That session should end at the last.
That session should be implement in Selenium Web driver by using Unittest frame works in python language.
please can anyone suggest any methods or how to... | The simplest way to achieve this is not to use the Setup() and TearDown() methods, or more specifically not to create a new instance of the WebDriver object at that start or each test case, and not to use the Quit() method at the end of each test case.
In your first test case create a new instance of the WebDriver obj... | 0 | false | 1 | 3,297 |
2014-07-22 14:54:03.737 | make a Client-Server application | I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?
I mean, for example I have an html form and a button "ok" :
If the server and the client are in the same computer, in action = " " we put localhost/file.py , but if the server... | Your script is supposed to be run as a CGI script by a web-server, which sets environment variables like REMOTE_ADDR, REQUEST_METHOD ...
You are running the script by yourself, and this environment variable are not available.
That's why you get the KeyError. | 1.2 | true | 2 | 3,298 |
2014-07-22 14:54:03.737 | make a Client-Server application | I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?
I mean, for example I have an html form and a button "ok" :
If the server and the client are in the same computer, in action = " " we put localhost/file.py , but if the server... | The "action" part of a form is an url, and If you don't specify the scheme://host:port part of the URL, the client will resolve it has the current page one. IOW: just put the path part of your script's URL and you'll be fine. FWIW hardcoding the scheme://host:port of your URLs is an antipattern, as you just found out. | 0.201295 | false | 2 | 3,298 |
2014-07-23 10:36:59.650 | Managing a different python version as a branch in git | I am working on a python app that uses python 2.4, postgres 8.2 and old versions of pygresql, xlrd, etc. Because of this it is quite a pain to use, and has to be used in a windows xp VM. There are other problems such as the version of xlrd doesn't support .xlsx files, but the new version of xlrd doesn't work with pytho... | IMHO you should probably commit in your master branch, then rebase your upgrade branch, it will make more sense in your repository history.
If those commits are working on both environments, you should use a different branch based on the master one, so you can work out on the newer version of python, then merge it in t... | 1.2 | true | 1 | 3,299 |
2014-07-23 22:34:02.593 | How to ignore SIGKILL or force a process into 'D' sleep state? | I am trying to figure out how to get a process to ignore SIGKILL. The way I understand it, this isn't normally possible. My idea is to get a process into the 'D' state permanently. I want to do this for testing purposes (the corner case isn't really reproducible). I'm not sure this is possible programatically (I don't ... | It is not possible to ignore SIGKILL or handle it in any way.
From man sigaction:
The sa_mask field specified in act is not allowed to block SIGKILL or SIGSTOP. Any attempt to do so will be silently ignored. | 0.986614 | false | 1 | 3,300 |
2014-07-24 13:33:18.877 | How to overcome version incompatibility with Abaqus and Numpy (Python's library)? | I want to run an external library of python called NLopt within Abaqus through python. The issue is that the NLopt I found is compiled against the latest release of Numpy, i.e. 1.9, whereas Abaqus 6.13-2 is compiled against Numpy 1.4. I tried to replace the Numpy folder under the site-packages under the Abaqus installa... | I have similar problems. As an (annoying) work around I usually write out important data in text files using the regular python. Afterwards, using a bash script, I start a second python (different version) to further analyse the data (matplotlib etc). | 0 | false | 1 | 3,301 |
2014-07-24 21:51:36.090 | Python-bytes() vs struct.pack() | I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). ... | bytes() does literally what the name implies:
Return a new “bytes” object, which is an immutable sequence of
integers in the range 0 <= x < 256
struck.pack() does something very different:
This module performs conversions between Python values and C structs represented as Python strings
While for some inputs thes... | 1.2 | true | 2 | 3,302 |
2014-07-24 21:51:36.090 | Python-bytes() vs struct.pack() | I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). ... | They do two different things; compare bytes(1234) with struct.pack("!H", 1234). The first just provides a 4-byte string representation of the number bytes object with 1,234 null bytes; the second provides a two-byte string with the (big-endian) value of the integer.
(Edit: Struck out irrelevant Python 2 definition of b... | 0.386912 | false | 2 | 3,302 |
2014-07-26 02:41:50.317 | One-hot encoding of large dataset with scikit-learn | I have a large dataset which I plan to do logistic regression on. It has lots of categorical variables, each having thousands of features which I am planning to use one hot encoding on. I will need to deal with the data in small batches. My question is how to make sure that one hot encoding sees all the features of eac... | There is no way around finding out which possible values your categorical features can take, which probably implies that you have to go through your data fully once in order to obtain a list of unique values of your categorical variables.
After that it is a matter of transforming your categorical variables to integer v... | 0.545705 | false | 1 | 3,303 |
2014-07-26 17:19:11.993 | How do I remove/add the python interpreter from eclipse? | I'm an eclipse noob.
After adding PyDev to eclipse, I try to create a "PyDev Django Project", but and I get the "Django not found" error.
I heard that you have to remove the python interpreter from eclipse, then add it again. But I don't know how to do that.
Can someone show me how to remove/add the python interpret... | On the menubar go to Window -> Preferences -> Pydev -> Interpreters -> Python
Remove the interpreter and click on Quick Auto Config.
That should do the trick. Make sure django is installed first. | 0 | false | 1 | 3,304 |
2014-07-27 09:28:03.223 | A paperjs-equivalent for python (specifically, Pythonista for iOS)? | I've taken to creative coding on my iPad and iPhone using Codea, Procoding, and Pythonista. I really love the paper.js Javascript library, and I'm wondering how I might have the functionality that I find in paper.js when writing in Python.
Specifically, I'd love to have the vector math and path manipulation that paper.... | The ui module actually includes a lot of vector drawing functions, inside a ui.ImageContext. ui.ImageContext is a thin wrapper around part of one of the Objective-C APIs (maybe CALayer?) The drawing methods are designed to operate inside the draw method of a custom view class, but you can present these things in other ... | 0.386912 | false | 1 | 3,305 |
2014-07-27 10:39:38.300 | Sign in with Twitter: how to verify the current user is stil logged in | I have managed to use oauth authentication and add a Sign in with Twitter functionality to a Google App Engine web app.
How should I verify, during the site navigation, if the user is still logged in Twitter? | Are you talking about being logged in to Twitter.com or your app? If you have received oAuth access tokens by authenticating an app, then logging out of twitter.com won't 'log you out' of any apps, the tokens will remain valid until the user revokes the access. | 0 | false | 1 | 3,306 |
2014-07-27 12:56:28.443 | get input file name and file extention using flask | lets say that I have <input name="upload" type="file"> and I am uploading picture.jpg. The question is how can I get the file name+extention? By other words the correct script for request.files.filename or request.upload.filename | Found the answer. request.files['upload'].filename gives the file name and extension in flask | 1.2 | true | 1 | 3,307 |
2014-07-28 10:16:29.580 | Call python FUNCTION from javascript | this question have been asked numerous times, I know and I'm sorry if by ignorance I didn't get the answers.
I have a hosting plan which doesn't allow me to install django, which was really nice to call an rest api easily with the routing settings.
What I want is to be able to call a python function from javascript cod... | It doesn't have much to do with Python, really. Your javascript code is executed on the client's brower, and all it can do is issuing HTTP requests (synchronous or asynchronous). At this point which webserver / technology / language is used to handle the HTTP request is totally irrelevant. So, from the client javascrip... | 1.2 | true | 1 | 3,308 |
2014-07-28 14:52:37.220 | how to handle UNICODE characters in cherrypy-sqlalchemy-mysql application? | I am using cherrypy along with sqlalchemy-mysql as backend. I would like to know the ways of dealing with UNICODE strings in cherrypy web application. One brute-force way would be to convert all string coming in as parameters into UNICODE (and then decoding them to UTF-8) before storing them to database. But I was wond... | SQLAlchemy provides Unicode or UnicodeText for your purposes.
Also don't forget about u'text' | 0 | false | 1 | 3,309 |
2014-07-28 18:27:32.527 | Use named pipes to send input to program based on output | Here's a general example of what I need to do:
For example, I would initiate a back trace by sending the command "bt" to GDB from the program. Then I would search for a word such as "pardrivr" and get the line number associated with it by using regular expressions. Then I would input "f [line_number_of_pardriver]" into... | My recommendation is not to do this. Instead there are two more supportable ways to go:
Write your code in Python directly in gdb. Gdb has been extensible in Python for several years now.
Use the gdb MI ("Machine Interface") approach. There are libraries available to parse this already (not sure if there is one in ... | 1.2 | true | 1 | 3,310 |
2014-07-28 19:45:35.773 | Django cutting off uploaded file | I'm making a Django app in which a user can upload a file (an image) using AJAX.
While developing locally, I saw that PIL, which I used to process the image after upload, had a bug. After investigating I found out it's because PIL is getting the file data cut off. It's only getting the first 1MB of the file, which is w... | Turns out it was a "feature" of the client-side AJAX package we were using (flow.js) and we just had to increase chunkSize. | 1.2 | true | 1 | 3,311 |
2014-07-28 23:28:35.977 | Window closes immediately after running program | I am new to all programming and I just started to get interested in learning how to program. So to do so I started with what most people consider the easiest language: Python.
The problem I am having right now though is that if I say to Python print("Hello!"), save it in a file, and then run it, a black window opens up... | Insert input() in the last line. It will make the program wait for a input. While it doesn't occur the windows program will be open. If you press any key and then enter, it will close. | 0 | false | 1 | 3,312 |
2014-07-29 09:30:26.647 | How to calculate percentage of english words in a paragraph using Python | Let's say that I have a paragraph with different languages in it. like:
This is paragraph in English. 这是在英国段。Это пункт на английском языке. این بند در زبان انگلیسی است.
I would like to calculate what percentage (%) of this paragraph includes English words. So would like to ask how to do that in python. | If all your words written in latin letters are in English you could use regular expressions. | 0 | false | 1 | 3,313 |
2014-07-30 01:11:49.650 | How to get data from inspect element of a webpage using Python | I'd like to get the data from inspect element using Python. I'm able to download the source code using BeautifulSoup but now I need the text from inspect element of a webpage. I'd truly appreciate if you could advise me how to do it.
Edit:
By inspect element I mean, in google chrome, right click gives us an option cal... | BeautifulSoup could be used to parse the html document, and extract anything you want. It's not designed for downloading. You could find the elements you want by it's class and id. | 0 | false | 1 | 3,314 |
2014-07-31 11:38:10.990 | How do I right align the text in a wx.ComboBox? | I have a combobox in wxpython but I cant figure out how to align the text it contains to the right?
I have tried to use wx.ComboBox(self, choices=["1","2","3"], style=wx.TEXT_ALIGNMENT_RIGHT) but that didnt work. | The widget probably doesn't support text alignment. If you want complete control over how it displays its contents, then you should probably switch to a custom drawn control, such as ComboCtrl. | 1.2 | true | 1 | 3,315 |
2014-08-02 10:17:24.430 | how to test changes to an installed package | I have installed a python package slimit and I have cloned the source code from github.
I am doing changes to this package in my local folders which I want to test (often) but I don't want to do allways python setup.py install.
My folder structure is:
../develop/slimit/src/slimit (contains package files)
../develop/tes... | When you're working on a library you can use python setup.py develop instead of install. This will install the package into your local environment and keep it updated as you develop.
To be clear, if you use develop you don't have to run it again when you change your source files. | 1.2 | true | 1 | 3,316 |
2014-08-03 16:52:59.073 | Python Openpyxl display left to right | I was wondering how to adjust display left to right / right to left with openpyxl or if its even possible.
haven't really found anything in the documantation, maybe im blind.
thanks in advance :) | As A-Palgy said you have to add
worksheet.sheet_view.rigtToleft = True
but first, you have to enable that feature in the views.py file in this path:
C:\python36\Lib\site-packages\openpyxl\worksheet\views.py
and edit the line :
rightToLeft = Bool(allow_none=True)
to
rightToLeft = Bool(allow_none=False) | -0.201295 | false | 1 | 3,317 |
2014-08-04 01:23:41.587 | how to write a multi-command cronjob on a raspberry pi or any other unix system | I am trying to run a cron script in python 3 so I had to setup a virtual environment (if there is an easier way, please let me know) and in order to run the script I need to be in the script's parent folder as it writes to text files there. So here is the long string of commands I have come up with and it works in cons... | It looks like you may have a stray . in there that would likely cause an error in the command chain.
Try this:
cd usr/local/sbin/cronjobs && virtualenv/secret_ciphers/bin/activate
&& cd csgostatsbot && python3 CSGO_STATS_BOT_TASK.py && deactivate
Assuming that the virtualenv directory is in the cronjobs directory.
... | 1.2 | true | 1 | 3,318 |
2014-08-04 13:44:42.623 | is socket thread safe in writing or reading a 1byte? | as i have found on thread safety of socket, it was not,
But how about each thread accesses a socket to write or read only one byte at a once.(1 byte means 1 character)
is it also un-safe?
i am coding in python. | The socket API is thread safe (at least on linux and windows) to the extent that the system won't crash and the data will all be transferred. Its just that data sent among threads may be interleaved and there is no guarantee what any given thread will receive. But the minumum unit of transfer is 1 byte so if you have a... | 1.2 | true | 1 | 3,319 |
2014-08-04 18:49:32.633 | iexpress assistance for my program | ok so i've used iexpress a few times without a problem. i created a nice little program for my buddies and i and i'm now in the process of creating a installation package for it. i like iexpress cause it makes it easy and has the license agreement window n whatnot.
ok so program is made. using windows & iexpress i att... | iexpress doesn't let you include folders, but you can include a batch file, which may create folders and copy files to the respective folder. To run a batch file, specify cmd /c IncludedBatchFile.bat under Install Program in the iexpress wizard. | 0.386912 | false | 1 | 3,320 |
2014-08-05 12:11:11.697 | How to check a random 3d object surface if is flat in python | I used micro CT (it generates a kind of 3D image object) to evaluate my samples which were shaped like a cone. However the main surface which should be flat can not always be placed parallel to the surface of image stacks. To perform the transform, first of all, I have to find a way to identify the flat surface. Theref... | Firstly, all lines in 3d correspond to an equation; secondly, all lines in 3d that lie on a particular plane for part of their length correspond to equations that belong to a set of linear equations that share certain features, which you would need to determine. The first thing you should do is identify the four corner... | 0 | false | 1 | 3,321 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.