text
stringlengths
226
34.5k
Rounding logic in Python? Question: In my original code I was trying to compute some indices out of some float values and I faced the following problem: >>> print int((1.40-.3)/.05) 21 But: >>> print ((1.40-.3)/.05) 22.0 I am speechless about what is going on. Can someb...
How can I access a file in a completely different directory based on absolute path (Python) Question: import os test = os.path.exists("c:/conf.txt") if test == False: with open("c:/conf.txt", "w") as Inc: Inc.write("0") Inc.close() quit() if test == True: ...
StatementError: SQLite Date type only accepts Python date objects as input Question: I am using Flask-Security, the code seems fine, but when inserting a data from register view it gives the bellow error. Since I made SECURITY_TRACKABLE = True I added some extra fields in my models and the problem might be there :( ...
Why is requests.get() retrieving different HTML using Python than browser? Question: I am attempting to extract data from an HTML table, but it appears that the HTML isn't loading correctly when using `requests.get()`. Instead, a line in the source reads: > "JavaScript is not enabled and therefore this page may not fu...
Porting algorithm from Python to Go Question: I am trying to port this python code to Go but there is no **beta()** in math package. Where can i find beta and other functions required for this? from numpy import * from scipy.stats import beta class BetaBandit(object): def __init...
Biopython SeqIO processing NNNNN in *.ab1 files Question: Thanks for your help. I apologize in advance if there is a function built into Biopython that handles this, I read the whole manual and couldn't find anything. **Goal:** Read in a raw sequencing file (*.ab1) and process using sequence.seq.translate(11) However,...
Fast and efficient way to detect if two images are visually identical in Python Question: Given two images: image1.jpg image2.jpg What's a fast way to detect if they are visually identical in Python? For example, they may have different EXIF data which would yield different checksums, even thou...
drmaa error with sun grid engine - No active session Question: Hi I've installed gridengine on a 4-node cluster using the following command: sudo apt-get install gridengine-client gridengine-qmon gridengine-exec gridengine-master sudo apt-get install gridengine-exec gridengine-client And it ret...
How can I log a functions arguments in a reusable way in Python? Question: I've found myself writing code like this several times: def my_func(a, b, *args, **kwargs): saved_args = locals() # Learned about this from http://stackoverflow.com/a/3137022/2829764 local_var = "This is some other...
python button does not work when image is added Question: When I try to add and image to the button, the program will run, but the button will be blank and you cannot click on it. If I change `image=Tkinter.PhotoImage(file="C:/TeDOC/OpenFolder.gif")` to `text='Open Directory` it works fine and you are able to click the...
Continuing code after executing a File - Python Question: I have made a Simple GUI that launches when i run my Twitch TV IRC Bot. But, the main bot doesn't continue until after i close the GUI. How would i make it so the Script runs at the same time as the GUI? This is the GUI: ##--GUI--## def whitel...
psutil - getting process name is blank Question: I'm trying to run this code and I'm not getting the list of processes by name: import psutil PROCNAME = "python.exe" for proc in psutil.process_iter(): if proc.name == PROCNAME: print proc What I get is nothing e...
Create a Student-Age graph in Python-Matplotlib Question: import matplotlib.pyplot as plt x = ['Eric','Jhon','bill','Daniel'] y = [10, 17, 12.5, 20] plt.plot(x,y) plt.show() When I run this code, I get this error `ValueError: could not convert string to float:` I want all names in list `x` a...
Comparing two strings in Python - depends on string source...? Question: I have the following python script: import sys import io str1 = 'asd' str2 - 'asd' if (str2.find(str1)==-1): print('FALSE') else: print('TRUE') #Prints "TRUE" It works fine. N...
How to execute sql Python script in Windows command Prompt? Question: I have a simple script that uses sqlite3 in Python. However, when I run this from cmd.exe in Windows I get an "Open With" window. If I click 'cancel' it says "Access is denied." in cmd.exe. import sqlite3 connection = sqlite3.conn...
Check whether an entry present in python list and add the elements Question: I have two python list of the form list1 = [('TGFB1', 'TGFB1', 1), ('TGFB1', 'CRP', 0.4),('BRCA2', 'TP53', 0.3)] list2 = [('BRCA1', 'TP53', 2), ('TGFB1', 'CRP', 0.4),('BRCA2', 'TP53', 0.3)] I need to check whether each...
What is the canonical way to check if a function has been called in Python unittest without use of a mock? Question: If I have a class similar to the 1 below and I want to test the various cases for the bar function, how can I accomplish this without mocking the private functions? In other words, how in Python's unitte...
Create a matrix of tf-idf values Question: I have a set of `documents` like: D1 = "The sky is blue." D2 = "The sun is bright." D3 = "The sun in the sky is bright." and a set of `words` like: "sky","land","sea","water","sun","moon" I want to create a matrix like this: ...
Asserting execution order in python unittest Question: I have a function that creates a temporary directory, switches to that temporary directory, performs some work, and then switches back to the original directory. I am trying to write a unit test that tests this. I don't have a problem verifying that the current dir...
How do I keep the focus on the command prompt when calling pylab.show? Question: I am calling a python script from the comandline (bash under Ubuntu): > python myScript.py within this script, I create a figure, show it (nonblocking) with PyLab and wait for a user entry: import matplo...
Spyder SymPy Wont Print Symbolic Math Question: I setup Anaconda 2.0.0 (Win 64). It has SymPy 0.7.5. I configured Spyder (2.3.0rc that came with Anaconda) to use symbolic math: _Tools > Preferences > iPython console > Advanced Settings > Symbolic Mathematics_ I create a new project and a new file: # -...
Merging two Excel files by ID and combining columns with same name (python, pandas) Question: I am new to stackoverflow and pandas for python. I found part of my answer in the post [Looking to merge two Excel files by ID into one Excel file using Python 2.7](http://stackoverflow.com/questions/17661836/looking-to-merge-...
Dynamically assign values - python Question: looking to improve the efficiency of my code, as while my current method works, i feel it can be improved currently this is my code : if ouroraddrlen == (4,): ouropip = struct.unpack(">bbbb", payload[6:10]) # Need to change this to accept ipv6 as ...
Python ginput not allowing new points to be plotted Question: This code asks the user to digitize three points (using ginput), then should plot those points to the screen atop the imshow plot. It does not. Any ideas why? from pylab import show, ginput, rand, imshow, plot from matplotlib.figure import...
Skip subdirectory in python import Question: Ok, so I'm trying to change this: app/ - lib.py - models.py - blah.py Into this: app/ - __init__.py - lib.py - models/ - __init__.py - user.py - account.py...
How to extract the string values "Hello" and "World" from the XML using Python 2.6 Question: I need to extract the strings "Hello" and "World" using Python 2.6. Please advice. <Translate_Array_Request> <App_Id /> <From>language-code</From> <Options> <Category xmlns="http://schem...
How do I get the "biggest" path? Question: I need to write some Python code to get the latest version of Android from a path. For example: $ ls -l android_tools/sdk/platforms/ total 8 drwxrwxr-x 5 deqing deqing 4096 Mar 21 11:42 android-18 drwxrwxr-x 5 deqing deqing 4096 Mar 21 11:42 android-...
python error in get trending topic using tweepy Question: I am trying to get top 20 trending topic through twitter api based on the Tweepy library. Here is my python code: import tweepy import json import time today = time.strftime("%Y-%m-%d") CONSUMER_KEY = "" CONSUMER_SEC...
Argparse mutally exclusive by subgrouping Question: Currently the argparse of my code gives the following: usage: ir.py [-h] [-q | --json | -d ] Some text optional arguments: -h, --help show this help message and exit -q gene query terms (e.g. ...
ImportError: No module named ui_imagedialog Question: I am new to pyQt4. First I installed pyqt4 then installed QTDesigner. And tried to run the given program( From internet). The file is named as main.py import sys from PyQt4.QtGui import QApplication, QDialog from ui_imagedialog import Ui_Image...
Passing thread to threaded object Question: Quick question on the use of `QThread` in PyQt4 and Python 2.7. I am creating a process inherited from `QObject`, and assigning this to a `Qthread` I have created in a separate class (also inherited from `QObject`). Is it safe to pass the `QThread` object to the process obje...
Using owl:Class prefix with rdflib and xml serialization Question: I would like to use the `owl:` prefix in the XML serialization of my RDF ontology (using rdflib version 4.1.1); unfortunately I'm still getting the serialization as `rdf:Description` tags. I have looked at the answer about binding the namespace to the g...
LED fade in python - implementing multithreading Question: I'm trying to build a program that controls an RGB LED through a RaspberryPi. I was able to build a simple fade program in python using [pi- blaster](https://github.com/sarfata/pi-blaster/), which works fine but doesn't let me do what I want. Here's my code: ...
Find edges in a cycle networkx python Question: I would like to make an algorithm to find if an edge belongs to a cycle, in an undirected graph, using networkx in Python. I am thinking to use `cycle_basis` and get all the cycles in the graph. My problem is that `cycle_basis` returns a list of nodes. How can I convert t...
Clustering 500,000 geospatial points in python Question: I'm currently faced with the problem of finding a way to cluster around 500,000 latitude/longitude pairs in python. So far I've tried computing a distance matrix with numpy (to pass into the scikit-learn DBSCAN) but with such a large input it quickly spits out a ...
When I run my fabfile, I am being asked for password although I specified a key. Why? Question: Good Day, I have a python script which runs a fabfile. My issue is that I am asked for a password whenever I run the fabfile from my script. However, the login works fine with the specified key when I run the fabfile manual...
Handling an image download popup Question: I'm trying to download an image using Python's Mechanize, and that's an easy thing to do with urlretrieve, however this image's 'src' attribute holds a url which initiates a download popup. There doesn't seem to be a url that points to the image. I'm using Python Mechanize, b...
Starting script using pyinotofy as daemon process Question: I have a number of questions regarding starting a script using pyinotify as a daemon. I have some code like this: #!/usr/bin/env python import sys import pyinotify import shutil import glob PACKAGES_DIR = '/var/my-...
How to extract all columns but one from an array (or matrix) in python? Question: Given a numpy 2d array (or a matrix), I would like to extract all the columns but the i-th. E. g. from 1 2 3 4 2 4 6 8 3 6 9 12 I would like to have, e.g. 1 2 3 2 4 6 3 6 9 or ...
Debug django tests Question: I see that [TestCase](https://docs.python.org/3/library/unittest.html) has a method [Debug()](https://docs.python.org/3/library/unittest.html#unittest.TestCase.debug), but I can't find any example on how to implement it. As far as I've tried, nothing works. Can anyone provide some code as ...
python throwing an error HTTP 401 while accessing https://stream.twitter.com/1.1/statuses/filter.json Question: This is the Code I am running to get the stream of tweets using Streaming API by accessing the stream.twitter url mentioned in title. but it is throwing an error (HTTP error 401) In the code I am trying to tr...
Hidden (missing) library dependency, when linking with cl.exe Question: I've just been exposed to a large non-trivial CMake/Eclipse based C++ project. One of the build targets is Windows/nmake based. In the final step of building an executable, the linker throws LNK1104: cannot open file 'python27.lib'. This is correct...
flask-restless with mod_wsgi can't connect to MySQL server Question: I am trying to run a flask-restless app in apache using mod_wsgi. This works fine with the development server. I have read everything I can find and none of the answers I have seen seem to work for me. The app handles non-database requests properly bu...
Saving Image in a temporary file in django Question: I am very new in python and django.I have developed a project using django. Here all the images are watermarked.I have watermarked all the images using the following code... from PIL import Image def image_watermark(request,image_id): ...
How to read from QTextedit in python? Question: I created the GUI using QTDesigner and save the file as .ui extension. Then convert the file to .py file using the following code pyuic4 -x test.ui -o test.py Now I want to integrate my project code to this test.py file. Since I am new to pyqt4, I do...
Attribute error in python while trying to sign in Question: I am using python (with selenium webdriver) to sign into yahoo. Below is the code: import unittest from selenium import webdriver from selenium.common.exceptions import NoSuchElementException #Set Selenium firefox browser o...
python write files and maintain folder structure Question: I'm working on a script that will read files from one location, manipulate the data, and then write the output to a different location. At the command line the user will use a -p to specify a top-level folder and then the script will recurse through there and f...
Running multiple stored procedures using pypyodbc giving incomplete results Question: I'm running a relatively simple python script that is meant to read a text file that has a series of stored procedures - one per line. The script should run the stored procedure on the first line, move to the second line, run the stor...
Encoding with pandas.read_csv when file name has accents Question: I'm trying to load a CSV with pandas, but am running into a problem if the file name has accents. It's clearly an encoding problem, but although `read_csv` lets you set encoding for text within the file, I can't figure out how to encode the file name pr...
How do I load a modified python module? Question: I'm using the widely used module PySerial (<http://pyserial.sourceforge.net/index.html#>) for serial communication in Python. One of it's functions is readline() which reads a line until end of line '\n'. I created a new function readline_v2() similar to readline() in t...
Kivy Garden in PyInstaller - stuck trying to trace import Question: I have a Kivy-based Python project that I'm trying to build. It uses the NavigationDrawer component from Kivy Garden, through an import: > from kivy.garden.navigationdrawer import NavigationDrawer I have a PyInstaller spec file for it which builds a ...
Efficient way to aggregate and remove duplicates from very large (password) lists (SOLVED) Question: Context: * I am attempting to combine a large amount of separate password list text files into a single file for use in dictionary based password cracking. * Each text file is line delimited (a single password per...
Tkinter Ttk Python: limiting text entry widget values to numbers and limiting amount of characters Question: Probably an easy one here: in tkinter, ttk, how do you limit the amount of characters that can be input by the user into an entry field? For example, only allowing the user to insert one character and limiting t...
Best way to package a Python library that includes a C shared library? Question: I have written a library whose main functionality is implemented in C (speed is critical), with a thin Python layer around it to deal with the `ctypes` nastiness. I'm coming to package it and I'm wondering how I might best go about this. ...
AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10c49a668> ignored Question: I'm trying to implement my coursera python project in flask environment. Also I'm using the <https://github.com/miguelgrinberg/flasky> (branch 7a) to understand how the blueprints work. Now, I define 2 blu...
Django Error: __init__() takes exactly 2 arguments (3 given) Question: Anyone can find what is causing the error in my code? I already searched, but didn't find an answer. I think the problem is with the function objects.get(param), but I'm not sure. What I wanted to do with my code was to retrieve the objects Genre, ...
How is semaphore variable passed into the following object in python? Question: After tweaking with this piece of code a few times, I dropped sem.release() in the Server object WITHOUT actually passing the variable sem into it. But it works wonderfully... Can't seem to understand why a error wasn't throw for undeclared...
How can I use "include.yaml" in google appengine to share a library within two apps? Question: I have two different applications on GAE, but both have some code in common. I wanted to share that code but I can't find a way to import a .py file that's not in the same directory as the main app. I think that "includes" ...
detect key press in python? Question: I am making a stopwatch type program in python and I would like to know how to detect if a key is pressed (such as p for pause and s for stop), and I would not like it to be something like raw_input that waits for the user's input before continuing execution. Anyone know how to do ...
python motor mongo cursor length or peek next Question: is there a way of determining the length of the motor mongo cursor or peeking ahead to see if there is a next ( instead of `fetch_next` perhaps `has_next` ) and not the `cursor.size()` that does not take into the provided limit() basically i desire to add the re...
how to access global variable within __main__ scope? Question: I'm confused about the namespace and scope of variables in python Suppose I have a test.py: # -*- coding: utf-8 -*- """ @author: jason """ if __name__ == '__main__': global strName print strName and...
from qgis.core import QgsFeature, QgsGeometry. DLL load failed Question: I recently installed QGIS and I want to import qgis module of Python. I use Windows 7 x64 and QGIS 2.2 x64. I set the PATH to : C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\P...
Python: Trouble with encoding on Windows (Bokeh plotting library) Question: I am trying to reproduce the simplest examples from the [Bokeh tutorial](http://bokeh.pydata.org/tutorial/basic.html), on a 64-bit Windows machine with Python 3.3.0. Here is the code in its entirety import pandas as pd impor...
python 2.7 imaplib error Question: I tried to connect to my mail server via imaplib and got an error in constructor: My code: import imaplib imaplib.IMAP4_SSL('my_host.com', 1234) Error: Traceback (most recent call last) /home/username/www/site/<ipython console> in <modu...
How to create graphic slider in Python that can be modified with mouse? Question: How can i create a graphic slider similar to a progress bar in PyQt that can be modified from 0 to 100 with mouse? ![enter image description here](http://i.stack.imgur.com/rUa9m.jpg) Answer: You have to set QSlider stylesheet appropria...
Python Searching and returning text inside parentheses Question: Okay, I have read many similar questions and tried them out but it's not working for some reason. I have a file with a bunch of lines that look like this: Here are some words: "<Hello> (silly girl) that isn't what she want(s)" I am t...
Create crontab with python-crontab in Python? Question: I am trying to add a line to my system user's crontab, from a Python script which uses the package python-crontab. My crontab file does not exist yet, and when I run this code, nothing happens (no errors, no results, no creation of crontab file): fr...
Auto running a script in python Question: I'm looking for a script that auto spams pictures of nicholas cage on the desktop I have this script right now but what I want to do is make it automatically run as soon as the USB is plugged in import shutil src = ('Kim.jpg') dst = ('H:/profile/deskto...
trac ticketlog.web_ui error when browsing trac Question: I am receiving the following errors. i am using trac 0.12 on centos 5. I have plugins, advancedticketworkflow, ldaplugin, smtpldapemailsender, tracannouncer, tracwysiwg. i am trying to install commit ticket updater and similar plugins but they are not showing up....
Why is `subprocess.call` not invoking the command Question: I'm trying to run a .wav file through ffmpeg using the `subprocess.call(shell=True)` in the following code and it doesn't seem to run. I know this because the `output_file` isn't created and I'm getting an exception in the `open()` method. What am I doing wron...
Prevent Python from showing entered input Question: In Python when I change the value of a variable through raw_input in the terminal it would write a new line stating its new value. I wanted to know if there is a way to avoid that because straight after user's input there is a print function which uses the value recei...
Python scikit-learn (using grid_search.GridSearchCV) Question: I'm using grid search to fit machine learning model parameters. I typed in the following code (modified from the sklearn documentation page: <http://scikit- learn.org/stable/modules/generated/sklearn.grid_search.GridSearchCV.html>) from skle...
IOError: decoder jpeg not available when using Pillow Question: Before someone says `"sudo apt-get install libjpeg-dev"` or something along those lines, I do not have sudo access. I am on a slice of a server that does NOT allow me to have sudo access. So I've gotta do this entire thing in my local directory. That's the...
Shared library from Boost python build does not contain any functions Question: I'm having trouble building a shared library from my Boost Python project. For some reason, the final shared library is nearly empty and doesn't contain any of my wrapped functions. I've managed to get the "Hello World" example running on m...
Python: difficult in converting csv to list of list Question: I want to read a .csv file which has data format like -179.750 71.250 -26.7 -19.5 -22.5 -22.3 -8.0 -0.6 2.5 -179.750 68.750 -28.5 -21.3 -24.4 -24.4 -8.0 0.0 4.0 ..... and I want to convert ...
SAWarning: Could not instantiate type <class 'sqlalchemy.sql.sqltypes.INTEGER'> when I use sqlalchemy and pd.io.sql.read_sql Question: I try to read pandas DataFrame from my SQLite table. When I run the code below import pandas as pd import sqlalchemy dbname = "sqlite:////Users/leda/home/Mag...
Why does this Python 3 code fail to remove Unicode accented characters using str.translate()? Question: I am trying to normalise accented characters in a string in Python 3 like this: from bs4 import BeautifulSoup import os def process_markup(): #the file is utf-8 encoded fn ...
Can't sort into categories, values will increase indefinitely, can't remove enemies Question: import random from random import * import math from math import * from pygame import * import pygame, sys from pygame.locals import * import pygame.font from pygame.font import * ...
Split a huge CSV in three random files in Python Question: I have a huge CSV and I want to split it in 3 random files with almost* equal size. *almost: the size cannot be divided by 3 I was thinking to create 3 blank lists, then in a for loop, I would randomly choose one number between `range(0,len(mycsv))` and appen...
"self" as method attribute Question: I am attempting to teach myself Python at the moment and I am trying to work my way through a python program, which is essentially a pacman game. Whilst doing so, I discovered the following class call which contains 'self' as a method attribute. game = Game(agents, di...
How to get a list of axes for a figure in pyplot? Question: I am new to `python` and `pyplot`. I am trying to understand the documentation for the Matplotlib API related to the Figure [Figure API](http://matplotlib.org/api/figure_api.html). In the beginning it says there is a `class matplotlib.figure.AxesStack`, and t...
3D volume acrobatics in python.. selecting x/y/z rows/columns in 3D numpy arrays Question: I'm new to ndarrays in Numpy, so please be kind. I have a 3D raw volume imported into numpy as a dtype uint8 array with shape `(309L, 138L, 134L)` representing Z, Y, X dimensions. The Raw image dimensions are (x,y,z), 134 138 30...
Python Pandas calucate Z score of groupby means Question: I have a dataframe like this: df = pd.DataFrame({'Year' : ['2010', '2010', '2010', '2010', '2010', '2011', '2011', '2011', '2011', '2011', '2012', '2012', '2012', '2012', '2012'], 'Name' : ['Bob', 'Joe', 'Bill', 'Bob', 'Joe'...
In PyGame, how to move an image every 3 seconds without using the sleep function? Question: Recently I've learned some basic Python, so I am writing a game using PyGame to enhance my programming skills. In my game, I want to move an image of a monster every 3 seconds, at the same time I can aim it with my mouse and cl...
Python regex matching pattern not surrounded by double quotes Question: I'm not comfortable with regex, so I need your help with this one, which seems tricky to me. Let's say I've got the following string : string = 'keyword1 keyword2 title:hello title:world "title:quoted" keyword3' What would be ...
Why does Python run a C++ function faster than C++ running its own function via its main() function? Question: I wrote an extremely brute force function to check if a number is a prime number. The loop goes up to 1,000,000. I compiled that C++ code into a shared library and ran that function with Python, then I ran the...
Color image segmentation with Python Question: I have many pictures as below: ![target picture example](http://i.stack.imgur.com/C31sn.jpg) My objective is to identify those "beads", try to mark it with a circle, and count the detected numbers. I tried to use image segmentation algorithms via Python and the source co...
Running A Process In the Background In Flask Question: I am making a webapp in python and flask which will email & tweet to the webmaster when the moment his website goes down. I am thinking of running an infinite while loop which waits for 10 minutes and then send a request to the website to be checked and checks if t...
How to automatically cluster my dataset images into different groups based on local features or global using python or OpenCV? Question: I have a dataset of images , and i want to group my images into different groups based on content. What i have tried till now is find median of images and thought to group them into d...
Compare specific fields in two files -Python Question: I want to compare two files(file1 and file2) with different columns but have the first 4 columns in common, the output should be the lines of file2 existing in file1: **file 1:** 132.227.127.170 49163 173.194.40.110 443 132.227.127.170 49164 ...
How to plot a density map in python? Question: I have a .txt file containing the x,y values of regularly spaced points in a 2D map, the 3rd coordinate being the density at that point. 4.882812500000000E-004 4.882812500000000E-004 0.9072267 1.464843750000000E-003 4.882812500000000E-004 1.405174 ...
How to show webcam capture in Plone site using OpenCV? Question: I am using Plone 4.3. I am trying to create a face recognition system on the Plone site. I need to show webcam captures using a template page. My sample code is below. However, when I run this code, I can't get the captured image in the template file. sa...
Adding more than one list Question: I want to try the many ways the function of python So, I want to not use zip use other python function ,how can i do to? this is use zip and adding more than one list: but i want to other way not use zip: x = [12, 22, 32, 42, 52, 62, 72, 82, 29] y = [10, 11, 12, 1...
pandas ValueError: numpy.dtype has the wrong size, try recompiling Question: I took a new clean install of OSX 10.9.3 and installed pip, and then did pip install pandas pip install numpy Both installs seemed to be perfectly happy, and ran without any errors (though there were a zillion warnings...
how to merge file lines having the same first word in python? Question: I have written a program to merge lines in a file containing the same first word in python.However I am unable to get the desired output. Can anyone please suggest me the mistake in my program? **Note:- (line1,line 2)** and **(line4,line5,line6)**...
cx_Oracle - DLL load failed Question: I have a problem importing cx_Oracle with Python. I know a lot of issues with cx_Oracle have been discussed here, but it seems that I cannot find a solution to my problem after reading all the related topics. I have two machines, one is my computer and another one is a remote work...
Replace lowercase ASCII characters with X in Python Question: What is the cleanest, most Pythonic code for replacing lowercase characters with 'X' in a string? For example, `ABCDEFGhijklmnopQRSTUVwxyz` would become `ABCDEFGXXXXXXXXXQRSTUVXXXX`. Answer: I'd use [`str.translate()`](https://docs.python.org/2/library/std...
Using CouchDB Kit and Python; Trying to setup database without having to set DB inline Question: I am using `couchdbkit` to build a small Flask app and I am trying to write out some Python models so that interacting with the DB is easier (not inline). Here is my code so far: base.py from couchdbkit imp...
How to access MySQL from python Question: I've always used Xampp for db/ server purposes. I'm trying to use the same with my Python project but cannot seem to get it to work. Error from Python Shell import MySQLdb ImportError: No module named 'MySQLdb' I've been all around but nothing seems to...
function names from config file in python Question: I have a JSON config file which tells me what kind of distribution to sample from. For example: { "parameter1" : { "distribution" : "exponential", "mean" = 5}, "parameter2" : { "distribution" : "poisson", "mean" = 3} } The list above can be ...