python

Keystroke detection using Python

How is keystroke detection done using Python? ...

Override DEFINEs in setup.cfg in source eggs

The source egg of PySQLite 2.6.0 contains a file setup.cfg that looks like this: [build_ext] #define= #include_dirs=/usr/local/include #library_dirs=/usr/local/lib libraries=sqlite3 define=SQLITE_OMIT_LOAD_EXTENSION I'd like to build the egg with the SQLITE_OMIT_LOAD_EXTENSION define disabled (not set). I could do that by uncommenting...

Parsing XML using xml.etree.cElementTree

I have the following XML in a string named 'xml': <?xml version="1.0" encoding="ISO-8859-1"?> <Book> <Page> <Text>Blah</Text> </Page> </Book> I'm trying to get the value Blah out of it but I'm having trouble with xml.etree.cElementTree. I've tried the find() and findtext() methods but nothing. Eventually I did this: import xm...

Sequence and merge jpeg images using Python?

hi, 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 purpose my tuto...

Validating and filling default values in XML based on XSD in Python

How do I fill the default value in my XML during validation against XSD? If my attribute is not defined as use="require" and have default="1", it could be possible to fill these default values from the XSD to the XML. Example: Original XML: <a> <b/> <b c="2"/> </a> XSD scheme: <xs:element name="a"> <xs:complexType> <xs:sequence...

When where and how can i change the __class__ attr of an object in Python?

I'd like to be able to do: >>> class a(str): ... pass ... >>> b = a() >>> b.__class__ = str Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: __class__ assignment: only for heap types ...

Imaplib: how to delete an email from Gmail?

Hi everyone, I am trying to do something as simple as moving an email from inbox to trash using the imaplib of python. However, I am having some problems and I don't know how to solve them. After connect and login into the server, I select the INBOX mailbox and I get the ids list this way: typ, ids = imap_object.search(None, 'INBOX') ...

How to delete every reference of an object in Python?

Supose you have something like: x = "something" b = x l = [b] How can you delete the object only having one reference, say x? del x won't do the trick; the object is still reachable from b, for example. ...

How to get all attributes for a particular xml node in qt

hello is it possible to get all attributes for a particular node in pyqt ? for example .. consider for following node: < asset Name="3dAsset" ID="5"/> i want to retrieve the ("Name" and "ID") strings is it possible? thanks in advance ...

A good matplot tutorial (from beginner to intermidiate)?

Can anyone recommend a good matplot tutorial. I am a complete beginner - but have used similar software (matlab, R etc), in my halcyon days at University (i.e. a long time ago). A google search brings up a list of dubious quality, and the 'official' docs are too terse, or provide examples that are more 'edge case' (e.g. drawing dolphins...

How to change the amount of increments in pyplot axis

Hi probably quite a simple question but.. When plotting a graph using matplotlib.pyplot my Y axis goes from -0.04 to 0.03 which is fine but there are 8 labels for increments (eg 0.03,0.02,0.01 etc.). I need more maybe 16 or so. Thanks for your help ...

Problem with eastern european characters when scraping data from the European Parliament Website

Dear Experts EDIT: thanks a lot for all the answers an points raised. As a novice I am a bit overwhelmed, but it is a great motivation for continuing learning python!! I am trying to scrape a lot of data from the European Parliament website for a research project. The first step is to create a list of all parliamentarians, however due ...

List filtering: list comprehension vs. lambda + filter

I happened to find myself having a basic filtering need: I have a list and I have to filter it by an attribute of the items. My code looked like this: my_list = [i for i in my_list if i.attribute == value] But then i thought, wouldn't it be better to write it like this? filter(lambda x: x.attribute == value, my_list) It's more rea...

[python] voice communication for python help!

Hello! I'm currently trying to write a voicechat program in python. All tips/trick is welcome to do this. So far I found pyAudio to be a wrapper of PortAudio. So I played around with that and got an input stream from my microphone to be played back to my speakers. Only RAW of course. But I can't send RAW-data over the netowrk (due the ...

trunk works tag doesn't? ---ImportError: No module named 2.1.2

Very confused. In my workspace, the trunk works fine when I do a: python ./manage.py runserver 9090 However when I tag it @ 2.1.2 and then check it out clean from the repository to a temporary directory on my desktop.. I get the following error: Traceback (most recent call last): File "./manage.py", line 33, in execute_manag...

Python : get all exe files in current directory and run them?

Hey all, First of all this is not homework, I'm in a desperate need for a script that will do the following, my problem is, I've never had to deal with python before so I barely know how to use it - and I need it to launch unit tests in TeamCity via a commandline build runner What I need exactly is : a *.bat file that will run the sc...

Python and libpcap. find source mac address of packet.

Hello! I'm writing python program to build mac-address cache using pcap. But pcap module for python has no good documentation. I have found this page http://pylibpcap.sourceforge.net/ with code example and it works fine. Can anybody modify this example to make it able to show the source mac-address for each packet? Or point me to the do...

How can I get the types of entities in an SQLALchemy query

I know how to get the columns that would be returned from a select statement but how do I get the entities that would be returned from an sqlalchemy.orm.Query object? >>> sess = Session() >>> q = sess.query(Entity1, Entity2) >>> q.statement.c.keys() ['e1_col1', 'e1_col2', ..., 'e2_col1', 'e2_col2, ...] I want [Entity1, Entity2] or som...

Django date filter: how come the format used is different from the one in datetime library ???

Hello ! For formatting a date using date filter you must use the following format : {{ my_date|date:"Y-m-d" }} If you use strftime from the standard datetime, you have to use the following : my_date.strftime("%Y-%m-%d") So my question is ... isn't it ugly (I guess it is because of the % that is used also for tags, and therefore is ...

Python ftplib - any way to shut it up?

I am writing a test harness in python and as part of the testing I need to initialise an FTP server and upload various files. I am using ftplib and everything is working ok. The only problem I have is that I am seeing loads of FTP text appearing in the console window intermixed with my test results, which makes scanning the results quite...