python

How can I discover classes in a specific package in python?

I have a package of plug-in style modules. It looks like this: /Plugins /Plugins/__init__.py /Plugins/Plugin1.py /Plugins/Plugin2.py etc... Each .py file contains a class that derives from PluginBaseClass. So I need to list every module in the Plugins package and then search for any classes that implement PluginBaseClass. Ideall...

Using Sphinx for documenting projects and modules on demand

Hello: I use Sphinx for documenting a Python module. I have a master doc directory, where I put individual *.rst files (on for each module component) to be included in the index.rst main file. That works great (please check the source of the Python Library Reference to see exactly how I do it). My problem is when I need to create a sta...

How can I strip comment tags from HTML using BeautifulSoup?

I have been playing with BeautifulSoup, which is great. My end goal is to try and just get the text from a page. I am just trying to get the text from the body, with a special case to get the title and/or alt attributes from <a> or <img> tags. So far I have this EDITED & UPDATED CURRENT CODE: soup = BeautifulSoup(page) comments = soup...

Recommended language for multithreaded data work

Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the...

Add one to a function call in python

What does the last line, return 1 + .... do ? How can you return 1 plus a function call? Below is the assignments text: These functions recursively count the number of instances of the key in the target string def countSubStringMatchRecursive(target, key): currentPosition = find(target, key) if find(target, key) == -1: ...

Paragraph translation in Python/Django

Hello, I translated a site using django i18n, I have no problems for menus, little paragraph, etc.. The thing I dont understand is for translating big paragraph. On my site, the admin can write some news by administration page, but he wants them in differents languages. I can imagine some methods to do that : one field per langage, b...

Inserting Encrypted Data in Postgres via SQLALchemy

Hi, I want to encrypt a string using RSA algorithm and then store that string into postgres database using SQLAlchemy in python. Then Retrieve the encrypted string and decrypt it using the same key. My problem is that the value gets stored in the database is not same as the actual encrypted string. The datatype of column which is storin...

Sending integer values to Arduino from PySerial

I need to send integers greater than 255? Does anyone know how to do this? ...

Use (Python) Gstreamer to decode audio (to PCM data)

I'm writing an application that uses the Python Gstreamer bindings to play audio, but I'm now trying to also just decode audio -- that is, I'd like to read data using a decodebin and receive a raw PCM buffer. Specifically, I want to read chunks of the file incrementally rather than reading the whole file into memory. Some specific quest...

Read 40 bytes of binary data as ascii text

I have some binary data, in hex editor it looks like: s.o.m.e.d.a.t.a with all these dots in between each letter when I read with filehandle.read(40) it shows these dots I know that the dots aren't supposed to be there, is there a way to unpack some ascii data that is 40 bytes long with struct? I tried '40s' and 's' but it shows wei...

How can I know if the user is connected to the local machine via ssh in my python script?

How can I know if the user is connected to the local machine via ssh in my python script? ...

Converting a list with many items into single item lines in python

Hi, I want to convert lines in a text file from this: animal cat, mouse, dog, horse numbers 22,45,124,87 to this: animal cat animal mouse animal dog animal horse numbers 22 numbers 45 numbers 124 numbers 87 How would I do this conversion in python? Thanks ...

[GTK+ Builder] Trouble Updating Label Text

Environment: Built interface using Glade3. Backend is written in Python using the GTK+ Builder library. - Although I know the method I need to use to update a label's text (label.set_text("string")), I'm having trouble obtaining the label object in the python code. Here's what my code looks like: #!/usr/bin/python # Filename: Hel...

I have a series of python modules I would like to put into a package, how can I do this?

I have a series of python modules I would like to put into a package. I would like to set it up such that anyone interested can just download it and install it (on unix). How can I do this? ...

Start a script on a remote machine through ssh with python - but in reverse?

Here's what I need to do: The user is on a remote machine and connects to a server via ssh. He runs a python script on the server. The script running on the server starts a script on the user's remote machine as a subprocess and opens a pipe to it for communication. First, is this at all possible? Second, is this possible in such a ...

How do I find only whole words using re.search?

I have a list of words built from different HTML pages. Instead of writing rule after rule to strip out different elements, I am trying to go through the list and say if it's not a full word with only alpha characters, just move on. This is not working. for w in words: if re.search('\b[a-zA-Z]\b', w) == None: continue I...

Python: How to check if a unicode string contains a cased character?

Hi! I'm doing a filter wherein I check if a unicode (utf-8 encoding) string contains no uppercase characters (in all languages). It's fine with me if the string doesn't contain any cased character at all. For example: 'Hello!' will not pass the filter, but "!" should pass the filter, since "!" is not a cased character. I planned to u...

Is there a time limit to Cron jobs in Google Apps?

I have created a cron job to scan rss/atom feeds but want to know if there is a timeout on this. The documentation says that requests are limited to 30 seconds; is a cron job a regular request that is subject to this restriction? Should I break the job up into one scan per cron job just to be on the safe side, or is there a better way?...

python one-liner

Hello, I want a one-liner solution In Python of the following code but how? total = 0 for ob in self.oblist: total+=sum(v.amount for v in ob.anoutherob) It returns total value. I want it one liner , plz any one help me ...

Looking For: A “demo” web web-based application that uses web services

Greetings – I am experimenting with various software techniques to capture and analyze the messages being exchanged between web services, web services that together would form a cloud hosted web application. One of the initial steps is locating a “demo” application to actually experiment against, one that actually consists of and uses a ...