Understanding the nested list

I have 2 lists, A and B. A is list of dictionaries which contain list of values. B is a simple list. Requirement is to add the elements of list B into dictionary values of A. Below is the code, a = [{'a':[1,5]}, {'b' : [6,10]}, {'c' : [11,15]}] b = [

How do I allow spaces in a regex of Django username?

I am trying to allow spaces to be accepted into the username field of the default django.contrib.auth.models User, other people have asked directly or similar questions before: Here, Here, and Here. I have tried to implement these suggestions however

Pip does not show the installed module - argparse

I've already installed argparse successfully, but it doesn't show up on pip list. C:\Python34>pip install argparse Collecting argparse Downloading argparse-1.4.0-py2.py3-none-any.whl Installing collected packages: argparse Successfully installed argp

Complex non-greedy correspondence with regular expressions

I'm trying to parse rows from a HTML table with cells containing specific values with regular expressions in Python. My aim in this (contrived) example is to get the rows with "cow". import re response = ''' <tr class="someClass">

How to sort through WebElements

I'm trying to come up with a script/for-loop that will locate all input elements on the form and depending the the type of the input will send string/number keys or perform select class So i got my createForm : <form id="createForm" class=&qu

How to debug Python in C Level?

How to debug python in c level? in PyCharm,i cannot step into the c level code. could it? or which tool can do it?Use GDB, there's a ton of information on it here. https://wiki.python.org/moin/DebuggingWithGdb You need to install the python version w

Lights for Mongoengine with Django do not work

I am using Mongoengine(version: 0.9.0 ) with Django(version: 1.8). This is my settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.dummy' } } MONGO_DBNAME = "mydatabasename" MONGO_HOSTNAME = "localhost" connect(MONGO_DB

Why is the exception not properly entered?

I have a piece of code. import sys while(True): print "Enter a number: " try: number = int(sys.stdin.readline()) except ValueError: print "Error! Enter again an integer value" continue finally: print number break Here I expect when I e

How to get the current value of ndarray based?

There is the function which operates with numpy.ndarray: def func(x): print x # here I need a current value of ndarray return 5*x For some calculation I need a current value of passed ndarray, something like np.nditer() while iterating. Output: x = a

Insert spaces and values ​​in the Python list

I'm trying to create a file with numbers from 0 to 99, but each one has to be an a line of the txt. lista=[] for i in range (100): a=str(i) lista.append(a) print lista arch = open('numeros.txt', 'w') for i in range (100): linea = lista[i] arch.write(

Use the Saxon with python

I need to process XSLT using python, currently I'm using lxml which only support XSLT 1, now I need to process XSLT 2 is there any way to use saxon XSLT processor with python?There are two possible approaches: set up an HTTP service that accepts tran

Unable to configure python.exe on * .py scripts on Win7

i've installed py 2.7 (64bit) on my PC with Win7 (64bit) without problem but I'm not able to run *.py scripts via DOS shell without declare python full path. Let me better explain : If I type D:\ myscript.py it doesn't work. The script is open with w

Use 3 vectors as columns in a matrix

I realize this should be really easy, but I have a large dataset (14k points) and I was having memory issues with my dumb new to coding way of doing this. So. I have three ordered lists, xnew is x coordinates, ynew is y coordinates, and znew is z coo

Python ValueError with Tuple being the correct length

I'm getting the following error: Traceback (most recent call last): File "C:/Users/user/Documents/Data Munger/new_munger.py", line 49, in <module> for a, b in temp_tuple: ValueError: too many values to unpack (expected 2) from the followin

Numpy where the multiple conditions of the function

I have an array of distances called dists. I want to select dists which are between two values. I wrote the following line of code to do that: dists[(np.where(dists >= r)) and (np.where(dists <= r + dr))] However this selects only for the condition

Counting values ​​in the dictionary

I have a dictionary as follows. dictA = { 'a' : ('duck','duck','goose'), 'b' : ('goose','goose'), 'c' : ('duck','duck','duck'), 'd' : ('goose'), 'e' : ('duck','duck') } I'm hoping to loop through dictA and output a list that will show me the keys in

call an EDITOR (vim) from a python script

I want to call up an editor in a python script to solicit input from the user, much like crontab e or git commit does. Here's a snippet from what I have running so far. (In the future, I might use $EDITOR instead of vim so that folks can customize to

Recovering html string on a non-unique array

Here is the html I am trying to parse. <TD>Serial Number</TD><TD>AB12345678</TD> I am attempting to use regex to parse the data. I heard about BeautifulSoup but there are around 50 items like this on the page all using the same tab

Coordinates of the element on the array numpy

I have a numpy array: [[ 0. 1. 2. 3. 4.] [ 7. 8. 9. 10. 4.] [ 14. 15. 16. 17. 4.] [ 1. 20. 21. 22. 23.] [ 27. 28. 1. 20. 29.]] which I want to quickly find the coordinates of specific values and avoid python loops on the array. For example number 4 i

Queries Django Special Characters

I Working on location from google maps and using django to. My question is: I have a String in request.GET['descricao'] lets say it contains "Via rapida". In my database i have store = "Via RĂ¡pida" i'm doing : local = Local.objects.fil

Python optparse and spaces in an argument

When using optparse i want to get the whole string after an option, but I only get part of it up to the first space. e.g.: python myprog.py --executable python someOtherProg.py What I get in 'executable' is just 'python'. Is it possible to parse such

Python and dictionary as object

I need a python 3.1 deep update function for dictionaries (a function that will recursively update child dictionaries that are inside a parent dictionary). But I think, in the future, my function could have to deal with objects that behave like dicti

python + spreadsheet

Can anybody please tell me is there any possible way to connect to spreadsheet from python? I want to store some data from a form and submit it to google spreadsheet. Please help on this issue. What steps do I have to follow? Thanks in advance...The