For example in Lua you can place the following line at the end of a script:
return <some-value/object>
The value/object that is returned can then be retrieved by the hosting application.
I use this pattern so that scripts can represent factories for event handlers. The script-based event handlers are then used to extend the applicat...
First off the html row looks like this:
<tr class="evenColor"> blahblah TheTextIneed blahblah and ends with </tr>
I would show the real html but I am sorry to say don't know how to block it. feels shame
Using BeautifulSoup (Python) or any other recommended Screen Scraping/Parsing method I would like to output about 1200 .htm files i...
Given:
urlpatterns = \
patterns('blog.views',
(r'^blog/(?P<year>\d{4})/$', 'year_archive', {'foo': 'bar'}),
)
in a urls.py file. (Should it be 'archive_year' instead
of 'year_archive' ? - see below for ref.)
Is it possible to capture information from the URL
matching (the v...
When i tried recording using QTP, every thing goes well till the application sign in. i.e it gets upto the user Id and password entry, But QTP fails to recognise afterthat. Is there any way to handle this?
Application is to be invoked using Citirx, in VPN.
...
I was working with generator functions and private functions of a class. I am wondering
Why when yielding (which in my one case was by accident) in __someFunc that this function just appears not to be called from within __someGenerator. Also what is the terminology I want to use when referring to these aspects of the language?
Can the ...
I have several python.exe processes running on my Vista machine and I would like to kill one process thanks to the Windows task manager.
What is the best way to find which process to be killed. I've added the 'command line' column on task manager. It can help but not in all cases.
is there a better way?
...
As we know, Python has boolean values for objects: If a class has a length attribute, every instance of it which happens to have length 0 will be evaluated as a boolean False (for example, the empty list).
In fact, every iterable, empty custom object is evaluated as False if it appears in boolean expression.
Now suppose I have a class ...
I need to write a script that connects to a bunch of sites on our corporate intranet over HTTPS and verifies that their SSL certificates are valid; that they are not expired, that they are issued for the correct address, etc. We use our own internal corporate Certificate Authority for these sites, so we have the public key of the CA to ...
There is an eval function in Python I stumbled upon while playing around.
I cannot think of a case when this function is needed, except maybe as syntactic sugar.
Can anyone give an example?
Thanks :)
...
I had been using the reportlab NumberedCanvas given at http://code.activestate.com/recipes/546511/ . However, when i try to build a PDF that contains Image flowables, the images do not show, although enough vertical space is left for the image to fit. Is there any solution for this?
...
Suppose that I need to swap keys for values in dictionary.
This is what I have in mind (Assuming that the values' value is unique):
>>> my_dict = {'x':1, 'y':2, 'z':3}
>>> my_dict2 = {}
>>> for key, val in my_dict.items():
my_dict2[val] = key
Is there any other efficient way to do it?
...
I need to launch an external process that is to be controlled via messages sent back and forth via stdin and stdout. Using subprocess.Popen I am able to start the process but am unable to control the execution via stdin as I need to.
The flow of what I'm trying to complete is to:
Start the external process
Iterate for some number o...
I want to write some unittests for an application that uses MySQL. However, I do not want to connect to a real mysql database, but rather to a temporary one that doesn't require any SQL server at all.
Any library (I could not find anything on google)? Any design pattern? Note that DIP doesn't work since I will still have to test the inj...
myPythonClient (below) wants to invoke a ringBell function (loaded from a DLL using ctypes). However, attempting to access ringBell via its name results in an AttributeError. Why?
RingBell.h contains
namespace MyNamespace
{
class MyClass
{
public:
static __declspec(dllexport) int ringBell ( void ) ;
} ;
...
How can i check if a file on a remote ftp is a folder or not using ftplib?
Best way i have right now is to do a nlst, and iterate through calling size on each of the files, if the file errors out then it is a folder?
Is there a better way? I cannot parse the output of list, since there is about a dozen different ftp servers(many extrem...
Ok, I've got a list like this (just a sample of data):
data = {"NAME": "James", "RANK": "3.0", "NUM": "27.5" ... }
Now, if I run something like this:
sortby = "NAME" //this gets passed to the function, hence why I am using a variable sortby instead
data.sort(key=itemgetter(sortby))
I get all the strings sorted properly - alphabetic...
I'm writing a mixin which will allow my Models to be easily translated into a deep dict of values (kind of like .values(), but traversing relationships). The cleanest place to do the definitions of these seems to be in the models themselves, a la:
class Person(models.Model, DeepValues):
name = models.CharField(blank=True, max_length...
Hi all! I am using ElementTree to parse a XML file. In some fields, there will be HTML data. For example, consider a declaration as follows:
<Course>
<Description>Line 1<br />Line 2</Description>
</Course>
Now, supposing _course is an Element variable which hold this Couse element. I want to access this course's description, so I ...
Okay so a bit of forward:
We have a service/daemon written in python that monitors remote ftp sites. These sites are not under our command, some of them we do NOT have del/rename/write access, some also are running extremely old ftp software. Such that certain commands do not work. There is no standardization among any of these ftp's, a...
How can I get at the Labels data from within my Task model?
class Task(db.Model):
title = db.StringProperty()
class Label(db.Model):
name = db.StringProperty()
class Tasklabel(db.Model):
task = db.ReferenceProperty(Task)
label = db.ReferenceProperty(Label)
creating the association is no problem, but how can I get at the labe...