In PyQt you can do something like the following to allow the user to select a file
filename = QtGui.QFileDialog.getOpenFileName(self, "Choose file..")
However I would like a QFileDialog to open in which the user would be able to select either a file or a directory.
I'm sure I've seen this feature in PyQt applications before, but I can...
I have a Pylons controller action that needs to return a file to the client. (The file is outside the web root, so I can't just link directly to it.) The simplest way is, of course, this:
with open(filepath, 'rb') as f:
response.write(f.read())
That works, but it's obviously inefficient for large files. What's the best way...
Hi i an building an mbox file from a db blob and would like to add an hyperlink to the Attachement header
I am building the header like this
msg=email.message_from_string(blob)
msg["Content-Disposition"]="attachment; filename=filename.txt;"
What do i need to add to add a http or ftp hyperlink for the filename?
Thnks
...
Would it be possible to integrate Python (and/or Perl) and Ruby? I've looked at http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/ and http://code.google.com/p/ruby-perl/ , but they both seem rather outdated.
Has someone generated a Ruby interface for Python's C API?
Edit: Python can be integrated with many other languages ac...
I'm looking into releasing a python package which includes an existing fortran or C program. The fortran/C program is compiled by running
./configure
make
The python code calls the resulting binary through subprocess calls (i.e. the code is not really wrapped as such). What I would like is that when the user types
python setup.py ins...
def sortProfiles(p):
return sorted(p, key=itemgetter('first_name'))
I have a list with dictionaries. This function allows me to sort them by their first_name. However, it's case-sensitive.
...
Suppose my model is this:
class Ego(models.Model):
event = models.ForeignKey(Event)
user = models.ForeignKey(User)
As you can see, this table has 2 columns, and they're both foreign keys.
How do I "order by" User.first_name?
Is this it? But it doesn't look like it.
Ego.objects.all().order_by("User.first_name")
...
Hi
I have an XML (in the form of tree), I require to create sub-tree out of it.
For ex:
<a>
<b>
<c>Hello</c>
<d>
<e>Hi</e>
</a>
Subtree would be
<root>
<a>
<b>
<c>Hello</c>
</b>
</a>
<a>
<d>
<e>Hi</e>
</d>
</a>
</root>
What is the best XML library in python to do it? Any algorithm that already does...
I want that find empty tags, here is a example
txt ="<lol1><><lol2>"
rgx = "<([a-zA-Z_0-9]+)>"
print re.findall(rgex, txt)
I get this
['lol1', 'lol2']
I want
['lol1', '', 'lol2']
How I can do this with regex?
...
I have a simple .exe that needs to be running continuously.
Unfortunately, sometimes it crashes unexpectedly, and there's nothing that can be done for this.
I'm thinking of like a C# program that scans the running application tree on a timer and if the process stops running it re-launches it... ? Not sure how to do that though....
An...
Hello members,
I am trying to install the MySQL-python on MAC OS 10.6 (Snow leopard, 64 bit). I followed the steps:
1. Installed MySQL for Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive.
2. Downloaded MySQL-python-1.2.3c1.tar.gz and unzipped it
3. CD to MySQL-python-1.2.3c1 and built it as:
ARCHFLAGS="-arch x86_64" python setup.py bui...
Is there something string class like stringbuilder in c#?
Thanks
...
How to sort the following dictionary by the value of "remaining_pcs" or "discount_ratio"?
promotion_items = {
'one': {'remaining_pcs': 100, 'discount_ratio': 10},
'two': {'remaining_pcs': 200, 'discount_ratio': 20},
}
EDIT
What I mean is getting a sorted list of above dictionary, not to sort the dictionary itself.
...
Hi, I'd like to begin thinking about how I can scale up my algorithms that I write for data analysis so that they can be applied to arbitrarily large sets of data. I wonder what are the relevant concepts (threads, concurrency, immutable data structures, recursion) and tools (Hadoop/MapReduce, Terracota, and Eucalyptus) to make this happe...
What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome
...
Hello Everyone,
I am looking for a python module that will help me get rid of HTML tags but keep the text values. I tried BeautifulSoup before and I couldn't figure out how to do this simple task. I tried searching for Python modules that could do this but they all seem to be dependent on other libraries which does not work well on AppE...
I have 2 hard-drives, C:\ and D:\
Django imports correctly (which is in my C drive), but my application is on my D drive. I can't move it to the C drive because of some back-up software I'm running/
I'm trying to get auto-complete to work in Komodo Edit 5 which works fine for Django, but not for my application. There are a few other re...
Given
<field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000008000 seconds" size="0" pos="0" show="0.000008000"/>
<field name="frame.time_relative" showname="Time since reference or first frame: 0.000008000 seconds" size="0" pos="0" show="0.000008000"/>
<field name="frame.number" showname="Fr...
Are there any easy installation tools like "perl -MCPAN -e shell;" to install python modules and its dependents???
...
I have the following ini file
[Section]
value=test
When i use the ConfigParser Module :
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('config.ini')
str=config.get('Section', 'value')
if str == 'test':
print 1
else :
print 0
it always print 0 could someone help
...