text stringlengths 226 34.5k |
|---|
Python PIL has no attribute 'Image'
Question: I'm using python2.6 and got a problem this morning. It said 'module' has no
attribute 'Image'. Here is my input. Why the first time I can not use
PIL.Image?
>>> import PIL
>>> PIL.Image
Traceback (most recent call last):
File "<stdin>", line 1, ... |
Multipart form encoding file upload in Python 3
Question: I was wondering if it was possible to post to a form with
`enctype='multipart/form-data'` in Python 3. I looked around and could only
find things for Python 2 (such as poster).
Answer: Use [requests](http://docs.python-requests.org/en/latest/), it supports pyt... |
Packaging and distributing a python (for windows) application for client side
Question: Lets say I have developed a desktop application using python for windows
users. I want to distribute this application.
So what is the standard process of packaging and distributing? I want the
setup to be installed other .msi or .e... |
Python: Unit Testing Module and Relative Imports
Question: Currently have the following file hierarchy:
\package
__init__.py
run_everything.py
\subpackage
__init__.py
work.py
work1.py
work2.py
\test
__in... |
Ideal Way to Create a Python "Library"
Question: I want to create a "library" of Python modules which I will be able to access
from several separate project folders.
For example, I want the Python scripts in /proj1/ and /proj2/ to have access
to /lib/.
/lib/help.py
/lib/more_help.py
/proj1/... |
How do I run os.walk in parallel in Python?
Question: I wrote a simple app in Java that takes a list of paths and generates a file
with all the file paths under that original list.
If I have paths.txt that has:
c:\folder1\
c:\folder2\
...
...
c:\folder1000\
My app runs the recursiv... |
What is the Python equivalent of Ruby's fork block?
Question: With Ruby, a `fork` block can be used to express that
> Statements in this block are only executed in the child process and will be
> skipped over by the parent process.
Is there something similar in Python?
Answer: If you want to have some code executed... |
Configuring apache2 conf for several python web.py apps
Question: I am working on a small web dashboard -project that has backend implemented
with python's web.py framework.
The dashboard has all sorts of widget's on it, one of which also has its
backend implemented using web.py. The problem is that only one of the
de... |
python: download file and send it to online storage in realtime
Question: I want to download file to my server and automatically send it to online
storage(minus or dropbox) via minus or dropbox API, without saving the
downloaded file in my server. So, its like streaming or pipe the HTTP
connection. Right now im using m... |
Python sys.argv TypeErrors with printing function results?
Question: I have been trying to learn how to use sys.argv properly, while calling an
executable file from the command line.
I wanted to have the functions results print to the command line when passing
the filename and argument on the command line but, I get a... |
How to pass a C++ object to another C++ object with Boost.Python
Question: I have some C++ code that defines two classes, A and B. B takes an instance of
A during construction. I have wrapped A with Boost.Python so that Python can
create instances of A, as well as subclasses. I want to do the same with B.
... |
Declaring a python function with an array parameters and passing an array argument to the function call?
Question: I am a complete newbie to python and attempting to pass an array as an
argument to a python function that declares a list/array as the parameter.
I am sure I am declaring it wrong,
here goes:
... |
(Python) Append text dynamically in multi-threaded IRC GUI
Question: I'm writing a simple IRC server and client GUI using wxPython. In my
application, I had two threads running: One for the GUI, and one for the
socket connections required to send and receive information. So far, I believe
that I am successfully connect... |
Pyconfigini: ImportError: No module named lib.pyconfigini
Question: I have been looking for an ini parse with inheritance support such as
Zend_Config_Ini, So I found pyconfigini
(https://bitbucket.org/maascamp/pyconfigini)
I have the following project structure:
* app
* __ init __.py
* settings.py
* lib ... |
How to check in makefile if python script outputs OK
Question: I have a Python script, which checks my language translation files (in CSV
format), if all the lines contain translations for all languages included in
the CSV's first, header line. Script lists files/lines with missing
translations. If no problem is found,... |
Twisted Python: reactor and protocol
Question: I have several questions about the Twisted reactor.
1/ What kind of errors would crash/stop/terminate the reactor? what kind of
errors would not?
2/ I have two reactors, each running a different protocol. I have protocols A
and B.
One reactor creates a new instance of p... |
PYGame - ImportError: No module named locals Raspberry Pi
Question: I have the following code:
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import pygame, random
from pygame.locals import *
pygame.init()
clock = pygame.time.Clock()
and so on
The app all a... |
Sharing object (class instance) in python using Managers
Question: I need to share an object and its methods between several processes in python.
I am trying to use Managers (in module multiprocessing) but it crashes. Here
is a silly example of producer-consumer where the shared object between the
two processes is just... |
How to preserve matlab struct when accessing in python?
Question: I have a mat-file that I accessed using
from scipy import io
mat = io.loadmat('example.mat')
From matlab, example.mat contains the following struct
>> load example.mat
>> data1
data1 =
... |
How to read Excel files from a stream (not a disk-backed file) in Python?
Question: XLRD is installed and tested:
>>> import xlrd
>>> workbook = xlrd.open_workbook('Sample.xls')
When I read the file through html form like below, I'm able to access all the
values.
xls_file = req... |
logging module for python reports incorrect timezone under cygwin
Question: I am running python script that uses logging module under cygwin on Windows 7.
The `date` command reports correct time:
$ date
Tue, Aug 14, 2012 2:47:49 PM
However, the python script is five hours off:
2... |
Python 3: apply an operator over an iterable
Question: `sum(iterable)` is effectively:
def sum(iterable):
s = 0
for x in iterable:
s = s.__add__(x)
return s
Does Python have a built-in function that accomplishes this without setting
the initial value?
... |
Why isn't my python code printing my list?
Question: I've written a function that should return a list of column numbers that
correspond to specific variables I'd like to extract later on from a csv file.
The variable names are specified by `state_aggregate_vars`.
import csv
import numpy
def... |
Exploring Python Exercise
Question: I am learning Python from the book _Exploring Python_ by Timothy Budd. One of
the exercises from this chapter is this:
15. The function `randint` from the random module can be used to produce random numbers. A call on `random.randint(1, 6)`, for example, will produce the values 1 to... |
Time slot availablity in python
Question: I am writing a slot booking algorithm for my application in python like this
from datetime import datetime, timedelta
appointments = [(datetime(2012, 5, 22, 10), datetime(2012, 5, 22, 10, 30)),
(datetime(2012, 5, 22, 12), datetime(201... |
Numpy arrays, fancy indexing, complex numbers
Question: The following code multiplies a part of the array by a number
def mul_by_num(a,b):
a[0:2] *= b
import numpy as np
a = np.ones(5,dtype=np.float64)
mul_by_num(a,1.0)
mul_by_num(a,1j) #Generates a warning (and casts to... |
Is is possible for a python script to know whether it is run with the interactive option '-i'?
Question: > **Possible Duplicate:**
> [tell whether python is in -i
> mode](http://stackoverflow.com/questions/640389/tell-whether-python-is-in-i-
> mode)
> [Tell if python is in interactive
> mode](http://stackoverflow... |
Printing all combinations, python
Question: say I have 3 different variables and each has 2 possible values, so in total I
have 8 different combinations. Is there a python library function, or an
algorithm that I can use to print all possible combinations?
Thanks
Answer: I think you're looking for
[product](http://d... |
python multiprocessing, pool workers do not complete all tasks
Question: I have a relatively simple python multiprocessing script that sets up a pool
of workers that append output to a pandas dataframe by way of a custom
manager. What I am finding is when I call close()/join() on the pool, not all
the tasks submitted b... |
Lists as reference types in python
Question: Following is the piece of code that i wrote to calculate the nth prime number.
I initialize arr = [2,3,5]; and prime(arr,n) is supposed to modify arr to
contain first n prime numbers. But arr does not reflect changes after
prime(arr,n) is executed. I read that lists are pass... |
Monkey Patching in python: When we need it?
Question: In Python, the term `monkey patch` only refers to dynamic modifications of a
class or module at runtime, As a beginner its really difficult to me
understand this term in context of python. Can anybody explain to me with a
real world example How exactly we do ?
1.... |
Python Error Getting Timestamp from List Slice
Question: I'm in the process of writing a script that chunks a large CSV file down into
smaller chunked files. It cross references a log file that holds the last
timestamp that was chunked so that only the timestamps that are later than the
logged time are written/chunked.... |
Reverse dns lookup with scapy in python
Question: How can I do reverse DNS lookup using `scapy` in Python? I look for it in
Google but I couldn't find related to this topic.
Answer: Reverse DNS is already written into Python's Socket module. Simply use the
following:
>>> import socket
>>> socket.... |
"password authentication failed for user" after push to Heroku
Question: I followed the [heroku
documentation](https://devcenter.heroku.com/articles/django) to install a
django app and at first it worked fine. After a day I pushed some changes to
the server. After that, I was not able to access the app at all: `FATAL:
... |
python: integer out of range for 'L' format code
Question: In python, the code is the following
envimsg = struct.pack("!LHL", 1, 0, int(jsonmsg["flow_id"], 16)) + \
struct.pack("!HQH", 1, int(flow["src id"],16), 0) + \
struct.pack("!HQH", 1, int(flow["dst id"],16), int(flow["d... |
Python hashlib & decode() on a Bytes Object
Question: I'm not understanding something about hashlib. I'm not sure why I can decode a
regular byte object, but can't decode a hash that's returned as a byte object.
I keep getting this error:
**UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 1:
invali... |
python salesforce beatbox: beatbox._beatbox.SoapFaultError: 'INVALID_FIELD'
Question: I am using [beatbox](http://www.pocketsoap.com/beatbox/) to connect to
Salesforce from Python and it works fine until I try to add constraint with
dates.
When I add a CreatedDate constraint it fails saying
File "/Libra... |
Error with class in python
Question: I've written some code that works when typed directly into the interpreter,
but fails when called.
Here's some code (there's a lot here to make it reproducible):
import scikits.statsmodels.api as sm
import pandas as pd
data = sm.datasets.longley.load()
df... |
Python how to access subfolder of subfolders
Question: I am new to python and I have trouble accessing the math text-files within the
subfolders.

This is the code I have written so far:
import os, sys
for folder, su... |
Made a new model in Django. But it's not showing up in the database
Question: I am using Django 1.1.4 with python 2.6. I just added a new model to the list
of models and used the syncdb command, but it's not showing in the database. I
have already made sure I use 'my_app' name for app label in the Meta class. I
also tr... |
Pythons Multiprocess on Windows in a Package
Question: I am trying to use multiprocess on windows but I am encountering the infinite
loop error. Now I know this can be fixed by using the **name** == "**main** "
in a standard python script. My problem is I am packaging the script so
**name** is equal to "testmultiproces... |
python: export method as function close over object
Question: In python I would like to export an object-method as a normal function. The
object will be closed over. Like in the following:
from functools import partial
class A(object):
def __init__(self,a):
self.a = a
... |
calling CLR method with variable arguments from IronPython
Question: I am using Iron Python as an added 'for free' tool to test the an API that
wrapps comms to some custom hardware so the non-development team can play with
the hardware via python.
However I can't work out how to get .NET `void func(params object[] arg... |
Python nosetests skip certain Tests
Question: I am working on tests for a web application written in python.
Suppose I have 5 tests in my test_login.py module.
Every single test is a Class.
There is often one, base test that extends TestFlow class, which is our
predefined test class.
And then other tests in this mo... |
Better ways to get nth element from an unsubscriptable iterable
Question: Sometimes an iterable might be not subscriptable. Say the return from
`itertools.permutations`:
ps = permutations(range(10), 10)
print ps[1000]
Python will complain that `'itertools.permutations' object is not
subscriptab... |
importing without executing the class - python
Question: my problem is about i have a file that contain class and inside this class
there is bunch of code will be executed
so whenever i import that file it will executed ! without creating an object
of the class ! , here is the example
FILE `X`
class d:... |
Alternate Data Streams on a folder
Question: I'm using StgCreateStorageEx from python win32com based adapting the code in
[testStorage.py](http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/file/9f6fdae45eb7/com/win32com/test/testStorage.py)
to write my own file_id attribute onto any file.
According to [alternate... |
Error connecting to mysqldb
Question: how to solve the following error on the below code. The application is a
python phones application that retrieves names and phone numbers from a
mysqldb database. The line that gives me the error is phoneList =
c.fetchrows(). I really appreciate your assistance.
# AttributeError: ... |
Python tkinter app adding a right click context menu?
Question: I have a python-tkinter gui app that I've been trying to find some way to add
in some functionality. I was hoping there would be a way to right-click on an
item in the app's listbox area and bring up a context menu. Is tkinter able to
accomplish this? Woul... |
How to fix this UnicodeDecodeError that appears when I try to remove accents in Python strings?
Question: I'm trying to use this function:
import unicodedata
def remove_accents(input_str):
nkfd_form = unicodedata.normalize('NFKD', unicode(input_str))
return u"".join([c for c in n... |
Python3: How to dynamically resize button text in tkinter/ttk?
Question: I want to know how to arrange for the text on a ttk widget (a label or button,
say) to resize automatically.
Changing the size of the text is easy, it is just a matter of changing the
font in the style. However, hooking it into changes in the siz... |
wpa-handshake with python - hashing difficulties
Question: I try to write a Python program which calculates the WPA-handshake, but I have
problems with the hashes. For comparison I installed cowpatty _(to see where I
start beeing wrong)_.
My PMK-generation works fine, but the PTK-calculation alsways seems to be
wrong.... |
PYTHON: Trying to create a vocabulary/translation quiz (Beginner)
Question: I'm new to Python (and also to stackoverflow, as you will easily notice it !)
I'm actually trying to write a program that would work as follow : the user
launch the program. he's being asked whether he wants to enter a new word, and
the transl... |
Python + Windows: How to write a script that pops up a reminder on computer sleep/shutdown?
Question: I want to write a Python script that will remind me to take my medicine on
sleep/shutdown. (just a simple pop up message). Where do I begin?
(I'm looking for a really simple implementation if it exists. I don't want t... |
Danger of mixing numpy matrix and array
Question: The science/engineering application I'm working on has lots of linear algebra
matrix multiplications, therefore I use Numpy matrices. However, there are
many functions in python that interchangeably accept matrix or array types.
Nice, no? Well, not really. Let me demons... |
Trying to serve django static files on development server - not found
Question: I've followed the instructions in [this
question](http://stackoverflow.com/q/9197599/344286), [the
documentation](https://docs.djangoproject.com/en/dev/howto/static-files/), and
I've even looked at [this one](http://stackoverflow.com/q/1064... |
importing updated files into a database
Question: I have files that are updated every 2 hours. I have to detect the files
automatically and insert the extracted information from them into a database.
Our DBMS is Postgresql and programming language is Python. How would you
suggest I do that?
I want to make use of DAL ... |
python regex of group match
Question: here is my code:
import re
pattern_str = '(?P<style>[^|]*>)\|(?P<tags>[^|]*)'
p = re.compile(pattern_str)
m = p.match('OL|AAAAA')
a = m.group('style') # AttributeError: 'NoneType' object has no attribute 'group'
print a
it do... |
Making a job fail in jenkins
Question: This question might sound weird, but how do I make a job fail?
I have a python script that compiles few files using scons, and which is
running as a jenkins job. The script tests if the compiler can build x64 or
x86 binaries, I want the job to fail if it fails to do one of these.... |
How to avoid blocking code in python with gevent?
Question: I am playing around with gevent, and I am trying to understand why my code is
blocking and how I can fix it.
I have a pool of greenlets, and each of them talk to a thrift client which
gathers data from a remote thrift server. For the purpose of the exercise, ... |
(not list inherited) Deck class (card games) can be used in for loops, without __iter__
Question: 'sup guys,
I'm just doing my usual random little programs before my exam within a few
days and I decided to write a five card draw poker. Since it's simply for
playing a bit with code, I didn't inherit anything from basi... |
Is there any case where datetime.fromtimestamp returns an incorrect result using pytz?
Question: `pytz` asks you to use the `.astimezone` method for all time conversion to and
from UTC. However, in one special case — `datetime.fromtimestamp` — it looks
like you should be able to use the Python library's datetime method... |
Python log-the-display problems
Question: I'm trying to log the terminal display produced by a script which contains a
Scipy optimization routine. I've tried three different ways, all with
disappointing results.
open() and cmd-prompt redirection (">") did not log the warnings nor the per-
iteration information I would... |
Is it safe in Python to use 'from copy import copy' statement?
Question: Python has complicated namespaces and modules notion, so i unsure about this.
Normally python `module` and something that is imported from it has different
names or only module is imported and it's content used by fully qualified
name:
... |
scipy's splrep/splev for python interpolation returns nan
Question: I have a [data set](http://users-phys.au.dk/daniel89/test.txt) with the first
column is the `x` data (wavelenght) and the second column is the `y` data
(relative intensity).
I wish to interpolate it on to another `x_new`-data but my problem is that
`s... |
Getting the "wrong" type generated with SQLAlchemy 0.7.8 and Oracle XE
Question: Can anyone please tell me why the DateTime type below creates a "DATE" object
and not a DateTime (or more appropriately, a TIMESTAMP type) as I have to
force the type as in the row below :
#!/bin/python
import sqlal... |
How to make an object in VPython move through the camera automatically?
Question: I have this grocery isle and I'm supposed to make it seem as if the person is
walking through the isle, but in order to do that the object has to pass the
camera and every time it gets close, it hits the frame of the window and it
almost ... |
why is Python datetime.date inconsistent with the input format it allows? is this a bug in datetime.date?
Question: Why does using date(2012,08,01) & date(2012,09,01) fail but date(2012,01,01)
through date(2012,07,01) succeed?
I'm using Python v.2.6.6
here is a copy paste from my console
In [2]: from d... |
installing pytz in gae is giving UnknownTimeZoneError
Question: [unutbu](http://stackoverflow.com/users/190597/unutbu) answered my previous
question nicely [here 2](http://stackoverflow.com/questions/11925664/what-is-
the-local-timezone), but there does not appear to be a pytz to import directly
using my SDK. So I went... |
Fastest way to count three items referenced by one of them (using python)?
Question: I have a multi column (13 columns) space separated file (some 5 million+
lines), going like this:
1. W5 403 407 P Y 2 2 PR 22 PNIYR 22222 12.753 13.247
2. W5 404 408 N V 2 2 PR 22 PIYYR 22222 13.216 13.247
... |
Is There Any Way To Check if a Twitch Stream Is Live Using Python?
Question: I'm just wondering if there is any way to write a python script to check to
see if a twitch.tv stream is live? Any and all thoughts are appreciated!
EDIT: I'm not sure why my app engine tag was removed, but this would be using
app engine.
A... |
How do I convert a string to a python datetime object with a relevant timezone?
Question: I have a string similar to "2012-06-14 20:38:24.213-7:00" and want to convert
it to a python date time object with the time zone kept intact, how would I do
this?
Answer: [A fixed offset is not enough to find out the timezone
na... |
itertools: Cartesian product of permutations
Question: Using pythons `itertools`, I'd like to create an iterator over the outer
product of all permutations of a bunch of lists. An explicit example:
import itertools
A = [1,2,3]
B = [4,5]
C = [6,7]
for x in itertools.product(itertools.... |
Globals and singletons in Python
Question: I have some few classes which are widespread in my Python application and
which should have only one global instance (eg Logger, DbConnection). Python
does not support static variables/methods in a class, so the usual Java/C++
way to create a singleton here does not work. I ha... |
Created with py2exe program doesn't work on Windows XP without python
Question: I need to use my python program on many different computers with Windows XP
and 7, without having to download a Python interpreter. So I create *.exe with
py2exe. But when I start it on XP without python installed, I'm getting an
error mess... |
Why does this go code fail?
Question: I have written some go code in FP style to generate primes:
package main
import (
"fmt"
)
func gen_number_stream() func() (int, bool) {
i := 1
return func() (int, bool) {
i += 1
return i, true
}... |
Converting an image instance (file) to an array (python)
Question: I have an image sequence and I am trying to run a script on a specific frame.
I need to switch to this frame and convert it to an array. However, I am
unable to as the frame is an instance `<TiffImagePlugin.TiffImageFile image
mode=I;16 size=512x512 at ... |
Python module to change system date and time
Question: How can I change System Date, Time, Timezone in Python? Is there any module
available for this?
1. I don't want to execute any system commands
2. I want one common solution, which should work on both Unix and Windows.
Answer:
import sys
import datet... |
Set up python path in mac osx?
Question: I installed python on mac os (mountain lion) with Macports. When I run $python
It gives an error on "cannot import urandom" when I try to import pandas or
matplotlib.
If I run $python 2.7 Everything runs perfectly.
I want to change python to use python2.7 always.
I tried usin... |
Is there any way to install nose in Maya?
Question: I'm using Autodesk Maya 2008 on Linux at home, and Maya 2012 on Windows 7 at
work. Most of my efforts so far have been focused on the former. I found [this
thread](http://stackoverflow.com/questions/639744/running-unit-tests-with-
nose-inside-a-python-environment-such... |
DateField always return None value
Question:
class News(models.Model):
title = models.CharField(max_length=70)
full_text = models.TextField()
pub_date = models.DateField('-pub_date')
then i run python manage.py shell whatever i do value for News.pub_date is
None
i am using sqlite3 and when... |
python:print(''.join(doc.xpath('//text()'))
Question: What is wrong? Please,somebody says me,what I have to write instead of
application/x-abiwordAbiWord.
Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information... |
Reading multiple XML files in a specific folder - Python
Question: I need a little help from you guys.
Im new to programming, so dont expect much from my code.
Here is the thing, i need to parse a bunch of XML files in a folder and write
it on a .xls or a .csv. Until now i've made it to parse the xml and write it
to ... |
How to detect Endianess and Filesystem with Python3
Question: I'm theorizing of a project where my python script looks at filesystem(s) on
the machine running the script but also reports back on the filesystem(s) of
devices that it mounts, thumb drives, mobile devices, etc.
Is anyone aware of the a BIF in python3 that... |
Reading files in a particular order in python
Question: Lets say I have three files in a folder: file9.txt, file10.txt and file11.txt
and i want to read them in this particular order. Can anyone help me with
this?
Right now I am using the code
import glob, os
for infile in glob.glob(os.path.join( '*... |
python webcrawler downloading files
Question: I have a webcrawler that searches for certain files and downloads them, but
how do I download a pdf file when the "save as or open" dialog prompts up. I
am currently using python selenium to crawl. Here is my code.
from selenium import webdriver
import ti... |
What is causing my HTTP server to fail with "exit status -1073741819"?
Question: As an exercise I created a small HTTP server that generates random game
mechanics, similar to [this
one](http://inventwithpython.com/randommechanic.html). I wrote it on a Windows
7 (32-bit) system and it works flawlessly. However, when I r... |
Issues that could happen if importing site-packages from python2.6 to be used with python2.7?
Question: I finally managed to install numpy, but it seems to only work in python2.6 . I
don't know how to install it in the 2.7 folder (been trying for hours, but I'm
just a beginner developer in my first months). Anyway, if ... |
getting output with weird text like☻
Question: Hey! I am getting a problem with my script.
I wrote it when reading [LPTHW](http://learnpythonthehardway.org/) book.
I am not getting an error message but I am not getting the correct output, I
think there might be a setting wrong with my system. I am confused.
Here is ... |
Listing installed modules in Python
Question: Here is a basic code I came up with to list modules installed.
import sys as s
mod=s.modules.keys()
for indx,each in enumerate(mod):
print indx,each
But what I am looking for is, it should only print out the parent module name
like for
... |
Using Cython to speed up connected components algorithm
Question: First off, I am using python[2.7.2], numpy[1.6.2rc1], cython[0.16], gcc[MinGW]
compiler, on a windows xp machine.
I needed a 3D connected components algorithm to process some 3D binary data
(i.e. 1s and 0s) stored in numpy arrays. Unfortunately, I could... |
A value in a list, python
Question: Every character in the English language has a percentage of occurrence, these
are the percentages:
A B C D E F G H I
.0817 .0149 .0278 .0425 .1270 .0223 .0202 .0609 .0697
J K L M ... |
python: logging output from external API to logger module
Question: I am python beginner. My python script logs output to a file (say example.log)
using the basic python logging module. However, my python script also makes
some 3rd party API calls (for example, parse_the_file) over which I don't have
any control. I wan... |
UnicodeWarning: Unicode equal comparison. How to replace non-standard characters in NavigableString dataype?
Question: I'm scraping a website with Python 2.7 using BeautifulSoup. Here's my code:
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib
import json
... |
Numpy distutils howto
Question: I spent almost an hour googling for the solution, but the documentation for
numpy.distutils is very sparse.
I have a f2py-wrapped module. It consists basically of 3 files:
a.f90
a.pyf
lib.a <- this is a static library that contains most of the computational code
... |
removing extra blank spaces in python
Question: I have a file which reads:
o hi! My name is Saurabh.
o I like python.
I want something like:
o hi! My name is Saurabh.
o I like python.
I tried the line:
removedSpaces=' '.join(lineW... |
calling third party c functions from python
Question: I have a requirement of calling third party c functions from inside python. To
do this I created a c api which has all the python specific c code ( using
METH_VARARGS) to call the third party functions. I linked this code liba.so
with the 3 party library libb.so In ... |
Python: tf-idf-cosine: to find document similarity
Question: I was following a tutorial which was available at [Part
1](http://blog.christianperone.com/?p=1589) & [Part
2](http://blog.christianperone.com/?p=1747) unfortunately author didn't have
time for the final section which involves using cosine to actually find th... |
Twython updateStatus - Unauthorized: Invalid / expired Token
Question: I'm trying to post a tweet using Twython from Django-powered site. However,
the 'twitter.updateStatus(status=tweet_text)' line results in the following
error:
TwythonError: u'Unauthorized: Authentication credentials were missing or in... |
How to achieve forward compatible string literals in python?
Question: I've got a script which runs with python 3 except string literals. Python 2.x
force me to prefix string literals with u'' and python 3 dosen't understand
it. How to so solve that?
Answer: try this when running it in python 2.x:
>>> ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.