text
stringlengths
226
34.5k
Getting "AttributeError" while printing stopwords from nltk toolbox in python Question: from nltk import stopwords print(stopwords.words('english')) Second line is giving error which is Traceback (most recent call last): File "<pyshell#16>", line 1, in <module> print(stopwor...
Django AttributeError: 'CharField' object has no attribute 'model' after migration Question: **Note: I'm using Django 1.9 and Python 3.4.2** I'm getting a strange error when I make a change to one of my models, make a migration (`./manage.py makemigrations`) and then try to apply the migration (`./manage.py migrate`)....
Read in a CSV file in lower case with Python Question: I'm reading a CSV file into a namedtuple as so: import csv from collections import namedtuple #So we can handle bad CSV files gracefully def unfussy_reader(reader): while True: try: yield next(read...
Convert excel-file to pdf-file Question: I have used openpyxl to autogenerate 154 excel files. Everything worked like a charm! Now I need to convert the excel-files into pdf-files. Can this be done automatically or do I need to do it manually? Note: It is important that I have the option to define margins and horizon...
Why I get error from pip installing getch? Question: I'm doing a small file checker, and I need to do a (character pressed?) command. So I used getch. I get this error when trying to pip install it: Command "c:\python27\python.exe -c "import setuptools, tokenize;__file__='c:\\us ers\\manolo\\appdata\...
3-Layer Neural Network Getting Stuck in Local Minima Question: I've programmed a 3-Layer Neural Network in Python, based on [this tutorial](http://iamtrask.github.io/2015/07/12/basic-python-network/), to play Rock, Paper, Scissors, with sample data using _-1 for rock_ , _0 for paper_ , and _1 for scissors_ , and simila...
Extraxt & save all text() with Scrapy Question: I'd like to extract the text from an HTML file using Python. I want essentially the same output I would get if I copied the text from a browser and pasted it into notepad. To solve this problem I need to use the framework. As an example, take a page <https://en.wikipedia....
Interpolation of 3D data in Python Question: I have data in 3D. I would like to interpolate this data layer by layer (in the plane X, Y) because calculating each layer takes a lot of time. I try to use the interp2D function and loop through the layers but f seems to apply only to the last value of i0. X...
Read pdf page by page Question: I searched for my question and did not get my answer in the two available questions 1. [Extract text per page with Python pdfMiner?](http://stackoverflow.com/questions/12605170/extract-text-per-page-with-python-pdfminer) 2. [PDFMiner - Iterating through pages and converting them to...
Python 3.4 Tkinter, Understanding code/setting window size Question: I'm trying to make a tkinter GUI using classes, which I'm pretty new to (I have watched all of TNB's tutorials on it), and I'm having some issues with implementing features into my code and understanding it. I'm trying to adapt code I found on this si...
python checking surrounding points list of lists index out of range Question: I'm working on a school project and i'm trying to go through list of lists containing numbers. I'm trying to check all 8 surrounding "block" but i'm getting index out of range exception filling the list: for i in range(0, self...
Error while installing oursql in virtualenv Question: When I try to install oursql under virtual environment using pip install oursql I get following error: Collecting oursql Using cached oursql-0.9.3.1.tar.bz2 Building wheels for collected packages: oursql Running setup.py bdist_wheel fo...
How to give path for file passed through command line Question: I got answer for how to pass file as argument here [How to access variables from file passed through command line](http://stackoverflow.com/questions/34596823/how-to-access-variables- from-file-passed-through-command-line) But I am asking separately since...
how can I convert a binary float to a base 10 float and vice versa? Question: I have a binary float like '10.1' and want to convert it to a decimal float. Then I want to do some operations on it and convert it back to a binary float. Are there builtins in python 2 to do this? If not, what is the shortest (in bytes) way...
How to return to my main program from an imported function in python? Question: I'm trying to go back to my main program from an imported function. My situation is something like this: main program || \/ imported function || \/ imported function (2) now I...
Python connect o Access error Question: I am using Python 2.7.8 32-bit to call MS Access 2007. Below is the code I use: import sys import pypyodbc import os import pyodbc conn = pyodbc.connect(r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=D:\Access\Geocoding.accdb;") ...
Python - Requests module, getting the domain name? Question: I'm trying to build a web crawler using the `requests` module, and basically what I want it to do is go to a webpage, get all the `href`'s and then write them to a text file. So far my code looks like this: def getLinks(url): response = re...
MySQL export to CSV file as UTF-8 via Python script Question: I'm able to export a MySQL table into a CSV file via Python `csv` module but there are no utf-8 characters. (example: `????` chars insted of `ąöę`). The table data is in utf-8 format (phpMyAdmin let me see correct data). I found some information that in Py...
Python problems with background image Question: I've been trying to insert a background image to python in pygame, I'm a beginner in pygame and I know how to do some simple tasks with pygame, however, when I try to add an image to the background, I'm kind of lost on this, I've been trying to apply this on a tutorial I ...
Reference Excel in Python Question: I am writing a python code for beam sizing. I have an Excel workbook from AISC that has all the data of the shapes and other various information on the cross-sections. I would like to be able to reference data in particular cells in this Excel workbook in my python code. For example...
Reading and Writing data in CSV files in Python Question: I am new to Python and I am having some problems with CSV files in Python. Please help me out 1. How do I open and read csv files in Python which are present in some other directory? I know we can do import csv f = open('attendees1.csv') ...
Unable to send email from python Question: I am using the following code to send email from python program in localhost, import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText me = "tonyr1291@gmail.com" you = "testaccount@gmail.com" ...
How to plot two values as a histogram using Python script? Question: I have to plot two length of the values in histogram using python script. File=[1,2,3] File1=[3,4,5,6] files=len(File) files1=len(File1) I want to plot the length of the values . The files and files 1 in x axis....
How to get xml output in a file with new line using python xml.etree? Question: I am generating xml file using "from xml.etree import ElementTree" and placing the generated output in to a new file "test.xml". The output is getting placed inside the test.xml but there is no new line its a big big line. So, what shall i ...
Is it possible to keep the same window for every class in python's tkinter? Question: I am trying to create a program in tkinter which allows me to open an initial window then to keep it throughout all classes used. For example, if I was to create a button in a window then when I click this button, it would exuecute a ...
Translate argparse's internal strings Question: How can I translate Python's argparse module strings? For example, when you display the help, it says `"usage: "`, string that is translatable but I don't know how to do it in my program. This is the source code part of `argparse.py`: def _format_usage(se...
Python: flip a bit in a float Question: I would like to flip a specific bit in a float in Python. It seems to be quite difficult, because the operand | works only for int. For now I have tried to convert a float into a int: [Get the "bits" of a float in Python?](http://stackoverflow.com/questions/14431170/get-the-bits...
Modifying built-in function Question: Let's consider any user-defined pythonic class. If I call `dir(obect_of_class)`, I get the list of its attributes: ['__class__', '__delattr__', '__dict__', '__dir__', ... '__weakref__', 'bases', 'build_full_name', 'candidates', ... 'update_name']. You can ...
How to expand matrix expression in sympy Question: Hi I'm trying to do a matrix multiplication and expand it afterwards. However, `sympy` does not seem to support expansion of matrix equations. For example Runge-Kutta 4 for matrices: from sympy import init_session init_session() from sympy import...
Python: FFT parallel computing Question: I have a cluster of few PC's with Ubuntu and MPICH server - I use them to parallel computing with C++ and MPI. Now I want to do similar with Python. My question is - is there any easy method to make Fast Fourier Transform on many CPU cores (on many computers)? Example of usage w...
How to embed a plot directly into a Window (python; QT;) Question: I wanna embed a Matplotlib plot directly into a window, QMainWindow. It should be part of my program with a more complex GUI. ;) The only way I found was to add the figure as widget into a QTabWidget. See sample code below. I lost the link to the webpa...
Python: How to print my simple poem Question: I would like to know how I could print out sentences using my triplet poem program. My program randomly picks a list of nouns to use. My program: import random def nouns(): nounPersons = ["cow","crowd","hound","clown"]; nounPlace = [...
Theano simple linear regression runs on CPU instead of GPU Question: I created a simple python script (using Theano) performing linear regression which should be run on GPU. When code starts it says "using gpu device", but (according to the profiler) all operations are CPU-specific (ElemWise, instead of GpuElemWise, no...
OOP in python (related to scrapy) Question: The question is how to share data between objecs in a safe and maintainable manner. Example: I've build the scrapy application which spawns numerous spiders. Although each spider is connected to separate pipeline object, I need to compare and sort the data between different ...
Simple Python SMTP Enumeration script Question: I am trying to write a simple Python SMTP enumeration script, which reads usernames from a text file (filename supplied as the second argument - `sys.argv[2]`), and checks them against an SMTP server (hostname or ip supplied as the first argument - `sys.argv[1]`. I found ...
How to fix unicode error while generating xml file using python xml.etree.ElementTree without misssing any data? Question: I am generating xml file using xml.etree.ElementTree in python and then writting the generated xml file into a file. One of the tag of the xml is regarding system installed software which will have...
Python: Retrieve the Mac Address of the client using bottle framework Question: I am looking to retrieve the Mac_Address of the user accessing my application. I have tried the following code: import uuid from uuid import getnode as get_mac mac_address = get_mac() mac_address = ':'.join(("%012...
Python apply class method to row of data frame Question: My class takes a row of a dataframe to construct an object and I would like to create an array of objects by applying init to every row of a dataframe. Is there a way to vectorize this? My class definition looks like class A(object): def __...
How to obtain all the links in a domain using Python? Question: I want to use Python to obtain all the links in a domain given the 'root' URL (in a list). Suppose given a URL <http://www.example.com> this should return all the links on this page of the same domain as the root URL, then recurse on each of these links vi...
How to set PYTHONPATH differently for version 2 and 3? Question: Let's assume that I set PYTHONPATH in `.bashrc` as below: export PYTHONPATH=$PYTHONPATH:/ver2packages And when I check my python path in Python 3: $ python3 >>> import sys >>> print(sys.path) ['', '/home/use...
Python 3.4 AssertEqual() unpredicted behavior when using in a Django unit test Question: I faced some strange behavior of the AssertEquals() in a Django unit test (Python 3.4). The following test results in an **assertion error like this** : > line 113, in test_index_view_with_questions_without_choices > self.assertEq...
How to draw graph in python or convert python into java and Matlab? Question: Recently i need to do a project with digit recognition using data from UCI <https://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits> I want to use source code fromhttps://github.com/khiner/Linear-Discrimination- with...
python script parsing multiple arguments Question: I have trouble passing parameters to my script. Script launch command line : myscript.py -c Random I'm using getopt in my code (given down there) but this code is not looping through the arguments because later on the program the tested_company varible is not defined, ...
How insert in Cassandra without null value in Column Question: I'm trying to store some tweets in Cassandra Database using Python and DataStax driver ( Python -> Cassandra ). Everything works well, but there's something that I can't understand. How to insert a row without null value ? As example, CREAT...
wxPython - Prevent the same warning dialog from appearing twice Question: I have a textctrl accepting user input. I want to check the text after the user enters it to see if it is also in a predefined list of words. I can do this check when the textctrl loses focus. I can also set it to check when the enter key is pres...
Plot arbitrary 2-D function in python/pyplot like Matlab's Ezplot Question: I'm looking for a way to generate a plot similar to how ezplot works in MATLAB in that I can type: ezplot('x^2 + y^2 = y + 5') and get a graph ready to go for any arbitrary function. I'm only worrying about the case where I...
How to convert paragraphs to double quotes sentences in python Question: I have a text file having many paragraphs, i want to split it by sentences i.e. after every dot "." or ? it split and include the sentence in double Qoutes like: This is a sentence. This is an excited sentence! And do you think this is a question...
How should the values of a list be scaled such that they meet standard deviation and mean requirements? Question: I have lists of values that I want to have scaled to meet certain standard deviation and mean requirements. Specifically, I want the datasets standardised to mean 0 with standard deviation 1, except for dat...
Convert categorical data into various columns for plotting in pandas Question: I'm new to `python` and `pandas` but I've used `R` in the past for data analysis. I have a simple dataset: df.head() Sequence Level Count 1 Easy 5 1 Medium 7 ...
Amazon + Django each 12 hours appears that [Errno 5] Input/output error Question: I recently setup and deploy an Amazon EC2 instance for deploy my django project. I was interacting with my application via browser when I get this error in the browser: errno 5 input/output error django [![enter imag...
Iterator produced by itertools.groupby() is consumed unexpectedly Question: I have written a small program based on iterators to display a multicolumn calendar. In that code I am using `itertools.groupby` to group the dates by month by the function `group_by_months()`. There I yield the month name and the grouped date...
Can't call multiple functions in the same time with multiprocessing Question: I'm trying to figure out how could I run the same function multiple times in the same time. I could implement something with the multiprocessing that based on other SO questions, but unfortunately it doesn't work as I wanted. Actually when I ...
Can I connect an external (R) process to each pyspark worker during setup Question: I want to have each python worker start an R shell using rpy2. Can I do this during some sort of setup phase similar to how I assume this would happen when you import a Python module to be used for later executor tasks? For example: ...
How do I work with images in Bokeh (Python) Question: For example you can plot an image in matplotlib using this code: %matplotlib inline import matplotlib.pyplot as plt import matplotlib.image as mpimg img=mpimg.imread('image.png') plt.imshow(img) Is something like this possible wi...
Unknown characters fetching stock data from yahoo in csv format Question: When I try to get historical stock data from yahoo finance in python I'm getting correct output in html, but in csv, it returns unknown characters output of csv : 摁彪汣獯ⱥ汃獯ⱥ慄整䠬杩ⱨ潌ⱷ灏湥匬浹潢ⱬ潖畬敭㈊㄰ⴴ㐰㈭ⰵ䡙住ㄬ㐹㄰〶ⰰ㐳㐮ⰸ㔳〮㤹㤹ⰸ㐳㈮〹〰ⰱ㐳㐮ⰸ㔳〮㤲㤹ⰹ He...
Why can't PhantomJS open my Web page? Question: I'm trying to load [this Web page](https://f8790d1e-aknuds1.node.tutum.io/) from PhantomJS 2 on Ubuntu 15.04, via Python 2/Selenium, but the request simply times out. Why is it unable to open the page? I've tried the following Python script: from selenium ...
pass data from java to python and back jython Question: I am using Jython to run a python script from Java. I am able to send data to the python script as command line arguments when I invoke the script using a `PythonInterpreter`. Now I want to call a Java method from within the Jython script, passing a `List` as a m...
NetworkX: How to find the source and target nodes of a directed edge Question: dito above.. I couldn't find anything in the NetworkX docs... In Python Igraph, i can just use: import igraph as ig G = ig.Graph(directed=True) G.add_vertices(2) G.add_edge(0,1) eid = G.get_eid(0,1) edge =...
Unwrapping Numpy "object" dtypes Question: Could someone please suggest a pythonic way to unwrap a numpy array with dtype=object? For example, if I started with: array([array([ 1, 2, 3]), array([ 4, 5, 6]), array([ 7])], dtype=object) I would like to return: ar...
Evaluation of math formula in Python (with custom variable names and subscripts) Question: I need to evaluate a bunch of math formulas (string format) for a time series for example: " y = 0.5 * gdp[t] + 0.2 * ln( sp500[t-2] ) " The math formula has two elements I need to take care of: * Custom v...
Refreshing or re-running a class in Python 2.7 Question: I have a class that retrieves values from a configuration file and a function that adds them. I call the class, change values then run the function to write them. When I call the class afterwards the values are not updated. I check the config file and the values ...
How to add all elements from python dictionary to database? Question: I'm trying to add the elements of a dictionary to the database. I'm completely new to working with databases and I'm just wondering if I'm doing it right or not, because it seems to me that not. If so, how can I do it ? And how can I print all the el...
Closing all the opened chrome windows using selenium - python - osx Question: I have to download some files from a website, I'm using Python - Selenium - Chrome - Osx. I have his code so far: lnk = "www.foobar.com" CHROMEDRIVER=webdriver.Chrome() options = webdriver.ChromeOptions() profile =...
python join/format possible hex values for regex Question: I'd like to create a template string as possible values for an expression: '\x1C,\x2C,\x3C,\x4C,\x5C,\x6C,\x7C,\x8C,\x9C,\xAC,\xBC,\xCC,\xDC,\xEC,\xFC' in a manner like this: from string import digits, ascii_uppercase ','...
Pattern Matching Tkinter child widgets (winfo_children) to determine type (Python) Question: I'm trying to automatically clear all Entry widgets in a parent widget. import Tkinter import re root=Tkinter.Tk() E1=Tkinter.Entry(root) E1.pack() E2=Tkinter.Entry(root) E2.pack...
Email an attachment with non-ascii filename with python email Question: How can I send an email with a file attached where the file name contains unicode characters? Up to now, the file will arrive but with the filename _"noname"_. This is the part that works perfectly well for ASCII filenames: import ...
"Placing" arbitrary number of values into Python Flask request_context? Question: So I have a Python Flask app such as the following: (it's actually a [Clay Flask](https://pypi.python.org/pypi/clay-flask/1.1 "Clay Flask") app, but whatever): `some_file.py`: @app.route('/v1/some/route', methods=['GET']) ...
P4Python - Create a pending changelist and keep default pending Question: I use change = P4.fetch_change() change['Description'] = Description result = p4.save_change(change) but it will move my default file into this changelist. is there has any way to just create empty pending changelist...
Initializing Python static class attributes in the constructor call Question: In some Google [documentation](https://cloud.google.com/appengine/docs/python/tools/protorpc/) there is the following code (abbreviated for clarity). The class `Note` is defined and then instantiated with a parameter in the constructor call. ...
running a django app on apache with SSL: pexpect spawn/expect doesn't work Question: I'm running a django app on apache 2.2 with SSL enabled. When I don't have the SSL enabled, all is well. But with security, there probably are some restrictions on how an os can fork off a process, etc. I'm not aware of those at all. ...
Python import class simple example error Question: I wonder why my simple example building a class is not properly working: The tree-structure looks like the following class_project/ ├── class_project │   ├── __init__.py │   └── classtheclass.py └── tests ├── __init__.py ...
matplotlib - How can I use MaxNLocator and specify a number which has to be in an axis? Question: I do have a question with matplotlib in python. I create different figures, where every figure should have the same height to print them in a publication/poster next to each other. If the y-axis has a label on the very to...
Premailer - UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position Question: I am trying to use `premailer` to transform an html document that I've created into something that I can email with inline css styling. However when I try make the transform I am getting the following error: ...
Python: how to convert a string array to a factor list Question: Python 2.7, numpy, create levels in the form of a list of factors. I have a data file which list independent variables, the last column indicates the class. For example: 2.34,4.23,0.001, ... ,56.44,2.0,"cloudy with a chance of rain" ...
Choose three different values from list in Python Question: I have a list of points with their coordinates, looking like this: [(0,1),(2,3),(7,-1) and so on.] What is the Pythonic way to iterate over them and choose three different every time? I can't find simpler solution than using three `for` lo...
Python: setup() vs __init__ ()for a socketserver's handler class Question: I am trying to define a handler class for a `socketserver`. When the handler class had no `__init__()` method defined, my server worked. The message sent by the client was written to the output window. However, when I added an `__init__()` metho...
Python flask-sqlalchemy - windows functions query error? Question: I'm trying to use a windows function so that I can ultimately pull up just the last result frrom each eternal_id, and am getting stuck just trying to get a windows function to work. I see the error whether I connect to the engine and select from it, or ...
How can I measure elapsed time between the press of buttons in python with tkinter? Question: I'm very new to python and I'm trying to do a little project for myself, but I don't understand how to use the initial time variable from the start function in the stop function where I can do math with it. This is my code cur...
Not working in Python 2, Python 2 vs Python 3 Inheriting a wrapper Question: I am working on a Flask based OAuth project that has a single instance of `OAuthSignIn` class. This class has three subclasses for each OAuth client I support, Facebook, Twitter, and Google. There is only one instance of each on the server and...
Error exporting symbol when building Python C Extension in Windows Question: I'm working on porting a Python module to Windows. I have a toy example as follows. The folder structure is: foo/ libfoo/ foo.c setup.py **setup.py** from setuptools import setup, Extens...
python xml.etree.ElementTree get everything inside element whether its text or children Question: I am using `xml.etree.ElementTree`, and if possible would like not to change XML parsing library. I can parse XML file without any problem. I have a speclial `<description>` tag which contains text and want to retrieve th...
How to implement roulette wheel for picking random objects in python? Question: In python, I have a list of objects (size of list is >= 2), which have a property called `score` which has a value which is any float that's >= 0 (no upper bound). I want to randomly pick 2 different objects from the list, but make sure th...
Website scraping: python requests not downloading full site? Question: I'm having problems in scraping a website. The aim will be to scrape prices for hotels in London for certain days. For that I'm loading the below URL from booking.com and then try to search for keywords. But for some reason the requests.get doesn't ...
Python 3.5 - Placing Buttons on Top of Buttons Question: So I am creating a piano program that plays sound when a button is pressed on the tkinter gui interface. When I place the buttons at the places I want them to be. The black keys for the piano are behind the white keys. [Image Link](http://i.stack.imgur.com/MjoHd....
Unable to locate english.txt file when trying to install Python Bitcoin module Question: When I try and import pybitcointools using "from bitcoin import *" from (<https://github.com/vbuterin/pybitcointools>) I get the following error, indicating the "english.txt" file is missing from one of the installation directories...
More efficient way to loop? Question: I have a small piece of code from a much larger script. I figured out that when the function `t_area` is called, it is responsible for most of the run time. I tested the function by itself, and it is not slow, it takes a lot of time because of the number of times that it has to be ...
run imposm commands from a python script Question: I'm just getting started using imposm to help get openstreetmap data into a postgis database. All the docs point to making all commands via Terminal. This is fine for one off imports but I plan to have many many imports of varying bounding boxes and would like to scrip...
Python yielding when not requested by an object method Question: I am trying to findout why I get a `generator` instead of getting item printed since the second time I instanciate the `Scrape()` i did not request for a `yield`ed result which I find strange that it returns one. I would like to avoid this assuming it is...
Plotting points based on what value they end up being in matplotlib and numpy Question: I apologize, since I don't exactly know how to word my title. I'm brand new to Python and especially new to matplotlib. I am also using numpy for my arrays in this case. Currently, I have a set of data: `X` that has four properties...
HTMLParser python turn data into string? Question: Hi I'm using this following python parser to read an html file <https://docs.python.org/2/library/htmlparser.html> class MyHTMLParser(HTMLParser): def __init__(self): HTMLParser.__init__(self) self.inLink = False self.dataArr...
How to dynamically generate Kivy objects Question: So I figure out how to dynamically add labels to Kivy, but then I realized that Kivy has a listview module already, and that that would make things easier. I found this [Python Kivy ListView: How to delete selected ListItemButton?](http://stackoverflow.com/questions/25...
How can I import a .pyc compiled python file and use it Question: Im trying to figure out how to include a `.pyc` file in a python script. For example my script is called: myscript.py and the script I would like to include is called: included_script.pyc So, do I just use: ...
Python is filtering out currency markers Question: **Objective** : Write a screenscraper that cycles through a selection of web pages containing old prices and new prices, reads in the prices, and writes them to a CSV file. **Method** : The config file urls.txt contains the list of pages. Open that file and cycle thro...
Selenium - Python - Select dropdown meun option - No ID or Name Question: I am trying to select and element in a dropdown menu: The HTML is: <div class="col-lg-6"> <select data-bind="options: indicator_type_list,value: indicatorType,optionsCaption: 'Choose...', disable: $root.mode().isReadOnl...
extracting result text from xml using Python Question: I have the following xml : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns3:result xmlns:ns2="http://ws.def.com/"> <ns3:value>QWESW12323D2412123S</ns3:value> </ns3:result> and want to parse it with python and extract thi...
Error tokenizing data. C error: EOF following escape character Question: I'm trying to load a csv text file that I created with an OS X app written in Objective-C (using XCode). The text file (temp2.csv) looks fine in an editor but there's something wrong with it and I get this error when reading it into a Pandas dataf...
Check for number of columns in each row of CSV Question: I have the following Python code: import os import csv import sys g = open('Consolidated.csv', "wb") for root, dirs, files in os.walk('D:\\XXX\\YYY\\S1'): for filename in files: pathname = os.path.join(r...
TypeError when passing a 'file' variable to a fuction Question: When I first coded this in to a single function, it worked. But I want to do more things when I am checking for files in to the directory, so I have divided the code in two functions : One checks for files on a directory that end with *.rar extension, if i...
Subtract all items in a list against each other Question: I have a list in Python that looks like this: myList = [(1,1),(2,2),(3,3),(4,5)] And I want to subtract each item with the others, like this: (1,1) - (2,2) (1,1) - (3,3) (1,1) - (4,5) (2,2) - (3,3) (2,2) - (4,5...
python ordered_dict from json Question: I am using Python 2.6.6, and trying to generate a ordered_dict from json string. I could understand that I could use object_pairs_hook of json Decoder/loads, but unfortunately it's not supported in 2.6.6. Is there any way out? e.g. template_s = '{ "aa": {"_typ...