text
stringlengths
226
34.5k
Read in csv file with one column of strings in the middle Question: I have a csv input file of standard format with a messy header that I am stripping off, and then an array of 35 columns and 8760 rows. All of this data is numeric, except the 6th column, which is text. I have tried allowing `genfromtxt()` to figure thi...
Python Pandas Histogram Log Scale Question: I'm making a fairly simple histogram in with pandas using `results.val1.hist(bins=120)` which works fine, but I really want to have a log scale on the y axis, which I normally (probably incorrectly) do like this: fig = plt.figure(figsize=(12,8)) ax = fig....
How to run Flask-Login, Flask-BrowserID and Flask-SQLAlchemy in harmony? Question: **The Whole Point** I am attempting to make a fairly basic website with Flask (noob!) and am running into trouble with the user login system. I've decided that I want to use Flask-Login, Flask-BrowserID (Mozilla Persona) and SQLAlchemy....
Python Incrementing Question: I am writing a program that will accept text as an input. The program has a value "tone" that starts at 0. Tone increments by +1 when it sees a word in that text that is also in a list of words "posfeats." Tone increments by -1 when it sees a word in that text that is also in a list of wo...
Executing different functions based on options selected Question: I wanted to know if there is a way of populating a option menu with choices and then each of the different choice gives the build button a different function for eg: Type = cmds.optionMenu('type',w = 300 ,label = 'Type of crowd:') cmd...
ImportError: DLL load failed: %1 is not a valid Win32 application - paramiko Question: I have a situation in win7 64bit, after I installing paramiko 1.12.1 by using easy_install paramiko,I'm using 64bit python2.7 , also installed 64bit pycrypto, there is a import error: >>> import paramiko ent...
Switch chars with regex Question: Say I have something like `s='abaabbab'`. Is it possible to change this to `s='babbaaba'` using regex? I mainly want to know if this is possible, not if it is reasonable. I thought perhaps one of these would work (having previously imported [`re`](http://docs.python.org/2/library/re.h...
make from a list the dictionary lists by key Question: I have a list: ['8C', '2C', 'QC', '5C', '7C', '3C', '6D', 'TD', 'TH', 'AS', 'QS', 'TS', 'JS', 'KS'] I need to get a dictionary something like this: (sorting is not important) {'C': ['QC', '8C', '7C', '5C', '3C', '2C'], ...
Python on windows subprocess don´t work Question: I want test to open a winrar password protected file, testing with dictionay of words. This is my code, but it don't work can any help me ? thanks import subprocess def extractFile(rFile, password): try: subprocess.call(['c:\\mio\\unrar\\u...
Adding a new column to a FITS file via python Question: I have created an array named **distance** that contains 1242 values. I want to add this array as the 11th column in an already existing FITS file that contains 10 columns. I am using pyfits. I tried pyfits.append(filename, distance) which showed no errors but d...
Python date conversion Question: Okay, I give up. Python version 2.7.2 >>> from datetime import datetime >>> datestr = "2014-01-24" >>> displaydateobj = datetime.date(datetime.strptime(datestr,'%Y-%d-%m')) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:...
Finding a combination in a string using regex in python Question: I'm trying to find a combination but it is not working >>> whole = ('\n1. WIPO is located at\n(A) New York\n(B) London\n(C) Geneva\n(D) Paris\n') >>> match = re.findall('1\.\s(\w+\s)+\w+\n', whole) >>> print(match) ['located'] ...
How to test a python eval statement in UWSGI application's ini config? Question: As far I can tell, my eval statement within a USWGI's app config isn't working/executing, but I cannot figure out how to test this. * **OS:** Debian GNU/Linux 7.1 (wheezy) * **UWSGI:** 1.2.3-debian * **Python:** 2.7 I'm actually tr...
PyQt crashing out as a Windows APPCRASH Question: I have a [very short PyQt program](http://pythonfiddle.com/pyqt-crashing- example) (n.b. that is a PythonFiddle link - this seems to crash horribly in Firefox, so code is also posted below) which prints output to a `QTextEdit` (using code [from this SO answer](http://st...
How do I finish this Rock, Paper, Scissors game in Python? Question: import random userscore = 0 computerscore = 0 print("Welcome to the Rock, Paper, Scissors Game") while True: print("User Score = ", userscore, " Computer Score = ", computerscore) print("Rock, Paper or Sc...
What does "del" do exactly? Question: Here is my code: from memory_profiler import profile @profile def mess_with_memory(): huge_list = range(20000000) del huge_list print "why this kolaveri di?" This is what the output is, when I ran it from interpreter: # Li...
extracting and listing word in python Question: i have difficult to do this project python script to extract and list all words that meets the following conditions: (1) words with two consonants next to each other. (2) words of length 5 or more that start and ends with a vowel. (3) words of length 7 or more that ...
returning one value from a dict key with multiple values in python Question: I am trying to return "runnerName" from the following dict: {u'marketId': u'1.112422365', u'marketName': u'1m Mdn Stks', u'runners': [{u'handicap': 0.0, u'runnerName': u'La Napoule', ...
Wsgiref Error: AttributeError: 'NoneType' object has no attribute 'split' Question: I am trying to implement my own version of wsgiref for learning purpose and i ended up here. from wsgiref.simple_server import make_server class DemoApp(): def __init__(self, environ, start_response): ...
pyglet on_draw event occurs only when mouse moves Question: I have a strange problem. When pyglet app starts it just draws 1-2 frames then freezes. on_draw event just stops occuring. But everytime I move mouse or press keys, on_draw event dispatches as well. In short I have to move mouse to make my pyglet application b...
How to import text file from different folder? Question: I have my project folder `\FNAL PROJ\project` and I need to open `file.txt` from folder `\FNAL PROJ\project\data` How to do it in Python? Answer: Assuming your main script is somewhere on \FNAL PROJ\project folder: with open("data/file.txt", "r"...
How to change the images in python Question: I'm working on xbmc to run four images with my own python script. I have set up the keyboard control using keymap.xml as I want to change the images in python when pressing on the left arrow on the keyboard. I'm using xml file to store the parser path for the images. Here'...
My program in python to count the number of different words only returns the value six. Any ideas why? Question: Here is my code. I am using Python: import re file = open('TEST.txt') text = file.read() file.close() words = list(text.split()) myset= set(words) num = len(myset) ...
How to generate a deck of cards in Python Question: How do you generate a full deck of 52 cards the most efficiently in list format in Python so that the list will look like this: `['1 of Spades', '1 of Hearts', '1 of Clubs', '1 of Diamonds', '2 of Spades', '2 of Hearts'` etc. Answer: I would prefer the following co...
Running django tutorial tests fail - No module named polls.tests Question: I'm playing with django 1.6 tutorial but i can't run tests. My project (name mydjango) and app structure (name is polls) are as shown below in a virtualenv. (.nja files are just created by ninja-ide the ide i'm using) . ├── __...
How to put random lines from a file into a string in python? Question: what i want to do is write a code that has a file (in the code, no need to be input by user), and the code picks a random line from the file - whatever it is, a long line, an ip or even a word and at the end of the loop puts it into a string so i co...
Python regex findall to capture repeated groups Question: # Context I am using python [regex](https://pypi.python.org/pypi/regex "regex") to parse some HTMLs because they are too broken to use processors better suited for those tasks (e.g. scrapy selectors). An excerpt of the HTML I want to parse looks like this: ...
Using Surface.copy() sometimes loses transparency Question: For some (but not all!) images, copying a surface using `surface.copy()` loses the transparency. So I've got two questions? 1. **Why does copy lose the transparency?** The [docs](http://www.pygame.org/docs/ref/surface.html) sound like _everything_ about the...
'tuple' object has no attribute 'update' Question: I'd like to extend my user profiles using custom models. Unfortunately whenever I'm visiting the page where the profile is located I receive 'tuple' object has no attribute 'update' I've tried to get around this myself but after 2,5hrs it did hit me that I'm stuck. C...
Iterating Swap Algorithm Python Question: I have an algorithm. I want that last solution of the algorithm if respect certains conditions become the first solution. In my case I have this: 1. First PArt Split the multidimensional array q in 2 parts split_at = q[:,3].searchsorted([1,random.randrange(LB...
no python output using print Question: Hi am new to python and just trying to read a simple csv file and output to the terminal using: import csv with open('cancerdata.csv', 'rb') as csvfile: data = csv.reader(csvfile, delimiter=' ') for row in data: print row How...
How to dismiss a dialog box displayed by MS Word when openning document in Python/Win32 Question: I'm trying to write a script that would go though content of all ms word docs in a folder and collect some information. I use Python 2.7.3 and Ms Office 2007 The issue I have is that sometimes MS Word is coming with a warn...
python or awk comparing files Question: I have two files that are tab delimited.I need to compare file 1 column 3 to file 2 column 1 .If there is a match I need to write column 2 of file 2 next to the matching line in file 1.here is a sample of my file: file 1: a rao rocky1 beta b rao buzzy2 be...
Mouser Cart API Request Question: I don't know if I'm going to post it here but I am trying to request to the Mouser Cart API using python, and the suds library def updateCart(): url = "https://mews.mouser.com/cartservice.asmx?op=UpdateCart&wsdl" client = Client(url) xmlns = Attribute("xmlns"...
Parsing JSON with Python Requests for Django App Question: I'm having trouble parsing this request. It looks like this: {"randomnumber": {"id":blah, "name":blah, ... }, "randomnumber22": { ... }} Using python requests, I retrieve the url that returns that data, and decode it so I can try to loop th...
Scipy Sparse - distance matrix (Scikit or Scipy) Question: I am trying to compute nearest neighbour clustering on a Scipy sparse matrix returned from scikit-learn's `DictVectorizer`. However, when I try to compute the distance matrix with scikit-learn I get an error message using 'euclidean' distance through both `pair...
Python not calling Jython using 'subprocess' module Question: I'm trying to call a Jython script from a Python file. I've the **Jython file:`testing.py`**, which contains: print "Hello" Then, I've the **Python file`caller.py`** that contains: import subprocess subprocess.call(['...
mpi4py Send/Recv with tag Question: How can I pass a the rank of a process as a tag to the mpi4py.MPI.COMM_WORLD.Send() function and correctly receive it with mpi4py.MPI.COMM_WORLD.Recv()? I'm referring to the following code example for [sending and receiving messages between two processes using Send and Recv function...
Why don't a singleton-shaped Thread-subclass instance's attributes of type Event return the same value? Question: I have this part of code: from threading import Thread, Event class mySubThread(Thread): instance = [] def __new__(cls): if not cls.instance: ...
Python Pysftp Error Question: My code: import pysftp s = pysftp.Connection(host='test.rebex.net', username='demo', password='password') data = s.listdir() s.close() for i in data: print i I'm getting an error trying to connect to a SFTP server using pysftp. This should...
python 2.7 : appending log return to csv Question: With the following code I'm trying to grab data from a website every 5 mins, timestamp it, calculate its logn return and append all that to a csv file. Grabbing the data, time stamping it and appending to csv works, but when I try to figure out how to include the log ...
Scrapy: How do I set an HTTP proxy to connect to HTTPS websites (HTTP works)? Question: I'm using a middleware to enable a proxy like this: I have this in settings.py HTTP_PROXY='127.0.0.1:8080' This is my middleware from mybot.settings import HTTP_PROXY class ProxyMiddlewa...
NotImplementedError Django Command Question: I created a simple django command and when I want to test it from the command line (terminal) I get a NotImplementedError. My code: from django.db import models from django.core.management.base import NoArgsCommand from email.mime.text import MIMEText...
How to round up to 32 using the math module (Python 3,) Question: Is it possible to round upwords using the built-in math module? I know that you can use math.floor() to round down, but is there a way to round up? Currently, I use this to round: def roundTo32(x, base=32): return int(base * round(...
Custom pyqtSignal implementation Question: In PyQt, you can use `QtCore.pyqtSignal()` to create custom signals. I tried making my own implementation of the Observer pattern in place of `pyqtSignal` to circumvent some of its limitations (e.g. no dynamic creation). It works for the most part, with at least one differen...
virtualenv AssertionError with Red Hat Enterprise Linux Server release 6.3 Question: I am using RHEL 6.3 and have 2.6.6. I need to use the Python 2.7.6. I compiled python from source, installed pip and virtual env. Now I am trying in different ways: virtualenv-2.7 testvirtualenv virtualenv --python=...
What is the best way to capture output from a process using python? Question: I am using python's `subprocess` module to start a new process. I would like to capture the output of the new process in real time so I can do things with it (display it, parse it, etc.). I have seen many examples of how this can be done, som...
Why is Django calling my datetimes naive when they are not? Question: I've got a blog system I'm building in Django 1.6, and I'm trying to render a YearArchiveView, or at least get a list of years with posts, from my Post model's DateTimeField, pub_date. It keeps telling me my pub_date is naive, but I've explicitly cha...
How to Install pre-requisites with setup.py Question: I have pure python package that relies on 3 other python packages: I'm using distutils.core.setup to do the installation. This is my code from setup.py: from distutils.core import setup setup( name='mypackage', version='0.2',...
Python: Is there syntax-level support for unpacking, from tuples, the arguments to an *anonymous* function? Question: Suppose we have the following: args = (4,7,5) def foo(a,b,c): return a*b%c Python conveniently allows tuple unpacking: foo(4,7,5) # returns 3 foo(...
Fitting gaussian to a curve in Python II Question: I have two lists . import numpy x = numpy.array([7250, ... list of 600 ints ... ,7849]) y = numpy.array([2.4*10**-16, ... list of 600 floats ... , 4.3*10**-16]) They make a U shaped curve. Now I want to fit a gaussian to that curve. ...
ElementTree and UnicodeEncodeError: Question: I'm processing the following xml file: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <tag>…</tag> Just like python documentation says: import xml.etree.cElementTree as ET tree = ET.parse('file.xml') print(tree.ge...
Jython by Keyword-Parameter passing to invoke Java methods Question: I have this Java class, public class sample { public Integer foo(Integer x){ return x+5; } } And with Jython I want to call `.foo` while passing "keyword-parameter" to the argument. I ended up with ...
Async Thread Deadlock in Julia When Used With PyCall Question: I'm trying to implement a basic client-server socket structure using Python and Julia, where the producer is in Python and the consumer is in Julia. My code on the Python side looks like this: def startServer(host='127.0.0.1', port=4002): ...
Calling methods of a Java subclass using Jython Question: I have this Java class, public class sample { public Integer foo1(Integer x){ return x+5; } } class SubClass extends sample{ public Integer foo2(Integer x){ return x+100;...
Predefine routine in scala sbt console? Question: I am recently writing scala, using sublimetext to write *.scala and run sbt in another window. When I use sbt console to debug, every time I need to manually import packages and do routines. It's really annoying to repeat copying codes again and again after I recompil...
Python - OSError: [WinError 17] The system cannot move the file to a different disk drive: Question: I'm using os.rename() to try to move pdf files between drives. Attempting this I receive the error: OSError: [WinError 17] The system cannot move the file to a different disk drive ...
Python2.7, the use of import matplotlib results in function output being assigned to a list twice Question: I've been testing the use of an accumulate function in the following python code. This code works well in producing the correctly accumulated output, however it assigns the output to the list "test" twice. If I c...
How to use the sublime plugin api to create a new layout and open a file in each cell Question: I'm trying to write a plugin that will allow me to open a group of related files in one go. The premise being: 1. The plugin presents the user with a list of directories (ostensibly self contained ui components) 2. The ...
How do I get MathJax to enable the mhchem extension in ipython notebook Question: Okay, this has been a very frustrating adventure for me. I have spent many hours over several successive days trying to get MathJax to enable and recognize the mhchem extension within a Markdown cell in ipython notebook. Math expressions ...
input() error - NameError: name '...' is not defined Question: I am getting an error when I try to run this simple python script: input_variable = input ("Enter your name: ") print ("your name is" + input_variable) Lets say I type in "dude", the error I am getting is: line 1, in ...
Loop with after() in Tkinter Question: I am a newbie with Tkinter and am still very unsure of the things I am trying to do, hopefully it is not to stupid. Every help is welcome. I want to use my Rasberry Pi to controll some motors. These motors put ingredients together. It works fine in Python, but I want to have a GU...
Python exec() when called in class breaks on lambda Question: I'm doing code generation and I end up with a string of source that looks like this: **Source** import sys import operator def add(a,b): return operator.add(a,b) def mul(a,b): return operator.mul(a,b) ...
Label textvariable wont display on secondary window. Python 3/Tkinter Question: I want to display the same label (textvariable) on multiple windows at once but it will only show the content on the window that is created first. The label appears on the other but it is basically an empty field. Something interesting to ...
Python 2.7: log displayed twice when `logging` module is used in two python scripts Question: # Context: Python 2.7. Two files in the same folder: * First: main script. * Second: custom module. # Goal: Possibility to use the `logging` module without any clash (see output below). # Files: ## a.py: ...
Factorial function works in Python, returns 0 for Julia Question: I define a factorial function as follows in Python: def fact(n): if n == 1: return n else: return n * fact(n-1) print(fact(100)) and as follows in Julia: function fact(n...
How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte" Question: as3:~/ngokevin-site# nano content/blog/20140114_test-chinese.mkd as3:~/ngokevin-site# wok Traceback (most recent call last): File "/usr/local/bin/wok", line 4, in Engine() File "/usr/local/lib/python2.7/site-packages/wo...
Error in for loop. (Finding three integers) Question: So, our teacher gave us an assignment to find three integers a, b c. They are in all between 0 and 450 using Python. a = c + 11 if b is even a = 2c-129 if b is odd b = ac mod 2377 c = (∑(b-7k) from k = 0 too a-1) +142 (Edited. I wrote it wrong. Was -149) I tir...
Dynamic INSERT Statement in Python Question: I am working on updating some Python code I have been working with and was looking for some advice on the best way to deal with an idea I am working with. The part of my code that I wish to change is : my_reader = csv.reader(input, delimiter = ',',quotechar='|...
ignore socket.error in python Question: using a simple code to get hostname from ip address. #!/usr/bin/python import socket import os import sys try: fdes = open ("ip.txt","r") for line in fdes.readlines(): print socket.gethostbyaddr(line)...
cogent.db.ensembl cookbook's example of .getGeneByStableId() returns 'ProgrammingError' Question: I get an error using PyCogent to query EnsEMBl's database - could this bug result from updates in EnsEMBL or PyCogent? When trying to reproduce the code for the PyCogent Cookbook's [Querying Ensembl](http://pycogent.org/e...
flask isnt reading or interpreting css file Question: Im basically trying to follow this tutorial ( <http://net.tutsplus.com/tutorials/python-tutorials/an-introduction-to- pythons-flask-framework/>) Now when the css part comes in, and i copy the code it simply wont come out styled even afterr main.css is added it stil...
Pandas: import multiple csv files into dataframe using a loop and hierarchical indexing Question: I would like to read multiple CSV files (with a different number of columns) from a target directory into a single Python Pandas DataFrame to efficiently search and extract data. Example file: Events 1...
launch external shell python instance in shell from python Question: I'd like to call a separate non-child python program from a python script and have it run externally in a new shell instance. The original python script doesn't need to be aware of the instance it launches, it shouldn't block when the launched process...
An efficient way to search similar words (with specified length) in two strings using python Question: My input is two strings of the same length and a number which represents the length of the common words I need to find in both strings. I wrote a very straightforward code to do so, and it works, but it is super super...
How do I count only weekdays from timedelta in python Question: I am getting the number of days until the next "billing cycle" (for example) which starts on the `nth` day of the month: from dateutil.relativedelta import relativedelta dt = datetime.utcnow() + relativedelta(months=1,day=schedule.c...
No output in XML file using XMLITEMEXPORTER Question: I am beginner to python and I am working with scrapy. I have used xmlitemexporter to export my scraped data to xml file. But i get only "<"/item"">" in the xml file. My items.py is like follow: from scrapy.item import Item, Field class Workwi...
Frequent "OperationalError: unable to open database file" with in memory sqlite3 database Question: I'm using an in-memory database for a Python app, and am hitting pretty frequent "unable to open database file" errors when attempting to access the same in memory database from multiple threads. Because it says that th...
While using Python's msilib- UPDATE statement fails with error 2259 Question: I have the following class method that is meant to run database statements: class CDatabaseModifier(object): def __init__(self, database): """ Constructor gets database """ self._data...
Python 3.x - Getting the state of caps-lock/num-lock/scroll-lock on Windows Question: Just as the question asks, I know this is possible [on](http://stackoverflow.com/questions/13129804/python-how-to-get-current- keylock-status) [Linux](http://stackoverflow.com/questions/3207032/detect- caps-lock-in-python-curses), but...
Django Internationalization doesn't work (makemessages doesn't find .py file) Question: I'm trying to internationalize my Django site with I18N. When I do the makemessages. Bit that did not get the text of the view.py. I have done the following things: # my flow PROJECT - LOCALE - MYSITE ...
interacting between modules / classes in wxPython Question: I have a task of migrating a multi-userframe VBA project with a lot od database interaction into something different - as this must be something that cannot demand installing software (so JRE and .NET are out of the question) I believe this can be done with Py...
Python - scipy fmin, giving the arguments to fmin Question: I'm a bit of a newbie in Python. I'm writing a little piece of code in order to find the minimum of a function: import os,sys,matplotlib,pylab import numpy as np from scipy.optimize import fmin par = [2., 0.5, 0.008] x1 = 0....
Editing PDF attributes using sed Question: I'm trying to develop a python script for blender to output a rendered image sequence to a PDF. I am using Imagemagick to convert to PDF, that part is working fine, However, I want the thumbnail preview to also be included in the PDF. The PDF format is a bit confusing to me, ...
Python convert WKT polygon to row wise points Question: "POLYGON ((12 13,22 23,16 17,22 24))",101,Something,100000 "POLYGON ((10 12,40 42,46 34,16 24,88 22,33 24,18 20 ))",102,another,200000 How can I get something like below in a csv file: UID(like 101,102 etc) represents an unique identifier for each ...
Installing mysqldb with a new version of python on linux Question: I have mysqldb installed and it works for python2.4. But I've recently installed python2.6 and when I run it I can't import mysqldb. I get the following: import MySQLdb ImportError: No module named MySQLdb I've looked over how t...
Problems running flask app on uwsgi / nginx Question: I have created a flask app and up to this point have been using the default flask server for creating/testing it. Now i want to deploy it to a server. I am using uwsgi and nginx, though i am pretty new to both. i know there are a lot of guides and questions about si...
Python Shortest path between 2 points Question: I have found many algorithms and approaches that talk about finding the shortest path between 2 points , but i have this situation where the data is modeled as : [(A,B),(C,D),(B,C),(D,E)...] # list of possible paths If we suppose i need the path from ...
BeautifulSoup is not scraping ALL anchor tags in a page with .find_all('a'). Am I overlooking something? Question: Okay, so in a terminal, after importing and making the necessary objects--I typed: for links in soup.find_all('a'): print(links.get('href')) which gave me all the links on a w...
selenium python not working with phantomjs Question: I have installed phantomjs with npm and selenium-python via python. Everything works properly with Headless Firefox, but not with phantomjs. Here is the code. In [1]: from selenium import webdriver In [2]: browser = webdriver.PhantomJS() ...
How to save all instances in a single transaction in the peewee (python)? Question: How to save all instances in a single transaction in the [peewee](http://peewee.readthedocs.org/en/latest/) (python orm library)? For example: from peewee import SqliteDatabase, Model, TextField DB_NAME = 'users....
Getting the start time of a new process which I triggered Question: I am using Multiprocessing module in python and triggering many processes. Is there a way where I can find out the START TIME of each process that I triggered? Since the processes are triggered quickly, I am looking to get the time in milliseconds or ...
Customizing Regex for Validator in Python Question: Just came across a line of code that enforces an user's text input into the dialog's field. Regardless of the input only IP format will be allowed at the end such as : **123.456.789.100** regexIP=QtCore.QRegExp("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") ...
Same but without loops Question: So I've got this module called risar. And what it does, it draws. But that's not really of importance. I wrote this code which sets 20 flowers on the background. The code works but it looks horribly awkward to me. I'd like it to look more "fancy" or maybe that less loops would be used. ...
What happened in the Django 1.6 branch that affected how Manager metaclasses work? Question: I have a little utility module, [django- delegate](https://github.com/fish2000/django-delegate), that lets you define methods on a QuerySet subclass and then “delegate” those method definitions to a corresponding Manager subcla...
Is subprocess.Popen not thread safe? Question: The following simple script hangs on the subprocess.Popen call intermittently (roughly 30% of the time). Unless use_lock = True, and then it never hangs, leading me to believe subprocess is not thread safe! The expected behavior is script finishes within 5-6 seconds. T...
Dictionary that counts occurrences of its items Question: I'd like to create a [`dictionary`](http://docs.python.org/2/tutorial/datastructures.html#dictionaries) in python that automatically counts the repetitions of its elements: when an element that is not contained is added it should insert it with corresponding va...
Gedit problems with python Question: I'm just learning Python in school and we were suppose to draw something (code it in gedit for python) on canvas (Tkinter). Instead of getting something drawn up I only get an empty canvas. [It looks like this on my computer](https://db.tt/X2vvLfQ9). The code is correct as I copied ...
How to limit by column repetitions in Python Pandas Question: I want to select only rows that contain fewer than 3 total repetitions of an element in a column. To be specific, I have a large directory of phone numbers, names, and cities. I want to export a list of only "small cities," such that any line with a city tha...
Python 3.3.3 Running Files with Command Line Question: I just started learning Python 3.3.3 with the book "Learning Python" from O'Reilly by Mark Lutz, 4th Ed. I was able to run code interactively, but when I tried to run the code from files through the command line, I just kept getting syntax errors. FYI, I am using...