text stringlengths 226 34.5k |
|---|
mysql-connector-python GBK encoding error
Question: I have a GBK encoding data table. Sometimes, a insert SQL with unicode string
failed with exception:
mysql.connector.errors.ProgrammingError: Failed processing pyformat-
parameters; 'gbk' codec can't encode character u'\u2022' in position 14:
illegal
It is caused by... |
Pycharm and bitbucket plugin
Question: I have installed bitbucket plufin to connect my Pycharm with bitbucket.I have
tried in VCS menu in PyCharm -> import into Versions control -> Share project
(with bitbucket icon) -> name it like my project -> mark that it is Git
repository -> click Ok and I get then error message "... |
Error on Tkinter import
Question: I'm writing a Tkinter app in Python 2.7, but I'm running into some troubles
that I haven't had before. From what I can tell, it looks like the Tkinter
module is getting imported for the `__init__` function in my class, but not
for the other functions. Here's a simplified version of wha... |
more efficient way to calculate distance in numpy?
Question: i have a question on how to calculate distances in numpy as fast as it can,
def getR1(VVm,VVs,HHm,HHs):
t0=time.time()
R=VVs.flatten()[numpy.newaxis,:]-VVm.flatten()[:,numpy.newaxis]
R*=R
R1=HHs.flatten()[numpy.n... |
pymssql (python module) losing item when fetching data
Question: I have a database named "sina2013",and the columus is Title,Content Now I want
to use pymssql module to get the data.At the same time ,using the Title as the
filename of a txt file,the Content as the content of the txt file. The strange
thing is the numbe... |
Python PIL TypeError: integer argument expected, got float
Question: I keep getting this error when running a paste script in Python 3.x:
TypeError: integer argument expected, got float
from PIL import Image
img=Image.open('C:\Mine.jpg','r')
img_w,img_h=img.size
background = Image.new('RGBA',... |
Can't import turtle module in Python 2.x and Python 3.x
Question: I want to play with [turtle](http://docs.python.org/2/library/turtle.html)
module in Python. But when i do import turtle module, i've the following
error:
$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux... |
Issue with python module importing
Question: In dir tree looks like this
PyPong \+ Main.py \+ Rectangle.py
Now, I have imported Rectangle.py like this in Main.py
import pygame, sys, Rectangle
However, whenever I try making an instance of the class Rectangle.py like here
rectangles.... |
Refactor Python Code
Question: I was wondering if anyone could help me refactor the following Python code:
In this example, `endDate` is a string like such: `"2012-08-22"`
dateArray = [int(x) for x in endDate.split('-')]
event.add('dtend', datetime(dateArray[0], dateArray[1], dateArray[2]))
I ... |
Look ahead without itertools
Question: I am looking for a way to look at the next line in a text file when the first
characters are the letters are only A,G,C,U or N. I created a dict. of all
possibilities in which I can look. I have tried itertools, but to no avail and
I have heard that the itertools would keep everyt... |
How to convert UTC-4 to US/Eastern in python?
Question: I read time stamps from text file. These time stamps are in UTC-4. I need to
convert them to US/Eastern.
import datetime
datetime_utc4 = datetime.datetime.strptime("12/31/2012 16:15", "%m/%d/%Y %H:%M")
How do I convert it to US/Eastern? On... |
How to install a package using the python-apt API
Question: I'm quite a newbie when it comes to Python, thus I beg foregiveness beforehand
:). That said, I'm trying to make a script that, among other things, installs
some Linux packages. First I tried to use subopen as explained
[here](http://stackoverflow.com/question... |
get ''expected-doctype-but-got-chars " error when i use html5lib of python?
Question: This is my code:
from html5lib import treebuilders, HTMLParser
parser = HTMLParser(tree=treebuilders.getTreeBuilder("lxml"))
parser.parse("hello world!")
print parser.errors
what cause the error?
But ... |
Python: Appending API Calls to Spreadsheet
Question: I'll start out by saying I'm very new to Python and programming in general but
am very hands on in my learning style.
I would like to use Python to:
1. Gather an entire column of a spreadsheet into a list
2. Call to Klout's API to (a) Get the Klout User ID and ... |
Compile thread-safe tcl for python on Windows
Question: I'm doing a project with Python and I need to put something in thread. It
turned out that if you do something that uses Tk in thread, it will somehow
crash. The error is:
TclError: out of stack space (infinite loop?)`
I searched on Google and ... |
How to count number of files available in a directory recursively in Python using rsync?
Question: I want to count number of files recursively in a remote server path using
rsync in Python? I tried it doing like this:
def find_remote_files(source, password):
cmdline = ['sshpass', '-p', password, ... |
Python how to filter string based on substring
Question: Im new to Python coming from Java world.
1. I'm trying to write a simple python function that prints out only the data rows of a CSV or "arff" file. The non data rows begin with these 3 patterns @ , [@ , [%, and such rows should not be printed.
2. Example d... |
Vertical text in Tkinter Canvas
Question: Is there a way to draw vertical text in Tkinter library? (Python recommended)
textID = w1.create_text(5, 5, anchor="nw")
w1.itemconfig(textID, text = "This is some text")
Answer: If you are asking whether
[`tkinter.Canvas.create_text`](http://effbot.or... |
Sqlite3 / python - Export from sqlite to csv text file does not exceed 20k
Question: I am attempting to export a sqlite table to a text file and I found some great
help at this site. It works great for smaller outputs, but once I reach around
20k it appears to limit the output.
# first attempt was:
Mark Bells UniCode... |
MATLAB twice as fast as Numpy
Question: I am an engineering grad student currently making the transition from MATLAB
to Python for the purposes of numerical simulation. I was under the impression
that for basic array manipulation, Numpy would be as fast as MATLAB. However,
it appears for two different programs I write ... |
Python group and splice: splicing the result returned from itertools.groupby
Question: I am trying to read a csv file using numpy genfromtxt into a structured array.
I plan to sort it and then use groupby to separate the file into groups based
on the string values of one of the columns. Finally, I will splice the colum... |
python csv list by rows instead of columns
Question: I have a script that can take the final redirection url and save it into CSV
file.
The script write codes in 1 column for example A1 then A3 then A5
How to make it write the codes by rows for example A1 B1 C1 D1
please see [this](http://i.imgur.com/Gl5jdrf.jpg) th... |
Calculating power for Decimals in Python
Question: I want to calculate power for `Decimal` in Python like:
from decimal import Decimal
Decimal.power(2,2)
Above should return me as `Decimal('2)`
How can I calculate power for `Decimals`?
EDIT: This is what i did
y = Decimal('10')... |
What's the fastest way to create an API over a RESTful JSON interface for MongoDB?
Question: My technical experise is restricted to **Javascript** and **Python**.
How can I create an API for MongoDb that I may use with my client side
Javascript MVC framework?
Answer: If you are working with Django I'd recommend a st... |
Pexpect throws unicode decode error when make command is run to compile C libraries
Question: I am running make to compile C libraries in a python project and using
python(python 3.3) pexpect for automation part. So the output of make command
is read in chunks by pexpect and in one such chunk it throws the following
er... |
Printing all elements of graph one by one in python
Question: I tried to traverse a graph in this algorithm in python. What Changes should I
make if I want to print all elements of graph one by one or traversing the
whole graph.
Any help will be very much appreciated. Thanks.
grapth={'A': ['B', 1... |
Improve python performance for array operations
Question: I have a python script that reads two tiff images and finds unique
combinations, counts the observations and saves the count to a txt file.
You can find the full script [in www.spatial-ecology.net](http://spatial-
ecology.net/dokuwiki/doku.php?id=wiki%3ageotool... |
Looping in Python
Question: I am trying to make a sprite in pygame throw a grenade. What I would like is
for it to move forward a bit, then stopping. My problem is getting the grenade
to smoothly move forward. What the following code does is having it move to
the point of intrest immediately, not smoothly moving.
[Gre... |
Using python to issue command prompts
Question: I have been teaching myself python over the past few months and am finally
starting to do some useful things.
What I am trying to ultimately do is have a python script that acts as a
queue. That is, I would like to have a folder with a bunch of input files that
another p... |
Python selenium error when trying to launch firefox
Question: I am getting an error when trying to open Firefox using Selenium in ipython
notebook. I've looked around and have found similar errors but nothing that
exactly matches the error I'm getting. Anybody know what the problem might be
and how I fix it? I'm using ... |
Search an id in python with BeautifulSoup
Question: I need help with a problem... I am doing a code for know the content of a tag
but... What can I do for take the content if it have got a id?
from bs4 import BeautifulSoup
import urllib2
code = '<span class="vi-is1-prcp" id="v4-27"> 15,00 EU... |
Multiple, specific, regex substitutions in Python
Question: What I would like to do is to make specific substitions in a given text. For
example, '<' should be changed to '[', '>' to ']', and so forth. It is similar
to the solution given here: [How can I do multiple substitutions using regex
in python?](http://stackove... |
I am having difficulty using mincemeat in python for map-reduce to calculate wordcount of different files
Question: Here is the code:
import glob
import mincemeat
import re
text_files = glob.glob('finalcount/1/*')
def file_contents(file_name):
f = open(file_name)
try:... |
What does hash do in python?
Question: I saw an example of code that where `hash` function is applied to tuple. As a
result it returns a negative integer. I wonder what does this function does.
Google does not help. I found a page that explains how hash is calculated but
it does not explain why we need this function.
... |
Drawing text in python
Question: I have the following code (derived from [this
answer](http://stackoverflow.com/a/17556210/35070)) with my attempt to add the
text drawing of numbers. It doesn't work. It doesn't create an image and the
cmd prompt is too fast to see which error it is throwing.
#!/usr/bin/e... |
Port Python virtualenv to another system
Question: I am using many python packages like numpy, bottleneck, h5py, ... for my daily
work on my computer. Since I am root on this machine it is no problem to
install these packages. However I would like to use my "environment" of
different packages also on a server machine w... |
Can I get a list of the variables that reference an other in Python 2.7?
Question: Imagine I have:
X = [0,1]
Y = X
Z = Y
Is there a function like referenced_by(X) that returns something like `['Y',
'Z']`? And a function like points_to(Y) that returns `'X'`?
I know there is `is` to test whe... |
Python Function returns wrong value
Question:
periodsList = []
su = '0:'
Su = []
sun = []
SUN = ''
I'm formating timetables by converting
extendedPeriods = ['0: 1200 - 1500',
'0: 1800 - 2330',
'2: 1200 - 1500',
'2: 1800 - 2330',
'3: 1200 - 1500'... |
GAE: Exceeded maximum allocated IDs
Question: It seems gae assigns very high IDs to the models. When I download my entities,
I get for some entries very big numbers. These were autogenerated in first
place. Downloading them as csv is no problem. But deleting the existing data
and re-uploading the same data throws an ex... |
Installing matplotlib on Ubuntu: ImportError
Question: My platform:
Ubuntu 13.04, Python 2.7.4.
Installing matplotlib failed, ImportError: No module named pyplot.
I have tried many ways such as
$ sudo apt-get install python-matplotlib
and easy install, install from source..., I'm folllowing
<htt... |
correct style for element-wise operations on lists without numpy (python)
Question: I would like to operate on lists element by element without using numpy, for
example, i want `add([1,2,3], [2,3,4]) = [3,5,7]` and `mult([1,1,1],[9,9,9]) =
[9,9,9]`, but i'm not sure which way of doing is it considered 'correct'
style.
... |
Installing MySQL-python on mac
Question: I am using OSX 10.8 and PyCharm to work on a Python development project. I
have installed MySQL-python for the mac using the instructions on the website
<http://blog.infoentropy.com/MySQL-
python_EnvironmentError_mysql_config_not_found>
However, running the project gives me th... |
Dynamically choosing class to inherit from
Question: My Python knowledge is limited, I need some help on the following situation.
Assume that I have two classes `A` and `B`, is it possible to do something
like the following (conceptually) in Python:
import os
if os.name == 'nt':
class newCla... |
Commit file in svn with python3
Question: Is there any simple way to commit a file (.txt) that my script creates to svn?
I found a lot of tools but seems complicated to use
Answer: I need to know which OS are you using before I answer this.
Anyway if you are using linux/unix you can use this:
Suppose all the files... |
Better way to initialize python ctypes structure field
Question: Is there a better way to initialize a ctypes field that is meant to be
static/constant than what I have below?
from ctypes import *
class foo(LittleEndianStructure):
_fields_ = [
("signature", c_ulonglong),
]
... |
How to pass a list of strings to an opencl kernel using pyopencl?
Question: How to pass list of strings to an opencl kernel the right way?
I tried this way using buffers (see following code), but I failed.
OpenCL (struct.cl):
typedef struct{
uchar uc[40];
} my_struct9;
inlin... |
Regex findall start() and end() ? Python
Question: i'm trying to get the start and end positions of a query in sequence by using
re.findall
import re
sequence = 'aaabbbaaacccdddeeefff'
query = 'aaa'
findall = re.findall(query,sequence)
>>> ['aaa','aaa']
how do i ... |
Python Overwriting text in Tkinter
Question: I'm having some trouble updating the countdown timer text printed on a canvas.
My current code leaves the area where the text should be blank.
I've tried placing it in various places, but they all lead to no effect or the
same effect I described above. Removing the `canvas.... |
python script to remove reversed repeated lines
Question: I got a python code that removes lines if they are similar when reversed. For
example if I have a document that contains:
1,2 3,4
5,6 7,8
2,1 4,3
5,6 8,7
After executing the script, the output is
5,6 7,8
2,1 4,... |
Haystack indexing error
Question: I am trying to implement haystack [tutorial](https://django-
haystack.readthedocs.org/en/latest/tutorial.html#installation) : But i am
facing problems :
If i already have data in my DB and try to build index using :
`python manage.py rebuild_index` it gives the following error :
... |
Why is my python output delayed to the end of the program?
Question: I've got an extremely simple application:
import sys
from time import sleep
for i in range(3):
sys.stdout.write('.')
sleep(1)
print('Welcome!')
I expect it to print out a dot every second (3 t... |
python check if colour exists on mouse click
Question: I am trying to automate part of a game. I've done all but one part of what I
need and its proving to be difficult. My code so far:
import win32api, win32con, time
import win32com.client as comclt
counter = 0
holder = 611
def... |
Python: Running a strip of code unless imported
Question: I have a file that I'm importing into my program (say a file with
dictionaries). At the beginning of this file I want to put a strip of code
which prints that this is not the main file and then `exit()`. The problem I
find is that this code is being run on impor... |
Import a .mdb to SQLServer via Stored Procedure
Question: **Context**
We need to import a .mdb archive to our local database so that we can
manipulate all the DATA.
**DATA**
that .mdb file Always have the same amount of tables (58) and the same table
structure, those tables may have 109.000 to 10million entries
**A... |
Add files from one tar into another tar in python
Question: I would like to make a copy of a tar, with some files removed (based on their
name and possably other properties like symlink or so). As I already have the
tar file open in python, so I would like to do this in python. I understood
that TarFile.getmembers() re... |
Python: "if closest to 1"
Question: I am doing some calculations on a dictionary. But the important thing is I
want to make a if-condition that kind of says
"if **x** has a value that is closer to 1 (or equal to 1) than **variable** "
kind of hard to explain, but hope you understand.
Answer: You can use [absolute
v... |
Python Sigma Sums
Question: I have a list of values x=`[1,-1,-1,1,1,-1,1,-1,1,-1]` and I have another
blank list `y=[ ]`
I am trying to create a function that will take a sigma sum of values in `x`
and store them in `y`.
For instance, `y[0]` should be the sum of `x[0]*x[0] + x[0]*x[1] + x[0]*x[2] +
... + x[0]*x[9]` .... |
py2app ImportError with watchdog
Question: I am attempting to use py2app to bundle a small Python app that I've made in
Python 2.7 on Mac. My app uses the [Watchdog
library](http://pythonhosted.org/watchdog/), which is imported at the top of
my main file:
from watchdog.observers import Observer
from ... |
How to get a Python console to access the vim module
Question: Recently I have been looking into vim plugin development, and I found I missed
the ability to use a Python REPL (ipython/bpython for eg) to inspect the vim
module, and generally the environment (current open document, line number,
selection etc).
This is i... |
Variables while reading a file with multiple rows in a list - python or shell
Question: I am looking to do this in python or a basic shell script.
I have a file with multiple entries that I would like to manipulate its data
and store them in variables.
The file has rows with multiple columns. The first column is a pe... |
python: several functions in one file, AttributeError 'module' object has no attribute
Question: I am a beginner of python, and I just created a module file in python which
includes several functions together. When I called the first function defined
in the file, it was fine. But when I tried to call the second functio... |
NLTK with flask import error
Question: My folder directory is as such
/maindir
__init__.py
settings.py
start
/run.py
/venv
.. other directories for flask here bin,include..etc
/app
__init__.py
main.py
views.py
/nbc
/__i... |
Something like python timedelta in golang
Question: I want to get a datetime, counting weeks from a date, days from a week and
seconds from 00:00 time.
With Python I can use this:
BASE_TIME = datetime.datetime(1980,1,6,0,0)
tdelta = datetime.timedelta(weeks = 1722,
da... |
Setting font in tkinter returns errors
Question: I'm in the middle of rewriting the code for my first tkinter application, in
which I'd avoided using classes. That was a dead end and I have to finally
learn class programming in python. I've encountered a very weird error and I
have no idea how to fix it. I've tried, bu... |
SQLAutoCode - error when attempting to generate schema
Question: I'm trying to auto generate a schema for use in SQLalchemy, I'm using
sqlautocode to do this, I use the following command
D:~ admin$ sqlautocode mysql://'user':"pass"@xx.xx.xx.xx:3306/db_name -o tables.py
but I keep getting the follow... |
Python -- special method arithmetic using existing class methods
Question: This class takes a finite field polynomial string, parses it, operates
(+-*/%), then outputs in the same format as the input. It works fine (so far).
However, now I'm trying to implement special methods on the arithmetic
operators, and I can't g... |
How to set a date restriction for returned events in Google Calendar and put them in order - Python
Question: Ok, so I've seen similar questions to this, but most of them are in regards to
different languages, none seem to be within the realm of Python. I've also
searched the documentation on Google for the different o... |
Python doesn't detect my unittest
Question: I have following code snippet -
import unittest
class SimpleWidgetTestCase(unittest.TestCase):
def setUp(self):
print 'setup'
def method_test(self):
print 'test method'
def tearDown(self):
pri... |
Python Relative Path Import from subfolder
Question: first post to SO, so if I'm missing some details, please forgive me.
Is there a way to use relative paths from another subfolder without resorting
to modifying sys.path via os? Eventually this will be run from a cgi webserver
so I'd rather stay away from any -m argu... |
replacing only single instances of a character with python regexp
Question: I am trying to replace single `$` characters with something else, and want to
ignore multiple `$` characters in a row, and I can't quite figure out how. I
tried using lookahead:
s='$a $$b $$$c $d'
re.sub('\$(?!\$)','z',s)
... |
Disjoint set of records from two pandas DataFrames
Question: Is there an easy way to find the disjoint set of records (what would be left
on each of the two original dataframes that is not included in the resulting
inner join) between two pandas dataframes based on a MultiIndex?
Am I missing something rather obvious o... |
python inside vim to obtain file list from current directory
Question: How would I use python script to communicate with vim..
Using ultisnips plugin, I have option to include shell script or python script
inside snippet definition, using `!p` for python for example. Now, what I am
trying to do is to get list of files... |
Saving data in Python without a text file?
Question: I have a python program that just needs to save one line of text (a path to a
specific folder on the computer).
I've got it working to store it in a text file and read from it; however, I'd
much prefer a solution where the python file is the only one.
And so, I ask... |
Python3 multipartmime email (text, email, and attachment)
Question: I'm creating some emails in Python and I'd like to have HTML, text, and an
attachment. My code is 'working', though its outputs are shown by Outlook as
EITHER HTML or text, while showing the other 'part' (email or txt) as an
attachment. I'd like to hav... |
Does the python code executes in order
Question: I am creating a file and then doing diff on it.
I want to do diff on the file which iscreated in previous step but i get the
error that file dont exist .
This is my code
os.popen("mysqldump --login-path=server1_mysql -e --opt --skip-lock-tables --skip-e... |
Using Python in vimscript: How to export a value from a python script back to vim?
Question: I'm struggling with Python in vim.
I still haven't found out how I can import a value from a python script (in a
vim function) back to vim p.e.
function! myvimscript()
python << endpython
imp... |
Python OpenCV extremely high CPU usage after 10 second runtime
Question: I'm currently doing a project where I'm building an autonomous driving car. So
far I have sorted out the image processing parts as well as training the SVM
(libSVM). I'm getting the video feed from an IP camera but even using a video
file I'm enco... |
Specify the return type for a ctypes call (in python) to a fortran function that returns an array of doubles
Question: I'm trying to use the ctypes module to call, from within a python program, a
(fortran) library of linear algebra routines that I have written. I have
successfully imported the library and can call my _... |
import MySQLdb ImportError
Question: I think I installed MySQL correctly. Almost positive, except for the fact that
it isn't working
$ python
>>> import MySQLdb
returns
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", ... |
Cannot connect to mssql db using pymssql
Question: I have FreeTDS installed and configured correctly. My freetds.conf file as
this appended to the end:
[myserver]
host = myserver
port = 1433
tds version = 7.0
And I can running the following command gives me a SQL prompt:
... |
Understanding routing error (Python)
Question: I'm trying to make a program work that calls files in a specific folder.
However, for some reason, I keep getting an error. I'll post the relevant code
and error message.
Code:
def objmask(inimgs, inwhts, thresh1='20.0', thresh2='2.0', tfdel=True,
... |
no module named requests
Question: I will first state I have searched for this problem, and found the exact same
problem here ( [ImportError: No module named
'requests'](http://stackoverflow.com/questions/16265368/importerror-no-module-
named-requests) ) but that hasn't helped me.
I am using macports on osx (mountain ... |
Releasing a python package - should you include doc and tests?
Question: So, I've released a small library on pypi, more as an exercise (to "see how
it's done") than anything else.
I've uploaded the documentation on readthedocs, and I have a test suite in my
git repo.
Since I figure anyone who might be interested in ... |
How to find by _id in ming?
Question: I have a mapped class in [ming](http://merciless.sourceforge.net/)
from ming import Session, create_datastore
from ming import schema
from ming.odm import ODMSession
from ming.odm.mapper import MapperExtension
from ming.odm.property import ForeignIdPr... |
import wx not working in uncompiled scripts
Question: I have installed Python 2.7.5 and wxPython 2.8.12.1 on my new Windows 7
machine, and the 'import wx' statement doesn't work when I try to run the
containing .py script directly from the Windows command prompt or from the
Windows explorer. (It does work in the compil... |
Create a continuous distribution in python
Question: I am having trouble creating a continuous distribution in python and its
really beginning to annoy me. I have read and re-read [this python guide
(scipy
guide)](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html#scipy.stats.rv_continuo... |
How can I add context to an exception in Python
Question: I would like to add context to an exception like this:
def process(vals):
for key in vals:
try:
do_something(vals[key])
except Exception as ex: # base class. Not sure what to expect.
... |
Flask instanciation app = Flask()
Question: I intentionally removed **name** in app = Flask(**name**) and I get this
error:
Traceback (most recent call last):
File "routes.py", line 4, in <module>
app = Flask()
TypeError: __init__() takes at least 2 arguments (1 given)
this... |
Multiple linear regression with python
Question: I would like to calculate multiple linear regression with python. I found this
code for simple linear regression
import numpy as np
from matplotlib.pyplot import *
x = np.array([1, 2, 3, 4, 5])
y = np.array([2, 3, 4, 4, 5])
... |
same implemention on java and python, two very different running times
Question: My friend and I made a program to do the same thing, his was in java and mine
in python. The question we had to solve was "What is the smallest positive
number that is evenly divisible by all of the numbers from 1 to 20?" We both
got the r... |
How to Use unicode with a list or a string in Python
Question: So i Have a list of some Irish(gaelic words) words that I want to use the
unicode with so that RDFlib will be able to understand the accents above some
of the letters in the word. I dont know whether to use the unicode before the
words are in the list or af... |
Referencing a RegEx Variable
Question: I'm using python to loop through a large list of self reported locations to
try to match them to their home states. The RegEx expression I'm using is:
/^"[^\s]+,\s*([a-zA-Z]{2})"$/
Basically, I'm trying to find a pattern that looks like `XXXCITYXXX,
[Statecode... |
How make dns queries in dns-python as dig (with aditional records section)?
Question: I trying use `dns python` and want get all records with `ANY` type query:
import dns.name
import dns.message
import dns.query
domain = 'google.com'
name_server = '8.8.8.8'
domain = dns.name... |
Passing a Python list to PHP - Only achievable with JSON?
Question: I've been doing some research around and haven't found a way to solve the
situation I'm faced with now.
I need to pass a Python list to PHP. I've been reading about doing it with
JSON but I was wondering if it was possible without it.
My list looks s... |
Extract email sub-strings from large document
Question: I have a very large .txt file with hundreds of thousands of email addresses
scattered throughout. They all take the format:
...<[email protected]>...
What is the best way to have Python to cycle through the entire .txt file
looking for a all ins... |
Python subprocess: stderr only saving the first line. Why?
Question: I am running `tcpdump` from within **Python** and I would like to know how
many **packets** are **dropped by the kernel**.
When run on a command line, tcpdump looks like this:
me@mypc:$ sudo tcpdump -w myPackets.cap -i eth0 ip
tcpd... |
Python convert csv to xlsx
Question: In [this post](http://superuser.com/questions/301431/how-to-batch-convert-csv-
to-xls-xlsx) there is a Python example to convert from csv to xls.
However, my file has more than 65536 rows so xls does not work. If I name the
file xlsx it doesnt make a difference. Is there a Python p... |
Python: testing for utf-8 character in string
Question: I need to test whether a string that has already been encoded with
str.encode('utf-8') is right-to-left. I tried
if u'\u200f' in str.decode('utf-8'):
print 'found it'
It neither complains nor works.
Q: What is the correct syntax to test... |
Install a packet with pip, ImportError
Question: When I install a packet with pip (for example patsy)
[sudo] pip install patsy
Downloading/unpacking patsy
Downloading patsy-0.1.0.tar.gz (258kB): 258kB downloaded
Running setup.py egg_info for package patsy
no previously-included ... |
Get the number of friends a facebook user has
Question: I have 2 unrelated questions.
1. How many posts does facebook allow you to get with an api?
2. Using facepy, facebook, or any other api, how do I get the number of friends a user has? (This user is not my friend). The user id is provided.
This is how I curre... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.