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 |
|---|---|---|---|---|---|---|---|
2013-01-11 12:14:49.723 | Pycharm External tools relative to Virtual Environment | Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?
An example being pylint - where I'd want the virtual env version and not the system one to run. | just found your post while looking for documentation about the "variables" that could bew used when setting parameters for external tools.
No documentation but you can see a list of all the available stuff after pressing thE "INSERT MACRO" button in the Edit Tool dialog.
I don't see any reference to the interpreter pa... | 0 | false | 3 | 2,312 |
2013-01-11 12:14:49.723 | Pycharm External tools relative to Virtual Environment | Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?
An example being pylint - where I'd want the virtual env version and not the system one to run. | Not sure about older versions, but in PyCharm 5 one can use $PyInterpreterDirectory$ macro. It's exactly that we want | 0.999329 | false | 3 | 2,312 |
2013-01-11 12:14:49.723 | Pycharm External tools relative to Virtual Environment | Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?
An example being pylint - where I'd want the virtual env version and not the system one to run. | In Tool Settings, set Program: to $PyInterpreterDirectory$/pylint | 0 | false | 3 | 2,312 |
2013-01-11 23:13:18.717 | Interact with other programs using Python | I'm having the idea of writing a program using Python which shall find a lyric of a song whose name I provided. I think the whole process should boil down to couple of things below. These are what I want the program to do when I run it:
prompt me to enter a name of a song
copy that name
open a web browser (google chro... | You should look into a package called selenium for interacting with web browsers | 0.081452 | false | 1 | 2,313 |
2013-01-12 02:41:24.737 | How does one get a C++ library loaded into Python as a shared object file (.so)? | I'm a Python guy building a Linux-based web service for a client who wants me to interface with a small C++ library that they're currently using with a bunch of Windows based VB applications.
They have assured me that the library is fairly simple (as far as they go I guess), and that they just need to know how best to ... | Due to complexities of the C++ ABI (such as name mangling), it's generally difficult and platform-specific to load a C++ library directly from Python using ctypes.
I'd recommend you either create a simple C API which can be easily wrapped with ctypes, or use SWIG to generate wrapper types and a proper extension module ... | 0 | false | 1 | 2,314 |
2013-01-14 17:21:55.213 | qt phonon - returning video dimensions | Can anybody tell me how I can return the dimensions of a video (pixel height/width) using Qt (or any other Python route to that information). I have googled the hell out of it and cannot find a straight answer.
I assumed it would either be mediaobject.metadata() or os.stat() but neither appear to return the required i... | OK - for others out there looking for the same info, I found Hachoir-metadata and Hachoir-parser (https://bitbucket.org/haypo/hachoir/wiki/Home).
They provide the correct info but there is a serious lack of docs for it and not that many examples that I can find. Therefore, while I have parsed a video file and returned... | 1.2 | true | 1 | 2,315 |
2013-01-16 10:05:11.013 | Python list and c/c++ arrays | For e.g. if we have an array in python arr = [1,3,4]. We can delete element in the array by just using arr.remove(element) ot arr.pop() and list will mutate and it's length will change and that element won't be there. Is there a way to do this is C ot C++?. If yes the how to do that? | I guess you're looking for std::vector (or other containers in the standard library). | 0.470104 | false | 3 | 2,316 |
2013-01-16 10:05:11.013 | Python list and c/c++ arrays | For e.g. if we have an array in python arr = [1,3,4]. We can delete element in the array by just using arr.remove(element) ot arr.pop() and list will mutate and it's length will change and that element won't be there. Is there a way to do this is C ot C++?. If yes the how to do that? | In C++ either you can use std::list or std::vector based on your mileage
If you need to implement in C, you need to write your double-link list implementation or if you wan't to emulate std::vector, you can do so by using memcpy and array indexing | 0 | false | 3 | 2,316 |
2013-01-16 10:05:11.013 | Python list and c/c++ arrays | For e.g. if we have an array in python arr = [1,3,4]. We can delete element in the array by just using arr.remove(element) ot arr.pop() and list will mutate and it's length will change and that element won't be there. Is there a way to do this is C ot C++?. If yes the how to do that? | As I understand, you don't want or able to use standard library (BTW, why?).
You can look into the code of the vector template in one of STL implementations and see, how it's implemented.
The basic algorithm is simple. If you're deleting something from the middle of the array, you must shrink it after. If you're insert... | 0 | false | 3 | 2,316 |
2013-01-16 10:27:12.240 | Adding external Ids to Partners in OpenERP withouth a new module | My Question is a bit complex and iam new to OpenERP.
I have an external database and an OpenERP. the external one isn't PostgreSQL.
MY job is that I need to synchronize the partners in the two databases.
External one being the more important. This means that if the external one's data change so does the OpenERp's, bu... | Add an integer field in res partner table for storing external id on both database. When data is retrived from the external server and adding to your openerp database, store the external id in the record of res partner in local server and also save the id of the newly created partner record in the external server's par... | 0 | false | 1 | 2,317 |
2013-01-16 17:29:18.690 | How to approach updating an database-driven application after release? | I'm working on a web-app that's very heavily database driven. I'm nearing the initial release and so I've locked down the features for this version, but there are going to be lots of other features implemented after release. These features will inevitably require some modification to the database models, so I'm concern... | Some thoughts for managing databases for a production application:
Make backups nightly. This is crucial because if you try to do an update (to the data or the schema), and you mess up, you'll need to be able to revert to something more stable.
Create environments. You should have something like a local copy of the da... | 1.2 | true | 1 | 2,318 |
2013-01-16 20:55:26.313 | Django: How to query objects immediately after they have been saved from a separate view? | Suppose I want to query and display all the images that the user just uploaded through a form on the previous page (multiple images are uploaded at once, each is made into a separate object in the db).
What's the best way to do this?
Since the view for uploading the images is different from the view for displaying the ... | What other fields are there in the model db?
You could add an upload_id, which is set automatically after uploading, send it to the next view, and query for that in the db. | 0 | false | 1 | 2,319 |
2013-01-17 02:11:28.927 | Pytest and Python 3 | I've installed pytest 2.3.4 under Debian Linux. By default it runs under Python 2.7, but sometimes I'd like to run it under Python 3.x, which is also installed. I can't seem to find any instructions on how to do that.
The PyPI Trove classifiers show Python :: 3 so presumably it must be possible. Aside from py.test s... | Install it with pip3:
pip3 install -U pytest | 0.327599 | false | 3 | 2,320 |
2013-01-17 02:11:28.927 | Pytest and Python 3 | I've installed pytest 2.3.4 under Debian Linux. By default it runs under Python 2.7, but sometimes I'd like to run it under Python 3.x, which is also installed. I can't seem to find any instructions on how to do that.
The PyPI Trove classifiers show Python :: 3 so presumably it must be possible. Aside from py.test s... | I found a workaround:
Installed python3-pip using aptitude, which created /usr/bin/pip-3.2.
Next pip-3.2 install pytest which re-installed pytest, but under a python3.2 path.
Then I was able to use python3 -m pytest somedir/sometest.py.
Not as convenient as running py.test directly, but workable. | 1.2 | true | 3 | 2,320 |
2013-01-17 02:11:28.927 | Pytest and Python 3 | I've installed pytest 2.3.4 under Debian Linux. By default it runs under Python 2.7, but sometimes I'd like to run it under Python 3.x, which is also installed. I can't seem to find any instructions on how to do that.
The PyPI Trove classifiers show Python :: 3 so presumably it must be possible. Aside from py.test s... | python3 doesn't have the module py.test installed. If you can, install the python3-pytest package.
If you can't do that try this:
Install virtualenv
Create a virtualenv for python3
virtualenv --python=python3 env_name
Activate the virtualenv
source ./env_name/bin/activate
Install py.test
pip install py.test
Now... | 0.999753 | false | 3 | 2,320 |
2013-01-17 09:02:53.413 | Compile Python 2.7.3 on Linux for Embedding into a C++ app | I have a C++ application from Windows that I wish to port across to run on a Red Hat Linux system. This application embeds a slightly modified version of Python 2.7.3 (I added the Py_SetPath command as it is essential for my use case) so I definitely need to compile the Python source.
My problem is that despite lookin... | You want to link to the python static library, which should get created by default and will be called libpython2.7.a
If I recall correctly, as long as you don't build Python with --enable-shared it doesn't install the dynamic library, so you'll only get the static lib and so simply linking your C++ application with -l... | 1.2 | true | 1 | 2,321 |
2013-01-17 10:30:33.380 | Jinja2 substring integer | I have a question and I tried to solve diff way with Jinja2. I have a number that is saved in database. When I print the original number is for ex: 907333-5000. I want that number to be printed in this format: (907) 333-5000 but I don't know exactly how to do with Jinja2. Thank you | Or you can create a filter for phonenumbers like {{ phone_number|phone }} | 0.386912 | false | 1 | 2,322 |
2013-01-17 15:58:37.990 | Pydev: How to import a gae project to eclipse Pydev gae project? | Created a gae project with the googleappengine launch and have been building it with textmate.
Now, I'd like to import it to the Eclipse PyDev GAE project. Tried to import it, but it doesn't work.
Anyone know how to do that?
Thanks in advance. | You could try not using the eclipse import feature. Within Eclipse, create a new PyDev GAE project, and then you can copy in your existing files. | 1.2 | true | 2 | 2,323 |
2013-01-17 15:58:37.990 | Pydev: How to import a gae project to eclipse Pydev gae project? | Created a gae project with the googleappengine launch and have been building it with textmate.
Now, I'd like to import it to the Eclipse PyDev GAE project. Tried to import it, but it doesn't work.
Anyone know how to do that?
Thanks in advance. | If you want to use Eclipse's Import feature, go with General -> File system. | 0 | false | 2 | 2,323 |
2013-01-17 21:14:12.117 | How to delete or reset a search index in Appengine | The Situation
Alright, so we have our app in appengine with full text search activated. We had an index set on a document with a field named 'date'. This field is a DateField and now we changed the model of the document so the field 'date' is now a NumericField.
The problem is, on the production server, even if I clea... | If you empty out your index and call index.delete_schema() (index.deleteSchema() in Java) it will clear the mappings that we have from field name to type, and you can index your new documents as expected. Thanks! | 1.2 | true | 1 | 2,324 |
2013-01-17 23:15:08.830 | IPython Notebook: Plotting with LaTeX? | Displaying lines of LaTeX in IPython Notebook has been answered previously, but how do you, for example, label the axis of a plot with a LaTeX string when plotting in IPython Notebook? | I ran into the problem posted in the comments: ! LaTeX Error: File 'type1cm.sty' not found.
The issue was that my default tex command was not pointing to my up-to-date MacTex distribution, but rather to an old distribution of tex which I had installed using macports a few years back and which wasn't being updated since... | 0.386912 | false | 1 | 2,325 |
2013-01-18 09:46:58.113 | In Python how do you reverse this call: long("1234", 16)? | I'd like to be able to do the reverse of:
foo = long(binarystring.encode('hex'), 16) | use binascii.hexlify() - that should do it | 0 | false | 1 | 2,326 |
2013-01-18 12:28:13.847 | How to implement "last command" function in a console based python program | So I am working on a console based python(python3 actually) program where I use input(">")to get the command from user.
Now I want to implement the "last command" function in my program - when users press the up arrow on the keyboard they can see their last command.
After some research I found I can use curses lib to i... | What you can do, is to apply some sort of shell history functionality: every command issued by the user would be placed in a list, and then you'd implement a special call (command of your console), let's say 'history' that would print out the list for the user in order as it was being filled in, with increasing number ... | 0.201295 | false | 1 | 2,327 |
2013-01-18 12:41:57.153 | clang error when installing MYSQL-python on Lion-mountain (Mac OS X 10.8) | When I try installing mysql-python using below command,
macbook-user$ sudo pip install MYSQL-python
I get these messages:
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:891:1: warning: this is the location of the previous definition
/usr/bin/lipo: /tmp/_mysql-LtlmLe.o and /tmp/_m... | At first glance it looks like damaged pip package. Have you tried easy_install instead with the same package? | 0 | false | 1 | 2,328 |
2013-01-18 14:15:54.867 | Using python to download a file after clicking the submit button | I need to login to a website. Navigate to a report page. After entering the required information and clicking on the "Go" button(This is a multipart/form-data that I am submitting), there's a pop up window asking me to save the file. I want to do it automatically by python.
I search the internet for a couple of days, b... | There are python bindings to Selenium, that are helping in scripting simulated browser behavior allowing to do really complex stuff with it - take a look at it, should be enough for what you need. | 0 | false | 1 | 2,329 |
2013-01-18 23:44:14.563 | Python IDLE Multi-line Prompt | I'm using the IDLE command prompt with Python 3.3 and when I enter a multi-line command, I see a blank line rather than the multi-line prompt that has three dots. I know that this is a little thing, but does anyone know how to enable the multi-line prompt? | As others have noted, IDLE will not display the three dots that you are looking for; however, if you must have them, you could always run python from the terminal by typing 'python' into the terminal and pressing ENTER. To exit python from the terminal you could type either 'exit()' or 'quit()' followed by ENTER. | 1.2 | true | 1 | 2,330 |
2013-01-19 03:21:04.543 | Python getting Itunes song | I have been doing a little bit of research and haven't found anything that is quite going to work. I want to have python know what the current song playing in iTunes is so I can serially send it to my Arduino.
I have seen Appscript but it is no longer supported and from what I have read full of a few bugs now that it h... | You can set up a simple Automator workflow to retrieve the current iTunes song. Try these two actions for starters:
iTunes: Get the Current Song
Utilities: Run Shell Script
Change the shell script to cat > ~/itunes_track.txt and you should have a text file containing the path of the current track. Once you get your ... | 0 | false | 1 | 2,331 |
2013-01-20 11:10:19.690 | how to reveal an object's attributes in Python? | Is there any method to let me know the values of an object's attributes?
For example, info = urllib2.urlopen('http://www.python.org/')
I wanna know all the attributes' values of info. Maybe I don't know what are the attributes the info has. And str() or list() can not give me the answer. | You can use vars(info) or info.__dict__. It will return the object's namespace as a dictionary in the attribute_name:value format. | 0.16183 | false | 1 | 2,332 |
2013-01-21 00:23:21.757 | Wxpython dynamic programming | Im a newbie to Wxpython programming and I have a general on how to make my application more program.
Assume, I have a tree with the list of employees being listed in the tree. When I click a employee the information is retrieved in the db and the information is diplayed on the right side of the panel.
Now, when I edit... | I don't believe the default TreeCtrl has database interaction builtin. You would have to add that. If you want it to check for updates periodically, you could use a wx.Timer. If you'll be updating the database with your wxPython GUI, then there shouldn't be a problem as you'll have to update the display anyway.
You mig... | 0 | false | 1 | 2,333 |
2013-01-21 02:18:35.097 | How to set up a django test server when using gunicorn? | I am running an app in django with gunicorn. I am trying to use selenium to test my app but have run into a problem.
I need to create a test server like is done with djangos LiveServerTestCase that will work with gunicorn.
Does anyone have any ideas of how i could do this?
note: could also someone confirm me that LiveS... | Off top of my head, you can try to override LiveServerTestCase.setUpClass and wind up gunicorn instead of LiveServerThread | 0.201295 | false | 2 | 2,334 |
2013-01-21 02:18:35.097 | How to set up a django test server when using gunicorn? | I am running an app in django with gunicorn. I am trying to use selenium to test my app but have run into a problem.
I need to create a test server like is done with djangos LiveServerTestCase that will work with gunicorn.
Does anyone have any ideas of how i could do this?
note: could also someone confirm me that LiveS... | I've read the code. Looking at LiveServerTestCase for inspiration makes sense but trying to cook up something by extending or somehow calling LiveServerTestCase is asking for trouble and increased maintenance costs.
A robust way to run which looks like what LiveServerTestCase does is to create from unittest.TestCase a ... | 0.386912 | false | 2 | 2,334 |
2013-01-21 14:47:03.507 | Understanding what is API wrapper around existing library | How to write a python helper API to wrap existing python library.
I have never written anything like this or may be written but not realized it. Can someone tell me what exactly it is and how to do it ? | The process is mostly like this:
1) You write a new library (the wrapper)
2) This library depends on the existing library (the one you are going to wrap)
3) The wrapper will call the underlying library, offering a different API than the orignal library
Usually you want to do this because the orignal library has not dev... | 0 | false | 1 | 2,335 |
2013-01-21 15:17:09.220 | How to disable all default keystrokes on Gtk | I'm writing a source code editor, and I want to disable any of the pre-defined keystrokes, e.g Ctrl-V for paste, how can I do that? | I have found the way to do this: Return boolean True from the method which handles the key-press-event. Any value that doesn't evaluate to true passes control back to Gtk.
In the particular way I implement this editor, the key-press-event signal of the toplevel vindow is connected to the method __key_event_handler, whi... | 1.2 | true | 1 | 2,336 |
2013-01-22 10:02:10.327 | Adding an item to an already populated combobox | I have populated a combobox with an QSqlQueryModel. It's all working fine as it is, but I would like to add an extra item to the combobox that could say "ALL_RECORDS". This way I could use the combobox as a filtering device.
I obviously don't want to add this extra item in the database, how can I add it to the combobo... | You could use a proxy model that takes gets it's data from two models, one for your default values, the other for your database, and use it to populate your QComboBox. | 0.201295 | false | 1 | 2,337 |
2013-01-22 13:34:54.917 | A number out of digits | I want to know what is the biggest number you can make from multiplying digits entered by the user like this:
5*6*7*2 OR 567*2 OR 67*25 ...etc
so 5/6/7/2 should be entered by the user as variables, but how do I tell python to form a number from two variables (putting the two digits next to each other and treating the o... | Any solution that has you trying all permutations of digits will be horribly inefficient, running in O(n!). Just 14 digits (and the multiply operator) would give around 1 trillion combinations!
An O(n lg n) solution would be:
Sort the digits from high to low.
Concatenate them into one string.
Print the string.
If y... | 0.081452 | false | 1 | 2,338 |
2013-01-23 11:16:54.760 | xoauth.py IMAP token expires after 1 hour | I am Google Apps administrator and using xoauth.py and IMAP to download users mails without users password. But this process gets stopped after 1 hour. I searched many blogs and I came to know this token expires after 1 hour. Can anyone tell me how to extend that expiration time to Never, or how to refresh this token? | try: .. catch:.. logic can be used to handle such exceptions.
As Google has retired OAuth1.0, its recommended to use OAuth2.0 instead of OAUth1. | 0 | false | 1 | 2,339 |
2013-01-23 11:28:40.857 | How to a posteriori double the indentation levels on all lines of a file in Vim? | I want to change the indentation in all my existing(!) Python files from 2-space to 4-space shift width. Any suggestions how to do this in Vim? | It's not the best solution for your problem but for one file you can reindent the whole file (if you configured the indentation rules to match your taste):
Shift+V Shift+G = | 0.201295 | false | 1 | 2,340 |
2013-01-23 18:25:50.387 | Using a celery task to create a new process | In Celery, the only way to conclusively reload modules is to restart all of your celery processes. I know how to remotely shutdown workers (broadcast('shutdown', destination = [<workers>])), but not how to bring them back up.
I have a piece of Python code that works to create a daemon process with a new worker in it... | Run the Celery daemons under a supervisor, such as supervisord. When the celeryd process dies, the supervisor will spin it back up. | 0.386912 | false | 1 | 2,341 |
2013-01-23 22:42:57.863 | Python - popup message drawn on the screen | I'm writing a program and I need to inform the user about some changes with a popup message, but not a popup window. Something like the rectangle informing about new message in Kadu - no window, just a bitmap drawn directly on the screen for a few seconds.
I wonder if there is a simple way to do that with win32 packag... | I am using wxPython and looking for a way to have a popup message. Now I am using a popupmenu in which I append each item of the menu with one line of the message. | 0 | false | 1 | 2,342 |
2013-01-24 11:24:02.217 | Make a Python app package/install for Mac | I have developed an application for a friend. Aplication is not that complex, involves only two .py files, main.py and main_web.py, main being the application code, and _web being the web interface for it. As the web was done later, it's kept in this format, I know it can be done with one app but not to complicate it t... | I believe what you are looking for is to add: #!/usr/bin/python to the first line of your code will allow your friend to just double click on the file and it should open. Just as a warning osx does not tell us what version and as such what version of python and what standard libraries are going to be present.
Also, jus... | 1.2 | true | 1 | 2,343 |
2013-01-24 13:58:26.580 | How to crawl a web site where page navigation involves dynamic loading | I want to crawl a website having multiple pages and when a page number is clicked it is dynamically loaded.How to screen scrape it?
i.e as the url is not present as href or a how to crawl to other pages?
Would be greatful if someone helped me on this.
PS:URL remains the same when different page is clicked. | if you are using google chrome, you can check the url which is dynamically being called in
network->headers of the developer tools
so based on that you can identify whether it is a GET or POST request.
If it is a GET request you can find the parameters straight away from the url.
If it is a POST request you can find ... | 0.067922 | false | 1 | 2,344 |
2013-01-24 14:15:41.433 | Implementing a Flask blueprint so that it can be safely mounted more than once? | The Flask documentation says :
that you can register blueprints multiple times though not every blueprint might respond properly to that. In fact it depends on how the blueprint is implemented if it can be mounted more than once.
But I can't seem to find out what must be done to mount a blueprint safely more than onc... | It's hard to answer a question like this, because it is so general.
First, your Blueprint needs to be implemented in a way that makes no assumptions about the state of the app object it will be registered with. Second, you'll want to use a configurable url scheme to prevent route conflicts.
There are far more nuanced ... | 0.673066 | false | 1 | 2,345 |
2013-01-24 20:19:05.790 | Python trick in finding leading zeros in string | I have a binary string say '01110000', and I want to return the number of leading zeros in front without writing a forloop. Does anyone have any idea on how to do that? Preferably a way that also returns 0 if the string immediately starts with a '1' | I'm using has_leading_zero = re.match(r'0\d+', str(data)) as a solution that accepts any number and treats 0 as a valid number without a leading zero | 0 | false | 1 | 2,346 |
2013-01-24 22:06:32.997 | How can I find if the contents in a Google Drive folder have changed | I am currently working on an app that syncs one specific folder in a users Google Drive. I need to find when any of the files/folders in that specific folder have changed. The actual syncing process is easy, but I don't want to do a full sync every few seconds.
I am condisering one of these methods:
1) Moniter the chan... | There are a couple of tricks that might help.
Firstly, if your app is using drive.file scope, then it will only see its own files. Depending on your specific situation, this may equate to your folder hierarchy.
Secondly, files can have multiple parents. So when creating a file in folder-top/folder-1/folder-1a/folder-1a... | 0 | false | 2 | 2,347 |
2013-01-24 22:06:32.997 | How can I find if the contents in a Google Drive folder have changed | I am currently working on an app that syncs one specific folder in a users Google Drive. I need to find when any of the files/folders in that specific folder have changed. The actual syncing process is easy, but I don't want to do a full sync every few seconds.
I am condisering one of these methods:
1) Moniter the chan... | As you have correctly stated, you will need to keep (or work out) the file hierarchy for a changed file to know whether a file has changed within a folder tree.
There is no way of knowing directly from the changes feed whether a deeply nested file within a folder has been changed. Sorry. | 1.2 | true | 2 | 2,347 |
2013-01-24 22:30:48.483 | how to access and edit python library config file | I am trying to set my AWS id and secret in boto.cfg for the AWS python library "boto". I've installed it on my mac with pip install and I don't see it in /etc
How do I locate and access it or do I have to create it? And if so how? | The installer does not create a config file for you. You have to manually create one. You can create a system-wide config file in /etc/boto.cfg or a personal config file in ~/.boto. Or you can create one somewhere else and point the BOTO_CONFIG environment variable at it. | 1.2 | true | 1 | 2,348 |
2013-01-25 06:45:51.467 | Django : Call a method only once when the django starts up | I want to initialize some variables (from the database) when Django starts.
I am able to get the data from the database but the problem is how should I call the initialize method . And this should be only called once.
Tried looking in other Pages, but couldn't find an answer to it.
The code currently looks something l... | there are some cheats for this. The general solution is trying to include the initial code in some special places, so that when the server starts up, it will run those files and also run the code.
Have you ever tried to put print 'haha' in the settings.py files :) ?
Note: be aware that settings.py runs twice during st... | 0.201295 | false | 1 | 2,349 |
2013-01-25 17:18:35.263 | Download zip file via FTP and extract files in memory in Python | I'm trying to download a zip file via ftp, but then extract the files inside without ever actually saving the zip. Any idea how I do this? | The zipfile module can be used to extract things from a zip file; the ftplib would be used to access the zipfile. Unfortunately, ftplib doesn't provide a file-like object for zipfile to use to access the contents of the file. I suppose you could read the zip & store it in memory, for example in a string, which could ... | 0 | false | 1 | 2,350 |
2013-01-26 09:36:08.900 | How would I go about finding all possible permutations of a 4x4 matrix with static corner elements? | So far I have been using python to generate permutations of matrices for finding magic squares. So what I have been doing so far (for 3x3 matrices) is that I find all the possible permutations of the set {1,2,3,4,5,6,7,8,9} using itertools.permutations, store them as a list and do my calculations and print my results.... | Just pull the placed numbers out of the permutation set. Then insert them into their proper position in the generated permutations.
For your example you'd take out 1, 16, 4, 13. Permute on (2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15), for each permutation, insert 1, 16, 4, 13 where you have pre-selected to place them. | 0.201295 | false | 1 | 2,351 |
2013-01-28 00:05:23.270 | Root node operations in tree data structures | Need a way to indicate/enforce that certain methods can only be done on the root Node of my tree data structure. I'm working in Python 2.x
I have a class, Node, which I use in conjunction with another class, Edge, to build a tree data structure (edges are letters and nodes are words, in this case).
Some methods in Nod... | Make a Tree subclass of Node and add the tree-only methods on that class instead.
Then make your root an instance of Tree, the rest of your graph uses Node instances. | 1.2 | true | 1 | 2,352 |
2013-01-29 15:18:08.903 | Python and ControlDesk interaction | I hope someone can help us.
We are using a dSpace 1103 out of Simulink/Matlab and ControlDesk.
What I would like to know is, is it possible to use python in ControlDesk to transfer data into the dSpace from network? I mean, write an UDP Listener in python and use that script to update variables inside the Simulink/Matl... | Yes, it is quite possible. You should take a look at "Real-Time Testing" document which you can find in your dSPACE installation directory. | 0.386912 | false | 1 | 2,353 |
2013-01-29 21:12:51.170 | How can Linux program, e.g. bash or python script, know how it was started: from command line or interactive GUI? | I want to do the following:
If the bash/python script is launched from a terminal, it shall do something such as printing an error message text. If the script is launched from GUI session like double-clicking from a file browser, it shall do something else, e.g. display a GUI message box. | It can check the value of $DISPLAY to see whether or not it's running under X11, and $(tty) to see whether it's running on an interactive terminal. if [[ $DISPLAY ]] && ! tty; then chances are good you'd want to display a GUI popup. | 0.3154 | false | 1 | 2,354 |
2013-01-29 21:44:03.897 | Returning more than one page in Python Twitter search | So I'm trying to run a search query through the Twitter API in Python. I can get it to return up to 100 results using the "count" parameter. Unfortunately, version 1.1 doesn't seem to have the "page" parameter that was present in 1.0. Is there some sort of alternative for 1.1? Or, if not, does anyone have any suggestio... | I think you should use "since_id" parameter in your url. since_id provides u getting pages that older than since_id. So, for the next page you should set the since_id parameter as the last id of your current page. | 1.2 | true | 1 | 2,355 |
2013-01-30 21:32:10.950 | How to run a python background process periodically | I have a fairly light script that I want to run periodically in the background every 5 hours or so. The script runs through a few different websites, scans them for new material, and either grabs .mp3 files from them or likes songs on youtube based on their content. There are a few things I want to achieve with this pr... | Have the program run every 5 hours -- I'm not to familiar with
system-level timing operations.
for nix cron is the default solution to accomplish this
Have the program efficiently run in the background -- I want these
'updates' to occur without the user knowing.
Using cron the program will be run in the backgrou... | 0.386912 | false | 1 | 2,356 |
2013-01-31 19:11:44.590 | Reformat census title | I've been tasked to dig through census data for things at the block level.
After learning how to navigate AND find what i'm looking for I hit a snag.
tabblock polygons (block level polygon) have an id consisting of a 15 length string,
ex: '471570001022022'
but the format from the census data is labelled:
'Block 2022, B... | well, i got it.
ex = 'Block 2022, Block Group 2, Census Tract 1, Shelby County, Tennessee'
new_id = '47157' + ex[40:len(ex)-26].zfill(4) + '0' + ex[24] + ex[6:10]
state and county values are constant; block groups only go to one digit (afaik). | 0.135221 | false | 1 | 2,357 |
2013-01-31 21:42:59.997 | GAE MapReduce, How to write Multiple Outputs | I have a data set which I do multiple mappings on.
Assuming that I have 3 key-values pair for the reduce function, how do I modify the output such that I have 3 blobfiles - one for each of the key value pair?
Do let me know if I can clarify further. | I don't think such functionality exists (yet?) in the GAE Mapreduce library.
Depending on the size of your dataset, and the type of output required, you can small-time-investment hack your way around it by co-opting the reducer as another output writer. For example, if one of the reducer outputs should go straight bac... | 1.2 | true | 1 | 2,358 |
2013-02-01 13:26:00.980 | PYTHONPATH vs symbolic link | Yesterday, I edited the bin/activate script of my virtualenv so that it sets the PYTHONPATH environment variable to include a development version of some external package. I had to do this because the setup.py of the package uses distutils and does not support the develop command à la setuptools. Setting PYTHONPATH wor... | Even when a package is not using setuptools pip monkeypatches setup.py to force it to use setuptools.
Maybe you can remove that PYTHONPATH hack and pip install -e /path/to/package. | 1.2 | true | 1 | 2,359 |
2013-02-02 08:58:21.347 | How to build a C library for python | I'm building a package with Python 2.7.3 and gcc 4.7.2. Build is scons based and it terminates complaining that it can't find 'C library for python2.7'?
What is this C library and how do I build it? | Often, packages are split into those parts for use and those parts that are required for development. You probably have those parts for use installed (interpreter, modules), but the libraries for development of modules are missing. Look for a python-dev package. | 0 | false | 1 | 2,360 |
2013-02-02 22:31:19.980 | Python, breaking up Strings | I need to make a program in which the user inputs a word and I need to do something to each individual letter in that word. They cannot enter it one letter at a time just one word.
I.E. someone enters "test" how can I make my program know that it is a four letter word and how to break it up, like make my program make ... | You don't want to assign each letter to a separate variable. Then you'd be writing the rest of your program without even being able to know how many variables you have defined! That's an even worse problem than dealing with the whole string at once.
What you instead want to do is have just one variable holding the stri... | 0 | false | 1 | 2,361 |
2013-02-02 23:15:39.850 | check if a number already exist in a list in python | I am writing a python program where I will be appending numbers into a list, but I don't want the numbers in the list to repeat. So how do I check if a number is already in the list before I do list.append()? | You could probably use a set object instead. Just add numbers to the set. They inherently do not replicate. | 0.081452 | false | 1 | 2,362 |
2013-02-03 05:38:10.283 | Is google app engine right for me (hosting a few rapidly updating text files created w/ python) | I have a python script that creates a few text files, which are then uploaded to my current web host. This is done every 5 minutes. The text files are used in a software program which fetches the latest version every 5 min. Right now I have it running on my web host, but I'd like to move to GAE to improve reliability. ... | Yes and no.
Appengine is great in terms of reliability, server speed, features, etc. However, it has two main drawbacks: You are in a sandboxed environment (no filesystem access, must use datastore), and you are paying by instance hour. Normally, if you're just hosting a small server accessed once in a while, you can... | 0 | false | 1 | 2,363 |
2013-02-03 11:36:36.253 | Transforming analog keypresses to digital | In python I want to simulate a joystick that when used, to give values between -63 and +63 let's say. When the value it's positive, I want to press the "w" key and "s" key when negative.
I am not having problems receiving the values, but to transform these analog values into digital key presses. Does anyone has any ide... | Use PostMessage with the WM_CHAR command (if you're using Windows - you didn't say). | 1.2 | true | 1 | 2,364 |
2013-02-03 21:34:07.340 | Upvote and Downvote buttons with Django forms | I want to make upvote and downvote buttons for comments but I want all the form inputs that django.contrib.comments.forms.CommentSecurityForm gives me to make sure the form is secure. Is that necessary? And if so, how do I make a form class that with upvote and downvote buttons? Custom checkbox styles? | I would suggest, you use separate view login for up and down voting.
Something like this /upvote/{{comment.pk|urlize}}
and then write a view that works with this url. With PK find the comment that the user is trying to up/down vote, then write the necessary condition to check if the user is authorized to perform that k... | 1.2 | true | 1 | 2,365 |
2013-02-04 06:52:37.517 | Show progress bar when running a script | I have developed the python script for checking out a source code from repository and build it using visual studio.When i run the script,a GUI opens(developed using wxPython) which shows a button,clicking on which does the checkout and build.I would want to show a progress bar showing the process running when i click o... | You probably won't be able to get an accurate progress unless your build scripts are generating some progress information in the output that you can parse and represent in your GUI. Either way you will probably want to use wx.ProgressDialog or use a wx.Gauge in your main panel or something like that. Both wx.Progress... | 1.2 | true | 1 | 2,366 |
2013-02-04 12:58:05.380 | What tests do I need to write for the customfield that I have developed? | i have developed a custom field that extends ImageField and this custom field, dynamically creates 2more normal fields. Now, I need to write tests for this custom fields ?
What tests are needed for this customfield ? Can you name them so that I will code those test cases. I am not asking technically how to write a tes... | Try to test every case of how your custom field could be used. In example try to send by it different kind of datas (string, integers, blank, different image formats etc.) and check if it works according to your expectations. | 0 | false | 1 | 2,367 |
2013-02-04 18:11:09.813 | compile py2exe from executable | I have seen a similar question on this site but not answered correctly for my requirements. I am reasonably familiar with py2exe.
I'd like to create a program (in python and py2exe) that I can distribute to my customers which would enable them to add their own data (not code, just numbers) and redistribute as a new/ame... | I think it is possible. I'm not sure how py2exe works, but I know how pyinstaller does and since both does the same it should work similiar.
Namely, one-file flag doesn't really create one file. It looks like that for end user, but when user run app, it unpacks itself and files are stored somewhere physically. You cou... | 0.386912 | false | 1 | 2,368 |
2013-02-06 02:11:15.577 | How to monitor google app engine from command line? | I'm starting to use Google App Engine and being a newcomer to much of the stuff going on here, I broke my webpage (all I see is "server error" in my web browser). I'd like to be able to see a console of some sort which is telling me what's going wrong (python syntax? file not found? something else?). Searching around a... | I assume you are using Linux, Ubuntu/Mint If not that would be a good start
Debug as much as you can locally using dev_appserver.py - this will display errors on start up (in the console)
Add your own debug logs when needed
Run code snippets in the interactive console - this is really useful to test snippets of code:
... | 0.135221 | false | 1 | 2,369 |
2013-02-06 07:25:53.293 | python with .pdb files | I am working on bio project.
I have .pdb (protein data bank) file which contains information about the molecule.
I want to find out the following of a molecule in the .pdb file:
Molecular Mass.
H bond donor.
H bond acceptor.
LogP.
Refractivity.
Is there any module in python which can deal with .pdb file i... | A pdb file can contain pretty much anything.
A lot of projects allows you to parse them. Some specific to biology and pdb files, other less specific but that will allow you to do more (setup calculations, measure distances, angles, etc.).
I think you got downvoted because these projects are numerous: you are not the on... | 0.135221 | false | 1 | 2,370 |
2013-02-06 11:06:43.790 | Any ideas about how to get rid of self? | Is there anyway of making Python methods have access to the class fields/methods without using the self parameter?
It's really annoying having to write self. self. self. self. The code gets so ugly to the point I'm thinking of not using classes anymore purely for code aesthetics. I don't care about the risks or best pr... | No, there isn't. You could though use another word instead of self, although the convention is to use "self". | 1.2 | true | 2 | 2,371 |
2013-02-06 11:06:43.790 | Any ideas about how to get rid of self? | Is there anyway of making Python methods have access to the class fields/methods without using the self parameter?
It's really annoying having to write self. self. self. self. The code gets so ugly to the point I'm thinking of not using classes anymore purely for code aesthetics. I don't care about the risks or best pr... | The only possible solution (except for making your own no-self Python version (using sources))
Try another language. | 0.386912 | false | 2 | 2,371 |
2013-02-06 21:22:24.413 | Effective implementation of one-to-many relationship with Python NDB | I would like to hear your opinion about the effective implementation of one-to-many relationship with Python NDB. (e.g. Person(one)-to-Tasks(many))
In my understanding, there are three ways to implement it.
Use 'parent' argument
Use 'repeated' Structured property
Use 'repeated' Key property
I choose a way based on th... | A key thing you are missing: How are you reading the data?
If you are displaying all the tasks for a given person on a request, 2 makes sense: you can query the person and show all his tasks.
However, if you need to query say a list of all tasks say due at a certain time, querying for repeated structured properties is ... | 0.998178 | false | 2 | 2,372 |
2013-02-06 21:22:24.413 | Effective implementation of one-to-many relationship with Python NDB | I would like to hear your opinion about the effective implementation of one-to-many relationship with Python NDB. (e.g. Person(one)-to-Tasks(many))
In my understanding, there are three ways to implement it.
Use 'parent' argument
Use 'repeated' Structured property
Use 'repeated' Key property
I choose a way based on th... | One thing that most GAE users will come to realize (sooner or later) is that the datastore does not encourage design according to the formal normalization principles that would be considered a good idea in relational databases. Instead it often seems to encourage design that is unintuitive and anathema to established n... | 0.995055 | false | 2 | 2,372 |
2013-02-07 03:13:31.030 | Interpolation Function | This is probably a very easy question, but all the sources I have found on interpolation in Matlab are trying to correlate two values, all I wanted to benefit from is if I have data which is collected over an 8 hour period, but the time between data points is varying, how do I adjust it such that the time periods are e... | What you can do is use interp1 function. This function will fit in deifferent way the numbers for a new X series.
For example if you have
x=[1 3 5 6 10 12]
y=[15 20 17 33 56 89]
This means if you want to fill in for x1=[1 2 3 4 5 6 7 ... 12], you will type
y1=interp1(x,y,x1) | 0.16183 | false | 1 | 2,373 |
2013-02-08 20:09:40.227 | How to print the string "\n" | I want to print the actual following string: \n , but everything I tried just reads it in takes it as a new line operator.. how do I just print the following: \n ? | You have to escape \n somehow
Either just the sequence
print "\\n"
or mark whole string as raw
print r"\n" | 0.296905 | false | 1 | 2,374 |
2013-02-09 07:49:04.497 | Keep Secret Keys Out | One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS
keys, etc.. values into settings files has problem:
Secrets often should be just that: secret! Keeping them in version control means
that everyone with repository access has access to them.
My question is how to keep all keys as s... | Here's one way to do it that is compatible with deployment on Heroku:
Create a gitignored file named .env containing:
export DJANGO_SECRET_KEY = 'replace-this-with-the-secret-key'
Then edit settings.py to remove the actual SECRET_KEY and add this instead:
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
Then when you want... | 0.116092 | false | 4 | 2,375 |
2013-02-09 07:49:04.497 | Keep Secret Keys Out | One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS
keys, etc.. values into settings files has problem:
Secrets often should be just that: secret! Keeping them in version control means
that everyone with repository access has access to them.
My question is how to keep all keys as s... | You may need to use os.environ.get("SOME_SECRET_KEY") | 0 | false | 4 | 2,375 |
2013-02-09 07:49:04.497 | Keep Secret Keys Out | One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS
keys, etc.. values into settings files has problem:
Secrets often should be just that: secret! Keeping them in version control means
that everyone with repository access has access to them.
My question is how to keep all keys as s... | Store your local_settings.py data in a file encrypted with GPG - preferably as strictly key=value lines which you parse and assign to a dict (the other attractive approach would be to have it as executable python, but executable code in config files makes me shiver).
There's a python gpg module so that's not a problem.... | 0.336246 | false | 4 | 2,375 |
2013-02-09 07:49:04.497 | Keep Secret Keys Out | One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS
keys, etc.. values into settings files has problem:
Secrets often should be just that: secret! Keeping them in version control means
that everyone with repository access has access to them.
My question is how to keep all keys as s... | Ideally, local_settings.py should not be checked in for production/deployed server. You can keep backup copy somewhere else, but not in source control.
local_settings.py can be checked in with development configuration just for convenience, so that each developer need to change it.
Does that solve your problem? | 0.283556 | false | 4 | 2,375 |
2013-02-11 00:27:19.747 | How to match arbitrary data using hash codes? | I have some points in space where each point has an id. I also have a subset of these points in another group that have different id values.
How can I create a new type of id for both groups of points so that the points that have the same coordinates end up using the same id values?
I assume I need to generate hash cod... | Hash codes aren't meant to be unique for unequal objects - there typically will be some collisions. They definitely can't be used to test for equality.
Hash codes are used to place objects (hopefully) evenly across a data structure. If you want to test for equality, test whether the coordinates are equal. | 0 | false | 1 | 2,376 |
2013-02-11 15:59:14.273 | Matching contents of an html file with keyword python | I am making a download manager. And I want to make the download manager check the md5 hash of an url after downloading the file. The hash is found on the page. It needs to compute the md5 of the file ( this is done), search for a match on the html page and then compare the WHOLE contents of the html page for a match.
m... | import urllib and use urllib.urlopen for getting the contents of an html. import re to search for the hash code using regex. You could also use find method on the string instead of regex.
If you encounter problems, then you can ask more specific questions. Your question is too general. | 1.2 | true | 1 | 2,377 |
2013-02-11 17:17:45.260 | multiple users doing form submission with python CGI | I have a simple cgi script in python collecting a value from form fields submitted through post. After collecting this, iam dumping these values to a single text file.
Now, when multiple users submit at the same time, how do we go about it?
In C\C++ we use semaphore\mutex\rwlocks etc? Do we have anything similar in p... | If you're concerned about multiple users, and considering complex solutions like mutexes or semaphores, you should ask yourself why you're planning on using an unsuitable solution like CGI and text files in the first place. Any complexity you're saving by doing this will be more than outweighed by whatever you put in p... | 0 | false | 2 | 2,378 |
2013-02-11 17:17:45.260 | multiple users doing form submission with python CGI | I have a simple cgi script in python collecting a value from form fields submitted through post. After collecting this, iam dumping these values to a single text file.
Now, when multiple users submit at the same time, how do we go about it?
In C\C++ we use semaphore\mutex\rwlocks etc? Do we have anything similar in p... | The simple (and slow way) is to acquire a lock on the file (in C you'd use flock), write on it and close it. If you think this can be a bottleneck then use a database or something like that. | 0 | false | 2 | 2,378 |
2013-02-12 02:33:49.900 | Is possible to create a shell like bash in python, ie: Bash replacement? | I wonder if is possible to create a bash replacement but in python. I have done REPLs before, know about subprocess and that kind of stuff, but wonder how use my python-like-bash replacement in the OSX terminal as if were a native shell environment (with limitations).
Or simply run ipython as is...
P.D. The majority ... | Yes, of course. You can simply make an executable Python script, call it /usr/bin/pysh, add this filename to /etc/shells and then set it as your user's default login shell with chsh. | 0 | false | 1 | 2,379 |
2013-02-12 09:44:18.670 | Using Amazon SWF To communicate between servers | Use Amazon SWF to communicate messages between servers?
On server A I want to run a script A
When that is finished I want to send a message to server B to run a script B
If it completes successfully I want it to clear the job from the workflow queue
I’m having a really hard time working out how I can use Boto and S... | You can use SNS,
When script A is completed it should trigger SNS, and that will trigger a notification to Server B | 0.101688 | false | 2 | 2,380 |
2013-02-12 09:44:18.670 | Using Amazon SWF To communicate between servers | Use Amazon SWF to communicate messages between servers?
On server A I want to run a script A
When that is finished I want to send a message to server B to run a script B
If it completes successfully I want it to clear the job from the workflow queue
I’m having a really hard time working out how I can use Boto and S... | I don't have any example code to share, but you can definitely use SWF to coordinate the execution of scripts across two servers. The main idea with this is to create three pieces of code that talk to SWF:
A component that knows which script to execute first and what to do once that first script is done executing. T... | 0.470104 | false | 2 | 2,380 |
2013-02-12 14:54:16.330 | Understanding the boto documentation for Elastic Transcoder | I am trying to create my own pipe line in Elastic Transcoder. I am using the boto standard function create_pipeline(name, input_bucket, output_bucket, role, notifications).
Can you please tell me the notifications (structure) how it should look?
So far I have something like this:
create_pipeline('test','test_start', '... | It should be a dictionary with the 4 keys in the dictionary (I'm going to push a change that updates the structure type with the dict type). So if you don't want notifications, you just specify empty values for the keys:
{'Progressing': '', 'Completed': '', 'Warning': '', 'Error': ''} | 1.2 | true | 1 | 2,381 |
2013-02-13 03:30:57.420 | Shopify Python API: How do I add a product to a collection? | I am using the Shopify Python API in an django app to interact with my Shopify Store.
I have a collection - called - best sellers.
I am looking to create a batch update to this collection - that is add/remove products to this collection. However, they python API docs does not seem to say much about how to do so. How d... | The documentation is again not promising but one thing to bear in mind is that there should in actual fact be an existing collection already created
Find it by using this code
collection_id = shopify.CustomCollection.find(handle=<your_handle>)[0].id
then consequently add the collection_id, product_id to a Collect objec... | 0 | false | 1 | 2,382 |
2013-02-13 21:06:24.773 | sklearn logistic regression with unbalanced classes | I'm solving a classification problem with sklearn's logistic regression in python.
My problem is a general/generic one. I have a dataset with two classes/result (positive/negative or 1/0), but the set is highly unbalanced. There are ~5% positives and ~95% negatives.
I know there are a number of ways to deal with an u... | Have you tried to pass to your class_weight="auto" classifier? Not all classifiers in sklearn support this, but some do. Check the docstrings.
Also you can rebalance your dataset by randomly dropping negative examples and / or over-sampling positive examples (+ potentially adding some slight gaussian feature noise). | 1 | false | 1 | 2,383 |
2013-02-14 04:49:54.823 | Crawling a page using LazyLoader with Python BeautifulSoup | I am toying around with BeautifulSoup and I like it so far.
The problem is the site I am trying to scrap has a lazyloader... And it only scraps one part of the site.
Can I have a hint as to how to proceed? Must I look at how the lazyloader is implemented and parametrize anything else? | It turns out that the problem itself wasn't BeautifulSoup, but the dynamics of the page itself. For this specific scenario that is.
The page returns part of the page, so headers need to be analysed and sent to the server accordingly. This isn't a BeautifulSoup problem itself.
Therefore, it is important to take a look... | 1.2 | true | 1 | 2,384 |
2013-02-14 07:33:01.923 | Installing a new distribution of Python on Fedora | I have a Fedora virtual machine. It comes with Python pre-installed. I've read that it's not a good idea to uninstall it. I want to install a different version of Python, Enthought Python. Should I try to uninstall the existing Python installation and how would I do that? Should I instead install Enthought Python ... | Do not try to uninstall the pre-installed Python.
Install other Python interpreters side by side (in different directories).
You may come across an option to choose the default Python interpreter for your system. Don't change that from the pre-installed one, as that may break some important scripts used by the system. ... | 1.2 | true | 1 | 2,385 |
2013-02-14 13:01:32.190 | How to Train Single-Object Recognition? | I was thinking of doing a little project that involves recognizing simple two-dimensional objects using some kind of machine learning. I think it's better that I have each network devoted to recognizing only one type of object. So here are my two questions:
What kind of network should I use? The two I can think of tha... | First, a note regarding the classification method to use.
If you intend to use the image pixels themselves as features, neural network might be a fitting classification method. In that case, I think it might be a better idea to train the same network to distinguish between the various objects, rather than using a sepa... | 0.673066 | false | 1 | 2,386 |
2013-02-15 09:22:24.283 | Key length issue: AES encryption on phpseclib and decryption on PyCrypto | I am working on a data intensive project where I have been using PHP for fetching data and encrypting it using phpseclib. A chunk of the data has been encrypted in AES with the ECB mode -- however the key length is only 10. I am able to decrypt the data successfully.
However, I need to use Python in the later stages of... | I strongly recommend you adjust your PHP code to use (at least) a sixteen byte key, otherwise your crypto system is considerably weaker than it might otherwise be.
I would also recommend you switch to CBC-mode, as ECB-mode may reveal patterns in your input data. Ensure you use a random IV each time you encrypt and stor... | 1.2 | true | 1 | 2,387 |
2013-02-15 16:35:00.547 | how to find the integral of a matrix exponential in python | I have a matrix of the form, say e^(Ax) where A is a square matrix. How can I integrate it from a given value a to another value bso that the output is a corresponding array? | Provided A has the right properties, you could transform it to the diagonal form A0 by calculating its eigenvectors and eigenvalues. In the diagonal form, the solution is sol = [exp(A0*b) - exp(A0*a)] * inv(A0), where A0 is the diagonal matrix with the eigenvalues and inv(A0) just contains the inverse of the eigenvalue... | 0.673066 | false | 1 | 2,388 |
2013-02-15 19:34:13.590 | Django: how to make STATIC_URL empty? | Yep, I want it to work like in Flask framework - there I could set parameters like this:
static_folder=os.getcwd()+"/static/", static_url_path=""
and all the files that lies in ./static/files/blabla.bla would be accessible by mysite.com/files/blabla.bla address. I really don't want to add static after mysite.com.
But i... | I believe this is not supported out of the box. Off the top of my head, one way to do it would be with a special 404 handler that, having failed to match against any of the defined URLs, treats the request as a request for a static resource. This would be reasonably easy to do in the development environment but signifi... | 0.201295 | false | 1 | 2,389 |
2013-02-16 21:00:10.673 | Python built exe process to kill itself after a period of time | How is it possible to get a compiled .exe program written in Python to kill itself after a period of time after it is launched?
If I have some code and I compile it into an .exe, then launch it and it stays in a 'running' or 'waiting' state, how can I get it to terminate after a few mins regardless of what the program ... | Create a thread when your process starts.
Make that thread sleep for the required duration.
When that sleep is over, kill the process. | 0 | false | 1 | 2,390 |
2013-02-17 16:59:22.023 | Access Arguments to Parent Task from Subtask in Celery | Is it possible to access the arguments with which a parent task A was called, from its child task Z? Put differently, when Task Z gets called in a chain, can it somehow access an argument V that was invoked when Task A was fired, but that was not passed through any intermediary nodes between tasks A and Z? And if so, h... | I think you can, at least in chord. When you bind=True your task, you can access self.request. In self.request.chord You can find a detailed dict. In its kwargs or options['chord'] you will find what you're looking for, but it's not an elegant solution. Also, if the parent has been replaced, you will only be able to se... | 0 | false | 1 | 2,391 |
2013-02-18 08:04:12.337 | find django/contrib/admin/templates | I have trouble to see django/contrib/admin/templates folder. It seems like it is hidden in /usr/lib/python2.7/dist-packages/ folder, ctrl+h wont help ( appearencely all django files are hidden).
"locate django/contrib/admin/templates" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu ... | Should be here: /usr/lib/python2.7/site-packages/django/contrib/admin/templates | 0 | false | 3 | 2,392 |
2013-02-18 08:04:12.337 | find django/contrib/admin/templates | I have trouble to see django/contrib/admin/templates folder. It seems like it is hidden in /usr/lib/python2.7/dist-packages/ folder, ctrl+h wont help ( appearencely all django files are hidden).
"locate django/contrib/admin/templates" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu ... | Since, everyone is posting my comment's suggestion, might as well post it myself. Try looking at:
/usr/lib/python2.6/site-packages/django/ | 0 | false | 3 | 2,392 |
2013-02-18 08:04:12.337 | find django/contrib/admin/templates | I have trouble to see django/contrib/admin/templates folder. It seems like it is hidden in /usr/lib/python2.7/dist-packages/ folder, ctrl+h wont help ( appearencely all django files are hidden).
"locate django/contrib/admin/templates" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu ... | If you are using Python3, Django is located at your venv. In my case templates are located at <project_root>/venv/lib/python3.5/site-packages/django/contrib/admin/templates/. | 0 | false | 3 | 2,392 |
2013-02-18 16:06:57.243 | Aptana Studio 3 keeps adding .pydevproject file, how can I disable Python? | Aptana Studio 3 keeps adding .pydevproject file, how can I disable Python or whatever it's doing this | I accidentally somehow set the project as PyDev project. To disable, right click on the project > PyDev > Remove PyDev Project Config | 0 | false | 1 | 2,393 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.