python

Remembering to run tests before commit

We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay b...

Format of activate_time in Gtk.Menu

What is the format of the parameter activate_time in Python GTK+ when using Gtk.Menu.popup() method? I have tried using int(time.time()) but I get a traceback saying an integer is required... ...

Passing a list of strings to from python/ctypes to C function expecting char **.

Hello, I have a C function which expects a list \0 terminated strings as input: void external_C( int length , const char ** string_list) { // Inspect the content of string_list - but not modify it. } From python (with ctypes) I would like to call this function based on a list of python strings: def call_c( string_list ): li...

Python List Help

I have a list of lists that looks like: floodfillque = [[1,1,e],[1,2,w], [1,3,e], [2,1,e], [2,2,e], [2,3,w]] for each in floodfillque: if each[2] == 'w': floodfillque.remove(each) else: tempfloodfill.append(floodfillque[each[0+1][1]]) That is a simplified, but I think relevant part of the code. Does the flood...

Why am I receiving these syntax errors in Python 3.1.2?

I have been receiving errors when trying to save and run this Python 3.1 script, and I'm not sure why. I'm new to python, and I've been trying some of the Project Euler problems (this is problem 2). I recieve a "invalid syntac" error on "evenfibsum(v)", and on the colon after "__main__". I'm not sure why this is as I wrote a script for t...

How to get the last value of a list of tkinter Entry widgets

I have a list of n Entry widgets. Every widget accepts only one character, and then the focus is passed to the next one. I would like to ".get()" the values of the n widgets, but I can't get the last one. Here is the sample code: import Tkinter as tk def vf(event): actual=entrylist.index(root.focus_get()) print "--",len(entryli...

How do I merge a list of dicts into a single dict?

EDIT i have: [{'a':1},{'b':2},{'c':1},{'d':2}] the output should be: {'a':1,'b':2,'c':1,'d':2} ...

What's wrong with this code??

The code is to search for a substring...the code takes in 2 inputs...the 2nd string is used to search...i.e 2nd string is smaller in length. a=input("Enter the 1st string") //Giving error here b=input("Enter the second string") com="" for x in range(0,len(a)): com="" for j in range(x,len(b)+x): com=com...

how to send EOS message to the bus

ok, I have something like this: self.pipeline = gst.Pipeline() self.tee = gst.element_factory_make self.source = gst.element_factory_make('subdevsrc') self.source.set_property('viewfinder-mode', 1) self.source.set_property('camera-device', 1) self.capsfilter = gst.element_factory_make('capsfilter') caps = ...

python interpreter with ellipsis _ function?

>>> type(_) <type 'ellipsis'> >>> 1 + 1 2 >>> _ 2 >>> what's the usefulness of this _ function? ...

The best way to use python as a server scripting language for use on localhost

Hello all, relatively long-time PHP user here. I could install XAMPP in my sleep at this point to the point where I can get a PHP script running in the browser at "localhost", but in my searches to find a similar path using Python, I've run out of Googling ideas. I've discovered the mod_python Apache mod, but then I also discovered that ...

Python `YYYY-MM-DD`

In Python, what is the best way to get the RFC 3339 YYYY-MM-DD text from the output of gtk.Calendar::get_date()? ...

sqlite SQL query for unprocessed rows

Hi, I'm not quite even sure where / what to search for - so apologies if this is a trivial thing that has been asked before! I have two tables in sqlite: table_A = [id, value1, value2] table_A$foo = [id, foo(value1), foo(value2)] table_A$bar = [id, bar(value1), bar(value2)] Where foo() / bar() are arbitrary functions not really rele...

Help with multiline regex match

I am trying to have a regular expression match a value that spans multiple lines. I am using the re.S flag, but still get no results. Any ideas why? This is the text that I am searching through: <File id="abc.txt" EngRev="74"> <Identifier id="STRING_ID" isArray="1" goesWith="3027253"> <EngTranslation>"Value 1","Value 2","Value 3"...

How to organize GUI Code (for PyQt)?

Hi, i am looking for something similar to http://stackoverflow.com/questions/836218/organizing-gui-code, but for Python and PyQt4. Especially, I am looking at tips and examples of how to handle and store the configuration data, general state etc. EDIT: I have found some hints regarding older versions under: http://www.commandprompt.co...

LDAP connection problem with self-signed cert

The code I am using: # Create LDAPObject instance conn = ldap.initialize(url) conn.protocol_version=ldap.VERSION3 conn.simple_bind_s(binddn,bindpw) # This raises: # ldap.SERVER_DOWN: {'info': 'error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed', 'desc': "Can't contact LDAP server"} When I use ldap:...

Python Tips and Tricks

i'd like know about python tricks and tips. how write a cleaner code when you have an unfortunate situation where you need to fit as much as you can in one expression? i have some questions: Best way for speed propose Best way for readable code What you should never do What you should avoid Best expert python book Libraries that yo...

In django, how do I call the subcommand 'syncdb' from the initialization script?

I'm new to python and django, and when following the Django Book I learned about the command 'python manage.py syncdb' which generated database tables for me. In development environment I use sqlite in memory database, so it is automatically erased everytime I restart the server. So how do I script this 'syncdb' command?(Should that be d...

Compression types for a specific use in Python

I actually partially asked this in this thread http://stackoverflow.com/questions/3494020/organizing-files-in-tar-bz2-file-with-python But it mad eme rethink what I was doing. Now I think it might be a good idea to change the compression method I am using. I am currently using tar.bz2 compression. What I need to be able to do is access ...

What is the difference between a parameterized class and a metaclass (code examples in Python please)?

Hello Stack Overflow contributers, I'm a novice programmer learning Python right now, and I came upon this site which helps explain object-oriented paradigms. I know that metaclasses are classes of classes (like how meta-directories are directories of directories, etc. etc.), but I'm having trouble with something: What is the actual dif...