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 |
|---|---|---|---|---|---|---|---|
2009-02-05 21:19:20.087 | How to clear the interpreter console? | Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several... | OK, so this is a much less technical answer, but I'm using the Python plugin for Notepad++ and it turns out you can just clear the console manually by right-clicking on it and clicking "clear". Hope this helps someone out there! | 0.013605 | false | 7 | 94 |
2009-02-05 21:19:20.087 | How to clear the interpreter console? | Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several... | Use idle. It has many handy features. Ctrl+F6, for example, resets the console. Closing and opening the console are good ways to clear it. | 0.054368 | false | 7 | 94 |
2009-02-05 21:19:20.087 | How to clear the interpreter console? | Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several... | just use this..
print '\n'*1000 | 0.027204 | false | 7 | 94 |
2009-02-07 00:27:40.520 | how to search for specific file type with yahoo search API? | Does anyone know if there is some parameter available for programmatic search on yahoo allowing to restrict results so only links to files of specific type will be returned (like PDF for example)?
It's possible to do that in GUI, but how to make it happen through API?
I'd very much appreciate a sample code in Python, b... | Thank you.
I found myself that something like this works OK (file type is the first argument, and query is the second):
format = sys.argv[1]
query = " ".join(sys.argv[2:])
srch = create_search("Web", app_id, query=query, format=format) | 1.2 | true | 1 | 95 |
2009-02-07 16:30:31.217 | Insert Command into Bash Shell | Is there any way to inject a command into a bash prompt in Linux? I am working on a command history app - like the Ctrl+R lookup but different. I am using python for this.
I will show a list of commands from history based on the user's search term - if the user presses enter, the app will execute the command and print ... | You can do this, but only if the shell runs as a subprocess of your Python program; you can't feed content into the stdin of your parent process. (If you could, UNIX would have a host of related security issues when folks run processes with fewer privileges than the calling shell!)
If you're familiar with how Expect al... | 0.296905 | false | 1 | 96 |
2009-02-07 23:18:03.840 | Python, SQLite and threading | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Depending on the application the DB could be a real overhead. If we are talking about volatile data, maybe you could skip the communication via DB completely and share the data between the data gathering process and the data serving process(es) via IPC. This is not an option if the data has to be persisted, of course... | 0 | false | 4 | 97 |
2009-02-07 23:18:03.840 | Python, SQLite and threading | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | "...create several threads that will gather data at a specified interval and cache that data locally into a sqlite database.
Then in the main thread start a CherryPy app that will query that sqlite db and serve the data."
Don't waste a lot of time on threads. The things you're describing are simply OS processes. Just... | 0.067922 | false | 4 | 97 |
2009-02-07 23:18:03.840 | Python, SQLite and threading | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Short answer: Don't use Sqlite3 in a threaded application.
Sqlite3 databases scale well for size, but rather terribly for concurrency. You will be plagued with "Database is locked" errors.
If you do, you will need a connection per thread, and you have to ensure that these connections clean up after themselves. This is ... | 1.2 | true | 4 | 97 |
2009-02-07 23:18:03.840 | Python, SQLite and threading | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Depending on the data rate sqlite could be exactly the correct way to do this. The entire database is locked for each write so you aren't going to scale to 1000s of simultaneous writes per second. But if you only have a few it is the safest way of assuring you don't overwrite each other. | 0 | false | 4 | 97 |
2009-02-09 07:05:27.367 | How to modify existing panels in Maya using MEL or Python? | I've been writing tools in Maya for years using MEL and Python. I'd consider myself an expert in custom window/gui design in Maya except for one area; modifying existing panels and editors.
Typically, I'm building tools that need totally custom UIs, so its customary for me to build them from scratch. However, recentl... | Have you tried searching ui item names in MEL files under maya installation directory? It should be one of the MEL scripts included, and from there you can just modify it. | 1.2 | true | 1 | 98 |
2009-02-11 09:19:22.170 | Outputting data a row at a time from mysql using sqlalchemy | I want to fetch data from a mysql database using sqlalchemy and use the data in a different class.. Basically I fetch a row at a time, use the data, fetch another row, use the data and so on.. I am running into some problem doing this..
Basically, how do I output data a row at a time from mysql data?.. I have looked i... | Exactly what problems are you running into?
You can simply iterate over the ResultProxy object:
for row in conn_or_sess_or_engine.execute(selectable_obj_or_SQLstring):
do_something_with(row) | 0.201295 | false | 1 | 99 |
2009-02-11 16:11:44.397 | Standard python interpreter has a vi command mode? | I was working a bit in the python interpreter (python 2.4 on RHEL 5.3), and suddenly found myself in what seems to be a 'vi command mode'. That is, I can edit previous commands with typical vi key bindings, going left with h, deleting with x...
I love it - the only thing is, I don't know how I got here (perhaps it's th... | For Mac OS X 10.10.3, python2.7, vi mode can be configured by placing bind -v in ~/.editrc. The last few paragraphs of the man page hint at this. | 0.545705 | false | 1 | 100 |
2009-02-12 20:41:14.033 | Granularity of Paradigm Mixing | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Different problems require different solutions, but it helps if you solve things the same way in the same layer. And varying to wildly will just confuse you and everyone else in the project.
For C++, I've found that statically typed OOP (use zope.interface in Python) work well for higher-level parts (connecting, updati... | 0 | false | 4 | 101 |
2009-02-12 20:41:14.033 | Granularity of Paradigm Mixing | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Mixing paradigms has an advantage of letting you express solutions in most natural and esy way. Which is very good thing when it help keeping your program logic smaller. For example, filtering a list by some criteria is several times simpler to express with functional solution compared to traditional loop.
On the oth... | 0.101688 | false | 4 | 101 |
2009-02-12 20:41:14.033 | Granularity of Paradigm Mixing | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | I am not sure that I ever think about it like this.
Once you start "thinking in Ruby" the multi-paradigms just merge into ... well, Ruby.
Ruby is object-oriented, but I find that other things such as the functional aspect tend to mean that some of the "traditional" design patters present in OO languages are just simp... | 0.201295 | false | 4 | 101 |
2009-02-12 20:41:14.033 | Granularity of Paradigm Mixing | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Different paradigms mix in different ways. For example, Using OOP doesn't eliminate the use of subroutines and procedural code from an outside library. It merely moves the procedures around into a different place.
It is impossible to purely program with one paradigm. You may think you have a single one in mind when ... | 0.201295 | false | 4 | 101 |
2009-02-17 13:16:25.157 | Python list serialization - fastest method | I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.
Which is the fastest method, and why?
Using import on a .py file that just contains th... | cPickle will be the fastest since it is saved in binary and no real python code has to be parsed.
Other advantates are that it is more secure (since it does not execute commands) and you have no problems with setting $PYTHONPATH correctly. | 0.067922 | false | 1 | 102 |
2009-02-17 14:50:22.530 | How to re-use a reusable app in Django | I am trying to create my first site in Django and as I'm looking for example apps out there to draw inspiration from, I constantly stumble upon a term called "reusable apps".
I understand the concept of an app that is reusable easy enough, but the means of reusing an app in Django are quite lost for me. Few questions ... | An old question, but here's what I do:
If you're using a version control system (VCS), I suggest putting all of the reusable apps and libraries (including django) that your software needs in the VCS. If you don't want to put them directly under your project root, you can modify settings.py to add their location to sys.... | 0.386912 | false | 1 | 103 |
2009-02-18 15:25:25.633 | How to convert an integer to the shortest url-safe string in Python? | I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the ... | If you are looking for a way to shorten the integer representation using base64, I think you need to look elsewhere. When you encode something with base64 it doesn't get shorter, in fact it gets longer.
E.g. 11234 encoded with base64 would yield MTEyMzQ=
When using base64 you have overlooked the fact that you are not ... | 0.054368 | false | 2 | 104 |
2009-02-18 15:25:25.633 | How to convert an integer to the shortest url-safe string in Python? | I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the ... | Base64 takes 4 bytes/characters to encode 3 bytes and can only encode multiples of 3 bytes (and adds padding otherwise).
So representing 4 bytes (your average int) in Base64 would take 8 bytes. Encoding the same 4 bytes in hex would also take 8 bytes. So you wouldn't gain anything for a single int. | 0.108416 | false | 2 | 104 |
2009-02-19 19:50:27.033 | Python: Am I missing something? | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | I would suggest finding a personal python guru. Show them some of your code and have them review/rewrite it into idiomatic python. Thus will you be enlightened. | 0 | false | 5 | 105 |
2009-02-19 19:50:27.033 | Python: Am I missing something? | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Think like this:
If you are writing too much for little work, something is wrong, this is not pythonic.
Most Python code you will write is very simple and direct. Usually you don't need much work for anything simple. If you are writing too much, stop and think if there is a better way. (and this is how I learned many... | 0.101688 | false | 5 | 105 |
2009-02-19 19:50:27.033 | Python: Am I missing something? | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Write some Python code and post it on SO for review and feedback whether it is pythonic. | 0.050976 | false | 5 | 105 |
2009-02-19 19:50:27.033 | Python: Am I missing something? | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | To echo TLHOLADAY, read the standard library. That's where the "pythonic" stuff is. If you're not getting a good feel there, then read the source for sqlachemy or django or your project of choice. | 0 | false | 5 | 105 |
2009-02-19 19:50:27.033 | Python: Am I missing something? | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | To add to the answers of Andrew Hare and Baishampayan Ghose...
To learn the idiom of any language must involve reading code written in that idiom. I'm still learning the Python idiom, but I've been through this with other languages. I can read about list comprehensions, but the lightbulb only really comes on when you s... | 0.076382 | false | 5 | 105 |
2009-02-20 16:04:25.480 | Statistics with numpy | I am working at some plots and statistics for work and I am not sure how I can do some statistics using numpy: I have a list of prices and another one of basePrices. And I want to know how many prices are with X percent above basePrice, how many are with Y percent above basePrice.
Is there a simple way to do that using... | In addition to df's answer, if you want to know the specific prices that are above the base prices, you can do:
prices[prices > (1.10 * base_prices)] | 0.101688 | false | 1 | 106 |
2009-02-21 19:39:59.540 | Set up a scheduled job? | I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically.
Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this.
Does anyone know how to se... | I had something similar with your problem today.
I didn't wanted to have it handled by the server trhough cron (and most of the libs were just cron helpers in the end).
So i've created a scheduling module and attached it to the init .
It's not the best approach, but it helps me to have all the code in a single place an... | 0.034 | false | 1 | 107 |
2009-02-22 00:58:37.450 | How do YOU deploy your WSGI application? (and why it is the best way) | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | Apache+mod_wsgi,
Simple, clean. (only four lines of webserver config), easy for other sysadimns to get their head around. | 0.04532 | false | 4 | 108 |
2009-02-22 00:58:37.450 | How do YOU deploy your WSGI application? (and why it is the best way) | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | Apache httpd + mod_fcgid using web.py (which is a wsgi application).
Works like a charm. | 0.135221 | false | 4 | 108 |
2009-02-22 00:58:37.450 | How do YOU deploy your WSGI application? (and why it is the best way) | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | We are using pure Paste for some of our web services. It is easy to deploy (with our internal deployment mechanism; we're not using Paste Deploy or anything like that) and it is nice to minimize the difference between production systems and what's running on developers' workstations. Caveat: we don't expect low laten... | 0.04532 | false | 4 | 108 |
2009-02-22 00:58:37.450 | How do YOU deploy your WSGI application? (and why it is the best way) | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | Nginx reverse proxy and static file sharing + XSendfile + uploadprogress_module. Nothing beats it for the purpose.
On the WSGI side either Apache + mod_wsgi or cherrypy server. I like to use cherrypy wsgi server for applications on servers with less memory and less requests.
Reasoning:
I've done benchmarks with differe... | 0.265586 | false | 4 | 108 |
2009-02-24 09:15:24.853 | Python web programming | Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.
My major conc... | What is the best setup for a development environment?
Doesn't much matter. We use Django, which runs in Windows and Unix nicely. For production, we use Apache in Red Hat.
Is having to reload webserver to see the changes considered normal?
Yes. Not clear why you'd want anything different. Web application software sh... | 0.573727 | false | 2 | 109 |
2009-02-24 09:15:24.853 | Python web programming | Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.
My major conc... | When you use mod_python on a threaded Apache server (the default on Windows), CherryPy runs in the same process as Apache. In that case, you almost certainly don't want CP to restart the process.
Solution: use mod_rewrite or mod_proxy so that CherryPy runs in its own process. Then you can autoreload to your heart's con... | 0.081452 | false | 2 | 109 |
2009-02-25 15:39:46.823 | What are good ways to upload bulk .csv data into a webapp using Django/Python? | I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. ... | Look at csv module from stdlib. It contains presets for popualr CSV dialects like one produced by Excel.
Reader class support field mapping and if file contains column header it coes not depend on column order. For more complex logic, like looking up several alternative names for a field, you'll need to write your ow... | 0.067922 | false | 2 | 110 |
2009-02-25 15:39:46.823 | What are good ways to upload bulk .csv data into a webapp using Django/Python? | I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. ... | If you'll copy excel table into clipboard and then paste results into notepad, you'll notice that it's tab separated. I once used it to make bulk import from most of table editors by copy-pasting data from the editor into textarea on html page.
You can use a background for textarea as a hint for number of columns and p... | 0.067922 | false | 2 | 110 |
2009-02-26 06:44:48.240 | Python - How to check if a file is used by another application? | I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application.
Is there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows?
edit: I'll... | One thing I've done is have python very temporarily rename the file. If we're able to rename it, then no other process is using it. I only tested this on Windows. | 0 | false | 1 | 111 |
2009-02-28 19:55:21.193 | Calling function defined in exe | I need to know a way to call a function defined in the exe from a python script.
I know how to call entire exe from py file. | Not sure if it is for windows. But you can treat an exe like a dll (if functions are exported). And they can be used by other programs. | 0.135221 | false | 2 | 112 |
2009-02-28 19:55:21.193 | Calling function defined in exe | I need to know a way to call a function defined in the exe from a python script.
I know how to call entire exe from py file. | Unless the said executable takes command line arguments which will specify which function to use, I don't think this is possible.
With that being said, if you created the EXE, command line arguments are a good way to implement the functionality you're looking for. | 0 | false | 2 | 112 |
2009-02-28 20:54:02.567 | External classes in Python | I'm just beginning Python, and I'd like to use an external RSS class. Where do I put that class and how do I import it? I'd like to eventually be able to share python programs. | If you want to store your RSS file in a different place use sys.append("") and pout the module in that directory and use
import or from import * | 0 | false | 1 | 113 |
2009-03-01 03:40:26.020 | How can I manually register distributions with pkg_resources? | I'm trying to get a package installed on Google App Engine. The package relies rather extensively on pkg_resources, but there's no way to run setup.py on App Engine.
There's no platform-specific code in the source, however, so it's no problem to just zip up the source and include those in the system path. And I've go... | On your local development system, run python setup.py bdist_egg, which will create a Zip archive with the necessary metadata included. Add it to your sys.path, and it should work properly. | 0 | false | 2 | 114 |
2009-03-01 03:40:26.020 | How can I manually register distributions with pkg_resources? | I'm trying to get a package installed on Google App Engine. The package relies rather extensively on pkg_resources, but there's no way to run setup.py on App Engine.
There's no platform-specific code in the source, however, so it's no problem to just zip up the source and include those in the system path. And I've go... | Create a setup.py for the package just as you would normally, and then use "setup.py sdist --formats=zip" to build your source zip. The built source zip will include an .egg-info metadata directory, which will then be findable by pkg_resources. Alternately, you can use bdist_egg for all your packages. | 1.2 | true | 2 | 114 |
2009-03-02 20:24:41.853 | How do you get default headers in a urllib2 Request? | I have a Python web client that uses urllib2. It is easy enough to add HTTP headers to my outgoing requests. I just create a dictionary of the headers I want to add, and pass it to the Request initializer.
However, other "standard" HTTP headers get added to the request as well as the custom ones I explicitly add. Whe... | see urllib2.py:do_request (line 1044 (1067)) and urllib2.py:do_open (line 1073)
(line 293) self.addheaders = [('User-agent', client_version)] (only 'User-agent' added) | 0 | false | 1 | 115 |
2009-03-05 03:18:42.560 | Discovering public IP programmatically | I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)
Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it?
P.S. I'm planning on writing a short python script to do it | Here are a few public services that support IPv4 and IPv6:
curl http://icanhazip.com
curl http://www.trackip.net/ip
curl https://ipapi.co/ip
curl http://api6.ipify.org
curl http://www.cloudflare.com/cdn-cgi/trace
curl http://checkip.dns.he.net
The following seem to support only IPv4 at this time:
curl http://bot.wha... | 0.025505 | false | 3 | 116 |
2009-03-05 03:18:42.560 | Discovering public IP programmatically | I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)
Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it?
P.S. I'm planning on writing a short python script to do it | Your simplest way may be to ask some server on the outside of your network.
One thing to keep in mind is that different destinations may see a different address for you. The router may be multihomed. And really that's just where problems begin. | 0.076382 | false | 3 | 116 |
2009-03-05 03:18:42.560 | Discovering public IP programmatically | I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)
Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it?
P.S. I'm planning on writing a short python script to do it | If the network has an UpNp server running on the gateway you are able to talk to the gateway and ask it for your outside IP address. | 0.076382 | false | 3 | 116 |
2009-03-06 16:11:46.483 | Tools to ease executing raw SQL with Django ORM | I often need to execute custom sql queries in django, and manually converting query results into objects every time is kinda painful. I wonder how fellow Slackers deal with this. Maybe someone had written some kind of a library to help dealing with custom SQL in Django? | Since the issue is "manually converting query results into objects," the simplest solution is often to see if your custom SQL can fit into an ORM .extra() call rather than being a pure-SQL query. Often it can, and then you let the ORM do all the work of building up objects as usual. | 1.2 | true | 1 | 117 |
2009-03-08 04:44:41.143 | For my app, how many threads would be optimal? | I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is,... | It's usually simpler to make multiple concurrent processes. Simply use subprocess to create as many Popens as you feel it necessary to run concurrently.
There's no "optimal" number. Generally, when you run just one crawler, your PC spends a lot of time waiting. How much? Hard to say.
When you're running some small ... | 0.173164 | false | 3 | 118 |
2009-03-08 04:44:41.143 | For my app, how many threads would be optimal? | I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is,... | One thing you should keep in mind is that some servers may interpret too many concurrent requests from the same IP address as a DoS attack and abort connections or return error pages for requests that would otherwise succeed.
So it might be a good idea to limit the number of concurrent requests to the same server to a ... | 0.058243 | false | 3 | 118 |
2009-03-08 04:44:41.143 | For my app, how many threads would be optimal? | I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is,... | You will probably find your application is bandwidth limited not CPU or I/O limited.
As such, add as many as you like until performance begins to degrade.
You may come up against other limits depending on your network setup. Like if you're behind an ADSL router, there will be a limit on the number of concurrent NAT se... | 1.2 | true | 3 | 118 |
2009-03-09 09:57:36.500 | Is there a way to configure the Application Pool's "Idle timeout" in web.config? | I know one can set the session timeout. But, if the application itself has received no requests for a given period of time, IIS shuts down the application.
This behavior is configurable in the IIS management console, and I know how to do this. Still, I wonder if it is possible to configure this in web.config. | Not in IIS 6. In IIS 6, Application Pools are controlled by Worker Processes, which map to a Request Queue handled by HTTP.sys. HTTP.sys handles the communication with the WWW Server to determine when to start and stop Worker Processes.
Since IIS 6 was created before .Net, there's no communication hooks between .Net ... | 1.2 | true | 1 | 119 |
2009-03-09 15:48:55.827 | How do I find the Windows common application data folder using Python? | I would like my application to store some data for access by all users. Using Python, how can I find where the data should go? | You can access all of your OS environment variables using the os.environ dictionary in the os module. Choosing which key to use from that dictionary could be tricky, though. In particular, you should remain aware of internationalized (i.e., non-English) versions of Windows when using these paths.
os.environ['ALLUSERS... | 0.201295 | false | 1 | 120 |
2009-03-09 21:58:14.723 | Python equivalent to java.util.SortedSet? | Does anybody know if Python has an equivalent to Java's SortedSet interface?
Heres what I'm looking for: lets say I have an object of type foo, and I know how to compare two objects of type foo to see whether foo1 is "greater than" or "less than" foo2. I want a way of storing many objects of type foo in a list L, so th... | Do you have the possibility of using Jython? I just mention it because using TreeMap, TreeSet, etc. is trivial. Also if you're coming from a Java background and you want to head in a Pythonic direction Jython is wonderful for making the transition easier. Though I recognise that use of TreeSet in this case would not ... | 0 | false | 1 | 121 |
2009-03-11 02:32:55.053 | Viewing all defined variables | I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).
Is there a way, and how can I do that? | globals(), locals(), vars(), and dir() may all help you in what you want. | 0.573727 | false | 3 | 122 |
2009-03-11 02:32:55.053 | Viewing all defined variables | I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).
Is there a way, and how can I do that? | In my Python 2.7 interpreter, the same whos command that exists in MATLAB exists in Python. It shows the same details as the MATLAB analog (variable name, type, and value/data).
Note that in the Python interpreter, whos lists all variables in the "interactive namespace". | 0.201295 | false | 3 | 122 |
2009-03-11 02:32:55.053 | Viewing all defined variables | I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).
Is there a way, and how can I do that? | A few things you could use:
dir() will give you the list of in scope variables:
globals() will give you a dictionary of global variables
locals() will give you a dictionary of local variables | 1 | false | 3 | 122 |
2009-03-13 00:09:14.370 | Email integration | I was wondering if someone could help me out. In some web application, the app will send out emails, say when a new message has been posted. Then instead of signing into the application to post a reply you can just simply reply to the email and it will automatically update the web app with your response.
My question ... | Generally:
1) Set up a dedicated email account for the purpose.
2) Have a programm monitor the mailbox (let's say fetchmail, since that's what I do).
3) When an email arrives at the account, fetchmail downloads the email, writes it to disk, and calls script or program you have written with the email file as an argument... | 0.443188 | false | 1 | 123 |
2009-03-16 08:22:52.843 | Directory checksum with python? | So I'm in the middle of web-based filesystem abstraction layer development.
Just like file browser, except it has some extra features like freaky permissions etc.
I would like users to be notified somehow about directory changes.
So, i.e. when someone uploads a new file via FTP, certain users should get a proper mes... | A simple approach would be to monitor/check the last modification date of the working directory (using os.stat() for example).
Whenever a file in a directory is modified, the working directory's (the directory the file is in) last modification date changes as well.
At least this works on the filesystems I am working o... | 0 | false | 1 | 124 |
2009-03-17 01:33:18.047 | How to unlock an sqlite3 db? | OMG!
What an apparent problem... my django based scripts have locked my sqlite db...
Does anyone know how to fix? | Your database is locked because you have a transaction running somewhere.
Stop all your Django apps. If necessary, reboot.
It's also remotely possible that you crashed a SQLite client in the middle of a transaction and the file lock was left in place. | 1.2 | true | 1 | 125 |
2009-03-23 18:57:43.417 | Examples for string find in Python | I am trying to find some examples but no luck. Does anyone know of some examples on the net? I would like to know what it returns when it can't find, and how to specify from start to end, which I guess is going to be 0, -1. | if x is a string and you search for y which also a string their is two cases :
case 1: y is exist in x so x.find(y) = the index (the position) of the y in x .
case 2: y is not exist so x.find (y) = -1 this mean y is not found in x. | 0 | false | 1 | 126 |
2009-03-24 11:34:34.207 | How do I notify a process of an SQLite database change done in a different process? | Let's say I have two or more processes dealing with an SQLite database - a "player" process and many "editor" processes.
The "player" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.
An "editor" process is any edi... | I think in that case, I would make a process to manage the database read/writes.
Each editor that want to make some modifications to the database makes a call to this proccess, be it through IPC or network, or whatever method.
This process can then notify the player of a change in the database. The player, when he want... | 0.101688 | false | 5 | 127 |
2009-03-24 11:34:34.207 | How do I notify a process of an SQLite database change done in a different process? | Let's say I have two or more processes dealing with an SQLite database - a "player" process and many "editor" processes.
The "player" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.
An "editor" process is any edi... | A relational database is not your best first choice for this.
Why?
You want all of your editors to pass changes to your player.
Your player is -- effectively -- a server for all those editors. Your player needs multiple open connections. It must listen to all those connections for changes. It must display those ch... | 1.2 | true | 5 | 127 |
2009-03-24 11:34:34.207 | How do I notify a process of an SQLite database change done in a different process? | Let's say I have two or more processes dealing with an SQLite database - a "player" process and many "editor" processes.
The "player" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.
An "editor" process is any edi... | Just open a socket between the two processes and have the editor tell all the players about the update. | 0.101688 | false | 5 | 127 |
2009-03-24 11:34:34.207 | How do I notify a process of an SQLite database change done in a different process? | Let's say I have two or more processes dealing with an SQLite database - a "player" process and many "editor" processes.
The "player" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.
An "editor" process is any edi... | How many editor processes (why processes?), and how often do you expect updates? This doesn't sound like a good design, especially not considering sqlite really isn't too happy about multiple concurrent accesses to the database.
If multiple processes makes sense and you want persistence, it would probably be smarter to... | 0.050976 | false | 5 | 127 |
2009-03-24 11:34:34.207 | How do I notify a process of an SQLite database change done in a different process? | Let's say I have two or more processes dealing with an SQLite database - a "player" process and many "editor" processes.
The "player" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.
An "editor" process is any edi... | If it's on the same machine, the simplest way would be to have named pipe, "player" with blocking read() and "editors" putting a token in pipe whenever they modify DB. | 0.101688 | false | 5 | 127 |
2009-03-25 04:23:52.267 | How do I tell which Python interpreter I'm using? | I am using Python 2.5.2. How can I tell whether it is CPython or IronPython or Jython?
Another question: how can I use a DLL developed in VB.NET in my project? | If you are typing "python" to launch it, it is probably CPython. IronPython's executable name is "ipy". | 0.3154 | false | 1 | 128 |
2009-03-26 01:19:41.687 | How to re import an updated package while in Python Interpreter? | I often test my module in the Python Interpreter, and when I see an error, I quickly update the .py file. But how do I make it reflect on the Interpreter ? So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me. | So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me.
Yes, just saying import again gives you the existing copy of the module from sys.modules.
You can say reload(module) to update sys.modules and get a new copy of that single module, but if any other mod... | 0.998005 | false | 1 | 129 |
2009-03-26 13:01:52.357 | In Python, how do I take a list and reduce it to a list of duplicates? | I have a list of strings that should be unique. I want to be able to check for duplicates quickly. Specifically, I'd like to be able to take the original list and produce a new list containing any repeated items. I don't care how many times the items are repeated so it doesn't have to have a word twice if there are two... | the solutions based on 'set' have a small drawback, namely they only work for hashable objects.
the solution based on itertools.groupby on the other hand works for all comparable objects (e.g.: dictionaries and lists). | 0 | false | 1 | 130 |
2009-04-01 05:44:36.447 | How do I schedule a process' termination? | I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it? | One idea: Save the process's PID (returned by fork() in your child process) to a file, then either schedule a cron job to kill it or kill it manually, reading the PID from the file.
Another option: Create a shell script wrapper that automatically kills and restarts the process. Same as above, but you can keep the PID i... | 0 | false | 1 | 131 |
2009-04-02 06:35:38.017 | Python SAX parser says XML file is not well-formed | I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do ... | I would suggest putting those tags back in and making sure it still works. Then, if you want to take them out, do it one at a time until it breaks.
However, I question the wisdom of taking them out. If it's your XML file, you should understand it better. If it's a third-party XML file, you really shouldn't be fiddling ... | 0.201295 | false | 3 | 132 |
2009-04-02 06:35:38.017 | Python SAX parser says XML file is not well-formed | I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do ... | I would second recommendation to try to parse it using another XML parser. That should give an indication as to whether it's the document that's wrong, or parser.
Also, the actual error message might be useful. One fairly common problem for example is that the xml declaration (if one is used, it's optional) must be the... | 0 | false | 3 | 132 |
2009-04-02 06:35:38.017 | Python SAX parser says XML file is not well-formed | I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do ... | You could load it into Firefox, if you don't have an XML editor. Firefox shows you the error. | 0 | false | 3 | 132 |
2009-04-02 11:54:59.983 | Import an existing python project to XCode | I've got a python project I've been making in terminal with vim etc.. I've read that XCode supports Python development at that it supports SVN (which I am using) but I can't find documentation on how to start a new XCode project from an existing code repository.
Other developers are working on the project not using XCo... | There are no special facilities for working with non-Cocoa Python projects with Xcode. Therefore, you probably just want to create a project with the "Empty Project" template (under "Other") and just drag in your source code.
For convenience, you may want to set up an executable in the project. You can do this by ctrl/... | 0.101688 | false | 1 | 133 |
2009-04-05 16:07:30.077 | How can you make a vote-up-down button like in Stackoverflow? | Problems
how to make an Ajax buttons (upward and downward arrows) such that the number can increase or decrease
how to save the action af an user to an variable NumberOfVotesOfQuestionID
I am not sure whether I should use database or not for the variable. However, I know that there is an easier way too to save the nu... | You create the buttons, which can be links or images or whatever. Now hook a JavaScript function up to each button's click event. On clicking, the function fires and
Sends a request to the server code that says, more or less, +1 or -1.
Server code takes over. This will vary wildly depending on what framework you use (... | 0.296905 | false | 1 | 134 |
2009-04-05 23:34:32.857 | Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL | I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule.
There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advanc... | Have you considered keeping your same "schedule", and just shuffling the teams? Generating a schedule where everyone plays each other the proper number of times is possible, but if you already have such a schedule then it's much easier to just shuffle the teams.
You could keep your current table, but replace each team... | 0.265586 | false | 2 | 135 |
2009-04-05 23:34:32.857 | Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL | I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule.
There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advanc... | I'm not sure I fully understand the problem, but here is how I would do it:
1. create a complete list of matches that need to happen
2. iterate over the weeks, selecting which match needs to happen in this week.
You can use Python lists to represent the matches that still need to happen, and, for each week, the matches... | 0.135221 | false | 2 | 135 |
2009-04-07 00:39:25.627 | Import XML into SQL database | I'm working with a 20 gig XML file that I would like to import into a SQL database (preferably MySQL, since that is what I am familiar with). This seems like it would be a common task, but after Googling around a bit I haven't been able to figure out how to do it. What is the best way to do this?
I know this ability i... | It may be a common task, but maybe 20GB isn't as common with MySQL as it is with SQL Server.
I've done this using SQL Server Integration Services and a bit of custom code. Whether you need either of those depends on what you need to do with 20GB of XML in a database. Is it going to be a single column of a single row of... | 0 | false | 1 | 136 |
2009-04-07 08:36:07.227 | Python distutils, how to get a compiler that is going to be used? | For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)?
UPD.: I don't need the def... | You can subclass the distutils.command.build_ext.build_ext command.
Once build_ext.finalize_options() method has been called, the compiler type is stored in self.compiler.compiler_type as a string (the same as the one passed to the build_ext's --compiler option, e.g. 'mingw32', 'gcc', etc...). | 0.496174 | false | 2 | 137 |
2009-04-07 08:36:07.227 | Python distutils, how to get a compiler that is going to be used? | For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)?
UPD.: I don't need the def... | import distutils.ccompiler
compiler_name = distutils.ccompiler.get_default_compiler() | -0.067922 | false | 2 | 137 |
2009-04-13 16:20:47.457 | Django models - how to filter out duplicate values by PK after the fact? | I build a list of Django model objects by making several queries. Then I want to remove any duplicates, (all of these objects are of the same type with an auto_increment int PK), but I can't use set() because they aren't hashable.
Is there a quick and easy way to do this? I'm considering using a dict instead of a list... | If the order doesn't matter, use a dict. | 0 | false | 1 | 138 |
2009-04-15 01:05:26.610 | How to visualize IP addresses as they change in python? | I've written a little script that collects my external IP address every time I open a new terminal window and appends it, at well as the current time, to a text file. I'm looking for ideas on a way to visualize when/how often my IP address changes. I bounce between home and campus and could separate them using the scri... | There's a section in the matplotlib user guide about drawing bars on a chart to represent ranges. I've never done that myself but it seems appropriate for what you're looking for. | 0 | false | 1 | 139 |
2009-04-15 21:13:47.127 | Need to build (or otherwise obtain) python-devel 2.3 and add to LD_LIBRARY_PATH | I am supporting an application with a hard dependency on python-devel 2.3.7. The application runs the python interpreter embedded, attempting to load libpython2.3.so - but since the local machine has libpython2.4.so under /usr/lib64, the application is failing.
I see that there are RPMs for python-devel (but not versio... | You can use the python RPM's linked to from the python home page ChristopheD mentioned.
You can extract the RPM's using cpio, as they are just specialized cpio archives.
Your method of extracting them to your home directory and setting LD_LIBRARY_PATH and PATH should work; I use this all the time for hand-built newer v... | 1.2 | true | 1 | 140 |
2009-04-18 22:02:45.750 | How do I modify sys.path from .htaccess to allow mod_python to see Django? | The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python / mod_python to look for it... | You're using mod_python wrong. It was never intended to serve python web applications. You should be using WSGI for this... or at least FastCGI. | 0.135221 | false | 1 | 141 |
2009-04-19 18:00:40.033 | Convert timedelta to years? | I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years. | How exact do you need it to be? td.days / 365.25 will get you pretty close, if you're worried about leap years. | 0.096877 | false | 4 | 142 |
2009-04-19 18:00:40.033 | Convert timedelta to years? | I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years. | Get the number of days, then divide by 365.2425 (the mean Gregorian year) for years. Divide by 30.436875 (the mean Gregorian month) for months. | 0.135221 | false | 4 | 142 |
2009-04-19 18:00:40.033 | Convert timedelta to years? | I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years. | In the end what you have is a maths issue. If every 4 years we have an extra day lets then dived the timedelta in days, not by 365 but 365*4 + 1, that would give you the amount of 4 years. Then divide it again by 4.
timedelta / ((365*4) +1) / 4 = timedelta * 4 / (365*4 +1) | 0.019434 | false | 4 | 142 |
2009-04-19 18:00:40.033 | Convert timedelta to years? | I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years. | If you're trying to check if someone is 18 years of age, using timedelta will not work correctly on some edge cases because of leap years. For example, someone born on January 1, 2000, will turn 18 exactly 6575 days later on January 1, 2018 (5 leap years included), but someone born on January 1, 2001, will turn 18 exa... | 0.99126 | false | 4 | 142 |
2009-04-19 19:51:07.787 | Amazon S3 permissions | Trying to understand S3...How do you limit access to a file you upload to S3? For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file? It seems like the query string authentication requires an expiration date and that won't work f... | You will have to build the whole access logic to S3 in your applications | 0.101688 | false | 3 | 143 |
2009-04-19 19:51:07.787 | Amazon S3 permissions | Trying to understand S3...How do you limit access to a file you upload to S3? For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file? It seems like the query string authentication requires an expiration date and that won't work f... | There are various ways to control access to the S3 objects:
Use the query string auth - but as you noted this does require an expiration date. You could make it far in the future, which has been good enough for most things I have done.
Use the S3 ACLS - but this requires the user to have an AWS account and authentica... | 0.998178 | false | 3 | 143 |
2009-04-19 19:51:07.787 | Amazon S3 permissions | Trying to understand S3...How do you limit access to a file you upload to S3? For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file? It seems like the query string authentication requires an expiration date and that won't work f... | Have the user hit your server
Have the server set up a query-string authentication with a short expiration (minutes, hours?)
Have your server redirect to #2 | 0.673066 | false | 3 | 143 |
2009-04-20 19:27:37.197 | How do I load entry-points for a defined set of eggs with Python setuptools? | I would like to use the entry point functionality in setuptools.
There are a number of occasions where I would like to tightly control the list of eggs that are run, and thence the extensions that contribute to a set of entry points:
egg integration testing, where I want to run multiple test suites on different combin... | We're solving something similar, ability to use setup.py develop if You're mere user without access to global site-packages. So far, we solved it with virtualenv.
I'd say it will help for your case too: have minimal system-wide install (or explicitly exclude it), create virtual environment with eggs you want and test t... | 0 | false | 1 | 144 |
2009-04-21 14:43:48.383 | Free word list for use programmatically? | A friend of mine was talking about a word game she liked to play where you try to convert one word to another (they have the same number of letters) by switching one letter at a time, where each iteration produces a real word.
Example:
MOON --> WOLF
GOON
GOOF
GOLF
WOLF
I figured it'd be a fun little project t... | Most unix (which includes osx) have a file /usr/share/dict/words. | 0.999839 | false | 1 | 145 |
2009-04-23 12:20:12.113 | Python3 Http Web Server: virtual hosts | I am writing an rather simple http web server in python3. The web server needs to be simple - only basic reading from config files, etc. I am using only standard libraries and for now it works rather ok.
There is only one requirement for this project, which I can't implement on my own - virtual hosts. I need to have a... | Virtual hosts work by obeying the Host: header in the HTTP request.
Just read the headers of the request, and take action based on the value of the Host: header | 0.999909 | false | 1 | 146 |
2009-04-23 19:08:27.440 | How to connect to a WCF Service with IronPython | Has anyone done this? I've tried generating a c# proxy class and connecting through it, but I cannot figure out how to get IronPython to use the generated app.config file that defines the endpoint. It tries to connect, but I just get an error about no default endpoint. I would ideally like to make the connection usi... | Is your WCF service interface available in a shared assembly? If so, you could look at using the ChannelFactory to create your client proxy dynamically (instead of using the generated C# proxy). With that method you can supply all the details of the endpoint when you create the ChannelFactory and you won't require an... | 0 | false | 1 | 147 |
2009-04-24 14:45:27.703 | How to design an email system? | I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will... | A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner.
I would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues,... | 0.296905 | false | 2 | 148 |
2009-04-24 14:45:27.703 | How to design an email system? | I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will... | You might want to try Twisted Mail for implementing your own backend in pure Python. | 0 | false | 2 | 148 |
2009-04-24 14:46:45.890 | Basic MVT issue in Django | I have a Django website as follows:
site has several views
each view has its own template to show its data
each template extends a base template
base template is the base of the site, has all the JS/CSS and the basic layout
So up until now it's all good. So now we have the master head of the site (which exists in the... | Context processors and RequestContext (see Tyler's answer) are the way to go for data that is used on every page load. For data that you may need on various views, but not all (especially data that isn't really related to the primary purpose of the view, but appears in something like a navigation sidebar), it often ma... | 0.265586 | false | 1 | 149 |
2009-04-25 20:35:44.357 | What is the best way to redirect email to a Python script? | I'd like to provide a functionality for users of my website to get assigned an email address upon registration (such as firstname.lastname@mydomain.com) but I don't really think it is feasible to actually support all these emails account normally through a webmail program. I am also not sure if my webhost would be cool... | but I don't really think it is
feasible to actually support all these
emails account normally through a
webmail program
I think that your base assumption here is incorrect. You see, most 'webmail' programs are just frontends (or clients) to the backend mail system (postfix etc). You will need to see how your web... | 0 | false | 1 | 150 |
2009-04-27 21:42:12.717 | Is there an easy way to tell how much time is spent waiting for the Python GIL? | I have a long-running Python service and I'd like to know how much cumulative wall clock time has been spent by any runnable threads (i.e., threads that weren't blocked for some other reason) waiting for the GIL. Is there an easy way to do this? E.g., perhaps I could periodically dump some counter to its log file.
My... | I don't think there's an easy way. There's probably an awkward way, involving rebuilding Python to traverse the PyThreadState list and count the threads each time the lock is acquired, but I doubt it's worth the effort!
I know this is a speculative question but if you are even moderately concerned about there being del... | 0.545705 | false | 1 | 151 |
2009-04-28 12:56:05.873 | Django caching - can it be done pre-emptively? | I have a Django view, which receives part of its data from an external website, which I parse using urllib2/BeautifulSoup.
This operation is rather expensive so I cache it using the low-level cache API, for ~5 minutes. However, each user which accesses the site after the cached data expires will receive a significant d... | "I'm still unsure as to how I accomplish this with the python script I will be calling. "
The issue is that your "significant delay of a few seconds while I go to the external site to parse the new data" has nothing to do with Django cache at all.
You can cache it everywhere, and when you go to reparse the external sit... | 0.386912 | false | 2 | 152 |
2009-04-28 12:56:05.873 | Django caching - can it be done pre-emptively? | I have a Django view, which receives part of its data from an external website, which I parse using urllib2/BeautifulSoup.
This operation is rather expensive so I cache it using the low-level cache API, for ~5 minutes. However, each user which accesses the site after the cached data expires will receive a significant d... | I have no proof, but I've read BeautifulSoup is slow and consumes a lot of memory. You may want to look at using the lxml module instead. lxml is supposed to be much faster and efficient, and can do much more than BeautifulSoup.
Of course, the parsing probably isn't your bottleneck here; the external I/O is.
First off... | 0.386912 | false | 2 | 152 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.