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 |
|---|---|---|---|---|---|---|---|
2010-05-17 02:14:40.500 | Python: How do I create a reference to a reference? | I am traditionally a Perl and C++ programmer, so apologies in advance if I am misunderstanding something trivial about Python!
I would like to create a reference to a reference.
Huh? Ok. All objects in Python are actually references to the real object.
So, how do I create a reference to this reference?
Why do I need/... | This can't be done. Pass the desired attribute as a string and use getattr() and setattr(). | 0 | false | 1 | 563 |
2010-05-17 12:48:31.233 | Suggestions for a pluggable task framework in Django | I am developing a website which is aimed at being a GUI for several image processing algorithms (referred to as 'tasks').
At the moment, only one of these algorithms is finished, but there are more to come (which will have a similar, but not quite the same, workflow)
Basically, the algorithm works as follows (not that ... | I would make an app with a very abstract definition of a Task model. The Task model might contain properties for:
the input arguments,
the function to run,
the time that the task was submitted,
the time that the task has been actually running, and
the result (which would be something like a singleton Task.NotFinis... | 0 | false | 1 | 564 |
2010-05-17 18:21:51.340 | Using virtualenv to install different versions of same package | Since I have Django 1.1x on my Debian setup - how can I use virtualenv or similar and not have it mess up my system's default django version which in turn would break all my sites?
Detailed instructions or a great tutorial link would very much be appreciated - please don't offer vague advice since I'm still a noob.
Cur... | If you have easy_install, or better yet pip installed, should be as easy as:
easy_install/pip install virtualenv
mkdir django1.2
virtualenv django1.2
This will put the python binary in a bin folder inside the django1.2 folder. Just use that python binary, and you've got a nice little self-contained environment. You c... | 1.2 | true | 1 | 565 |
2010-05-18 07:52:19.637 | ropemacs USAGE tutorial | There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has "Rope" menu in it's top menu bar. Now what? So far I could use only "Show documentation" (C-c d by defaul... | You can set the root folder with rope-open-project . Once you've set the root project a .ropeproject dir will be created.
Inside it, a config.py file has hooks where you can run (python) code once the project is set. The project_opened(project): function is a good place to run code. I usually activate the virtual envi... | 0.986614 | false | 1 | 566 |
2010-05-18 13:24:38.767 | How can I create a GUI on top of a Python APP so it can do either GUI or CLI? | I am trying to write an app in python to control a motor using serial. This all works in a CLI situation fine and is generally stable. but I was wondering how simple it was to add a GUI on top of this code base?
I assume there will be more code, but is there a simple way of detecting something like GTK, so it only appl... | I don't recommend doing a GUI in XML. All the XML does is give you a mini language for describing a layout. Why use a mini language when you can have the full power of python?
As for detecting GTK, I wouldn't suggest that. Instead, add a command line argument to determine whether to create a GUI or not (eg: myprogram -... | 0 | false | 1 | 567 |
2010-05-18 14:14:02.787 | Django Inlines user permissions + view only - permissions issues | I'm not sure if this is a bug or I'm just missing something (although I have already parsed the documentation about inlines), but:
Let's say I have a model A. Model A is an inline of model B. User U has full access to model B, but only change permissions to model A (so, no add, nor delete).
However, when editing model ... | If I want a read-only version of what's in the admin, I just write some normal Django views and keep them out of the admin.
I don't think the kind of thing you're talking about (allowing changes to an object but not its inlines) is really supported by the admin. Don't get me wrong: the admin is very flexible and usefu... | 1.2 | true | 1 | 568 |
2010-05-18 17:06:52.540 | Distributing an executable zip file with __main__.py, how to access extra data? | I'm doing a little program and I want to distribute it using this recipe:
single directory with __main__.py in it
zip this directory and adding a shebang on it #!/usr/bin/env python
making it executable
The problem is that in this package I have also extra files (I'm using pygtk toolkit and I need images and ui xml f... | I figured out by myself, It's sufficient to use pkgutil.get_data to access the data inside a package. | 1.2 | true | 1 | 569 |
2010-05-18 23:22:21.140 | Queue remote calls to a Python Twisted perspective broker? | The strength of Twisted (for python) is its asynchronous framework (I think). I've written an image processing server that takes requests via Perspective Broker. It works great as long as I feed it less than a couple hundred images at a time. However, sometimes it gets spiked with hundreds of images at virtually the sa... | You might also like the txRDQ (Resizable Dispatch Queue) I wrote. Google it, it's in the tx collection on LaunchPad. Sorry I don't have more time to reply - about to go onstage.
Terry | -0.386912 | false | 1 | 570 |
2010-05-20 17:17:10.437 | What's the most scalable way to handle somewhat large file uploads in a Python webapp? | We have a web application that takes file uploads for some parts. The file uploads aren't terribly big (mostly word documents and such), but they're much larger than your typical web request and they tend to tie up our threaded servers (zope 2 servers running behind an Apache proxy).
I'm mostly in the brainstorming p... | See if you can push the files straight from the user's browser to a static file store, like Amazon S3 or rackspace's cloudfiles service.
Then you can handle a ton of parallel users. | 0 | false | 1 | 571 |
2010-05-23 03:10:52.283 | How to generate graphs and statistics from SQLAlchemy tables? | After running a bunch of simulations I'm going to be outputting the results into a table created using SQLAlchemy. I plan to use this data to generate statistics - mean and variance being key. These, in turn, will be used to generate some graphs - histograms/line graphs, pie-charts and box-and-whisker plots specificall... | It looks like matplotlib takes simple python data types -- lists of numbers, etc, so you'll be need to write custom code to massage what you pull out of mysql/sqlalchemy for input into the graphing functions... | 1.2 | true | 1 | 572 |
2010-05-23 22:09:10.470 | Where to use a pyc file | I want to know what a pyc file(python bytecode) is. I want to know all the details.
I want to know about how pyc files interface with the compiler. Is it a replacement for exe?
Does it need to be run by python?
Is it as portable as the .py file is?
Where should I use this? | Python bytecode requires Python to run, cannot be ran standalone without Python, and is specific to a particular x.y release of Python. It should be portable across platforms for the same version. There is not a common reason for you to use it; Python uses it to optimize out parsing of your .py file on repeated imports... | 0.995055 | false | 1 | 573 |
2010-05-24 01:07:28.420 | how do i edit a running python program? | scenario: a modular app that loads .py modules on the fly as it works. programmer (me) wishes to edit the code of a module and then re-load it into the program without halting execution.
can this be done?
i have tried running import a second time on an updated module.py, but the changes are not picked up | Alex's answer and the others cover the general case.
However, since these modules you're working on are your own and you'll edit only them, it's possible to implement some kind of a local reloading mechanism rather than rely on the builtin reload. You can architect your module loader as something that loads up the fil... | 0 | false | 1 | 574 |
2010-05-24 21:11:10.030 | how to set MATLABPATH in Python and using mlabwrap? | I tried to use mlab.path(path,'/my/path') but failed. Got NameError: name 'path' is not defined in python. Anyone has an idea? | Never mind. I found out how. Use mlab.addpath(). | 1.2 | true | 1 | 575 |
2010-05-25 18:43:59.550 | Good real-world uses of metaclasses (e.g. in Python) | I'm learning about metaclasses in Python. I think it is a very powerful technique, and I'm looking for good uses for them. I'd like some feedback of good useful real-world examples of using metaclasses. I'm not looking for example code on how to write a metaclass (there are plenty examples of useless metaclasses out th... | SQLalchemy also uses them for declarative database models.
Sorry my answer isn't very different from your example, but if you're looking for example code, I found declarative to be pretty readable. | 0 | false | 1 | 576 |
2010-05-26 00:21:50.267 | Is it bad practice to use python's getattr extensively? | I'm creating a shell-like environment. My original method of handleing user input was to use a dictionary mapping commands (strings) to methods of various classes, making use of the fact that functions are first class objects in python.
For flexibility's sake (mostly for parsing commands), I'm thinking of changing my s... | does getattr have the same problems as eval?
No -- code using eval() is terribly annoying to maintain, and can have serious security problems. Calling getattr(x, "foo") is just another way to write x.foo.
will I be taking a hit to the efficiency of my shell
It will be imperceptibly slower if the command isn't found... | 0.999909 | false | 1 | 577 |
2010-05-26 10:16:41.307 | clicked() signal for QListView in PyQt4 | I have a working QListView, but from the documentation, I can't figure out how to get a signal to fire with the index of the newly selected item. Any ideas? | Imho, an easier way to achieve this would be to use a QListWidget instead of a QListView, this way you could use the itemClicked signal, which sends the selected item to the callback function. | 0.201295 | false | 1 | 578 |
2010-05-26 19:30:41.847 | Distributing a Python library (single file) | For my project I would be using the argparse library. My question is, how do I distribute it with my project. I am asking this because of the technicalities and legalities involved.
Do I just:
Put the argparse.py file along with
my project. That is, in the tar file for my project.
Create a package for it for my
distr... | It would be best for the user to install it so that only one copy is present on the system and so that it can be updated if there are any issues, but including it with your project is a viable option if you abide by all requirements specified in the license.
Try to import it from the public location, and if that fails ... | 0.135221 | false | 1 | 579 |
2010-05-27 21:48:08.913 | Get "2:35pm" instead of "02:35PM" from Python date/time? | I'm still a bit slow with Python, so I haven't got this figured out beyond what's obviously in the docs, etc.
I've worked with Django a bit, where they've added some datetime formatting options via template tags, but in regular python code how can I get the 12-hour hour without a leading zero?
Is there a straightforw... | I know it's pretty cheap, but you could just discard the first character if it's a zero :) | 0.050976 | false | 1 | 580 |
2010-05-28 19:46:30.730 | Methods of sending web-generated config files to servers and restarting services | We're writing a web-based tool to configure our services provided by multiple servers. This includes interfaces configuration, dhcp configs etc. etc.
Having configs in database and views that generate proper output, how to send it/make it available for servers?
I'm thinking about sending it through scp and invoking rel... | It really depends what you're intending to do, as the question is a little vague. The other answers cover the tools available; choosing one over the other comes down to purpose.
Are you intending to manage servers, and services on those servers? If so, try Puppet, CFEngine, or some other tool for managing server conf... | 0 | false | 1 | 581 |
2010-05-29 15:35:55.667 | Task Queue stopped working | I was playing with Goole App Engine Task Queue API to learn how to use it. But I couldn't make it trigger locally. My application is working like a charm when I upload to Google servers. But it doesn't trigger locally. All I see from the admin is the list of the tasks. But when their ETA comes, they just pass it. It's ... | The development server won't run tasks automatically, you have to set them off yourself.
It's a design feature, so you can see what happens when you run them, instead of them running at any point.
Essentially, there's nothing wrong with your application, it's a feature of development server. | 1.2 | true | 1 | 582 |
2010-05-29 16:46:00.447 | can a python script know that another instance of the same script is running... and then talk to it? | I'd like to prevent multiple instances of the same long-running python command-line script from running at the same time, and I'd like the new instance to be able to send data to the original instance before the new instance commits suicide. How can I do this in a cross-platform way?
Specifically, I'd like to enable t... | Sounds like your best bet is sticking with a pid file but have it not only contain the process Id - have it also include the port number that the prior instance is listening on. So when starting up check for the pid file and if present see if a process with that Id is running - if so send your data to it and quit othe... | 0 | false | 2 | 583 |
2010-05-29 16:46:00.447 | can a python script know that another instance of the same script is running... and then talk to it? | I'd like to prevent multiple instances of the same long-running python command-line script from running at the same time, and I'd like the new instance to be able to send data to the original instance before the new instance commits suicide. How can I do this in a cross-platform way?
Specifically, I'd like to enable t... | Perhaps try using sockets for communication? | 0.101688 | false | 2 | 583 |
2010-05-30 05:06:28.333 | large amount of data in many text files - how to process? | I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and... | Yes. You are right! I/O would cost most of your processing time. I don't suggest you to use distributed systems, like hadoop, for this task.
Your task could be done in a modest workstation. I am not an Python expert, I think it has support for asynchronous programming. In F#/.Net, the platform has well support for tha... | 0.050976 | false | 4 | 584 |
2010-05-30 05:06:28.333 | large amount of data in many text files - how to process? | I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and... | (3) is not necessarily a bad idea -- Python makes it easy to process "CSV" file (and despite the C standing for Comma, tab as a separator is just as easy to handle) and of course gets just about as much bandwidth in I/O ops as any other language. As for other recommendations, numpy, besides fast computation (which you... | 1.2 | true | 4 | 584 |
2010-05-30 05:06:28.333 | large amount of data in many text files - how to process? | I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and... | When you say "accumulating" then solution (2) looks most suitable to problem.
After initial load up to database you only update database with new files (daily, weekly? depends how often you need this).
In cases (1) and (3) you need to process files each time (what was stated earlier as most time/resources-consuming), u... | 0.101688 | false | 4 | 584 |
2010-05-30 05:06:28.333 | large amount of data in many text files - how to process? | I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and... | With terabytes, you will want to parallelize your reads over many disks anyway; so might as well go straight into Hadoop.
Use Pig or Hive to query the data; both have extensive support for user-defined transformations, so you should be able to implement what you need to do using custom code. | 0.201295 | false | 4 | 584 |
2010-05-31 08:47:26.927 | python dictionary with constant value-type | I bumped into a case where I need a big (=huge) python dictionary, which turned to be quite memory-consuming.
However, since all of the values are of a single type (long) - as well as the keys, I figured I can use python (or numpy, doesn't really matter) array for the values ; and wrap the needed interface (in: x ; ou... | You might try using std::map. Boost.Python provides a Python wrapping for std::map out-of-the-box. | 0 | false | 1 | 585 |
2010-05-31 17:30:45.823 | python intercepting communication | lets say you run third party program on your computer whitch create a process named example.exe
how do i determinate if this process is running and how many windows does he open? How do i intercept network communication between this windows and server?
my goal is to create an app whitch will be monitoring network trafi... | You could use wireshark from wireshark.org to sniff the network traffic (or any other packet sniffer). | 0 | false | 1 | 586 |
2010-06-01 02:54:27.960 | python imaging library draw text new line how to? | i have a word that will be putted on a image but the problem is that the word continues even though the word exceeds the width of the image
is there anyway that the word shift's down if the word exceeds the width of the image or on a certain point the word shift's down if it exceeds the given point | PIL won't automatically do this, but you could easily do it yourself using the getsize method in the ImageFont module. That is, if the text is too big, just split it so that it's not, and put the rest on the next line. (You may want to do this recursively in case the text spans multiple lines.) | 0.999988 | false | 1 | 587 |
2010-06-02 20:36:22.790 | How to transition from PHP to Python Django? | Here's my background:
Decent experience with PHP/MySql.
Beginner's experience with OOP
Why I want to learn Python Django?
I gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes ... | No. You can only do a LOT better.
Awesome, popular. Supported by best hosters like Mediatemple.
No. You can just change 'mysql' to 'postgresql' or 'sqlite' in your settings.py.
NO! Python would never give you the right to mix up everything in one file and make the shittest shit in the world. Templates, static server.
... | 0.101688 | false | 2 | 588 |
2010-06-02 20:36:22.790 | How to transition from PHP to Python Django? | Here's my background:
Decent experience with PHP/MySql.
Beginner's experience with OOP
Why I want to learn Python Django?
I gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes ... | Can i do everything in Django as in PHP?
Always
Is Django a "big" hit in web development as PHP?
Only time will tell.
With PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql?
Django supports several RDBMS interfaces. MySQL is popular, so is SQLite and Postgres.
In PHP... | 1.2 | true | 2 | 588 |
2010-06-03 00:28:13.580 | Is PyOpenGL a good place to start learning opengl programming? | I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble?
I know C++ giv... | PyOpenGL
I don't think it is a good choice. In my opinon in C/C++ it is easier to play around around with your OpenGL code - start with simple app, then add shader, then add some geometry functions, make a texture/geometry generator, build scene via CSG, etc. You know - to have fun, play around with code, experiment a... | 0 | false | 2 | 589 |
2010-06-03 00:28:13.580 | Is PyOpenGL a good place to start learning opengl programming? | I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble?
I know C++ giv... | With the caveat that I have done very little OpenGL programming myself, I believe that for the purposes of learning, PyOpenGL is a good choice. The main reason is that PyOpenGL, like most other OpenGL wrappers, is just that: a thin wrapper around the OpenGL API.
One large benefit of PyOpenGL is that while in C you ha... | 1.2 | true | 2 | 589 |
2010-06-03 13:57:43.117 | C++ code generation with Python | Can anyone point me to some documentation on how to write scripts in Python (or Perl or any other Linux friendly script language) that generate C++ code from XML or py files from the command line. I'd like to be able to write up some xml files and then run a shell command that reads these files and generates .h files ... | A few years ago I worked on a project to simplify interprocess shared memory management for large scale simulation systems. We used a related approach where the layout of data in shared memory was defined in XML files and a code generator, written in python, read the XML and spit out a set of header files defining stru... | 0.050976 | false | 1 | 590 |
2010-06-03 22:20:11.297 | from string of bytes to OpenCV's IplImage in Python? | I am streaming some data down from a webcam. When I get all of the bytes for a full image (in a string called byteString) I want to display the image using OpenCV. Done fast enough, this will "stream" video from the webcam to an OpenCV window.
Here's what I've done to set up the window:
cvNamedWindow('name of window', ... | I actually solved this problem and forgot to post the solution. Here's how I did it, though it may not be entirely robust:
I analyzed the headers coming from the MJPEG of the network camera I was doing this to, then I just read from the stream 1 byte at a time, and, when I detected that the header of the next image was... | 0.386912 | false | 1 | 591 |
2010-06-04 15:19:33.893 | include udf in python? | i've a small user defined function in python, say fib(n), how do i use that in other programs or modules?
def fib(n):
should i use import or is there any other feature?
Also i'm learning python in eclipse IDE, it wont support
print "any string"
but i'm forced to use like,
print("string")
in python manual online, it... | You use import to include the function in other programs. Just say import mymodule where the code is located in file mymodule.py. Then say mymodule.fib to use the function.
To answer your second question: The syntax print "any string" is acceptable in Python 2, but is no longer allowed in Python 3. | 1.2 | true | 1 | 592 |
2010-06-04 21:01:38.043 | add xml node to xml file with python | I wonder if it is better add an element by opening file, search 'good place' and add string which contains xml code.
Or use some library... i have no idea. I know how can i get nodes and properties from xml through for example lxml but what's the simpliest and the best way to add? | The safest way to add nodes to an XML document is to load it into a DOM, add the nodes programmatically and write it out again. There are several Python XML libraries. I have used minidom, but I have no reason to recommend it specifically over the others. | 0.201295 | false | 1 | 593 |
2010-06-05 08:31:20.853 | Coloring close points | I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that ..
I'm using Tkint... | One approach is to go through your points and partition them into sets with a "center". Since you have 5 colours, you'll have 5 sets. You compare the distance of the new point from each of the centers and then put it in the same group as the closest one.
Each set corresponds to a different colour so you can just plot i... | 0 | false | 2 | 594 |
2010-06-05 08:31:20.853 | Coloring close points | I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that ..
I'm using Tkint... | I'd start with identifying the concentrations of the spots in the plane. Find the centers of those agglomerations and assign them each unique color. Then for other spots you could simply calculate the color using the linear principle. For example, if one center is red and the other is yellow, a point somewhere in the m... | 0 | false | 2 | 594 |
2010-06-06 19:53:26.243 | Adding percentage in python - xlwt / pyexcelerator | just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent.
Ty in advance.
Regards. | Note carefully: "modifying" and "multiplies with 100" affect the displayed result, they affect neither the value stored in the file nor the value used in formula calculations.
The technique of making an operator be treated as a literal is known as "escaping".
The escape character in Excel number format strings is the ... | 1.2 | true | 2 | 595 |
2010-06-06 19:53:26.243 | Adding percentage in python - xlwt / pyexcelerator | just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent.
Ty in advance.
Regards. | The 00.0% number format expects percentages, so multiplying by 100 to display it is the correct behavior. To get the results you want, you could either put the data in the cell as a string in whatever format you choose or you could divide by 100.0 before you store the value in the cell. | 0.101688 | false | 2 | 595 |
2010-06-07 02:24:39.973 | what should i do after openid (or twitter ,facebook) user login my site ,on gae | how to integration local user and openid(or facebook twitter) user ,
did you know some framework have already done this ,
updated
my mean is : how to deal with 'local user' and 'openid user',
and how to mix them in one model .
please give me a framework that realize 'local user' and 'openid user' | I understand your question.
You wish to be able to maintain a list of users that have signed up with your service, and also want to record users using OpenID to authenticate.
In order to solve this I would do either of the following:
Create a new user in your users table for each new user logged in under OpenID, and s... | 0.386912 | false | 1 | 596 |
2010-06-07 09:11:31.053 | How to read a single character at a time from a file in Python? | Can anyone tell me how can I do this? | You should try f.read(1), which is definitely correct and the right thing to do. | 0.029146 | false | 1 | 597 |
2010-06-09 03:55:24.860 | Fetching a random record from the Google App Engine Datastore? | I have a datastore with around 1,000,000 entities in a model. I want to fetch 10 random entities from this.
I am not sure how to do this? can someone help? | Assign each entity a random number and store it in the entity. Then query for ten records whose random number is greater than (or less than) some other random number.
This isn't totally random, however, since entities with nearby random numbers will tend to show up together. If you want to beat this, do ten queries bas... | 1.2 | true | 1 | 598 |
2010-06-09 11:54:40.923 | PyGTK: how to make a clipboard monitor? | How can I make a simple clipboard monitor in Python using the PyGTK GUI?
I found gtk.clipboard class and but I couldn't find any solution to get the "signals" to trigger the event when the clipboard content has changed.
Any ideas? | Without a proper notification API, such as WM_DrawClipboard messages, you would probably have to resort to a polling loop. And then you will cause major conflicts with other apps that are trying to use this shared resource.
Do not resort to a polling loop. | 1.2 | true | 1 | 599 |
2010-06-09 14:28:39.490 | how to speed up the code? | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling ... | As a general strategy, it's best to keep this data in an in-memory cache if it's static, and relatively small. Then, the 10k calls will read an in-memory cache rather than a file. Much faster.
If you are modifying the data, the alternative might be a database like SQLite, or embedded MS SQL Server (and there are others... | 0.240117 | false | 4 | 600 |
2010-06-09 14:28:39.490 | how to speed up the code? | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling ... | Opening, closing, and reading a file 10,000 times is always going to be slow. Can you open the file once, do 10,000 operations on the list, then close the file once? | 0.16183 | false | 4 | 600 |
2010-06-09 14:28:39.490 | how to speed up the code? | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling ... | Call the open to the file from the calling method of the one you want to run. Pass the data as parameters to the method | 0 | false | 4 | 600 |
2010-06-09 14:28:39.490 | how to speed up the code? | in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.
I approximatily need to call this method about 10,000 times.which is making my program very slow?
any method for handling ... | If the files are structured, kinda configuration files, it might be good to use ConfigParser library, else if you have other structural format then I think it would be better to store all this data in JSON or XML and perform any necessary operations on your data | 0 | false | 4 | 600 |
2010-06-09 16:11:57.480 | how to speed up code? | i want to speed my code compilation..I have searched the internet and heard that psyco is a very tool to improve the speed.i have searched but could get a site for download.
i have installed any additional libraries or modules till date in my python..
can psyco user,tell where we can download the psyco and its installa... | So it seems you don't want to speed up the compile but want to speed up the execution.
If that is the case, my mantra is "do less." Save off results and keep them around, don't re-read the same file(s) over and over again. Read a lot of data out of the file at once and work with it.
On files specifically, your perfor... | 0.201295 | false | 1 | 601 |
2010-06-10 08:07:48.540 | how to make a chat room on gae ,has any audio python-framework to do this? | i want to make a chat room on gae ,(audio chat)
has any framework to do this ?
thanks | You'll need two things:
A browser plugin to get audio. You could build this on top of eg. http://code.google.com/p/libjingle/'>libjingle which has the advantage of being cross-platform and allowing P2P communication, not to mention being able to talk to arbitrary other XMPP endoints. Or you could use Flash to grab the ... | 0 | false | 3 | 602 |
2010-06-10 08:07:48.540 | how to make a chat room on gae ,has any audio python-framework to do this? | i want to make a chat room on gae ,(audio chat)
has any framework to do this ?
thanks | App Engine doesn't directly support audio chat of any sort, and since it's based around a request-response system with (primarily) HTTP requests, you can't implement it yourself. | 1.2 | true | 3 | 602 |
2010-06-10 08:07:48.540 | how to make a chat room on gae ,has any audio python-framework to do this? | i want to make a chat room on gae ,(audio chat)
has any framework to do this ?
thanks | Try Adobe Stratus (it works with p2p connections) and you could use Google App Engine only for exchanging peer ids. | 0.101688 | false | 3 | 602 |
2010-06-10 09:21:55.470 | Sequence and merge jpeg images using Python? | im doing a project as part of academic programme.Im doing this in linux platform.here i wanted to create a application which retrieve some information from some pdf files .for eg i have pdfs of subject2,subject1,in both the whole pdf is divided in to 4 modules and i want to get the data of module 1 from pdf..for this ... | Not exactly knowing what you mean my sequence - ImageMagick, esp. its 'montage' is probably the tool you need. IM has python interface, too, altough I have never used it.
EDIT: As after your edit I do not get the point of this any more, I cannot recommend anything, either. :( | 0.673066 | false | 1 | 603 |
2010-06-10 13:19:06.677 | How can I build a wrapper to wait for listening on a port? | I am looking for a way of programmatically testing a script written with the asyncore Python module. My test consists of launching the script in question -- if a TCP listen socket is opened, the test passes. Otherwise, if the script dies before getting to that point, the test fails.
The purpose of this is knowing if a ... | Another option is to mock the socket module before importing the asyncore module. Of course, then you have to make sure that the mock works properly first. | 0 | false | 1 | 604 |
2010-06-10 15:31:25.473 | Fast Esp Custom Stage Development | I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especi... | I had worked with FAST ESP for document processing and we used to modify the python files. you can modify them but you need to restart the document processor each time you modify any file. You need to search for document processing in the admin UI, there you go to the pipelines, and you can create a custom pipeline bas... | 0 | false | 2 | 605 |
2010-06-10 15:31:25.473 | Fast Esp Custom Stage Development | I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especi... | The FAST documentation (ESP Document Processor Integration Guide) has a pretty good example of how to write a custom document processor. FAST does not provide the source code to any of it's software, but the AttributeFilter stage functionality should be very straightforward. | 1.2 | true | 2 | 605 |
2010-06-11 04:53:39.087 | how to make a python or perl script portable to both linux and windows? | I was wondering how to make a python script portable to both linux and windows?
One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux?
Are there other problems besides shebang that I should know?
Is the solution same for perl script?
Thanks and regards! | Windows will just ignore the shebang (which is, after all, a comment); in Windows you need to associate the .py extension to the Python executable in the registry, but you can perfectly well leave the shebang on, it will be perfectly innocuous there.
There are many bits and pieces which are platform-specific (many only... | 1.2 | true | 2 | 606 |
2010-06-11 04:53:39.087 | how to make a python or perl script portable to both linux and windows? | I was wondering how to make a python script portable to both linux and windows?
One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux?
Are there other problems besides shebang that I should know?
Is the solution same for perl script?
Thanks and regards! | The shebang line will be interpreted as a comment by Perl or Python. The only thing that assigns it a special meaning is the UNIX/Linux shell; it gets ignored on Windows. The way Windows knows which interpreter to use to run the file is through the file associations in the registry, a different mechanism altogether. | 0.201295 | false | 2 | 606 |
2010-06-11 07:35:15.440 | send xml file to http using python | how can i send an xml file on my system to an http server using python standard library?? | You can achieve that through a standard http post request. | 0.201295 | false | 1 | 607 |
2010-06-11 15:44:52.190 | How to merge or copy anonymous session data into user data when user logs in? | This is a general question, or perhaps a request for pointers to other open source projects to look at:
I'm wondering how people merge an anonymous user's session data into the authenticated user data when a user logs in. For example, someone is browsing around your websites saving various items as favourites. He's not... | If very much depends on your system ofcourse. But personally I always try to merge the data and immediately store it in the same way as it would be stored as when the user would be logged in.
So if you store it in a session for an anonymous user and in the database for any authenticated user. Just merge all data as soo... | 0.386912 | false | 1 | 608 |
2010-06-12 11:52:28.960 | Newbie : installing and upgrading python module | I have downloaded and install a python library, via setup.py , python2.5 setup.py install ...
now the version is changed at the source . a newer library is available. originally , i have clone it via mercurial, and install it. right now , i have updated repository.
how do i use the newer version ? overwrite the instal... | Yes, just do setup.py install again. | 1.2 | true | 1 | 609 |
2010-06-13 07:47:20.700 | Raising events and object persistence in Django | I have a tricky Django problem which didn't occur to me when I was developing it. My Django application allows a user to sign up and store his login credentials for a sites. The Django application basically allows the user to search this other site (by scraping content off it) and returns the result to the user. For ea... | Something else to remember: You need to maintain a browser session with the remote site so that site knows which CAPTCHA you're trying to solve. Lots of webclients allow you to store your cookies and I'd suggest you dump them in the Django Session of the user you're doing the screen scraping for. Then load them back up... | 1.2 | true | 2 | 610 |
2010-06-13 07:47:20.700 | Raising events and object persistence in Django | I have a tricky Django problem which didn't occur to me when I was developing it. My Django application allows a user to sign up and store his login credentials for a sites. The Django application basically allows the user to search this other site (by scraping content off it) and returns the result to the user. For ea... | request.session['name'] = variable will store it
then,
variable = request.session['name'] will retrieve it.
Remember though, its not a database, just a simple session store and shouldn't be relied on for anything critical | 0 | false | 2 | 610 |
2010-06-13 13:29:14.863 | Detecting and interacting with long running process | I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix an... | Sockets are easier to make portable between Windows and any other OS, so that's what I would recommend it over named pipes (that's why e.g. IDLE uses sockets rather than named pipes -- the latter require platform-dependent code on Windows, e.g. via ctypes [[or third-party win32all or cython &c]], while sockets just wor... | 1.2 | true | 2 | 611 |
2010-06-13 13:29:14.863 | Detecting and interacting with long running process | I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix an... | Well here is an idea...
place a status somewhere else, that
can be polled/queried.
when the process starts, post the
'running' status.
have the script check here to see if the process is running.
I would also use a seperate place to
post control values. e.g. set a
value to the 'control set' and have
the process lo... | 0 | false | 2 | 611 |
2010-06-13 23:32:37.893 | Removing python and then re-installing on Mac OSX | I was wondering if anyone had tips on how to completely remove a python installation form Mac OSX (10.5.8) ... including virtual environments and its related binaries. Over the past few years I've completely messed up the installed site-packages, virtual-environments, etc. and the only way I can see to fix it is to ju... | You should be able to delete the packages you've installed from /Library/Python/2.*/site-packages/. I do not think any package installers will install by default to /System/Library, which should save you from needing to remove Python itself.
That said, you could also use virtualenv with --no-site-packages, and just ign... | 0 | false | 1 | 612 |
2010-06-14 05:41:43.637 | how do i install zope interface with python 2.6? | During setup, I'm like missing vcvarsall.bat
running build
running build_py
running build_ext
building '_zope_interface_coptimizations' extension
error: Unable to find vcvarsall.bat | vcvarsall.bat is a batch file that comes with MSVC. Make sure that it is in your %PATH%. | 1.2 | true | 1 | 613 |
2010-06-14 11:05:46.023 | Django admin, filter objects by ManyToMany reference | There's photologue application, simple photo gallery for django, implementing Photo and Gallery objects.
Gallery object has ManyToMany field, which references Photo objects.
I need to be able to get list of all Photos for a given Gallery. Is it possible to add Gallery filter to Photo's admin page?
If it's possible, ho... | Well, that's how I've done it.
I made custom admin template "change_list.html". Custom template tag creates a list of all existing galleries. Filtering is made like this:
class PhotoAdmin(admin.ModelAdmin):
...
def queryset(self, request):
if request.COOKIES.has_key("gallery"):
gallery = Ga... | 0 | false | 1 | 614 |
2010-06-14 12:44:51.260 | Get number of results from Django's raw() query function | I'm using a raw query and i'm having trouble finding out how to get the number of results it returns. Is there a way?
edit
.count() doesnt work. it returns: 'RawQuerySet' object has no attribute 'count' | Count Works on RawQuerySet
ModelName.objects.raw("select 1 as id , COUNT(*) from modelnames_modelname") | 0.265586 | false | 1 | 615 |
2010-06-15 03:15:11.550 | How to determine what user and group a Python script is running as? | I have a CGI script that is getting an "IOError: [Errno 13] Permission denied" error in the stack trace in the web server's error log.
As part of debugging this problem, I'd like to add a little bit of code to the script to print the user and (especially) group that the script is running as, into the error log (presuma... | os.getgid() and os.getuid() can be useful. For other environment variables, look into os.getenv. For example, os.getenv('USER') on my Mac OS X returns the username. os.getenv('USERNAME') would return the username on Windows machines. | 0.135221 | false | 1 | 616 |
2010-06-15 13:49:18.710 | How does Qt work (exactly)? | When you write an application using Qt, can it just be run right away in different operating systems? And (correct me if I'm wrong) you don't need to have Qt already installed in all of the different platforms where you want to execute your application?
How exactly does this work? Does Qt compile to the desired platfor... | Qt (ideally) provides source compatibility, not binary compatibility. You still have to compile the application separately for each platform, and use the appropriate dynamic Qt libraries (which also need to be compiled separately, and have some platform-specific code).
For your final question, the user would need Py... | 0.999909 | false | 1 | 617 |
2010-06-15 14:19:33.083 | Django: how to create sites dynamically? | I need to create an application for the company where I can create sites dynamically. For example, I need an admin interface (Django's admin is enough) where I can setup a new site and add some settings to it.
Each site must hold a domain (domains can be manually added to apache conf, but if Django can handle it too wo... | The django site framework will do that, but it can't server the site according to the domain name. You'll have to do that using you server such as Apache, Nginx, etc. | 0 | false | 1 | 618 |
2010-06-15 14:37:21.637 | I suspect I have multiple version of Python 2.6 installed on Mac OS X 10.6.3; how do I set which one Terminal should launch? | When I enter in python in Terminal it loads up Python 2.6.2. However there are folders by the name of Python 2.6 in different places on my drive. I'm not sure if that's because Python 2.6 has been installed in different places or because Python just likes to have lots of folers in different places.
If there are multipl... | When you run python in a shell or command prompt it will execute the first executable file which is found in your PATH environment variable.
To find out what file is being executed use which python or where python. | 0.496174 | false | 1 | 619 |
2010-06-16 03:07:22.907 | redirection follow by post | just wonder how those air ticket booking website redirect the user to the airline booking website and then fill up(i suppose doing POST) the required information so that the users will land on the booking page with origin/destination/date selected?
Is the technique used is to open up new browser window and do a ajax PO... | It can work like this:
on air ticket booking system you have a html form pointing on certain airline booking website (by action parameter). If user submits data then data lands on airline booking website and this website proceed the request.
Usuallly people want to get back to the first site. This can be done by sendin... | 1.2 | true | 1 | 620 |
2010-06-16 03:18:12.867 | On Ubuntu, how do you install a newer version of python and keep the older python version? | Background:
I am using Ubuntu
The newer python version is not in the apt-get repository (or synaptic)
I plan on keeping the old version as the default python when you call "python" from the command line
I plan on calling the new python using pythonX.X (X.X is the new version).
Given the background, how do you install... | When you install from source, by default, the installation goes in /usr/local -- the executable in particular becomes /usr/local/bin/pythonX.Y with a symlink to it that's named /usr/local/python. Ubuntu's own installation is in /usr/ (e.g., /usr/bin/python), so the new installation won't overwrite it. Take care that t... | 1.2 | true | 1 | 621 |
2010-06-16 14:01:27.360 | Django : In a view how do I obtain the sessionid which will be part of the Set-Cookie header of following response? | In case of views that contain login or logout,
this sessionid is different from the one submitted in request's Coockie header.
I need to retrieve it before returning response for some purpose.
How can I do this ? | I think you should be able to access this via request.session.session_key | 1.2 | true | 1 | 622 |
2010-06-16 23:04:40.720 | Python CLI tool - general parsing question | If possible I would like to use the following structure for a command however I can't seem to figure out how to achieve this in Python:
./somescript.py arg <optional argument> -- "some long argument"
Would it be possible to achieve this in a feasible manner without too much dirty code? Or should I just reconsider the s... | You just need to stick something like this on the first line:
#/usr/local/bin/python
Just make yours be wherever your python binary is located.
As for args look at getopt or optparser
And remember to chmod your file to make it executable. | 0 | false | 1 | 623 |
2010-06-18 00:05:39.683 | Reboot windows machines at a certain time of day and automatically login with Python | I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + win... | Thanks for the responses. To be more clear on what I'm doing, I have a program that automatically starts on bootup, so getting logged in would be preferred. I'm coding a manager for a render-farm for work which will take all the machines that our guys use during the day and turn them into render servers at night (or wh... | 0 | false | 2 | 624 |
2010-06-18 00:05:39.683 | Reboot windows machines at a certain time of day and automatically login with Python | I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + win... | I can't think of any way to do strictly what you want off the top of my head other than the registry, at least not without even more drastic measures. But doing this registry modification isn't a big deal; just change the autologon username/password and reboot the computer. To have the computer reboot when the user log... | 1.2 | true | 2 | 624 |
2010-06-18 20:43:39.873 | ZeroConf Chat with Python | I am trying to set up a Bonjour (or Ahavi) chatbot for our helpdesk system that would answer basic questions based on a menu system. The basis of my question is how do I get python to create the bot so that it connects to the network as a chat client.
Basically, anyone on my network with iChat or Empathy (or any chat p... | The easiest thing to do is to use Telepathy Salut or Pidgin/libpurple, and talk with it over D-Bus. | 0 | false | 1 | 625 |
2010-06-19 02:38:53.503 | From the web to games | I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.
Now, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I alre... | If you want to learn more Python while doing so, you may want to take PyGame or an equivalent program. PHP, Ruby and JavaScript aren't going to help you in the video game section, though. They're all related to the internet.
If you want to start of real easy, try out Genesis3D. you can make awesome 3D FPS games, and i... | 0 | false | 4 | 626 |
2010-06-19 02:38:53.503 | From the web to games | I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.
Now, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I alre... | Python's Pygame is certainly a good choice as others have said. If you want to get in to deep video game programming though.. move on to something like C++ or another lower level language.. from experience, most higher level languages tend to put artificial hurdles up in regards to decent video games. Though for a simp... | 0.201295 | false | 4 | 626 |
2010-06-19 02:38:53.503 | From the web to games | I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.
Now, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I alre... | Looking at your tags, web games are mostly client side, and since you aren't going to use flash, i would say JavaScript would work for 2D. With all the libraries and plug-ins out there, JavaScript can actually handle it. | 0 | false | 4 | 626 |
2010-06-19 02:38:53.503 | From the web to games | I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.
Now, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I alre... | Taking a look at OpenGL may not be a terrible idea. You can use the library in many languages, and is supported with in HTML5 (WebGL). There are several excellent tutorials out there. | 0 | false | 4 | 626 |
2010-06-19 20:38:22.590 | Does GQL automatically add an "ID" Property | I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically?
regards, | Yes, they have id's by default, and it is named ID as you mentioned. | 1.2 | true | 2 | 627 |
2010-06-19 20:38:22.590 | Does GQL automatically add an "ID" Property | I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically?
regards, | An object has a Key, part of which is either an automatically-generated numeric ID, or an assigned key name. IDs are not guaranteed to be increasing, and they're almost never going to be consecutive because they're allocated to an instance in big chunks, and IDs unused by the instance to which they're allocated will n... | 0.496174 | false | 2 | 627 |
2010-06-20 13:24:12.277 | Ruby HAML with Django? | Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML.
I also love Python and Django.
So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning HAML-like syntax in Python ... | While this could end up being more trouble than it is worth, it is PROBABLY possible to leverage the Java or .NET platform and still run your Django application in Jython or IronPython (with some minor adjustments I'm sure) and also be able to leverage Ruby's HAML gem via jRuby or IronRuby.
I'm sure there will be some ... | 0 | false | 2 | 628 |
2010-06-20 13:24:12.277 | Ruby HAML with Django? | Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML.
I also love Python and Django.
So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning HAML-like syntax in Python ... | I strongly recommend that you do not fork any processes out of your django views, because the overhead is significant.
You should have a persistent ruby process to serve your templates for you, and invoke it from your django code. I leave the IPC technology to you, but the obvious choices would either be some kind of ... | 0.101688 | false | 2 | 628 |
2010-06-21 02:05:11.337 | can someone help me with tags in canvas? | i tried to figure out what tags were in canvas however i am having a hard time understanding it. can someone explain what tags do and how to use them in canvas when using python. | Every object in a canvas has an id. You can reference that object by that id to delete it, modify it, move it, etc.
Objects can also have one or more tags. A tag can be associated with a single object, in which case it is just another name for that object. For example, if you draw a red rectangle and a blue rectangle, ... | 0 | false | 1 | 629 |
2010-06-21 08:47:03.660 | How C# use python program? | If it doesn't use ironpython, how C# use cpython program(py file)?
Because there are some bugs that ironpython load cpython code. | If you need strict CPython behavior and do not want to change Python program I am afraid that in this case you should spawn separate CPython process and interact with it via some RPC protocol (there are plenty to choose from) via pipe or network connection to localhost.
As alternative to "serialized" RPC you might use... | 1.2 | true | 1 | 630 |
2010-06-21 10:17:18.530 | How do I get tags/keywords from a webpage/feed? | I have to build a tag cloud out of a webpage/feed. Once you get the word frequency table of tags, it's easy to build the tagcloud. But my doubt is how do I retrieve the tags/keywords from the webpage/feed?
This is what I'm doing now:
Get the content -> strip HTML -> split them with \s\n\t(space,newline,tab) -> Keyword... | What you have is a rough 1st order approximation. I think if you then go back through the data and search for frequency of 2-word phrases, then 3 word phrases, up till the total number of words that can be considered a tag, you'll get a better representation of keyword frequency.
You can refine this rough search patter... | 0 | false | 1 | 631 |
2010-06-22 15:29:38.457 | how to load a big file and cut it into smaller files? | I have file about 4MB (which i called as big one)...this file has about 160000 lines..in a specific format...and i need to cut them at regular interval(not at equal intervals) i.e at the end of a certain format and write the part into another file..
Basically,what i wanted is to copy the information for the big file in... | A 4MB file is very small, it fits in memory for sure. The fastest approach would be to read it all and then iterate over each line searching for the pattern, writing out the line to the appropriate file depending on the pattern (your approach for small files.) | 0.135221 | false | 1 | 632 |
2010-06-22 20:38:16.823 | How to calculate the time interval between two time strings | I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS). I need the difference between the two times. I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and/or time modules. I can't get it to work properl... | you could try this:
from datetime import datetime
start = datetime.now()
print(start)
#some code here
end = datetime.now()
print(end)
print(end - start) | 0 | false | 2 | 633 |
2010-06-22 20:38:16.823 | How to calculate the time interval between two time strings | I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS). I need the difference between the two times. I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and/or time modules. I can't get it to work properl... | Take a look at the datetime module and the timedelta objects. You should end up constructing a datetime object for the start and stop times, and when you subtract them, you get a timedelta. | 0.050976 | false | 2 | 633 |
2010-06-23 05:58:52.023 | Changing the selected item colour in a GtkTreeview using python | I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background.
The row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, "#C4... | Not sure what you mean by flickering. A border would require subclassing TreeView.
I'd make the STATE_SELECTED color identical to STATE_NORMAL to disable the built-in highlighting. Then set a data_func on each column and change some color on the cell renderer depending on whether it's in the selection or not.
You're pr... | 0 | false | 2 | 634 |
2010-06-23 05:58:52.023 | Changing the selected item colour in a GtkTreeview using python | I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background.
The row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, "#C4... | Calling both ModifyBase and ModifyText worked for me. Calling just ModifyBase changes the text color to White
Example in GTK C#:
treeViewList.ModifyBase(StateType.Selected, treeViewList.Style.Base(StateType.Normal));
treeViewList.ModifyText(StateType.Selected, treeViewList.Style.Text(StateType.Normal)); | 0 | false | 2 | 634 |
2010-06-24 01:43:41.017 | Any productive way to install a bunch of packages | I had one machine with my commonly used python package installed.
and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has som... | Pip has some great features for this.
It lets you save all requirements from an environment in a file using pip freeze > reqs.txt
You can then later do : pip install -r reqs.txt and you'll get the same exact environnement.
You can also bundle several libraries into a .pybundle file with the command pip bundle MyApp.pyb... | 0.999753 | false | 2 | 635 |
2010-06-24 01:43:41.017 | Any productive way to install a bunch of packages | I had one machine with my commonly used python package installed.
and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has som... | I keep a requirements.txt file in one of my repositories that has all my basic python requirements and use PIP to install them on any new machine.
Each of my projects also has it's own requirements.txt file that contains all of it's dependencies for use w/virtualenv. | 0 | false | 2 | 635 |
2010-06-24 08:25:55.350 | In Python script, how do I set PYTHONPATH? | I know how to set it in my /etc/profile and in my environment variables.
But what if I want to set it during a script?
Is it import os, sys? How do I do it? | you can set PYTHONPATH, by os.environ['PATHPYTHON']=/some/path, then you need to call os.system('python') to restart the python shell to make the newly added path effective. | -0.265586 | false | 1 | 636 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.