text stringlengths 226 34.5k |
|---|
python threads operating serially
Question: I am a python noob. I am trying to design a visual stimulus for experiments in
my lab. The stimulus should stop when the user presses a key. The entire
experiment is timing sensitive and so I cannot run the key check serially.
The code that I wrote looks like this.
* * *
... |
App Engine bulkloader transformation for datetime
Question: I'm trying to load a datetime field with the following format.
2013-02-05T10:09:38-08:00
- property: event_time
external_name: datetime
import_transform: transform.import_date_time('%Y-%m-%dT%H:%M:%S%z')
However, the transform... |
Is there an equivalent of a bootstrap.php for python?
Question: In php, people often call a bootstrap file to set variables used throughout a
program. I have a python program that calls methods from different modules. I
want those methods from different modules to share some variables. Can I set
these variables up in s... |
How to convert this non-tail-recursion function to a loop or a tail-recursion version?
Question: I've been curious for this for long. It is really very easy and elegant for
human to create a non-tail-recursive function to get something complicated,
but the speed is very slow and easily hit the limit of Python recursion... |
Why is a website's response in python's `urllib.request` different to a request sent directly from a web-browser?
Question: I have a program that takes a URL and gets a response from the server using
`urllib.request`. It all works fine, but I tested it a little more and
realised that when I put in a URL such as <http:/... |
Generate all unique permutations of 2d array
Question: I would like to be able to generate all unique permutations of a 2d array in
python.
For example take this 2d array [[1,1],[0,0]] I would like back
[[0,0],
[1,1]]
[[0,1],
[0,1]]
[[0,1]
[1,0]]
[[1,0]
[0,1]]
... |
Python yield multiple assignment
Question: I generally try to use yield whenever I can, but I don't get how I'd do it on
code like this:
numbers = [1,2,3,4,5,6,7,8,9,10]
def odd_and_even(numbers):
odd = []
even = []
for number in numbers:
if number % 2:
... |
Speed up vlookup like operation using pandas in python
Question: I have written some code to essentially do a excel style vlookup on two pandas
dataframes and want to speed it up.
The structure of the data frames is as follows: dbase1_df.columns:
'VALUE', 'COUNT', 'GRID', 'SGO10GEO'
merged_df.columns:
'GRID', 'ST... |
How to execute a python script and write output to txt file?
Question: I'm executing a .py file, which spits out a give string. This command works
fine
execfile ('file.py')
But I want the output (in addition to it being shown in the shell) written
into a text file.
I tried this, but it's not working :(
execfile ('f... |
How to read a large file set
Question: I am very new to Python. So please give specific advice. I am using Python
3.2.2.
I need to read a large file set in my computer. Now I can not even open it. To
verify the directory of the file, I used:
>>> import os
>>> os.path.dirname(os.path.realpath('a90000... |
Python 2&3: both urllib & requests POST data mysteriously disappears
Question: I'm using Python to scrape data from a number of web pages that have simple
HTML input forms, like the 'Username:' form at the bottom of this page:
<http://www.w3schools.com/html/html_forms.asp> (this is just a simple example
to illustrate ... |
change default path of django administration
Question: I am new to Django. I am using django administration for basic crud purpose. I
found that template for django admin resides at
C:\Python27\Lib\site-packages\django\contrib\admin\templates\admin
I need to change it as my own location .. i create... |
Can't understand 500: internal error with Django, Apache, Mod_python
Question: I'm getting a 500:Internal error when i try to start my apache server with
django. I tried the steps given in the previous questions [Django with Apache
500 Error](http://stackoverflow.com/questions/20262164/django-with-
apache-500-error) an... |
Import variables into functions from external file in Python
Question: I am trying to write a script that is rather long, uses several different data
sources and can go wrong at many different stages. Having to restart the whole
process from the beginning each time some error in the input data is
discovered is not too ... |
Why does my code only write the last line?
Question: I'm writing a list to file but it only writes the last line.
Here is my code. I'm on Python 2.7.
server=os.listdir('.') #contents of the current directory
for files in server:
public_html = []
if os.path.isfile(files) == True :
... |
BeautifulSoup - scraping a forum page
Question: I'm trying to scrape a forum discussion and export it as a csv file, with rows
such as "thread title", "user", and "post", where the latter is the actual
forum post from each individual.
I'm a complete beginner with Python and BeautifulSoup so I'm having a really
hard ti... |
Python sequence error
Question: I have written a code to solve various integrals using the midpoint method. I
had it working for some other functions, however when trying to compute this
particular function's integral (you will see it within the code), I am running
into this error: "setting an array element with a sequ... |
Randomizing Color Python Fractal
Question: I am currently working on a fractal generation, and I've got the fractal built
and functioning to my desired specifications, although I am looking to add
randomize coloring to it. Currently
I have the whole fractal to show as a random color after the program has ran,
but I wo... |
Logging data to CSV with python
Question: I am trying to update a log file form a python script. I have script that
generate 2 variables, inside & outside, and a log file templog.csv
The CSV file is in the format date,time,inside,outside
I need to generate the date and time and then write the whole lot with commas
to... |
creating multiple excel worksheets using data in a pandas dataframe
Question: Just started using pandas and python.
I have a worksheet which I have read into a dataframe and the applied forward
fill (ffill) method to.
I would then like to create a single excel document with two worksheets in it.
One worksheet would ... |
python serial 100% cpu
Question: A year ago I needed a script to capture input from a serial device and send it
to a web browser. (A touch sensor attached to a 3d printed Egyptian tablet in
a Museum.) I had originally intended to use Perl but as that wasn't playing
ball and I only had a few hours before launch I opted ... |
Waiting for xml file writing to finish in python
Question: I have written this script to write data to an xml file. It is writing
correctly, but I want to wait for finish writing in xml file then I will
execute another code. This means another code is depend on xml data write.
So how to wait for finish writing data in... |
C - Signed and Unsigned integer
Question: I'm delving into C because I need to import ctypes library to python to allow
for keyboard control. I'm trying to learn how the following code works:
import ctypes
import time
SendInput = ctypes.windll.user32.SendInput
# C struct redefinitio... |
More problems extracting frames from GIFs
Question: Following my previous question ([Gifs opened with python have broken
frames](http://stackoverflow.com/questions/21990868/gifs-opened-with-python-
have-broken-frames)) I now have code that works sometimes.
For example, this code
from PIL import Image
... |
Drawing ellipses on matplotlib basemap projections-How to extend the basemap class
Question: I am new to python and matplotlib (and stackoverflow). Can you please tell me
how do I extend my basemap class with this ellipse function? The original post
"Drawing ellipses on matplotlib basemap projections" from regeirk is e... |
Python - removing everything from a string except certain characters
Question: Not sure if this question has been asked before, but I couldn't find it, so
here it is:
randomList = ["ACGT","A#$..G","..,/\]AGC]]]T"]
randomList2 = []
for i in randomList:
if i <contains any characters other tha... |
Error using Requests in a frozen app
Question: I am trying to use the excelent requests library in a frozen app. The code
works fine when interpreted, but it stops working when I generate the dist
executable.
I tried this solution, but it is not working ([Requests library: missing file
after cx_freeze](http://stackove... |
The pygame drawing functions leave pixel-wide gaps. Why?
Question: After converting a piece of code (that animates a pattern of rectangles) from
Java to Python, I noticed that the animation that the code produced seemed
quite glitchy. I managed to reproduce the problem with a minimal example as
follows:
... |
python pandas: how to loop over dateframe and add columns
Question: I need a loop to do what this code is doing and automatically generate columns
ep1 ep2 and so on..
df['ep1'] = df.ep1.apply(lambda x: datetime.datetime(x.year,x.month,1))
df['ep2'] = df.ep1.apply(lambda x: datetime.datetime((x+dateti... |
Heroku App crashes immediately with R10 and H10 errors
Question: My app runs fine locally using foreman run, and when I execute my
`runserver.py` file using `python runserver.py`. When I push it to Heroku, it
just crashes. I even made changes to my procfile: `web: python runserver.py
${PORT}` so that Heroku will bind t... |
Scipy expit: Unexpected behavour. NaNs
Question: Noticed some _nan_ 's were appearing unexpectedly, in my data. (and expanding
out and _naning_ everything they touched) Did some careful investigation and
produced a minimal working example:
>>> import numpy
>>> from scipy.special import expit
>>> ... |
Running python files from command prompt
Question: I have written a python program in eclipse that imports the mechanize module.
It works perfectly there. When I run the .py file from the command prompt, it
shows this error: "No module named mechanize". How do I rectify this?
Answer: Make sure that Eclipse and prompt... |
Django: Cron job is not executing python script
Question: I am using csvimporter to import some a csv file into a Django model. I have 2
scripts - one python script to take the file:
import subprocess
subprocess.call("python manage.py csvimport --model='csv_reader.csv' /Users/path_to_csv", shell... |
How to process excel file headers using pandas/python
Question: I am trying to read
<https://www.whatdotheyknow.com/request/193811/response/480664/attach/3/GCSE%20IGCSE%20results%20v3.xlsx>
using pandas.
Having saved it my script is
import sys
import pandas as pd
inputfile = sys.argv[1]
xl =... |
How to handle a matplotlib pick Artist event within a dynamically created QMdiAreaSubWindow? (Example Given - Partially Working!)
Question: I am trying to create a Qt4 application using python and matplotlib, but I got
stuck in a behaviour, which is not quite clear to me.
This application has a QMdiArea which holds th... |
Python zipfile library fix
Question: I've got a problem. I've made a simple zip file with password 12345. Now, when
I try to extract the password using brute-force, zipfile chooses wrong
password. It says it found password aaln0, but the extracted file is completly
empty. Is there a way to 'fix' the library? Or is ther... |
OpenCV darken oversaturated webcam image
Question: I have a (fairly cheap) webcam which produces images which are far lighter
than it should be. The camera does have brightness correction - the
adjustments are obvious when moving from light to dark - but it is
consistently far to bright.
I am looking for a way to redu... |
Python, Generating random string of brackets
Question: I am looking to generate random lengths and patterns of square brackets for
example, [] ][ [] ][ [] [[ ]] []
I have so far managed to get my program to generate brackets randomly, but
randomly in terms of how many times it generates them, so currently my program
i... |
What is the canonical way of handling sys arguments in Python?
Question: Let's say I want to make a hashing script:
### some code here
def hashlib_based(path, htype='md5', block_size=2**16):
hash = eval(htype)
with open(path, 'rb') as f:
for block in iter(lambda: f.re... |
Create pdf with tooltips in python
Question: This a python copy of the popular and highly upvoted [Create pdf with tooltips
in R](http://stackoverflow.com/questions/4691780/create-pdf-with-tooltips-
in-r) .
Simple question: Is there a way to plot a graph from python in a pdf file and
include tooltips?
Answer: You ca... |
why networkx.draw() produces nothing?
Question: I'm new to python and I'm using IPython, I'm starting to learn about NetworkX,
but just in the starting point now I'm noticing that networkx.draw() is not
working, here is my code:
import networkx as nx
g = nx.Graph()
g.add_nodes_from([1... |
Creating password using Python passlib
Question: I'm trying to use the following that another user posted as an answer to a
different question:
>>> # import the hash algorithm
>>> from passlib.hash import sha256_crypt
>>> # generate new salt, and hash a password
>>> hash = sha256_crypt.e... |
Python: Pass a function as a variable with one input fixed
Question: Say I have a two dimensional function f(x,y) and another function G(function)
that takes a function as an input. BUT, G only takes one dimensional functions
as input and I'm wanting to pass f to G with the second variable as a fixed
parameter.
Right ... |
URL UTF-8 Decoding Python
Question: I am having some data in URL format and I want to decode it using Python. I
tried the (accepted) answer
[here](https://stackoverflow.com/questions/3563126/url-encoding-decoding-with-
python) but I am still not getting getting the correct decoding. My code is as
follows:
... |
python multiprocessing, do the processes share a common variable?
Question: I have this:
#!/usr/bin/env python
import multiprocessing
class MultiprocessingTest(object):
def __init__(self):
self.cmd = ''
def for_process_A(self):
self.cmd ... |
KeyError when writing NumPy values to GEXF with NetworkX
Question: Hi everyone I 'd like to compute node coordinates and then export graph to
GEXF and process it with Gephi. However when I run the following code
import networkx as nx
import numpy as np
....
area_ratios = [np.sum(new[:,0])/Sto... |
Converting ipython notebook to html with separate images
Question: I have an ipython notebook with a mixture of SVG and PNG graphs. I can export
it to html without any trouble, but it embeds the images as encoded text in
the body of the `.html` file.
I'm calling:
ipython nbconvert --to html mynotebook.i... |
How do I add a method to a class from a third-party Python module without editing the original module
Question: I'm using the `Basemap` object from `basemap` module in the matplotlib toolkit
(`mpl_toolkits.basemap.Basemap`). In `basemap`'s `__init__.py` file (i.e. the
`mpl_toolkits.basemap.__init__` module), a method `... |
How to log errors in python script (process)
Question: I need to log errors in python script which running as process.
My current code:
import ips
import sys
import time
import logging
import os
import string
import json
import multiprocessing
import MySQLdb as mdb
... |
Running tests with coverage using django-jenkins
Question: I've got a couple of Django projects that I work on, and I use Jenkins for
continuous integration purposes. I've had that arrangement up and running for
a while and it works well.
I'd like to be able to generate automated test coverage reports and have
Jenkins... |
Behavior of python method in absence of return statement
Question: I have a question related to change in program behavior the absence of
_return_ statement leads to in a python method.
The _count_ method below prints number of digits in a given integer. With the
below chunk of code I get the result as 4, which is the... |
Python subprocess communicate kills my process
Question: Why does communicate kill my process? I want an interactive process but
communicate does something so that I cannot take raw_input any more in my
process.
from sys import stdin
from threading import Thread
from time import sleep
i... |
Reference an arbitrary row and field in another table
Question: Is there any form (data type, inherence..) of implement in postgresql
something like this:
CREATE TABLE log (
datareferenced table_row_column_reference,
logged boolean
);
The referenced data may be any row field fro... |
pyparsing: grammar for list of Dictionaries (erlang)
Question: I'm trying to build a grammar to parse an Erlang tagged tuple list, and map
this to a Dict in pyparsing. I'm having problems when I have a list of Dicts.
The grammar works if the Dict has just one element, but when I add a second
can't work out now to get i... |
A simple Hello World setuptools package and installing it with pip
Question: I'm having trouble figuring out how to install my package using setuptools,
and I've tried reading the documentation on it and SO posts, but I can't get
it to work properly. I'm trying to get a simple helloworld application to
work. This is ho... |
How to use a map with *args to unpack a tuple in a python function call
Question: I am currently doing a merge over a set of variables that I'd like to
parallelize. My code looks something like this:
mergelist = [
('leftfile1', 'rightfile1', 'leftvarname1', 'outputname1'),
('leftfile1', 'righ... |
Open File Dialog freezes after tkinter askopenfilename method is called
Question: I'm trying to simply get a file name from the user by
`tkinter.filedialog.askopenfilename()`. The function returns fine and the code
below displays the file name okay but the dialog window doesn't close
immediately after hitting 'open' or... |
Convert Python's internal str to print equivalent
Question: Currently I have:
>> class_name = 'AEROSPC\xc2\xa01A'
>> print(class)
>> AEROSPC 1A
>> 'AEROSPC 1A' == class_name
>> False
How can I convert `class_name` into 'AEROSPC 1A'? Thanks!
Answer: ## Convert to Unicode
You ... |
Vector to string, save in file and again to vector? Python
Question: this is my first question, sorry for my english.
I have already search, but hmm, i didn't know how to search and i try
different ways and keywords, but nothing.
The problem is this:
I'm doing some scripts in blender with python and i want to use co... |
Python: Create File Directories based on Dictionary Key names
Question: I wonder if there is a way to turn a dictionary into a directory structure.
For a example a dictionary with following keys:
dict['dir1']['subdir1']['subsubdir']['folder1']
['subdir2']['subsubdir']['folder1']['folder2'... |
Python mockito - Mocking a class which is being instantiated from the testable function
Question: I am bit lost while writing the test case for
**UserCompanyRateLimitValidation** class. I am finding difficulty in mocking
the class which is being instantiated from inside this class.
class UserCompanyRateL... |
Managing dictionary memory size in python
Question: I have a program which imports a text file through standard input and
aggregates the lines into a dictionary. However the input file is very large
(1Tb order) and I wont have enough space to store the whole dictionary in
memory (running on 64Gb ram machine). Currently... |
How to decrypt 3DES in ECB mode (using a wordlist)?
Question: I have some encrypted texts (encrypted with 3DES in ECB mode without salt).
**My question: How can I decrypt them using a wordlist? (or without one?)**
Example:
Encrypted text:
Xfi+h4Ir6l7zXCP+N4EPvQ==
The wordlist for this:
... |
Python: How to sort a list of lists by the most common first element?
Question: How do you sort a list of lists by the count of the first element? For
example, if I had the following list below, I'd want the list to be sorted so
that all the 'University of Georgia' entries come first, then the 'University
of Michigan' ... |
python Eclipse - how to break/pause on warning?
Question: I found this which allows to break on exception.
[Break on exception in pydev](http://stackoverflow.com/questions/455552/break-
on-exception-in-pydev/6655894#6655894)
However, what I'd like is to break on a warning. This is the warning I get and
would like if ... |
Python client certificate authentication over https is failing
Question: I'm attempting to get https client authentication working using [this sample
code](http://stackoverflow.com/a/4464435/789671) in Python 2.7. Unfortunately,
the client script doesn't appear to be authenticating correctly and I've not
been able to t... |
Pymongo BSON Binary save and retrieve?
Question: I'm working in Python with MongoDB trying to save an array of floats tightly.
I can **Create and store correctly ***
but **I CANNOT RETRIEVE THE DATA IN A USABLE FORMAT.**
>>> import random, array, pymongo
>>> from bson.binary import Binary as BsonBi... |
One producer thread and multiple non-blocking simultaneous consumer threads (MROW) python
Question: I have one producer thread reading some data and processing them and other
threads reading that that, I was using a condition variable in the producer in
order to avoid busy wait and notify when the new adquisition of da... |
Minimum, mean and maximum distance between points 3-D in Python
Question: I have a list of x,y,z points. Using the formula to find the distance between
two points in 3-D
import math
import numpy as np
point0 = x0, y0, z0
point1 = x1, y1, z1
dist = math.sqrt((x0-x1)**2+(y0-y1)**2... |
Python: Testing Serial Ports for Answer
Question: I'm trying to build a short code that will test all Serial COM ports (I'm on
windows) for reply. For example, I have a Arduino connected on COM3, and when
it connects, it sends a serial message.
I want that when I run the python script it automatically detects which is... |
Positional Inverted Index in Python
Question: I recently developed a Python program that makes an inverted index out of
terms in a certain document. I now want to create position postings, such as
to, 993427:
⟨ 1, 6: ⟨7, 18, 33, 72, 86, 231⟩;
2, 5: ⟨1, 17, 74, 222, 255⟩; 4, 5: ⟨8, 16, 190, 4... |
Python Classify commands
Question: I am writing a python script to classify ip countries as they are in another
file .. for example .. I have 2 files in the script dir
IPCountries.txt contains :-
192.168.1.1 | US,
188.100.0.0 | AU,
and the file arrange.txt contains :-
... |
Speeding up Fourier-related transform computations in python (OpenCV)
Question: I have an image and I need to compute a fourier-related transform over it
called Short Time Fourier Transform (for extra mathematical info
check:<http://en.wikipedia.org/wiki/Short-time_Fourier_transform>).
In order to do that I need to :
... |
How to code a Python function that accepts float, list or numpy.array?
Question: I have the following simple Python function:
def get_lerp_factor( a, x, b ):
if x <= a: return 0.
if x >= b: return 1.
return (x - a) / (b - a)
Many numpy functions, like numpy.sin(x) can handle... |
Invoking destroy() method on window after mainloop in tkinter
Question: I'm relatively new to Python and Tkinter and I am striving to get my head over
how mainloop and the after method work. More specifically, I want to create a
splashScreen, which goes away after a timeframe, and then the actual
mainWindow is shown.
... |
Find and copy a line using regex in Python
Question: I am new to this forum and to programming and apologize in advance if I
violate any of the forum rules. I have researched this extensively, but I
couldn't find a solution for my problem.
So I have a very long file that has this general structure:
data... |
Installing Anaconda on Ubuntu 13.10 giving an error message
Question: I ran the installer of Anaconda and at the end I got this message:
...
installing: zlib-1.2.7-0 ...
installing: anaconda-1.9.1-np18py27_0 ...
installing: _cache-0.0-x0 ...
Anaconda-1.9.1-Linux-x86_64.sh: line 389: /home... |
Python reportlab put an image in a canvasmaker
Question: I'd like to put an image (a barcode more precisely) in a pdf doc generated by
reportlab. I can put it in a table. That works perfectly with
createBarcodeDrawing().
The point is that I'd like the barcode to change on each page. Thus, I want to
put it in a canvasm... |
How do I programmatically split a multi-page tiff into single pages using Adobe Acrobat and it's exposed COM Objects?
Question: I want to programmatically (using Python) split a multi-page tiff into single
pages using Adobe Acrobat's exposed COM Objects.
I am writing this in order to answer my own question in order to... |
why does this vimscript print more than it should?
Question: Here is the code:
function! test()
python << endpy
import vim
buf = vim.current.buffer
(row1, col1) = buf.mark('<')
(row2, col2) = buf.mark('>')
for i in range(row1, row2+1):
print i
endpy
endfunction
... |
How do I install pyPDF2 module using windows?
Question: As a newbie... I am having difficulties installing pyPDF2 module. I have
downloaded. Where and how do I install (setup.py) so I can use module in
python interpreter?
Answer: To install setup.py files under Windows you can choose this way with the
command line:
... |
java.io.IOException: Broken pipe on increasing number of mappers/reducers, a lot
Question: I am running MapReduce job on a hadoop cluster of 6 nodes with 4 map tasks and
10 reduce tasks configured.
Mapper/Reducer fails a lot on increasing number of map/reduce tasks as below,
 to transform the lenght in seconds for a
delay, someone know how to do it?
Answer: Here is an example of retrieving the resource (mp3 file), and printing the
track length via [mutagen](https://code.google.com/p/mutagen/) libr... |
Python - Sentiment Analysis using Pointwise Mutual Information
Question:
from __future__ import division
import urllib
import json
from math import log
def hits(word1,word2=""):
query = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=%s"
if word2 == "":
... |
Redirection of stdout to console and file with verbosity turned on or off
Question: I have written some code just to practice verbosity in python. Verbosity is
embedded by means of the `ArgumentParser` module. However, I'd also like to
write the `stdout` to file also when verbosity is disabled:
#!/usr/bi... |
Get all class names in a Python package
Question: I need to get the list of all classes in Python package. At first I get all
filenames (it works fine, took it from stackoverflow):
from os import listdir, getcwd
from os.path import isfile, join
mypath = os.getcwd()
onlyfiles = [ f for f in li... |
send email to recipient from .txt in python 3.3
Question: I am trying to send an email with smtp in python 3.3 to a recipient listed in
a text file. The error I receive is:
`session.sendmail(sender, recipient, msg.as_string())`
`smtplib.SMTPRecipientsRefused: {}`
Where is the error in sendmail? Thanks!
Full code be... |
Python connect to IRC function - must be integer
Question: I made a basic IRC bot that would join a certain channel and say a defined
phrase, as part of learning Python. However, are there changes in the latest
version of Python?
import socket
nick = 'TigerBot'
passdwd = '*****'
port = '... |
How to group multiples classes defined in several files in one package or namespace?
Question: I have c# background and learning python and I am confused between packages
and namespace. I want to define number of classes in different .py files and
some how they belong to same nsamespace (c# kind of namespace). How can ... |
How to make web based python interactive shell
Question: How do sites like <https://www.pythonanywhere.com/try-ipython/> work?
They probably do several `exec` commands, or interfacing with ipython.
However, this can be extremely insecure if they didn't do any "preventive
action" (which they did). A mere (and evil) us... |
How to execute git command in a identified path?
Question: I want to execute git command in python program. I have tried os.system("git-
command") As we know, git command can be executed correctly only in the
directories which contains repositories. I have tried to print current path
and this path is not what I hope fo... |
Counting chars in a file | python 3x
Question: I'm wondering, how can I count for example all "s" characters and print their
number in a text file that I'm importing? Tried few times to do it by my own
but I'm still doing something wrong. If someone could give me some tips I
would really appreciate that :)
Answer: Op... |
Twython update_status_with_media error
Question: I have the following code:
photo = open(os.path.join("images", localFileName), 'rb')
tweetThis = "status"
twitter.update_status_with_media(status=tweetThis, media=photo)
Here is the traceback:
twitter.update_status_with_med... |
Import a sequence of .svg files into FontForge as glyphs and output a font file
Question: I want to create a font with a large volume of glyphs. Think Japanese kanji,
in the thousands. So there will definitely be some scripting / batch
processing required. Luckily FontForge supports python scripting! Unluckily I
haven'... |
Read from CSV file and make plot
Question: I have a little problem I hope someone could help me with. I'm not the best at
python.
I have a "CSV" file that I have to manipulate. I have 3 questions I hope you
could help with.
**1: Print the first two lines**
The first I think I done already, I printed the first two li... |
python scrapy how to code the parameter instead of using cmd: use Custom code in Scrapy
Question: I am using scrapy 0.20 with puthon 2.7
i used to do this in cmd
-s JOBDIR=crawls/somespider-1
to handle the dublicated items. **note please, i already did the changes in
setting**
I dont' want to us... |
Python: Naming with Acronyms
Question: In Python code, what is the canonical way of dealing with well-known acronyms
when naming classes, methods and variables?
Consider, for example, a class dealing with RSS feeds. Would that rather be
this:
class RSSClassOne:
def RSSMethod(self):
s... |
How can I autospec mock attributes that are None by default in python 3?
Question: Consider this code:
import unittest
from unittest.mock import patch
class Foo(object):
def __init__(self, bar=None):
self.bar = bar
def methodA(self):
print("In met... |
Python ElementTree: find element by its child's text using XPath
Question: I'm trying to locate an element that has certain text value in one of its
child. For example,
<peers>
<peer>
<offset>1</offset>
<tag>TRUE</tag>
</peer>
<peer>
<offset>2</... |
Python- Share Variable Between Function and It's Decorator
Question: (Python 2.7)Since decorators can not share variables with the function they
are decorating, how can I make/pass `object_list` to the decorating function?
I have a few of functions that will be using `raw_turn_over_mailer()`
decorator and I would like ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.