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
2011-11-19 10:58:31.493
Predicting Values with k-Means Clustering Algorithm
I'm messing around with machine learning, and I've written a K Means algorithm implementation in Python. It takes a two dimensional data and organises them into clusters. Each data point also has a class value of either a 0 or a 1. What confuses me about the algorithm is how I can then use it to predict some values for...
If you are considering assigning a value based on the average value within the nearest cluster, you are talking about some form of "soft decoder", which estimates not only the correct value of the coordinate but your level of confidence in the estimate. The alternative would be a "hard decoder" where only values of 0 ...
0.101688
false
1
1,530
2011-11-19 19:24:18.203
How to duplicate a window's clientarea to another window?
I want to create a simple project (the language doesn't really matter/but I prefer C++) which simply takes a window title as it's input and duplicate it's visual part, bit by bit, to a new window. just like a mirror better I'd say. As far as I remember there was a win32 API for this but I can't remember, so would you p...
You can get DC of first window, and get DC of second window. And after this do BitBlt or StretchBlt. It has to work... But I don't know what about DirectX/Open-Gl... I think it has to work too. But anyway. It won't take much time to check it.
0
false
1
1,531
2011-11-20 16:35:38.280
How do I inspect a Python's class hierarchy?
Assuming I have a class X, how do I check which is the base class/classes, and their base class/classes etc? I'm using Eclipse with PyDev, and for Java for example you could type CTRL + T on a class' name and see the hierarchy, like: java.lang.Object java.lang.Number java.lang.Integer Is it possible for Pyt...
Hit f4 with class name highlighted to open hierarchy view.
1.2
true
1
1,532
2011-11-21 05:42:01.633
pywinauto with Remote Desktop
I have just started to use the pywinauto module to automate GUI tasks. One of them is to launch the remote desktop exe (mstsc.exe)->Login->Invoke another tool there. However, I manged to connect to the remote server but the control gets lost after that. I did not manage to login. So, the question is how to use the pywi...
After trying out various things I figured that the window which opens after pressing the "Connect" button on mstsc can be found by searching for the window with the title 'XYZ - Remote Desktop' where XYZ is the name of the remote server. I have tested this on the WinXP.
0.386912
false
1
1,533
2011-11-21 15:41:18.600
CSound and Python communication
I am currently working on a specialization project on simulating guitar effects with Evolutionary Algorithms, and want to use Python and CSound to do this. The idea is to generate effect parameters in my algorithm in Python, send them to CSound and apply the filter to the audio file, then send the new audio file back t...
You can use Csound's python API, so you can run Csound within python and pass values using the software bus. See csound.h. You might also want to use the csPerfThread wrapper class which can schedule messages to and from Csound when it is running. All functionality is available from python.
0.201295
false
2
1,534
2011-11-21 15:41:18.600
CSound and Python communication
I am currently working on a specialization project on simulating guitar effects with Evolutionary Algorithms, and want to use Python and CSound to do this. The idea is to generate effect parameters in my algorithm in Python, send them to CSound and apply the filter to the audio file, then send the new audio file back t...
sending parameter values from python to csound could be done using the osc protocol sending audio from csound to python could be done by routing jack channels between the two applications
0.201295
false
2
1,534
2011-11-23 20:06:01.947
How to know/change current directory in Python shell?
I am using Python 3.2 on Windows 7. When I open the Python shell, how can I know what the current directory is and how can I change it to another directory where my modules are?
If you import os you can use os.getcwd to get the current working directory, and you can use os.chdir to change your directory
0.173164
false
1
1,535
2011-11-24 00:27:42.660
Accessing Django Runserver on Shared Hosting
I'm developing a Django application on a shared hosting service (hostmonster) and am, of course, unable to access the runserver on the default localhost ip of 127.0.0.1:8000 over Firefox. The Django Project site's documentation details how to set up remote access to the run-server, but I'm not having any success with t...
I'm betting that port 8000 is blocked. That explains the timeouts you mention in the last couple sentences: the firewall is set to simply drop the packets and not return any connection refusal responses. You're going to have to ask your hosting company if there's a way around this, but there might not be one. At the le...
0
false
2
1,536
2011-11-24 00:27:42.660
Accessing Django Runserver on Shared Hosting
I'm developing a Django application on a shared hosting service (hostmonster) and am, of course, unable to access the runserver on the default localhost ip of 127.0.0.1:8000 over Firefox. The Django Project site's documentation details how to set up remote access to the run-server, but I'm not having any success with t...
First, a webserver typically has at least two "interfaces", each with one or more IPs. The "loopback" interface will have the IP 127.0.0.1, and is ONLY accessible from the machine running the server. So, running on 127.0.0.1:8000 means that you are telling runserver to be accessible ONLY from that server itself, on po...
0
false
2
1,536
2011-11-24 13:16:38.747
Virtual memory address management in c#
I'm working on a monte carol pricer and I need to improve the efficiency of the engine. MonteCarlo path are created by a third party library (in c++) Pricing is done in IronPython (script created by the end user) Everything else is driven by a c# application the pricing process is as follow: C# application request t...
Finding out how much memory an object takes in .NET is a pretty difficult task. I've hit the same problem several times. There are some imperfect methods, but none are very precise. My suggestion is to get some estimate of how much a path will take, and then pass a bunch of them leaving a good margin of safety. Even if...
1.2
true
1
1,537
2011-11-24 20:06:28.207
Vector in python
I'm working on this project which deals with vectors in python. But I'm new to python and don't really know how to crack it. Here's the instruction: "Add a constructor to the Vector class. The constructor should take a single argument. If this argument is either an int or a long or an instance of a class derived from o...
Your instructor seems not to "speak Python as a native language". ;) The entire concept for the class is pretty silly; real Python programmers just use the built-in sequence types directly. But then, this sort of thing is normal for academic exercises, sadly... Add a constructor to the Vector class. In Python, the co...
0.16183
false
2
1,538
2011-11-24 20:06:28.207
Vector in python
I'm working on this project which deals with vectors in python. But I'm new to python and don't really know how to crack it. Here's the instruction: "Add a constructor to the Vector class. The constructor should take a single argument. If this argument is either an int or a long or an instance of a class derived from o...
This may or may not be appropriate depending on the homework, but in Python programming it's not very usual to explicitly check the type of an argument and change the behaviour based on that. It's more normal to just try to use the features you expect it to have (possibly catching exceptions if necessary to fall back t...
0
false
2
1,538
2011-11-25 13:17:33.497
how do i go over lines in an open text file on Python (2.72)
I have text files with a few thousands words in them (one word in a line). I've written a function which take two words (strings), and checks if one word is an Anagram of the other (that means if the two words contains the same letters, even if in different order). Now I want to go over my huge text file and search for...
load all words (lines) into list, while words are in separate lines this can be done via readlines() (you will have to use strip() to remove line ends): words = [s.strip() for s in f.readlines()] for each word create anagram use word list in operator for that anagram to check if anagram exists if exists then print
0
false
1
1,539
2011-11-25 22:07:31.913
Django design patterns - models with ForeignKey references to multiple classes
I'm working through the design of a Django inventory tracking application, and have hit a snag in the model layout. I have a list of inventoried objects (Assets), which can either exist in a Warehouse or in a Shipment. I want to store different lists of attributes for the two types of locations, e.g.: For Warehouses, ...
what about having a generic foreign key on Assets?
1.2
true
2
1,540
2011-11-25 22:07:31.913
Django design patterns - models with ForeignKey references to multiple classes
I'm working through the design of a Django inventory tracking application, and have hit a snag in the model layout. I have a list of inventoried objects (Assets), which can either exist in a Warehouse or in a Shipment. I want to store different lists of attributes for the two types of locations, e.g.: For Warehouses, ...
I think its perfectly reasonable to create a "through" table such as location, which associates an asset, a content (foreign key) and a content_type (warehouse or shipment) . And you could set a unique constraint on the asset_fk so thatt it can only exist in one location at a time
0
false
2
1,540
2011-11-26 22:30:42.270
In laymans terms, what does the Python string format "g" actually mean?
I feel a bit silly for asking what I'm sure is a rather basic question, but I've been learning Python and I'm having difficulty understanding what exactly the "g" and "G" string formats actually do. The documentation has this to say: Floating point format. Uses lowercase exponential format if exponent is less than -4 ...
g and G are similar to the output you would get on a calculator display if the output is very large or very small you will get a response in scientific notation. For example 0.000001 gives "1e-06" with g and "1E-06" with G. However numbers that are not too small or too large are displayed simply as decimals 1000 gives ...
0.986614
false
1
1,541
2011-11-26 23:13:00.050
Can a program written in Python be AppleScripted?
I want my Python program to be AppleScript-able, just like an Objective C program would be. Is that possible? (Note, this is not about running AppleScript from Python programs, nor about calling Python programs from AppleScript via Unix program invocation. Those are straightforward. I need genuine AppleScriptability of...
You can also use the py-aemreceive module from py-appscript. I use that to implement AppleScript support in my Tkinter app.
0
false
1
1,542
2011-11-27 06:45:25.727
How to calculating and testing the number of concurrent connections?
Twisted server supports more than 10,000 concurrent connections. I want to write a test case to check it using Python. What I know is just using multiprocessing + threading + greenlet. My question is how to confirm Twisted's support for more than 10,000 concurrent connections? Something I know is using logger, but is ...
It's easy to support more than 10,000 concurrent connections. What can be harder is supporting so many active connections. The kind of activity you expect to find on your connections is more likely to determine how many you can support at once. What do you expect these connections to be doing? Construct a test whic...
0.673066
false
1
1,543
2011-11-28 02:03:47.933
Draw complex table layout in Python GUI
I need to create a GUI in Python for a client server interaction. The GUI is on the client side for which I want to create complex tables. I tried to use wxPython's grid class, but its too tough to create a complex table in that. I saw a couple of examples for simple table layouts. I tried to put up a snapshot of the...
Tkinter would be enough for this. You can create any level of complexity on the layout even with the "grid" layout manager, which allows you to specify "columnspam" and "rowspam" for widgets that will take more than a single cell.
1.2
true
1
1,544
2011-11-28 11:22:12.170
"Invalidate" RabbitMQ queue or sending "DONE signal"
I'm using RabbitMQ with Python/pika to distribute some batch jobs. So I think I have a very common scenario: One process fills a queue with jobs to be done. Multiple workers retrieve jobs, transform data and put the results in a second queue. Another single process retrives the results and merges them. The works very f...
No, there is no way to find how many publishers are still publishing to a queue in AMQP. You'll have to roll your own system. A way to do this would be to have a fanout exchange that every worker binds a queue to (let's call it the "control" exchange), and have the publisher send a special message to it when it finish...
1.2
true
1
1,545
2011-11-28 15:51:31.137
Should I use a ramdisk for pictures that are converted and removed?
I have a little program here (python 2.7) that runs on an old machine and it basically keeps getting pictures (for timelapses) by running an external binary and converts them to an efficient format to save up disk space. I want to minimize the disk operations, because it's already pretty old and I want it to last some ...
Ah, proprietary binaries that only give certain options. Yay. The simplest solution would be adding a solid state hard drive. You will still be saving to disk, but disk IO will be much higher for reading and writing. A better solution would be outputting the tiff to stdout, perhaps in a different format, and piping it...
0
false
2
1,546
2011-11-28 15:51:31.137
Should I use a ramdisk for pictures that are converted and removed?
I have a little program here (python 2.7) that runs on an old machine and it basically keeps getting pictures (for timelapses) by running an external binary and converts them to an efficient format to save up disk space. I want to minimize the disk operations, because it's already pretty old and I want it to last some ...
If on Debian (and possibly its derivatives), use "/run/shm" directory.
0
false
2
1,546
2011-11-28 17:14:11.647
Could someone give me their two cents on this optimization strategy
Background: I am writing a matching script in python that will match records of a transaction in one database to names of customers in another database. The complexity is that names are not unique and can be represented multiple different ways from transaction to transaction. Rather than doing multiple queries on the d...
Regarding: "would this be faster:" The behind-the-scenes logistics of the SQL engine are really optimized for this sort of thing. You might need to create an SQL PROCEDURE or a fairly complex query, however. Caveat, if you're not particularly good at or fond of maintaining SQL, and this isn't a time-sensitive query, th...
0.265586
false
2
1,547
2011-11-28 17:14:11.647
Could someone give me their two cents on this optimization strategy
Background: I am writing a matching script in python that will match records of a transaction in one database to names of customers in another database. The complexity is that names are not unique and can be represented multiple different ways from transaction to transaction. Rather than doing multiple queries on the d...
Your strategy is reasonable though I would first look at doing as much of the work as possible in the database query using LIKE and other SQL functions. It should be possible to make a query that matches complex criteria.
0
false
2
1,547
2011-11-28 17:40:57.727
Biomorph Implementation in Python
I'm trying to create a Python implementation of Dawkins' biomorphs as described in his book, The Blind Watchmaker. It works like this: A parent organism is displayed, as well as its offspring which are just mutated versions of the parent. Then the user clicks on a descendant it wants to breed, and all the offspring wil...
Depending on graphical requirements, I would say that for a lightweight app you could get away with PyQt or PyGame. For more demanding real-time graphical requirements you could use something like PyOgre or PyOpenGL. You may need to also research graph-layout/data-visualisation algorithms or libraries (e.g. dot) depend...
1.2
true
1
1,548
2011-11-29 11:55:22.447
Corba python integration with web service java
i'm working on a project thata i need develop one web service ( in java ) that get one simple number from a Corba python implementation... how can i proceed with this?? im using omniOrb and already done the server.py that genetares one simple number! thx a lot
You will need a Java CORBA provider - for example IONA or JacORB. Generate the IDL files for your python service and then use whatever IDL -> stub compiler your Java ORB provides to generate the java client-side bindings. From there it should be as simple as binding to the corbaloc:// at which your python server is ru...
0.999329
false
1
1,549
2011-12-01 08:55:56.417
Implementation HMAC-SHA1 in python
I am trying to use the OAuth of a website, which requires the signature method to be 'HMAC-SHA1' only. I am wondering how to implement this in Python?
In Python 3.7 there is an optimized way to do this. HMAC(key, msg, digest).digest() uses an optimized C or inline implementation, which is faster for messages that fit into memory.
0
false
1
1,550
2011-12-01 11:23:56.213
Python ast to dot graph
I'm analyzing the AST generated by python code for "fun and profit", and I would like to have something more graphical than "ast.dump" to actually see the AST generated. In theory is already a tree, so it shouldn't be too hard to create a graph, but I don't understand how I could do it. ast.walk seems to walk with a BF...
If you look at ast.NodeVisitor, it's a fairly trivial class. You can either subclass it or just reimplement its walking strategy to whatever you need. For instance, keeping references to the parent when nodes are visited is very simple to implement this way, just add a visit method that also accepts the parent as an ar...
1.2
true
1
1,551
2011-12-01 13:45:32.507
Xpath vs DOM vs BeautifulSoup vs lxml vs other Which is the fastest approach to parse a webpage?
I know how to parse a page using Python. My question is which is the fastest method of all parsing techniques, how fast is it from others? The parsing techniques I know are Xpath, DOM, BeautifulSoup, and using the find method of Python.
lxml was written on C. And if you use x86 it is best chose. If we speak about techniques there is no big difference between Xpath and DOM - it's very quickly methods. But if you will use find or findAll in BeautifulSoup it will be slow than other. BeautifulSoup was written on Python. This lib needs a lot of memory for ...
0.201295
false
1
1,552
2011-12-02 12:45:05.637
Permanent 'Temporary failure in name resolution' after running for a number of hours
After running for a number of hours on Linux, my Python 2.6 program that uses urllib2, httplib and threads, starts raising this error for every request: <class 'urllib2.URLError'> URLError(gaierror(-3, 'Temporary failure in name resolution'),) If I restart the program it starts working again. My guess is some kind of r...
This was caused by a library's failure to close connections, leading to a large number of connections stuck in a CLOSE_WAIT state. Eventually this causes the 'Temporary failure in name resolution' error due to resource exhaustion.
1.2
true
1
1,553
2011-12-03 14:51:41.897
Is it necessary to have the knowledge of using terminal/command-prompt for learning python
I saw a couple of tutorials and they all make use of termial/command-prompt and I just dont know how they work. Is it necessary to know how they work before learning python or you can just earn it like you would learn some other language(lets say C) It'll be great if you could recommend something. NOTE: I am a windows...
No. If you know how to open the command prompt, navigate to a directory ("cd") and list a directory ("dir" on windows and "ls" on linux), then you can probably jump right into those python tutorials.
0
false
1
1,554
2011-12-03 18:59:02.863
how to pause a program until a button is pressed
I am using py2exe to make executable. I want to know how to pause the program until a button is pressed.. just like we do in C using system("pause"); As the program terminates automatically in windows, I need this tool. Is there anything better than py2exe which does similar work ?
import os Then in your code os.system("pause")
-0.265586
false
1
1,555
2011-12-03 20:57:22.533
What is the best Python library for 3D game development?
Pygame and Pyglet are for 2D game development. Pysoy needs many requirements to be installed. I can't figure out how to install Pyogre. Panda3d is giving me this error and don't know how to fix it. importerror no module named direct.showbase.showbase Is there any other good 3D game development library that could be ...
You can use pyopengl. i think you might have to install pygame...
1.2
true
1
1,556
2011-12-04 23:39:17.103
Start Python Celery task via Redis Pub/Sub
Is there an efficient way to start tasks via Redis Pub/Sub and return the value of the task back to a Pub/Sub channel to start another task based on the result? Does anybody have an idea on how to put this together? Maybe decorators are a good idea to handle and prepare the return value back to a Pub/Sub channel wi...
The problem with using pub/sub is that it's not persistant. If you're looking to do closer to real time communication celery might not be your best choice.
0.386912
false
1
1,557
2011-12-05 12:53:05.907
Why are NumPy arrays so fast?
I just changed a program I am writing to hold my data as numpy arrays as I was having performance issues, and the difference was incredible. It originally took 30 minutes to run and now takes 2.5 seconds! I was wondering how it does it. I assume it is that the because it removes the need for for loops but beyond that I...
Numpy arrays are extremily similar to 'normal' arrays such as those in c. Notice that every element has to be of the same type. The speedup is great because you can take advantage of prefetching and you can instantly access any element in array by it's index.
0
false
1
1,558
2011-12-06 07:20:01.970
Conditional formatting using ruby or python
Does anybody know how to apply conditional formatting to a google spreadsheet document using ruby or python?
This is not currently possible, Google does not let python or ruby runs in the browser. Conditional formatting is currently limited to simple rules based on cell contents. Google has recently rolled macros ability in their spreadsheets but that is limited to JavaScript and does not support conditional formatting.
1.2
true
1
1,559
2011-12-07 09:00:17.007
backup msSQL stored proc or UDF code via Python
The idea is to make a script that would get stored procedure and udf contents (code) every hour (for example) and add it to SVN repo. As a result we have sql versioning control system. Does anyone know how to backup stored procedure code using Python (sqlAlchemy, pyodbc or smth). I'v done this via C# before using SQL ...
There is no easy way to access SMO from Python (because there is no generic solution for accessing .NET from Python), so I would write a command-line tool in C# and call it from Python using the subprocess module. Perhaps you could do something with ctypes but I have no idea if that's feasible. But, perhaps a more impo...
0.386912
false
1
1,560
2011-12-07 15:36:34.360
Filter POST data in Django
I have a view in django that is going to save HTML data to a model, and I'm wondering how I might go about filtering it before saving it to the model? Are there built in functions for it? I know there are template filters, but I don't think those help me in this case. What I'll be doing is getting the content of a div ...
django takes care of safely storing strings in the database. html is a worry when displaying to the user, and django provides some help there as well, escaping html unless explicitly told not to
1.2
true
1
1,561
2011-12-07 17:17:05.077
In Python how to call subprocesses under a different user?
For a Linux system, I am writing a program in Python, who spawns child processes. I am using the "multiprocessing" library and I am wondering if there is a method to call sub-processes with a different user than the current one. I'd like to be able to run each subprocess with a different user (like Postfix, for example...
You could look in os.setpgid(pid, pgrp) direction.
0.386912
false
1
1,562
2011-12-08 01:35:55.407
Python - Read in binary file over SSH
With Python, I need to read a file into a script similar to open(file,"rb"). However, the file is on a server that I can access through SSH. Any suggestions on how I can easily do this? I am trying to avoid paramiko and am using pexpect to log into the SSH server, so a method using pexpect would be ideal. Thanks, Eric
If it's a short file you can get output of ssh command using subprocess.Popen ssh root@ip_address_of_the_server 'cat /path/to/your/file' Note: Password less setup using keys should be configured in order for it to work.
0
false
1
1,563
2011-12-08 04:32:42.317
What is the equivalent to python equivalent to using Class.getResource()
In java if I want to read a file that contains resource data for my algorithms how do I do it so the path is correctly referenced. Clarification I am trying to understand how in the Python world one packages data along with code in a module. For example I might be writing some code that looks at a string and tries to c...
For Pythonistas who don't know, the behaviour of Java's Class.getResource is basically: the supplied file name is (unless it's already an absolute path) transformed into a relative path by using the class' package (since the directory path to the class file is expected to mirror the explicit "package" declaration for t...
0
false
1
1,564
2011-12-08 13:07:03.767
How to store data with large number (constant) of properties in SQL
I am parsing the USDA's food database and storing it in SQLite for query purposes. Each food has associated with it the quantities of the same 162 nutrients. It appears that the list of nutrients (name and units) has not changed in quite a while, and since this is a hobby project I don't expect to follow any sudden c...
Use the second (more normalized) approach. You could even get away with fewer tables than you mentioned: tblNutrients -- NutrientID -- NutrientName -- NutrientUOM (unit of measure) -- Otherstuff tblFood -- FoodId -- FoodName -- Otherstuff tblFoodNutrients -- FoodID (FK) -- NutrientID (FK) -- UOMCount It will b...
0.673066
false
1
1,565
2011-12-08 14:35:47.680
QTreeWidget and PyQt: Methods to save and read data back in from file
I'm working on a project that contains a QTreeWidget. This widget will have Parent nodes with childs nodes and or other siblings nodes. Attached to each node will be a unique ID in the form of an integer as well as a name. Now..... what methods can or should I use to save all the nodes in the QTreeWidget to disk and...
I managed this by using the data property of the TreewidgetItem by setting a value in it. Using that value as a reference to find one or more or even all TreewidgetItem(s) makes it easy to save a complete tree.
0
false
1
1,566
2011-12-09 20:37:17.777
How do I list the libraries that exist in python?
For example, in rails you can do a 'gem list' and it will show all of the gems that you have installed. Any clue how I can do this in python? Also, I am using virtualenv, not sure if that helps?
Install pip and do pip freeze. If you are using virtualenv, it is already installed in it.
0.296905
false
1
1,567
2011-12-10 00:25:45.100
Simple python code to website
I am a beginner in python. For practice reasons I want to learn how to upload a python code to a website. I have a domain and web hosting service, however I'm really confused about how to integrate my code with a web page on my website. (I have a decent bit of knowledge with Tkinter) Can anybody show me how to upload t...
I would recommend you look at something like Django and mod_wsgi. Generally helps if you have shell access to the server.
0
false
1
1,568
2011-12-10 04:15:35.990
Append system python installation's sys.path to my personal python installation
I have a system python installation and a personal python installation in my home directory. My personal python comes in ahead in my $PATH and I usually run that. But the system python installation has some modules that I want to use with my personal python installation. So, basically, I want to append the sys.path of ...
python is gonna check if there is a $PYTHONPATH environment variable set. Use that for the path of your other modules. use export PYTHONPATH="path:locations"
0.201295
false
1
1,569
2011-12-11 19:37:40.357
Making first name, last name a required attribute rather than an optional one in Django's auth User model
I'm trying to make sure that the first name and last name field are not optional for the auth User model but I'm not sure how to change it. I can't use a sub class as I have to use the authentication system. Two solutions I can think of are: to put the name in the user profile but it's a little silly to have a field t...
I would definitely go with validating on the form. You could even go as far as having more form validation in the admin if you felt like it.
1.2
true
1
1,570
2011-12-11 21:38:08.333
How do I merge results from target page to current page in scrapy?
Need example in scrapy on how to get a link from one page, then follow this link, get more info from the linked page, and merge back with some data from first page.
Partially fill your item on the first page, and the put it in your request's meta. When the callback for the next page is called, it can take the partially filled request, put more data into it, and then return it.
1.2
true
1
1,571
2011-12-12 18:51:59.977
How to evenly distribute tasks among nodes with Celery?
I am using Celery with Django to manage a task que and using one (or more) small(single core) EC2 instances to process the task. I have some considerations. My task eats 100% CPU on a single core. - uses whatever CPU available but only in one core If 2 tasks are in progress on the same core, each task will be slowed d...
it's actually easy: you start one celery-instance per ec2-instance. set concurrency to the number of cores per ec2-instance. now the tasks don't interfere and distribute nicely among you instances. (the above assumes that your tasks are cpu bound)
0.673066
false
1
1,572
2011-12-14 06:17:00.793
How to pass object between python instances
I have a genetic expression tree program to control a bot. I have a GP.py and a MyBot.py. I need to be able to have the MyBot.py access an object created in GP.py The GP.py is starting the MyBot.py via the os.system() command I have hundreds of tree objects in the GP.py file and the MyBot.py needs to evaluate them. I c...
You could serialize the object with the pickle module (or maybe json?) If you really want to stick with os.system, then you could have MyBot.py write the pickled object to a file, which GP.py could read once MyBot.py returns. If you use the subprocess module instead, then you could have MyBot.py write the pickled objec...
1.2
true
1
1,573
2011-12-14 08:59:17.003
Representing filesystem table
I’m working on simple class something like “in memory linux-like filesystem” for educational purposes. Files will be as StringIO objects. I can’t make decision how to implement files-folders hierarchy type in Python. I’m thinking about using list of objects with fields: type, name, parent what else? Maybe I should loo...
What's the API of the filestore? Do you want to keep creation, modification and access times? Presumably the primary lookup will be by file name. Are any other retrieval operations anticipated? If only lookup by name is required then one possible representation is to map the filestore root directory on to a Python dict...
0
false
2
1,574
2011-12-14 08:59:17.003
Representing filesystem table
I’m working on simple class something like “in memory linux-like filesystem” for educational purposes. Files will be as StringIO objects. I can’t make decision how to implement files-folders hierarchy type in Python. I’m thinking about using list of objects with fields: type, name, parent what else? Maybe I should loo...
You should first ask the question: What operations should my "file system" support? Based on the answer you select the data representation. For example, if you choose to support only create and delete and the order of the files in the dictionary is not important, then select a python dictionary. A dictionary will map ...
0
false
2
1,574
2011-12-14 14:22:33.660
Tornadoweb webapp cannot be managed via upstart
Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything. I investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else. Strace shows that my d...
There are two often used solutions The first one is to let your application honestly report its pid. If you could force your application to write the actual pid into the pidfile then you could get its pid from there. The second one is a little more complicated. You may add specific environment variable for the script i...
0
false
2
1,575
2011-12-14 14:22:33.660
Tornadoweb webapp cannot be managed via upstart
Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything. I investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else. Strace shows that my d...
Sorry my silence, please. Investigation of the issue ended with the knowledge about uuid python library which adds 2 forks to my daemon. I get rid of this lib and tornado daemon works now properly. Alternative answer was supervisord which can run any console tools as a daemon which can't daemonize by itself.
1.2
true
2
1,575
2011-12-14 16:40:24.343
using data from a txt file in python
I'm learning python and now I'm having some problems with reading and analyzing txt files. I want to open in python a .txt file that contains many lines and in each line I have one fruit and it's price. I would like to know how to make python recognize their prices as a number (since it recognizes as a string when I us...
I had the same problem when I first was learning Python, coming from Perl. Perl will "do what you mean" (or at least what it thinks you mean), and automatically convert something that looks like a number into a number when you try to use it like a number. (I'm generalizing, but you get the idea). The Python philosophy ...
0
false
1
1,576
2011-12-17 14:48:37.237
Find the position of difference between two strings
I have two strings of equal length, how can I find all the locations where the strings are different? For example, "HELPMEPLZ" and "HELPNEPLX" are different at positions 4 and 8.
Easiest way is to split data into two char arrays and then loop through comparing the letters and return the index when the two chars do not equal each other. This method will work fine as long as both strings are equal in length.
0
false
1
1,577
2011-12-18 12:36:37.527
How do I run Python code from Sublime Text 2?
I want to set up a complete Python IDE in Sublime Text 2. I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?
I had the same problem. You probably haven't saved the file yet. Make sure to save your code with .py extension and it should work.
0
false
4
1,578
2011-12-18 12:36:37.527
How do I run Python code from Sublime Text 2?
I want to set up a complete Python IDE in Sublime Text 2. I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?
seems the Ctrl+Break doesn't work on me, neither the Preference - User... use keys, Alt → t → c
0.025505
false
4
1,578
2011-12-18 12:36:37.527
How do I run Python code from Sublime Text 2?
I want to set up a complete Python IDE in Sublime Text 2. I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?
[ This applies to ST3 (Win), not sure about ST2 ] To have the output visible in Sublime as another file (+ one for errors), do this: Create a new build system: Tools > Build Systems > New Build System... Use the following configuration: { "cmd": ["python.exe", "$file", "1>", "$file_name.__STDOUT__.txt",...
0.126864
false
4
1,578
2011-12-18 12:36:37.527
How do I run Python code from Sublime Text 2?
I want to set up a complete Python IDE in Sublime Text 2. I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?
You can access the Python console via “View/Show console” or Ctrl+`.
0
false
4
1,578
2011-12-18 20:27:54.363
Personalizing Online Assignments for a Statistics Class
I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex/markdown + knitr/sweave, using seeds. I am now interested in developing a web-based system, that would use ...
I found one possible solution that might work using the RGoogleDocs package. I am posting this as an answer only because it is long. I am still interested in better approaches, and hence will keep the question open. Here is the gist of the idea, which is still untested. Create multiple versions of each assignment usin...
0.201295
false
2
1,579
2011-12-18 20:27:54.363
Personalizing Online Assignments for a Statistics Class
I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex/markdown + knitr/sweave, using seeds. I am now interested in developing a web-based system, that would use ...
The way you have worded your question it's not really clear why you have to mark the students' work online. Especially since you say that you generate assignments using sweave. If you use R to generate the (randomised) questions, then you really have to use R to mark them (or output the data set). For my courses, I use...
0.725124
false
2
1,579
2011-12-19 09:37:12.580
python string parsing using regular expression
Given a string #abcde#jfdkjfd, how can I get the string between two # ? And I also want that if no # pair(means no # or only one #), the function will return None.
Use (?<=#)(\w+)(?=#) and capture the first group. You can even cycle through a string which contains several embedded strings and it will work. This uses both a positive lookbehind and positive lookahead.
0.265586
false
1
1,580
2011-12-20 05:57:10.960
Running .py files
I have .ui, .py and .pyc files generated. Now, when I edit the .py file, how will it reflect changes in the .ui file? How do I connect .the ui and .py files together as QT designer allows only .ui files for running purposes?
the .py file generated from pyuic is not supposed to be edited by the user, best way it is intended to use is to subclass the class in .py file into your own class and do the necessary changes in your class..
0
false
1
1,581
2011-12-21 10:08:50.210
SQLAlchemy or psycopg2?
I am writing a quick and dirty script which requires interaction with a database (PG). The script is a pragmatic, tactical solution to an existing problem. however, I envisage that the script will evolve over time into a more "refined" system. Given the fact that it is currently being put together very quickly (i.e. I ...
To talk with database any one need driver for that. If you are using client like SQL Plus for oracle, MysqlCLI for Mysql then it will direct run the query and that client come with DBServer pack. To communicate from outside with any language like java, c, python, C#... We need driver to for that database. psycopg2 is ...
0.999967
false
2
1,582
2011-12-21 10:08:50.210
SQLAlchemy or psycopg2?
I am writing a quick and dirty script which requires interaction with a database (PG). The script is a pragmatic, tactical solution to an existing problem. however, I envisage that the script will evolve over time into a more "refined" system. Given the fact that it is currently being put together very quickly (i.e. I ...
SQLAlchemy is a ORM, psycopg2 is a database driver. These are completely different things: SQLAlchemy generates SQL statements and psycopg2 sends SQL statements to the database. SQLAlchemy depends on psycopg2 or other database drivers to communicate with the database! As a rather complex software layer SQLAlchemy does...
1.2
true
2
1,582
2011-12-21 14:43:37.823
deploying a python web application
hi every one I was wondering how to go about deploying a small time python database web application. Is buying some cheap hardware and installing a server good on it a good route to go?
You can get a virtual server instance on amazon or rackspace or many others for a very small fee per month, $20 - $60. This will give you a clean install of the OS of your choice. No need to invest in hardware. From there you can follow any of the many many tutorials on deploying a django app.
1.2
true
1
1,583
2011-12-23 13:10:01.587
How to keep global variables persistent over multiple google appengine instances?
Our situation is as follows: We are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking. As such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google app...
Interesting question. Some bad news first, I don't think there's a better way of storing data; no, you won't be able to stop new instances from spawning and no, you cannot make seperate instances always have the same data. What you could do is have the instances perioidically sync themselves with a master record in th...
0
false
3
1,584
2011-12-23 13:10:01.587
How to keep global variables persistent over multiple google appengine instances?
Our situation is as follows: We are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking. As such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google app...
You should be using memcache. If you use the ndb (new database) library, you can automatically cache the results of queries. Obviously this won't improve your writes much, but it should significantly improve the numbers of reads you can do. You need to back it with the datastore as data can be ejected from memcache at ...
1.2
true
3
1,584
2011-12-23 13:10:01.587
How to keep global variables persistent over multiple google appengine instances?
Our situation is as follows: We are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking. As such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google app...
Consider jabber protocol for communication between peers. Free limits are on quite high level for it.
0
false
3
1,584
2011-12-24 18:25:48.433
Removing cocos2d-python from Mac
I installed cocos2d today on OS X Lion, but whenever I try to import cocos in the Python interpreter, I get a bunch of import errors. File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/ python2.7/site-packages/cocos2d-0.5.0-py2.7.egg/cocos/init.py", line 105, in import_...
You could fix it. The problem comes from the fact that cocos2D is built on top of Pyglet, and the stable release of pyglet does not yet support Mac OS X 64 bits architecture. You have to use the 1.2 release of pyglet or later, which by now is not released yet. A workaround is to remove any existing Pyglet install: pip ...
1.2
true
1
1,585
2011-12-24 23:22:13.187
Python's math module & "Think Python"
I'm stucked on the chapter 3.3 "Math functions" of "Think Python". It tells me to import math (through the interpreter). Then print math and that I should get something like this: <module 'math' from '/usr/lib/python2.5/lib-dynload/math.so'> Instead I get <module 'math' <built-in>> Anyway that's not the problem. Though...
You've figured it out - you have to set signal_power's value before using it. As to what you have to set it to - it's not really a Python related question, but 1 is always a safe choice :) While you are at it, don't forget to define noise_power.
0.296905
false
1
1,586
2011-12-25 09:05:56.223
How to delay/postpone Gearman job?
I'm using gearman for synchronizing data on different servers. We have 1 main server and, for example, 10 local servers. Let me describe one of possible situations. Say, gearman started working, and 5 jobs are done, data on that 5 servers is synced. When doing the next job is started, say, we lost the connection with s...
Gearman jobs can run in parallel or series. Instead of using single jobs, you should use concurrent jobs (one for each server).
0
false
1
1,587
2011-12-25 20:50:13.417
Click the javascript popup through webdriver
I am scraping a webpage using Selenium webdriver in Python The webpage I am working on, has a form. I am able to fill the form and then I click on the Submit button. It generates an popup window( Javascript Alert). I am not sure, how to click the popup through webdriver. Any idea how to do it ? Thanks
that depends on the javascript function that handles the form submission if there's no such function try to submit the form using post
0
false
1
1,588
2011-12-27 03:07:15.233
Completely lost: Python configure script runs with errors
I downloaded tarball of python 2.7.2 to install on Suse Linux server--it comes with 2.6 and 3.1. Untarred it (I know--wrong lingo, sorry) to a directory. When trying to run ./configure, which should create a valid makefile I can't get past the step one: the script reports that it can't find a compiler on the path. But...
Suse has a package manager called Yast. It would do your installation with no fuss.
0
false
1
1,589
2011-12-27 21:20:01.587
How do I transfer data between two computers ?
I have two computers on a network. I'll call the computer I'm working on computer A and the remote computer B. My goal is to send a command to B, gather some information, transfer this information to computer A and use this in some meaningfull way. My current method follows: Establish a connection to B with paramiko. ...
I have been doing something similar on a larger scale (with 15 clients). I use the pexpect module to do essentially ssh commands on the remote machine (computer B). Another module to look into would be the subprocess module.
0
false
1
1,590
2011-12-28 01:50:26.573
How to cache using Pyramid?
I've looked in the documentation and haven't seen (from first sight) anything about cache in Pyramid. Maybe I missed something... Or maybe there are some third party packages to help with this. For example, how to cache db query (SQLAlchemy), how to cache views? Could anyone give some link to examples or documentation?...
Your options are pyramid_beaker and dogpile.cache pyramid_beaker was written to offer beaker caching for sessions. it also lets you configure beaker cache regions, which can be used elsewhere. dogpile.cache is a replacement for beaker. it hasn't been integrated to offer session support or environment.ini based setup...
0.995055
false
1
1,591
2011-12-28 01:51:48.053
Thermostat Control Algorithms
I am wondering exactly how a thermostat program would work and wanted to see if anyone had a better opinion on it. From what I know, there are a few control algorithms that could be used, some being Bang-Bang (On/Off), Proportional Control Algorithms, and PID Control. Looking on Wikipedia, there is a great deal of expl...
The issue is overshooting the setpoint temperature. If you simply run the device until the set point temperature is reached, you will overshoot, wasting energy (and possibly doing damage, depending on what the thermostat controls.) You need to "ease up to" the setpoint so that you arrive at the set point just as the de...
1.2
true
1
1,592
2011-12-28 03:54:46.327
OpenERP - Report Creation
I am trying to create a new report with report plugin and openoffice but I don't know how to assign it in the OpenERP system. Is there someone who can give me exact steps for creation of new report and integration with openerp? Thanks in advance!
First you save .odt file then connect with server and select open new report and then send it ti server with proper report name and then keep on editing your report by selecting the option modify existing report.
0.101688
false
1
1,593
2011-12-28 23:36:06.063
Plotting Complex Numbers in Python?
For a math fair project I want to make a program that will generate a Julia set fractal. To do this i need to plot complex numbers on a graph. Does anyone know how to do this? Remember I am using complex numbers, not regular coordinates. Thank You!
You could plot the real portion of the number along the X axis and plot the imaginary portion of the number along the Y axis. Plot the corresponding pixel with whatever color makes sense for the output of the Julia function for that point.
0.386912
false
2
1,594
2011-12-28 23:36:06.063
Plotting Complex Numbers in Python?
For a math fair project I want to make a program that will generate a Julia set fractal. To do this i need to plot complex numbers on a graph. Does anyone know how to do this? Remember I am using complex numbers, not regular coordinates. Thank You!
Julia set renderings are generally 2D color plots, with [x y] representing a complex starting point and the color usually representing an iteration count.
0
false
2
1,594
2011-12-29 02:33:05.313
How do I transform every doc in a large Mongodb collection without map/reduce?
Apologies for the longish description. I want to run a transform on every doc in a large-ish Mongodb collection with 10 million records approx 10G. Specifically I want to apply a geoip transform to the ip field in every doc and either append the result record to that doc or just create a whole other record linked to th...
Actually I am also attempting another approach in parallel (as plan B) which is to use mongoexport. I use it with --csv to dump a large csv file with just the (id, ip) fields. Then the plan is to use a python script to do a geoip lookup and then post back to mongo as a new doc on which map-reduce can now be run for c...
0
false
2
1,595
2011-12-29 02:33:05.313
How do I transform every doc in a large Mongodb collection without map/reduce?
Apologies for the longish description. I want to run a transform on every doc in a large-ish Mongodb collection with 10 million records approx 10G. Specifically I want to apply a geoip transform to the ip field in every doc and either append the result record to that doc or just create a whole other record linked to th...
Since you have to go over "each record", you'll do one full table scan anyway, then a simple cursor (find()) + maybe only fetching few fields (_id, ip) should do it. python driver will do the batching under the hood, so maybe you can give a hint on what's the optimal batch size (batch_size) if the default is not good e...
1.2
true
2
1,595
2011-12-29 22:08:12.297
Website Links to Downloadable Files Don't Seem to Update
I have a problem with links on my website. Please forgive me if this is asked somewhere else, but I have no idea how to search for this. A little background on the current situation: I've created a python program that randomly generates planets for a sci-fi game. Each created planet is placed in a text file to be viewe...
I don't know anything about Python, but in PHP, in some fopen modes, if a file is trying to be made with the same name as an existing file, it will cancel the operation.
0
false
1
1,596
2011-12-30 06:05:55.800
getting 64 bit integer in python
So I am thinking of writing a bitboard in python or lisp. But I don't know how to ensure I would get a 64 bit integer in python. I have been reading documentation and found that mpz library returns a unsigned 32 bit integer. Is this true? If not what should I do?
Python 2 has two integer types: int, which is a signed integer whose size equals your machine's word size (but is always at least 32 bits), and long, which is unlimited in size. Python 3 has only one integer type, which is called int but is equivalent to a Python 2 long.
1
false
1
1,597
2011-12-30 20:00:00.603
Robocode + Python
The question is, how do you make a robot for Robocode using Python? There seem to be two options: Robocode + Jython Robocode for .NET + Iron Python There's some info for the first, but it doesn't look very robust, and none for the latter. Step by step, anyone?
As long as your java-class extends robocode.Robot everything is recognized as robot. It doesn't matter where you put the class.
0.386912
false
1
1,598
2011-12-31 14:51:11.027
how to decompile user password in django
I have a SECRET_KEY, how do i decompile a user password using python? I assume that the encryption method is sha1. thanks.
You are asking the impossible. The passwords are salted and hashed. The way they're validated is by performing the same process on the re-supplied password. There's no way to 'decrypt' it.
1.2
true
1
1,599
2012-01-02 14:39:08.840
How would I create "Omegle"-like random chat with gevent?
I have searched tutorials and documentation for gevent, but seems that there isn't lots of it. I have coded Python for several years, also I can code PHP + JavaScript + jQuery. So, how would I create Omeglish chat, where one random person connects and then waits for another one to connect? I have understood that Omegle...
If I've understood you right, you just need to link the second person with someone connected before. Think it's simple. The greenlet working with a person who comes first ('the first greenlet') just register somewhere it's inbound and outbound queues. The greenlet working with the second person gets this queues, unreg...
1.2
true
1
1,600
2012-01-03 00:53:28.813
Generating IDs how to make IDs same length using zeroes?
Update: The requirement is "fixed length 9 digits" so 460 000 000 138 should be 460 000 138 I want to generate IDs on a special form such as 460 000 000 138 where 46 is the country code and the rest is the ID and this number always(?) has the same number of digits ie four pairs of threes. My input is this ID that can b...
"always(?)" indeed. Sweden = 46 looks like you mean the telephone not-necessarily-a-country code which is VARIABLE LENGTH ... for example CHINA = 86, HONG KONG (not a country) = 852, CANADA = USA = 1. Is your ID allowed to be variable length or not? If it is allowed to be variable, you would need do str(countrycode) + ...
0.135221
false
1
1,601
2012-01-03 03:42:56.000
how to copy an executable file with python?
How can i copy a .exe file through python? I tried to read the file and then write the contents to another but everytime i try to open the file it say ioerror is directory. Any input is appreciated. EDIT: ok i've read through the comments and i'll edit my code and see what happens. If i still get an error i'll post my ...
Use shutil.copyfile(src, dst) or shutil.copy(src, dst). It may not work in case of files in the C:\Program Files\ as they are protected by administrator rights by default.
0
false
2
1,602
2012-01-03 03:42:56.000
how to copy an executable file with python?
How can i copy a .exe file through python? I tried to read the file and then write the contents to another but everytime i try to open the file it say ioerror is directory. Any input is appreciated. EDIT: ok i've read through the comments and i'll edit my code and see what happens. If i still get an error i'll post my ...
Windows Vista and 7 will restrict your access to files installed into the Programs directories. Unless you run with UAC privileges you will never be able to open them. I hope I'm interpreting your error properly. In the future it is best to copy and paste the actual error message into your question.
0.081452
false
2
1,602
2012-01-03 16:37:26.713
how to share variable between python and go language?
i need to know how share variable between two program, basically the go program have to write a variable ,like a string, and the python program have to read this variable. Please help me, thank you in advance.
use standard streams. use a simple printf type command to print the string to stdout. then read it with a raw_input() in python. run the two programs like so: ./output | ./read.py
1.2
true
2
1,603
2012-01-03 16:37:26.713
how to share variable between python and go language?
i need to know how share variable between two program, basically the go program have to write a variable ,like a string, and the python program have to read this variable. Please help me, thank you in advance.
In Windows, most common way to do communication between two processes is "Named Pipe" (could also be tcp/ip, web service, etc...). A ugly but lighter way is to write the value to a file, and read it from python.
0.201295
false
2
1,603
2012-01-04 04:03:34.797
How to transfer a file between two connected computers in python?
I don't know if this has been answered before(i looked online but couldn't find one), but how can i send a file (.exe if possible) over a network to another computer that is connected to the network? I tried sockets but i could only send strings and i've tried to learn ftplib but i don't understand it at all or if ftp ...
ZeroMQ helps to replace sockets. You can send an entire file in one command. A ZMQ 'party' can be written in any major language and for a given ZMQ-powered software, it doesnt matter what the other end it written in. From their site: It gives you sockets that carry whole messages across various transports like in-p...
0.296905
false
1
1,604
2012-01-04 17:26:46.170
How to start a script based on an event?
I'm in a red hat environment. I need to move a file from server A to server B when a file is available in a folder F. THere's no constraint on the method used. Is it possible to trigger this event in python or any other scripts? It could be run as a daemon but I'm not sure how to do that. Any advices?
This is a job for cron. Cron man, man cron!
-0.067922
false
1
1,605
2012-01-05 01:13:52.487
Parallel computing
I have a two dimensional table (Matrix) I need to process each line in this matrix independently from the others. The process of each line is time consuming. I'd like to use parallel computing resources in our university (Canadian Grid something) Can I have some advise on how to start ? I never used parallel computing ...
Like the commentators have said, find someone to talk to in your university. The answer to your question will be specific to what software is installed on the grid. If you have access to a grid, it's highly likely you also have access to a person whose job it is to answer your questions (and they will be pleased to h...
0
false
1
1,606
2012-01-05 20:13:13.497
Python: import symbolic link of a folder
I have a folder A which contains some Python files and __init__.py. If I copy the whole folder A into some other folder B and create there a file with "import A", it works. But now I remove the folder and move in a symbolic link to the original folder. Now it doesn't work, saying "No module named foo". Does anyone know...
This kind of behavior can happen if your symbolic links are not set up right. For example, if you created them using relative file paths. In this case the symlinks would be created without error but would not point anywhere meaningful. If this could be the cause of the error, use the full path to create the links and c...
0.999329
false
1
1,607
2012-01-07 18:46:22.470
how long can i store data in cPickle?
I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?
You can store it for as long as you want. It's just a file. However, if your data structures start becoming complicated, it can become tedious and time consuming to unpickle, update and pickle the data again. Also, it's just file access so you have to handle concurrency issues by yourself.
1.2
true
3
1,608
2012-01-07 18:46:22.470
how long can i store data in cPickle?
I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?
cPickle is just a faster implementation of pickle. You can use it to convert a python object to its string equivalent and retrieve it back by unpickling. You can do one of the two things with a pickled object: Do not write to a file In this case, the scope of your pickled data is similar to that of any other variable...
0
false
3
1,608
2012-01-07 18:46:22.470
how long can i store data in cPickle?
I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?
No. cPickle just writes data to files and reads it back; why would you think there would be a limit?
0
false
3
1,608