Write a function that accepts an input list and returns a new list which contains only the unique elements (Elements should only appear one time in the list and the order of the elements must be preserved as the original list. ). def unique_elements
Is it possible to pack 4 chars into an int in python and have it be represented as one value in a bytearray? I'm looking into packing it into a struct, but run into an error if I try something like characters = b'abcd' struct.pack('i',characters) ---
So... 1) sudo apt-get install python-setuptools 2) sudo apt-get install python-tk 3)sudo easy_install simplegui But the 3rd step doesn't work for me...it says this. Searching for simplegui Reading https://pypi.python.org/simple/simplegui/ No local pa
We are currently maintaining a homegrown python "web server" where generating the response for some requests can take a very long time mostly due to heavy computations - these requests are basically posts with very long timeouts (think minutes t
I have this csv file which contains data. It is an upper triangular matrix in the case that the diagonal and all values below the diagonal are zero, the others are positive. I converted this csv file to a list of lists. Now I want to create a weighte
I am working with Python. Writing a script, I am attempting to use os.system() to open a new terminal, create new tabs and run different commands in each respective tab (which appear to run simultaneously). I am familiar with gnome-terminal as it is
I've seen all of the other posts and done quite a bit of research but I am still scratching my head. Illustrating the problem: $ python Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "
I want a program so that the turtle goes to where you click. So far I have this: from turtle import * screen = Screen() turtle = Turtle() screen.onscreenclick(turtle.goto) But the problem is the turtle object just stays facing in the same direction.
I am using pygame to try and make a game. The graphics do not show up right and are distorted. I am using OSX El Capitan. People say that there is a bug that happens on El Capitan. The solution is to downgrade sdl_image to 1.2.10, which is what a lot
In my app I am trying to check if user is authorised to access the resource, for example when user requests to url api/proxy. I use before_request to call checking function @hook('before_request') def check_permission(): securityService = SecuritySer
here's the code... There must be some errors, cause, even though the code seems to work as I want, testing it, the decorated function resulted up to 30 time slower than the original. Decorator: import wrapt @wrapt.decorator class custom_with(object):
import scipy.spatial.distance as dist Y=[[1,2,3],[2,3,4]] Q=dist.pdist(Y,'jaccard') print Q The following snippet gives jaccard distance as 1 while it should be 0.5. On the other hand if Y=[[1,2,3],[4,2,3]] i.e if ordering is changed output is 0.33.
I have a file of documents labeled as follows: 101 magical awards hosted two days ago 102 it was a good badminton game where each sides ended up in a tie 101 the awards were hosted by the actor who received critical acclaim for his movie 103 heavy ra
Hi Friends I'm new person to Python language. I'm trying to write some small code which I want to integrate later in my python module. Here is my question I have a number like a[31:0]= 0X00010001 in a file and I want to get bit value based on positio
I wanted a very simple spring system written in numpy. The system would be defined as a simple network of knots, linked by links. I'm not interested in evaluating the system over time, but instead I want to go from an initial state, change a variable
When I try to install something with pip I have error. But with sudo everything is ok. pip install pillow Downloading/unpacking pillow Downloading Pillow-3.1.1.tar.gz (10.1MB): 10.1MB downloaded Running setup.py (path:/tmp/pip-build-hFguWU/pillow/set
I have been working on a project where I need to create rasters from irregularly spaced point clouds. I am resampling my point clouds to a regular 0.25 cm grid using a nearest neighbor method pyresample. I am using the output array to make a raster u
I'm trying to generate polygons for satellite orbital swaths. So far I have a method to generate two lines which represent the edge of each swath in [lat,long]. Some of the swath's cross the international dateline and so wrap round: I was able to sol
I wrote a function that adds items in a list, but my professor says to try and write it in a simpler way because he says I take too many steps. Is there any other way to write this? def additems(self, item): """Add <item> to this Prio
This is just a simple function to convert seconds to days, hours, minutes and seconds for a larger app I'm going to be building. I'm just looking for thoughts on it. import math def convert_seconds(x): # Day's days = x / 86400 fraction, whole = math.