text stringlengths 226 34.5k |
|---|
Using print() inside recursive functions in Python3
Question: I am following the book Introduction to Computing Using Python, by Ljubomir
Perkovic, and I am having trouble with one of the examples in recursion
section of the book. The code is as follows:
def pattern(n):
'prints the nth pattern'
... |
multiprocess.apply_async How do I wrap *args and **kwargs?
Question: I'm trying to get
[`multiprocess.apply_async`](http://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.multiprocessing.Pool.apply_async)
to take in both `*args` and `**kwargs`. The docs indicate that this might be
possible with the ... |
iPython giving me a syntax error
Question: I'm running python 2.4 right now and have installed iPython onto my ubuntu
machine. The problem I'm having right now is that it keeps giving me an
ImportError whenever I try to launch it from the terminal.
Right now the symbolic link is located `/usr/local/bin` and the actual... |
How can i quote escape characters in csv writer in python
Question: I am writing the csv file like this
for a in products:
mylist =[]
for h in headers['product']:
mylist.append(a.get(h))
writer.writerow(mylist)
My my few fields are text fields can conatins an... |
Python yaml dump confuse
Question: Let's say I have a json file like below, call it `src.json`.
{
"main": {
"contenttype": "Document"
},
"dublin": {
"title": "ダウンロード",
"description": "",
"creators": [
"池田大作"
... |
django reset contenttypes mismatch
Question: Have deleted my database.
Have run SyncDb.
Trying to load from dump ..-python manage.py loaddata dump.json.
Get- "<1062 Duplicate entry '' for key.."
Have run "python manage.py reset contentypes"
But get-
Error: Error: contenttypes couldn't be reset. Pos... |
apache server not using proper virtualenv with WSGI setting
Question: I am facing a problem related to django wsgi script. I have been using two
virtualenv for my two application and I have deployed these two application on
my local server with different port. Apache configuration file for first
Appplication looks like... |
Should unit tests run faster with a gevent patched codebase?
Question: We’re investigating gevent as a drop in performance enhancer for our Flask
API. There is a lot of communication over psycopg2 and Redis in our codebase.
We thought we’d try running the test suite with and without:
import gevent.monkey... |
Python: Create a list of nonmatching values
Question: I've been working on program which searches a folder and finds matching files
names based on a list of vaules from an input list and then copies them to a
folder. The program works but now I want to add one extra layer to it; Get a
list of non matching samples and t... |
How can i check call arguments if they will change with unittest.mock
Question: One of my classes accumulates values in a list, uses the list as an argument
to a method on another object and deletes some of the values in this list.
Something like
element = element_source.get()
self.elements.append(el... |
Issue installing cx_Oracle on Linux - Import only works from Site-Packages Directory
Question: I have installed cx_Oracle to connect Python and Oracle for programming;
however, I can only import cx_Oracle into python if I am in the directory
where cx_Oracle lives. How can I import cx_Oracle globally? Below is code
demo... |
Python background process not writing to MySQL db
Question: I apologize if this question has been asked before, but I was unable to find
any record of this issue. Full disclosure: I've only been using Python for a
few months and MySQL for about 1 month.
I've written a short Python script on a Raspberry Pi (running Ras... |
python ctypes vs namedtuple
Question: So I have two simple ctypes struct
class S2 (ctypes.Structure):
_fields_ = [
('A2', ctypes.c_uint16*10),
('B2', ctypes.c_uint32*10),
('C2', ctypes.c_uint32*10) ]
class S1 (ctypes.Structure):
_fields_ =... |
Two Class instances in Python not different
Question: I'm working on another data acquisition project, which has turned into an
object oriented programming question. In “main” at the bottom of my code I
make two instances of the Object DAQInput. When I wrote this, I thought my
method .getData would refer to the taskHan... |
Using Beautiful Soup to extract Norwegian text from HTML files, losing the Norwegian characters
Question: I have a Python script that uses Beautiful Soup to extract the text from HTML
files in a directory. However, I'm having trouble getting the encoding to work
properly. At first I though there may be a problem with t... |
PIP install my OS project
Question: I've created an open source project and tried to register it with PIP so
people can use pip install. Unfortunately I can't seem to get it work. Here
are the commands I've tried:
Created a setup.py file:
from distutils.core import setup
setup(name='AyeGotchoPa... |
Python HTTP Error 403 Forbidden
Question: I am a bit of a Python Newbie, and I've just been trying to get some code
working.
Below is the code, and also the nasty error I keep getting.
>
> import pywapi import string
>
> google_result = pywapi.get_weather_from_google('Brisbane')
>
> print google_resul... |
How to use a array of heaps in python
Question: I need to create and use n heaps, I am trying to use heapq and is trying to
push elements into a list of lists, where each element is to be considered a
seperate heap. But its behaving weirdly. I just wanna push the elements 6 and
7 into my 3rd heap. but its getting pushe... |
Draw a terrain with python?
Question: I have a numpy 2d-array representing the geometrical height of a specific area
where a street will be build. I can visualize this using `scipy.misc.toimage`.
However I would like to get a simple 3D view of the area. Is there a simple
way to plot or render this data as an 3d-image?
... |
How to convert country names to ISO 3166-1 alpha-2 values, using python
Question: I have a list of countries like:
countries=['American Samoa', 'Canada', 'France'...]
I want to convert them like this:
countries=['AS', 'CA', 'FR'...]
Is there any module or any way to convert the... |
Dynamically place legend in plot
Question: I am creating plots in pyplot in Python. Each plot contains two or more
subplots. I know I can statically place a legend in the plot by defining the
parameter `loc`; however, my choice of location will sometimes cover the data
in my plot. How would I place the legend dynamical... |
python package import modules using __init__.py
Question: I have made a package in the following structure:
test.py
pakcage1/
__init__.py
module1.py
module2.py
In the `test.py` file, with the code
from package1 import *
what I want it to do is to
... |
Python: Connect 4 with TKinter
Question: Alrighty I'm trying to implement a GUI for a game of Connect Four by using
TKinter. Now I have the grid and everything set up what I'm having trouble
with is getting the chip to show up on the board.
Here is my output: .read()
re.findall('\d+\.\d+\.\d+\.\d+', page)
i dont understand why it says:
File "C:\Python33\lib\re.py", line 20... |
Printing and editing multiple lists in python
Question: Im trying to create a small text based game, and to achieve this I am created
20 lists, added 75 spaces to fill the lists, then printed each of the lists
one at a time, all at the same time. I was hoping to then be able to edit the
lists at certain positions so th... |
scikit-learn svm import error
Question: I'm running [ Canopy ](https://enthought.com/products/canopy/) 64-bit on a
mac. After installing scikit-learn (using the package manager), I tried to
import svm, and got the following error.
ImportError: dlopen(/Users/johnsaccount/Library/Enthought/Canopy_64bit/Use... |
restart apache every 12 hours using linux service and python file
Question: Hi i want to use this for restart apache service every 12 hours and i put the
file `apache_rest` in `/etc/init.d/apache_rest` i run but get some error :
[root@localhost init.d]# service apache_rest start
Starting server
/... |
Releasing memory of huge numpy array in IPython
Question: _UPDATE:- This problem solved itself after a machine reboot. Not yet able to
figure out why this error was happening before._
I have a function that loads a huge numpy array (~ 980MB) and returns it.
When I first start Ipython and call this function, it loads ... |
Changes to a Gmail notification script
Question: After a long search I've found [this python
script](https://github.com/gevermann/gmail-iphone-
push/blob/master/server/server.py) that does what I need in order to get a
real time notification to my iOS app when a new email arrives. I usually write
in Objective-c and thi... |
Python non-int float
Question: Alright so I have beat my head over my desk for a few days over this one and I
still cannot get it I keep getting this problem:
Traceback (most recent call last):
File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 44, in <module>
... |
Python, using ctypes to create C++ class wrapper
Question: I'm well aware that there is no standard ABI for c++, so this is what I did:
//trialDLL.h
#ifndef TRIALDLL_H_
#define TRIALDLL_H_
class MyMathFuncs
{
private:
double offset;
public:
MyMathFuncs(do... |
How to get a row from coo_matrix as a dense vector in Python?
Question: I'm new to Python and could you help me about some basic sparse matrix
operation:
1. How to extract a dense row vector from a sparse matrix without make the whole matrix dense beforehand? `coo_matrix.getrow()` only returns a sparse representatio... |
Restrictions in terms of using external libraries (Python) in a Storm Bolt
Question: I want to implement a Bolt (<https://github.com/nathanmarz/storm>) that does
some heavy processing on a tuples using scikit Machine Learning API
(<http://scikit-learn.org/>)
For example -
from sklearn import decompositi... |
Python : efficient bytearray incrementation
Question: How to iterate all possible values of `bytearray of length = n` in Python ? in
worst case `n <= 40bytes`
For example, iterate for `n = 4` :
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000001
00000000 00000000 00000000 000... |
Python - variable is getting set to 0 and can't figure out why
Question: Okay, so I'm making a little game with pygame and building the map by
generating tiles to a multidimensional array. In order to do that I'm using
two for loops.
def create(this, t):
if t == "grasslands":
for... |
Ascii codec cannot decode HTML when saving to file in python
Question: I have a text that is part of html. I would like to save it to a file.
This works fine in debug mode in Eclipse, but fails on runtime from shell. I
am using a short example of html that fails.
xx = '<input type="hidden" name="charset... |
Read numeric value from txt. file and compare it to condition Python
Question: I'm new to Python and working on final project for my degree. I want to write
a Python script which will read numeric value (like: 21, 23, 28 etc.) and
compare it to value in the script. If the value matches it should execute
another python ... |
Python: loop through several csv files
Question: I was wondering if anybody knew how I could change a script in Python so it
goes through a folder containing csv files and takes them in groups of three.
The script is working when I type the file names in the command line, but I've
got lots of files, so that would take ... |
devappserver2, remote_api, and --default_partition
Question: To access a remote datastore locally using the original dev_appserver I would
set --default_partition=s as mentioned
[here](http://stackoverflow.com/questions/9280613/badrequesterror-app-
smyapphr-cannot-access-app-devmyapphrs-data-why/9281772#9281772)
In Ma... |
How to subclass Clock in Pyglet?
Question: I want to subclass Clock class of pyglet.clock module, but I have some
troubles when I use schedule_interval:
The following code doesn't print anything and the object c looks like if not
ticked at all:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
... |
python feedparser ImportError: No module named feedparser
Question: I receive an error when I attempt to include the feedparser library into the
interactive Python environment:
>>>> import feedparser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No modu... |
Controlling MDrive 23 with Python under Linux
Question: MDrive 23 motor takes commands from a terminal, and I got it to work with
screen program:
screen /dev/ttyUSB0
Is this is called a serial terminal? I'm unfamiliar with the details of the
connection, but feel like I should be able to use PySeria... |
Using the twitter API and Python to obatain retweeter's id
Question: I have an issue that has been bothering for a while now, and which I have
tried really hard to fix but have found no solution. So I'm doing an
internship doing research on complex networks, nothing business-oriented, it's
mostly physics and network th... |
Error using etree in lxml
Question: I want to use xpath in python . I tried
import xml.etree.ElementTree as ET
Since this library has limited usage I had to use lxml after a long session of
search on google. I had several problems during installation and finally i
installed lxml but when i use
... |
How to flag end of loop over dictionary with two int's tuple as key - combination-like loop needed
Question: i have in memory a dictionary with the following pattern:
value_refs[tuple([a,b])] = some float value
the dictionary is a pool of all the possible combinations of the values of
4000 referenc... |
Changing date format after converting from int value in python
Question: Is it possible to change format of date from (YYYY,MM,DD) to (DD,MM,YYYY)..
import datetime
date_value = 41381.0
date_conv= datetime.date(1900, 1, 1) + datetime.timedelta(int(date_value))
print date_conv
... |
How to prevent bottle from handling signals
Question: I am building an application using the Bottle web-framework.
I would like to catch signals USR1 and USR2 to do some work aside from the
bottle server. Mainly I want to be able to reload configuration without
shutting down the web server because I want some objects ... |
python pandas index is_unique not working
Question: I'm new to python so please call me on not including relevant information.
I've installed python, ipython, and am using the notebook on an Ubuntu
installation in a VM.
I'm working through examples laid out in Wes McKinney's Python for Data
Analysis. After the follow... |
AttributeError: Extension instance has no attribute '__version__'
Question: Here is the script..
from distutils.core import setup, Extension
nmap = Extension('nmap',sources = ['nmap/nmap.py',
'nmap/__init__.py', 'nmap/example.py'])
from nmap import *
... |
Enthought Canopy 64bit on OSX: import pyglet.gl failure
Question: ## Retaining question for posterity; see workaround in edit
The Pyglet package comes installed at base and isn't removable. Using the
current fully updated version 1.1.4 of Pyglet, I get repeatable errors related
to importing the item `pyglet.gl.gl_info... |
Putting a pointer as a value in a method call [python]
Question: I'm trying to have a function where I can put in a list and a pointer, and
have it apply that pointer to the objects in the list to give me the object
with the lowest value of that pointer.
def GetLowest(ListObject,Value):
Obje... |
Python ImportError for strptime in spyder for windows 7
Question: I can't for the life of me figure out what is causing this very odd error.
I am running a script in python 2.7 in the spyder IDE for windows 7. It uses
datetime.datetime.strptime at one point. I can run the code once and it seems
fine (although I haven'... |
Running code with another interpreter on a Perl script
Question: [This thread](http://unix.stackexchange.com/questions/74244/hybrid-code-in-
shell-scripts-sharing-variables) discusses a way of running Python code from
within a Bash script.
Is there any way to do something similar from within a Perl script? i.e. is
the... |
Python "ImportError: No module named numpy"
Question: Okay so I'm fairly new to Python, I ran the commands
sudo easy_install pip
sudo pip install numpy
Afterwards, I typed python followed by `import numpy` and got the error
`ImportError: No module named numpy`
Did I miss something? Do I need t... |
how to add all array's elements to one list in python
Question: with a 2 dimension array which looks like this one:
myarray = [['jacob','mary'],['jack','white'],['fantasy','clothes'],['heat','abc'],['edf','fgc']]
every elements is an array which has fixed length elements. how to become this
one,
... |
savetxt two columns in python,numpy
Question: I have some data as numpy 2D array list-
array([[ 0.62367947],
[ 0.95427859],
[ 0.97984112],
[ 0.7025228 ],
[ 0.86436385],
[ 0.71010739],
[ 0.98748138],
[ 0.75198057]])
arra... |
Make vim highlight python builtins when they are not followed by a dot
Question: Is there a way to highlight built in Python functions in vim _only_ when they
are preceded by 1 more whitespaces? Furthermore, is there a modular way to do
this? That is, I don't want to edit every single `syn keyword
pythonBuiltinFunc abs... |
can't concatenate strings in Python-3
Question: when running this script in Python-3:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import socket
import random
import os
import threading
import sys
class bot(threading.Thread):
def __init__( self, net, port, user, nick,... |
Add sub-elements to newly created elements in python elementtree
Question: I am trying to add the following subtree to an element 'Drugs' in an xml file
using elementtree in Python based on the data in CSV file:
<Drug>
<DrugID>1<DrugID>
<Dose>40</Dose>
<Unit>mg</Unit>
</Dru... |
Invisible button (using pack_forget) still occupies space
Question: I use pack_forget() to make a button invisible. But when i subsequently create
a label, it appears bellow the invisible button. How can i avoid this
displacement?
The following sample code demonstrates the issue:
from tkinter import *
... |
Executable Python Zip with C extensions
Question: I have a zip file with a `__main__.py` that executes fine: ./myapp
But inside of this zip, there is a C extension library.so file that must be
loaded but this library.so file is not being found.
If I execute the directory (without zipping it), it executes correctly. S... |
Python numpy loadtxt fails with date time
Question: I am trying to use numpy loadtxt to load a csv file into an array. But it seem
i can't get the date time correctly loaded.
Below demonstrates what is happening. Did I do something wrong?
>>> s = StringIO("05/21/2007,03:27")
>>> np.loadtxt(s, delimi... |
Using variables declared in functions and use them in another function in a different class
Question:
#!/usr/bin/python
import MainPanel
import wx
########################################################################
class OtherFrame(wx.Frame):##open PDB frame
""""""
#-... |
Point in convex polygon
Question: I'm trying to make a function that will return `True` if the given (x,y) point
is inside a convex polygon. I'm trying to make it without numpy or any similar
imports, just pure python code.
I've already found a sample solution, which seems OK at first sight, but it's
not working corre... |
Multiprocessing with Python and Arguements
Question: related to my last post (Which somehow got marked off and closed), I wrote
some code to create a thread for a command handler for my python TCP listener.
What basically happens is that I send in some data and it goes in the TCP
connecter. Then the TCP connector creat... |
Searching for books with the Amazon Product Advertising API - Python
Question: tl;dr : I am using the Amazon Product Advertising API with Python. How can I
do a keyword search for a book and get XML results that contain TITLE, ISBN,
and PRICE for each entry?
Verbose version:
I am working in Python on a web site that ... |
querying data from sqlalchemy database
Question:
engine = create_engine('sqlite:///nwtopology.db', echo=False)
Base = declarative_base()
class SourcetoPort(Base):
""""""
__tablename__ = 'source_to_port'
id = Column(Integer, primary_key=True)
port_no = Column(Inte... |
Registration Form import error
Question: I am following DjangoBook tutorial and i have encountered a problem on chapter
14 ( User Registration )
In _django.contrib.auth.forms_ , there is a `UserCreationForm` class. I am
trying to create a new class based on `UserCreationForm` called `RegisterForm`
This is my class `R... |
Synchronizing Plone 4 sites
Question: I'm using Plone 4 for my sites and I was wondering if there is a way to
synchronize two plone sites i.e. be able to synchronize my development site
with my production site.
I have looked at [Zsyncer](https://pypi.python.org/pypi/Products.ZSyncer)
product and it appears it is no lo... |
Global name in Python
Question: I want to find out whether two numbers **N1** and **N2** are the permutations
of the same digits. For example `123` and `321` are permutations of the same
digits, where as `234` and `123` are not. I have used Python to solve the
problem of which I am not an expert. I am using `IDLE Pytho... |
how to disable the automatic mapping of std::vector<std::vector<double> > to tuple of tuples in swig python?
Question: Apparently, swig transform automatically `std::vector<std::vector<double> >`
to a tuple of tuples. I want to prevent this, and I want the type to be kept
as is. How can I achieve it? I tried specifying... |
Importing the `this` module?
Question: Typing the following in a a Python shell does not produce an error:
from this import *
What is the `this` module?
Answer: `this` is the [`zen of python`](http://www.python.org/dev/peps/pep-0020/)
written by Tim Peters
>>> from this import *
... |
Assigning a function (which is assigned dynamically) along with specific parameters, to a variable.
Question: Ok, so here's the deal, say I have a function( take_action ), that calls
another function. But we don't know which function take_action is going to
call.
I had that part figured out thanks to [this
question](h... |
Take a screenshot from a website from commandline or with python
Question: i will take a screenshot from this page:
[http://books.google.de/books?id=gikDAAAAMBAJ&pg=PA1&img=1&w=2500](http://books.google.de/books?id=gikDAAAAMBAJ&pg=PA1&img=1&w=2500)
or save the image that it outputs.
But i can't find a way. With wget/c... |
Histogram in Python Using matplotlib
Question: I am struggling with this really badly. There is something that I'm just not
getting. I have a function, which I want to plot a histogram of a dictionary
with the keys on the x-axis and the values on the y-axis, then save the file
in a location specified when calling the f... |
Looking for command line ftp client (linux)
Question: I am looking to batch download a large number of files (>800). I have a text
file with the list of all the filenames. These filenames are then used to
derive the URL from which they can be downloaded. I had been parsing through
the file with a python script, using s... |
Using django.test.client to test app http requests, getting errors
Question: We're beginning to write unit tests for our API (created with the Django Rest
Framework). We decided to start off simple and use the built in unittest and
django.test.client classes. I've got the stub of a test written and it runs
just fine:
... |
Python function which will call a 1D vector values
Question: I have the next sequence of numbers of A array( is an array 1D )
1. -1.7654142212e-06
2. 7.0737426918e-07
3. 1.63230254789e-06
4. 1.88255344022e-06
5. 5.00966829007e-06
6. 1.88631278169e-06
7. -4.08751917695e-06
8. 9.12971786351e-07
9... |
python csv reader, loop from the second row
Question: In python 2.7.3, how can I start the loop from the second row? e.g.
first_row = cvsreader.next();
for row in ???: #expect to begin the loop from second row
blah...blah...
Answer:
first_row = next(csvreader) # Compatible with P... |
Certain trigonometry packages from numpy
Question: I'm writing code that solves the intersection of a few functions which involve
cos and sin and other various trig functions in python.
But I feel like importing NumPy as a whole is too much of a load on such a
small program, is there any other way to get basic trig fu... |
Accessing API using Python
Question: I was trying to retrieve data from an API and i was receiving
**'set' object has no attribute 'items'**
This is my api.py and i have import it to my views
import json
import urllib
import urllib2
import pycurl
def get_resources(request, filter, ... |
Implement nested interface of generic parent class with ironpython
Question: I wan't to implement the following C#/.Net interface with IronPython:
public static class Consumes<TMessage> where TMessage : class
{
public interface All
{
void Consume(TMessage message);
}
... |
Have a python file move itself
Question: I'm writing a script that emulates a unix environment with python (yes, I know
that may sound silly).
Basically I set up the "pwd" and "ls" commands before the "cd" command. Now I
need my python script to navigate itself around directories by moving itself.
I was wondering if a... |
Python File append error
Question: This code works fine for me. Appends data at the end.
def writeFile(dataFile, nameFile):
fob = open(nameFile,'a+')
fob.write("%s\n"%dataFile)
fob.close()
But the problem is when I close the program and later run again I found that
all the p... |
Is it possible to create a variable as a placeholder for 'current' value of a class in python?
Question: Let's say we have a class:
_NOTE: this is a dummy class only._
class C(object):
def __init__(self):
self.a = -10
self.b = 5
self.c = 2
def modify(s... |
is there an ast python3 documentation? (At least for the Syntax)
Question: Im trying to work with the ast class in python. I want to get all Function
calls and their corresponding arguments.
How can I Implement that? The official Documentation on python.org is really
vague.
Also i tried implementing visit_Name and vi... |
Unicode Disappearing in html.parser
Question: I am extracting HTML from some webpage with Unicode characters as follows:
def extract(url):
""" Adapted from Python3_Google_Search.py """
user_agent = ("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) "
"AppleWebKit/5... |
Tkinter adding line number to text widget
Question: Trying to learn tkinter and python. I want to display line number for the Text
widget in an adjacent frame
from Tkinter import *
root = Tk()
txt = Text(root)
txt.pack(expand=YES, fill=BOTH)
frame= Frame(root, width=25)
#
fra... |
construct an unknown url from known information
Question: I'm trying to create a python script... basically...
I have a url to some site
url = "http://www.somesite.com/foo/bar/"
Files on server:
1-123j.jpg
2-123.jpg
3-123d.jpg
4-1594ss.jpg
...
...
45000-457li... |
for loops, indexing, taking the min value of a list
Question: I have two shapefiles: of lakes and of cities. I need to find the closest city
to each lake and add the name of the city into the lake shapefile. I have:
for lake in lake_cursor:
lake_geom = lake.Shape
city_dist_list = [] #crea... |
improving speed of Python module import
Question: The question of how to speed up importing of Python modules has been asked
previously ([Speeding up the python "import"
loader](http://stackoverflow.com/questions/2010255/speeding-up-the-python-
import-loader) and [Python -- Speed Up
Imports?](http://stackoverflow.com/q... |
Lookarounds in python
Question: I have a problem regarding lookarounds in Python:
>>> spacereplace = re.compile(b'(?<!\band)(?<!\bor)\s(?!or\b)(?!and\b)', re.I)
>>> q = "a b (c or d)"
>>> q = spacereplace.sub(" and ", q)
>>> q
# What is meant to happen:
'a and b and (c or d)'
... |
Scrape a Google Chart script with Scraperwiki (Python)
Question: I'm just getting into scraping with Scraperwiki in Python. Already figured out
how to scrape tables from a page, run the scraper every month and save the
results on top of each other. Pretty cool.
Now I want to [scrape this
page](http://developer.android... |
Cannot import flask from project directory but works everywhere else
Question: So I have run into a funny problem when trying to use Flask, I can only run it
from ~/ (home) and not from ~/Projects/projectfolder. I'm using Python 2.7.4
installed via their homepage, virtualenv and virtualenvwrapper. Every time
it's the s... |
how to access a nested comprehensioned-list
Question: I have a working solution for creating a list some of random numbers, count
their occurrencies, and put the result in a dictionary which looks the
following:
random_ints = [random.randint(0,4) for _ in range(6)]
dic = {x:random_ints.count(x) for x... |
How to make each tweet on its own line?
Question: I am wanting to have each tweet be on its own line.
Currently, this breaks at each response (I listed Response_1...I am using
through Response_10)
Any ideas?
#!/usr/bin/env python
import urllib
import json
response_1 = urllib.urlop... |
Python: Number ranges that are extremely large?
Question:
val = long(raw_input("Please enter the maximum value of the range:")) + 1
start_time = time.time()
numbers = range(0, val)
shuffle(numbers)
I cannot find a simple way to make this work with extremely large inputs - can
anyone help?
I saw ... |
Go into sudo user, run couple of commands, go back to normal user in Python script
Question: The problem I've run into is that I want to temporarily get into the sudo
user, run a couple of commands, and then go back to a normal user and run the
commands in that mode.
You can find the script I'm gonna use it in here:
<... |
unable to run PyQt4 example
Question: I am trying to run a pyqt4 example through Notepad++. I asked this question
earlier ([Nothing happens when running PyQt4 example
code](http://stackoverflow.com/questions/16380923/nothing-happens-when-
running-pyqt4-example-code)), and ended up uninstalling Enthought Canopy and
all ... |
Python. Return current cursor position and position last left mouse click
Question: I want to be able to define the cursor position of the last left mouse click
as a point and the current cursor position as a point in real-world
coordinates. The code I have so far has the Tkinter import and Math import. I
have the GUI ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.