Python -- Add key/values to dictionary using condition

Python
I have a list of items that I'm adding to dictionary below: COLS = ['CUST', 'MODEL', 'SN', 'DATE', 'CHARGE', 'QTY', 'TOTAL'] with open('UserfeeInvoic...
2 years ago

Calculating a sequence of numbers using the while loop in Python

Python
I'm trying to return a sequence of numbers using the while loop, starting with the input value num and ending with 1. For example: >>> tray(...
2 years ago

=+ Python operator is syntactically correct

Python
I accidentally wrote: total_acc =+ accuracy instead, of course, of: total_acc += accuracy I searched the net and could not find anything. So wha...
2 years ago

sharing a :memory: database between different threads in python using sqlite3 package

Python
I would like to create a :memory: database in python and access it from different threads. Essentially something like: class T(threading.Thread): ...
2 years ago

How to join strings together within a list?

Python
my task is the following Write a menu for an online food service with the option of 4 different cuisines ie: Mexican Each of the cuisines should ha...
2 years ago

How can I make setuptools install a package that's not on PyPI?

Python
I've just started working with setuptools and virtualenv. My package requires the latest python-gearman that is only available from GitHub. The python...
2 years ago

Python, Determine if a string should be converted into Int or Float

Python
I want to convert a string to the tightest possible datatype: int or float. I have two strings: value1="0.80" #this needs to be a float value2="...
2 years ago

Finding most sequences of specified length

Python
I'm trying to write python code that will take a string and a length, and search through the string to tell me which substring of that particular leng...
2 years ago

Theano installation in Windows 32bit

Python
I am trying to install Theano library on a windows 32-bit machine. I've already installed python 2.7, numpy, scipy, mingw. The next dependency is bla...
2 years ago

how to declare variable type, C style in python

Python
i'm a programming student and my teacher is starting with C to teach us the programming paradigms, he said it's ok if i deliver my homework in python(...
2 years ago

how to assign variable value in python in terminal commands?

Python
My code: import os from xml.dom import minidom doc = minidom.parse("jobs.xml") job = doc.getElementsByTagName("job")[0] id = job.getElementsByTagNa...
2 years ago

Using metaclasses to "inherit" patched classes

Python
I have a base class extending unittest.TestCase, and I want to patch that base class, such that classes extending this base class will have the patche...
2 years ago

Is it true that I can't use curly braces in Python?

Python
I was reading that Python does all it's "code blocks" by indentation, rather than with curly braces. Is that right? So functions, if's and stuff like ...
2 years ago

Python cannot import (cython) shared library

Python
the last few days, I managed to compile rnnlib as shared library. It is a c++ library. I want to call it from python. My choice fell to cython. so I c...
2 years ago

Indexable weak ordered set in Python

Python
I was wondering if there is an easy way to build an indexable weak ordered set in Python. I tried to build one myself. Here's what I came up with: ...
2 years ago

When scattering Flask Models, RuntimeError: 'application not registered on db' was raised

Python
I am re-factoring my Flask application by scattering the models, blueprints but I am having a runtime error. def create_app(): app = flask.Flask...
2 years ago

Easy way to store multiple data in Python 3

Python
I am pretty new to Python, and so far I haven't stumbled upon any problems, until now. I need a data structure that allows me to store multi dimension...
2 years ago

Python for .NET installation: Could not load file or assembly 'clr.pyd'

Python
Really sorry guys! But for the life of me I am nearing the breaking point of going mad trying to install Python for .NET. I read the instructions meti...
2 years ago

Python: How to remove all empty fields in a nested dict

Python
If I have a dict, which field's values may also be a dict or an array. How can I remove all empty fields in it? "Empty field" means a field's value i...
2 years ago

Extract text of element line by line

Python
I am using BeautifulSoup to extract various elements from a website. I have run across a situation for which I am unable to determine an answer. I w...
2 years ago