Python Selenium: Link click does not work

I have following HTML, I want to click the a tag with text MOUNT TAMALPAIS SP, CA the href is actually a javascript method. Below are details: Code keyword = 'MOUNT TAMALPAIS SP' link_text = wait.until(EC.visibility_of_element_located((By.PARTIAL_LIN

PyQt wakes up the main thread of non-QThread

I have a PyQt application that receives information from an external source via callbacks that are called from threads that are not under my control and which are not QThread. What is the correct way to pass such information to the main thread, witho

KeyError: '_OrderedDict__root?

Hi I have following code snippet which gives KeyError. I have checked other links specifying make __init__ call to Ordered Dict which I have done. But still no luck. from collections import OrderedDict class BaseExcelNode(OrderedDict): def __init__(s

Indentation preserving multi-line string formatting

I generate bits of (C++) code using format strings such as memfn_declaration = '''\ {doc} {static}auto {fun}({formals}){const} -> {result}; ''' Format strings are nice for this, but is there a way to make them keep the indentation level for {doc} her

Using the digital form output in logic

I am using Python 2.7.5 on Windows 7. For some reason python doesn't like it when I use one of the dimensions of my numpy array to with a comparator in an if statement: a = np.array([1,2,3,4]) # reshapes so that array has two dimensions if len(np.sha

Python: Rearranging an integer into a larger palindrome number

I have written the following code to solve the topic "Rearrange an interger number to a largest palindrome number" Example: Input data is 485, the output should be 'Not palindrome number' Input data is 445, the output should be 454 Input data is

AttributeError: object 'module' has no 'picamera' attribute

I'm climbing the learning curve with my kids using a project involving rabbits (original project: hamster cam, We've followed the instructions to arrive at the program below. When w

django form field validation and error display

I want to make a signup page just like: When user click signup, I want to check the if the two password are the same, when not, give a error message after "confirm password". Here is my code: class SignupForm(forms.Form): username = for

Python 3.x: Transformation Chain

I need to transform source string into extended string, e.g: A1f4h3L2 => AffffhhhLL My code: source = [] answer = '' s1 = 'S15Y16r13g11b8X8J15Q9V2i18p5e10' source += s1 i = 0 while i <= (len(source)-1): if source[i].isalpha: if source[i+1].isdigit:

Counting elements in a list used as a dictionary value

I have the following dictionary of lists working fine, but the printing at the end is borked, I can't get the counter to return correct numbers of items in each list as soon as I get more than one key in my dictionary! It's supposed to tell me how ma

When to use the integrated reverse instead of slicing the list

In python, there are a number of ways to reverse a sequence: l = [1,2,3] reversed(l) #returns a reverse iterator l[::-1] #returns a reverse sequence Although there is a builtin specifically for reversing a sequence, it is more concise to use list sli

Delete a dictionary key if it is a substring in another key

I'm learning Python. I've got a performance issue. For a single dictionary, I want to remove keys if The a key is a substring in another key I don't want to remove keys if The key substring is itself My keys are unique strings mostly between 3-50 cha

Python list understandings nodejs / javascript

Is there anything similar to pythons list comprehension for nodejs/javascript? If there is not then is it possible to make a function that has similar behavior for example # Example 1 list_one = [[1, 2], [3, 4], [5, 6], [7, 8]] someOfList = sum(x[1]

How can I print a dictionary in a table format?

Let's say I have a dictionary like: my_dict = {1:[1,2,3],4:[5,6,7],8:[9,10,11]} I want to be able to print it so it looks like: 1 4 8 1 5 9 2 6 10 3 7 11 I'm actually working with much larger dictionaries and it would be nice if I can see how they lo

Deleting sprites in Pygame

I have a tile map that runs through a for loop similar to this: def Draw_Level( x, y, column, obsticles, entities, image_cache ): #Grass# if column == "G": g = Grass(x, y, image_cache) entities.add(g) #Plain Grass# elif column == "P":

Changing the Python logging level at runtime

In log4net we can change the log level in the xml config file on runtime from DEBUG to ERROR for example and the change take effect immediately. is there a way to do it in python? i haven't figured out yet how to do it. In addition, for some reason,

Can I use SQLPlus to run a .sql file?

I have a .sql file with the following code: delete from stalist where stalistid=4944 / insert into stalist (stalistid, staid) (select distinct 4944, staid from staref Where staid in( 3797,3798, 3870,4459, 3871,3872, 3876,3877, 0 )) / commit / I would

Unexpected python file behavior

Possible Duplicate: Weird behavior when writing and reading file When I try to write into a file and then read it, I get an unexpected result. My code is: f=open("z.txt","w+") f.write("Hello") print content f

Using a loop to obtain a specific index in a test / except

For a project I'm working on I am processing lots of deeply nested dict-and-list data structures. Often I find myself doing a lookup that I expect to return a list with a single member. Lookups may fail outright, or simply return zero results, so I c

POS tagging German text using NLTK

I would like to use NLTK for pos tagging german texts. I found this question and this project. Both look quite complicated and I cannot find some NLTK documentation about how to train pos taggers. Any hint? I'm looking for the most simple way to put

how to make a cell in a QTableWidget read only?

i have the following code defining the gui of my app class Ui (object): def setupUi(): self.tableName = QtGui.QTableWidget(self.layoutWidget_20) self.tableName.setObjectName(_fromUtf8("twHistoricoDisciplinas")) self.tableName.setColumnCount(4) s

Calling an external script from the Django admin interface?

I have a Django admin interface that is used almost solely as a gui form for making changes to a single postgresql table. There's also a Python script that's currently run manually from the command line whenever a change is made to the database, & I'

Python 2.5 problem subprocess.Popen

I'm trying to run the following little Python script: #!/usr/local/bin/python2.5 import sys, subprocess child = subprocess.Popen("muscle -stable -FASTA", stdin=sys.stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=(sys.platform!="