text stringlengths 226 34.5k |
|---|
Why does this Python Flask router return a 400 error when pinged by a crossdomain AJAX call?
Question: I have the below Python Flask router:
@app.route('/create', methods=['GET', 'POST'])
@crossdomain(origin='*')
def create():
if request.method == 'POST':
print(request.form)
... |
Writing a Python list of lists to a csv file
Question: I have a long list of lists of the following form ---
a = [[1.2,'abc',3],[1.2,'werew',4],........,[1.4,'qew',2]]
i.e. the values in the list are of different types -- float,int, strings.How
do I write it into a csv file so that my output csv fi... |
Python Introspection: Defining dynamic class methods during runtime
Question: I'm trying to create a unit test, that checks that every function in
`mymodule` has its own `TestCase` instance.
To reduce boiler-plate code and manual effort I wanted to use
introspection/reflection to dynamically add `lambda` functions as... |
using cx_freeze on flask app
Question: I am using Flask to develop a python app. At the moment, I want this app to be
run locally. It runs locally fine through python, but when I use cx_freeze to
turn it into an exe for Windows, I can no longer use the
Flask.render_template() method. The moment I try to execute a rende... |
How can module be visible from one import and not visible from another?
Question: So I've got an application that's using `pymysql`, the pure python mysql
client implementation. Before I go into my response, I'd like to stress the
fact that I am not open to using a different mysql driver.
I have a module implementing ... |
NameError: name 'Game' is not defined, but it is
Question: I am learning python using the book _Learn python the hard way_. I am doing
one of the exercises, which contains many if loop's. I met an error which says
`Game` is not defined, but I did define it before. Anyone ideas?
from sys import exit
... |
Parsing html in Python 2.7 with regex - don't really understand that
Question: Sorry for being kinda dumb, but I really need help in Python.
['<a href="needs to be cut out">Foo to BAR</a>', '<a href="this also needs to be cut out">BAR to Foo</a>']
So I have this tuple, and I need to cut out what's ... |
Gdata API Installation
Question: I have no idea what I'm doing. I'm using Python 2.7 on OSX with the Eclipse
PyDev IDE. I've never worked with an API before, but I need to use the google
calendar API with a Python application I'm developing. I downloaded the latest
gdata module from Google and installed it using this l... |
Retrieve Only the last values of a row in SQLITE with python 27
Question: I'm using this code to get all data from a sqlite row, but I would like to
retrieve only the last 30 entries.
import sqlite3
from matplotlib import pyplot
fig = pyplot.figure()
con = sqlite3.connect('growll.db')
... |
Search for words (exact matches) in multiple texts using Python
Question: I want to let the user choose and open multiple texts and perform a search for
exact matches in the texts. I want the encoding to be unicode.
If I search for "cat" I want it to find "cat", "cat,", ".cat" but not
"catalogue".
I don't know how to... |
Python - Returning max number in an array. Errors
Question: I have a Python script that connects to a website via FTP and lists the
current version numbers of programs located on the website. I created an array
to hold the version numbers till the script would pick the largest number out
of the array and tell me what i... |
adding noise to a signal in python
Question: I want to add some random noise to some 100 bin signal that I am simulating in
Python - to make it more realistic.
On a basic level, my first thought was to go bin by bin and just generate a
random number between a certain range and add or subtract this from the
signal.
I ... |
overlay a smaller image on a larger image python OpenCv
Question: Hi I am creating a program that replaces a face in a image with someone else's
face. However, I am stuck on trying to insert the new face into the original,
larger image. I have researched ROI and addWeight(needs the images to be the
same size) but I hav... |
Django output html time is 8 hours ahead of database time
Question: I'm very new to **Django** and I've been learning the framework from the book
_"Practical django Projects"_ (the book teaches us to write a cms). My code
runs fine, but I have time problem with the `get_absolute_url` function below.
It's actually outpu... |
Convert number to Italian and Italian to number in python
Question: I need Python code to convert numbers to and from Italian.
Looking at previous questions I learned that pynum2word does one way (num ->
words) in several languages but alas, not in Italian.
If no such code exist in Python, I wouldn't mind translating... |
Looping and Naming Variables in Python Bar Chart
Question: I'm using matplotlib in Python to create a stacked bar chart showing order
volume over the course of the day by hour, versus a calendar equivalent day
last year.
I've already arranged an array that includes today's and last year's order
volume:
... |
Subprocess: Execute two or more preexec_fn
Question: I was wondering if there is a way of creating a
[subprocess](http://docs.python.org/2/library/subprocess.html) (through
`subprocess.Popen`) that calls secuentially two (or more) `preexec_fn`.
For instance, calling `setegid` and `seteuid` (just for example purposes).... |
Python 3 parsing iTunes library plist file using plistlib
Question: I'm trying to parse a iTunes media library file, which is a plist file using
python & plistlib. I wrote a simple python script:
import plistlib
plist = plistlib.readPlist('tunes.xml')
print(plist['Tracks'])
But when I ... |
Django 1.4 on GAE: sqlite "ImportError: cannot import name utils"
Question: I'm trying to get sqlite3 support working on Django 1.4 on Google App Engine
1.7.4 on Python 2.7.
I fiddled around with the "Google Cloud SQL" database backend, all worked well
(syncdb, insert/update/delete, ...).
But then I enabled sqlite (a... |
Import error in pyzmq after updating libzmq
Question: I have an error when I attempt to update my ZeroMQ to the new version 3.2.
This is the ouput that I have:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/zmq/__init__.py",... |
Days of the week Django
Question: please, explain me, how do this thing: I have a week number (52, for example)
and year (2012). So, how I can get the days number (monday - 24, tuesday - 25,
etc). Yes, I read [this](http://docs.python.org/2/library/datetime.html), but
I cant understand, how to do it.
Thanks.
Answer:... |
How do you invoke a function on a bunch of lines selected via Ctrl-v?
Question: I am selecting some text via Ctrl-v (visual mode). Then I type \s to align
those lines and sort them like so:
"Strip trailing space
:map <Leader>S :1,$ s/\s\+$//g<CR>
:imap <Leader>S :1,$ s/\s\+$//g<CR>
How do ... |
Trouble with Apache, mod_wsgi, and Django configuration
Question: Just set up a 64 bit ubuntu EC2 instance using the Bitnami DjangoStack image.
So far I have installed a few python dependencies and removed the Project
django app which was created by default. I created a new app with 'django-
admin.py startproject proj... |
Error running Pyserial
Question: I just installed Pyserial 2.6 and I have Python 2.7.3 unfortunately it either
did not install correctly or I am not using it correctly. I installed it
through terminal using the line
sudo easy_install pyserial
Unfortunately it gave me 2 warnings:
warn... |
installing pybrain
Question: I am trying to install pybrain using :
git clone git://github.com/pybrain/pybrain.git
I installed git and then used windows command prompt to execute the above
command. Everything goes well but when I open my python IDE, I cant import
pybrain. The module doesn't exist. ... |
Pygame: Converting all white pixels to fully transparent in png image
Question: I have been trying to create an image processing program to take all the white
pixels (255,255,255) in a loaded image and set their alpha channels to 0 (non-
opaque), and then save the image.
I've been using Python's pygame extension to he... |
python: I want to find the first record in google place result but getting first character
Question: I'm using google place API to return a list of locations. I would like to find
the first name from the result set. I'm getting a list of values, but when I
try to get just the first name, it gives me the first character... |
what "self" is doing in the selenium python code?
Question: > **Possible Duplicate:**
> [Python ‘self’
> explained](http://stackoverflow.com/questions/2709821/python-self-explained)
I just wrote a code as below with the help of `selenium` documentation, but
confused with one what `self` does some methods `argument ... |
Viewing html text between tags (python, lxml, urllib, xpath)
Question: I am trying to parse some html and I want to retrieve the actual html between
the tags, but instead my code is giving me what I believe is the location of
the elements.
Here is my code so far:
import urllib.request, http.cookiejar
... |
How do I use python's choice just once?
Question: Consider the following:
I'm making a secret santa script for my family for next year using python, and
although I have figured out how to draw names (see code below), I need to
execute it just once. I'm planning to use the flask framework to create a page
counts down t... |
Python Spacing Between Print Calls
Question: I would like to make the spacing between print statements the same. I thought
that the spacing would be the same but between the third and fourth lines of
text there is a larger gap.
Here is my code
import random
import time
def UserI... |
threading python bind several ports
Question: I want to do a simple thing: just bind two ports to wait for incoming
connections and continous with the application code. This is the code.
import socket
import threading
import Queue
q = Queue.Queue()
q2 = Queue.Queue()
def esc... |
list inteprolation removing arbitary values - np.interp
Question: I am new to python coding:
I have a list of temperatures, for days where temperature was not recorded the
value 9999 is used. I want to use np.interp tp interpolate through the list to
remove 9999, with an estimated value. E.g.
max_temp = [40, 35, 32, ... |
Python SSL Socket Client Authentification
Question: I'm trying to set up a server and client in python where the server
authenticates clients using SSL with certificates. There are a lot of examples
of SSL certificates online, but everything I've found has the server providing
a certificate to the client and the client... |
Equivalent to: import *
Question: I am creating a Perl equivalent to my Python project.
Description: I have a base module "base.py" that is used by all my scripts via
"from base import *" The base module has common subroutines/functions that can
be executed inside the scripts
My attempt for Perl was placing inside ea... |
Python, subprocess, call(), check_call and returncode to find if a command exists
Question: I've figured out how to use call() to get my python script to run a command:
import subprocess
mycommandline = ['lumberjack', '-sleep all night', '-work all day']
subprocess.call(mycommandline)
... |
Could not import settings in zc.buildout
Question: I just setup my project and I'm having a problem getting Django to work.
Here's my `buildout.cfg`:
[buildout]
parts = python django
develop = .
eggs = myproject
[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ... |
How to download images from a list of scraped URLs?
Question: > **Possible Duplicate:**
> [How to download image using
> requests](http://stackoverflow.com/questions/13137817/how-to-download-image-
> using-requests)
I have this Python script for scraping image URLs of a tumblr blog, and would
like to download them ... |
Set a cookie and retrieve it with Python and WSGI
Question: a lot of questions exists that are similar to this, but none of them helped me
out. Basically I'm using WSGI start_response() method
[link](http://www.python.org/dev/peps/pep-0333/#the-start-response-callable).
I tried to set a dummy header in the response wit... |
Issue while importing nltk package in Python
Question: When I type
import nltk
in the Python interpreter, it gives me this --
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nltk/__ini... |
Processing data after returning content - GAE Python
Question: I want to collect some statistical data which needs some time to process, but
it is not going affect user content which is returning. I am currently doing
it by first caching, then processing it with a cron job.
Is there any way to do this job immediately ... |
Convert a string to a whitespace separated list w/quoted elements
Question: Is there a simple way in Python to convert a string to a list using
whitespaces as separators, but ignoring the whitespace within quoted text? IE:
each word is treated as a separate search term, but any quoted text is treated
as one term.
Ans... |
Ensure two Pandas DatetimeIndexes are the same?
Question: I have run into an issue when comparing two `DatetimeIndex`'s with different
lengths in an `assert` like the following:
In [1]: idx1 = pd.date_range('2010-01-01','2010-12-31',freq='D')
In [2]: idx2 = pd.date_range('2010-01-01','2010-11-01... |
Pygame installation for Python 3.3
Question: I am trying to import [Pygame](https://en.wikipedia.org/wiki/Pygame) to use
for my version of
[Python](http://en.wikipedia.org/wiki/Python_%28programming_language%29), 3.3.
The downloads on the Pygame website only have Python 3.1 and 3.2. I cannot
seem to be able to import P... |
Boost::python wrapper for derived class method
Question: I have C++ class and its wrapper for boost::python:
class CApp
{
public:
virtual bool FOOs (){}; //does not matter for now
bool Run( const char * First,const char * Last)
{
...
return "Running..."
... |
gui locked when calling QWebView.print_()
Question: I'm working with **Python 2.7** and **PySide** , and i need to export a big
html-file to a pdf-file.
I have tried loading it with a `QWebView` and then printing it to a `QPrinter`
configured for pdf-format. this works fine.
However, there is one big problem with my ... |
Python list comprehension expensive
Question: Im trying to find the effeciency of list comprehension but it look like its
more expensive than a normal function operation. Can someone explain?
def squares(values):
lst = []
for x in range(values):
lst.append(x*x)
return ... |
Two Columns of a pandas dataframe - Concat in Python
Question: New to pandas python.
I have a dataframe (df) with two columns of cusips. I want to turn those
columns into a list of the unique entries of the two columns.
My first attempt was to do the following:
cusips = pd.concat(df['long'], df['short']).
This retu... |
What do I import: file_name or class in Python?
Question: I have a file named **schedule.py** :
class SchedGen:
""" Class creates a pseudo random Schedule.
With 3/4 of total credit point required for graduation"""
def __init__(self, nof_courses=40):
random.seed()
... |
Protocol error between Android and Python using SSL
Question: This question has been asked, in various flavors, several times.
Unfortunately, none of the answers have yielded a solution for me.
I am attempting to connect to a python web server (code to follow) using the
https protocol, with client side authentication ... |
Killing child process when parent crashes in python
Question: I am trying to write a python program to test a server written in C. The
python program launches the compiled server using the `subprocess` module:
pid = subprocess.Popen(args.server_file_path).pid
This works fine, however if the python ... |
Creating a hook to a frequently accessed object
Question: I have an application which relies heavily on a `Context` instance that serves
as the access point to the context in which a given calculation is performed.
If I want to provide access to the `Context` instance, I can:
1. rely on `global`
2. pass the `Cont... |
installing libjpeg for pil and Google app engine on mac Mountain Lion
Question: I'm sure there's a duplicate of this somewhere out there but I looked and am
about at the end of my rope. I'm trying get PIL working on my mac OS X 10.8 so
that I can use `dev_appserver.py` to test an imaging feature. First I had
trouble in... |
Issue with finding parent of a particular tag in html using python
Question: I am trying to fetch parent element of a particular tag using below mentioned
code:
# -*- coding: cp1252 -*-
import csv
import urllib2
import sys
import time
from bs4 import BeautifulSoup
from itertools i... |
How to store OAuth token for Github in a Python script?
Question: I am working on a Python script that access Github using basic authentication.
I want to use OAuth so that user doesn't have to enter credentials every time
he uses the script. Most importantly, user's password does not get saved in
the `.bash_history`.
... |
Celery - Programmatically list workers
Question: How can I programmatically, using Python code, list current workers and their
corresponding `celery.worker.consumer.Consumer` instances?
Answer: You can use
[celery.control.inspect](http://docs.celeryproject.org/en/master/userguide/workers.html#inspecting-
workers) to ... |
Compare list of datetimes with datetime in Python
Question: I have a list of datetime objects and would like to find the ones which are
within a certain time frame:
import datetime
dates = [ datetime.datetime(2007, 1, 2, 0, 1),
datetime.datetime(2007, 1, 3, 0, 2),
dat... |
Passing parameters to a webapp2.RequestHandler object in python
Question: Is there any way to pass parameters to a RequestHandler object when I create
my WSGIApplication instance?
I mean
app = webapp2.WSGIApplication([
('/', MainHandler),
('/route1', Handler1),
('/route2', Handle... |
Python - Convert negative decimals from string to float
Question: I need to read in a large number of .txt files, each of which contains a
decimal (some are positive, some are negative), and append these into 2 arrays
(genotypes and phenotypes). Subsequently, I wish to perform some mathematical
operations on these arra... |
why does python require __init__.py to treat directories as containing packages?
Question: While going through 6.4 Packages section of [python
manual](http://docs.python.org/2/tutorial/modules.html) I came across the
following line:
> The `__init__.py` files are required to make Python treat the directories as
> conta... |
IncompleteRead using httplib
Question: I have been having a persistent problem getting an rss feed from a particular
website. I wound up writing a rather ugly procedure to perform this function,
but I am curious why this happens and whether any higher level interfaces
handle this problem properly. This problem isn't re... |
Twitter API Python Character Encoding
Question: I am experimenting with the Twitter API for Python and have run into a
character encoding/decoding issue; when I am collecting tweets for a user
(@BBCWorld in this instance), if there is _special_ punctuation I receive the
following error:
28695204481479475... |
Importing Python Librarys over C#?
Question: So I'm new to Python and I work with IronPython in Visual Studio.
So in my C# Project I call the Python Script for executing some tasks. Now I
work in a bigger company and so a lot of File Paths etc. are different. And
I'm wondering if it's possible to pass the Python file ... |
When is __lldb_init_module called?
Question: I'm following WWDC session 412 - Debugging in Xcode. There is a demo there
about creating custom LLDB summaries for your own classes.
I simply can't get the summaries to show up.
By inserting print calls in the Python script I have been able to determine
that:
1. The sc... |
Python: compare list items to dictionary keys twice in one for loop?
Question: ## I'm stuck in a script I have to write and can't find a way out...
I have two files with partly overlapping information. Based on the information
in one file I have to extract info from the other and save it into multiple
new files. The f... |
Converting nested JSON content dump to XLS
Question: I have a JSON dump from a content management site which follows the format:
[
{
id: "obj1",
children: [...]
},
{
id: "obj2",
children: [...]
}
]
There a... |
Memory leak in tornado generator engine with try/finally block when connections are closed
Question: This awesome code, shows memory leak in tornado's `gen` module, when
connections are closed without reading the response:
import gc
from tornado import web, ioloop, gen
class MainHandler(web.... |
socket programming in python doubts
Question: i am having trouble and a lot of questions about socket programming attached
code below ( all parts have been taken from the and written together) i am
trying to send mouse data to the client ,howver getting the error:
Traceback (most recent call last):
... |
How to use multiprocessing with class instances in Python?
Question: I am trying to create a class than can run a separate process to go do some
work that takes a long time, launch a bunch of these from a main module and
then wait for them all to finish. I want to launch the processes once and then
keep feeding them th... |
convert date to number python
Question: > **Possible Duplicate:**
> [Fetching datetime from float and vice versa in
> python](http://stackoverflow.com/questions/6706231/fetching-datetime-from-
> float-and-vice-versa-in-python)
Like many people I switched from `Matlab` to `Python`. `Matlab` represents
each date as a... |
How do I check gnome-shell notifications with Python?
Question: I'm having quite some trouble doing that :
I'm using Conky on my Archlinux distro and coded a quick script in python to
check if I have a new mail in my gmail. In my conkyrc this script executes
every 5 minutes and returns a number of mails (0 if I don't... |
Reading Chinese characters in a file and sending them to a browser
Question: I'm trying to make a program that:
* reads a list of Chinese characters from a file, makes a dictionary from them (associating a sign with its meaning).
* picks a random character and sends it to the browser using the `BaseHTTPServer` mod... |
Is it possible to push data from Excel sheet using Python into a database?
Question: I have a requirement where using Python I need to write into excel cell , the
data which i will be collecting from web page.
But not getting an option how to do that.
any idea from you people?
_**As per @Marcin comments here is the ... |
Importing class from another file in python - I know the fix, but why doesn't the original work?
Question: I can make this code work, but I am still confused why it won't work the first
way I tried.
I am practicing python because my thesis is going to be coded in it (doing
some cool things with Arduino and PC interfac... |
Python regex: Multiple matches in one line (using findall())
Question: I'm looking for these "tags" inside text: `{t d="var1"}var2{/t}` or `{t
d="varA"}varB{/t}` There can be more attributes, only "d" is mandatory: `{t
d="var1" foo="bar"}var2{/t}`
My problem is - if there are more tags on one line, just one result is
... |
python can not find attribute Thread
Question: my python code like this:
#!/usr/bin/env python
import threading
from time import sleep,ctime
loops=[4,2]
def loop(nloop,nsec):
print 'start loop',nloop,'at:',ctime()
sleep(nsec)
print 'loop',nloop,'done at:',ctim... |
Install TortoiseHg for mac : No module named mercurial
Question: I'm trying to install TortoiseHg for Mac following these instructions :
<https://bitbucket.org/tortoisehg/thg/wiki/developers/MacOSX#!alternative-
install-via-macports>
I'm trying to follow the instructions about the "Alternative: Install via
Homebrew" a... |
Python how do I overlay random images over images being generated to end up with 2 images with text
Question: Here is my code that I have so far. What it does is grabs a random text line
from the text file an generates a random color then creates the JPG image with
the text on top. What I want to do is take a random pi... |
Google App Engine aborts on missing environment variable DJANGO_SETTINGS_MODULE
Question: This is a follow-up question for [Google App Engine and Django
support](http://stackoverflow.com/questions/14137404/google-app-engine-and-
django-support):
The tutorial works great for an empty project, however when I try to depl... |
python topN max heap, use heapq or self implement?
Question: there's heapq in python, for general usage. i want recording topN(0~20) for
10e7 records.
if use heapq, should use '-' to translate max to min; and recording a min
number of bottom, to call heapq.heappushpop()
should i use heapq or self implement a heap(may... |
Python QueryFrame returns None, but C++ bindings work
Question: In OpenCV 2.3.1 (built from source) on Ubuntu 10.04, the C++ fragment
cvNamedWindow("Camera", 1);
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
while (1) {
IplImage* frame = cvQueryFrame(capture);
cvShowImage("Camera... |
Outlining a Solution Stack
Question: please excuse my ignorance as I'm an Aerospace Engineer going headfirst into
the software world.
I'm building a web solution that allows small computers (think beagleboard) to
connect to a server that sends and receives data to these clients. The
connection will be over many types ... |
python:Import module from memory
Question: > **Possible Duplicate:**
> [How to load compiled python modules from
> memory?](http://stackoverflow.com/questions/1830727/how-to-load-compiled-
> python-modules-from-memory)
I have some python file in the memory that may be StringIO.I how to import
module file stored in ... |
python Channel API expiry and usage in google app engine
Question: I want to use the channel api to push updates to open pages, What I have done
so far is to store the page client ids in ndb - I have included a code summary
My question is: How do I manage closed pages and expired tokens?
and is this the best way to p... |
How to handle download pop up window using Python and get the file saved?
Question: I have a link, which contains downloadble file,now when i am putting that link
onto the browser, and hit `ENTER` a popup window is coming to download. Now
using Python can we save that file in local machine?
say downloadable link :
... |
exit on KeyboardInterrupt after generating plots in while loop
Question: I am monitoring an experiment in real time using matplotlib to generate plots
in a while loop. Ideally, the loop should exit on something like a
`KeyboardInterrupt`. This works well enough in an Ubuntu test. In Windows 7,
using `ipython`, it exits... |
Impossible to initialize Elixir
Question: I'm starting with Elixir and SQL Alchemy. I've created a python file
connecting with a Mysql database to but as soon as I execute with python I get
the error bellow:
root@raspberrypi:/Python/mainFlask/yonkiPOPS# python yonki.py
Traceback (most recent call las... |
Python BeautifulSoup get text from HTML
Question: I have some HTML code like this:
<p>aaa</p>bbb
<p>ccc</p>ddd
How can I get 'bbb' and 'ddd'?
Answer: You can read the subsequent sibling of each `p` tag (note this is very
specific to this text, so hopefully it can be expanded to your situation... |
Deep version of sys.getsizeof
Question: I want to calculate the memory used by an object. `sys.getsizeof` is great,
but is shallow (for example, called on a list, it would not include the memory
taken by the list's elements).
I'd like to write a generic "deep" version of `sys.getsizeof`. I understand
there is some amb... |
Simply a try/except with lambda - Python?
Question: Is there a way to simplify this try/except into a one line with lambda?
alist = ['foo','bar','duh']
for j,i in enumerate(alist):
try:
iplus1 = i+alist[j+1]
except IndexError:
iplus1 = ""
Is there other way othe... |
Minimal HTTP server with Werkzeug - Internal Server Error
Question: To demonstrate basics HTTP handling, I'm in the process of trying to define a
really minimal HTTP server demonstration. I have been using the excellent
[werkzeug](http://werkzeug.pocoo.org/) library that I'm trying to "dumb" down
a bit more. My current... |
Automatically cropping an image with python/PIL
Question: Can anyone help me figure out what's happening in my image auto-cropping
script? I have a png image with a large transparent area/space. I would like
to be able to automatically crop that space out and leave the essentials.
Original image has a squared canvas, o... |
Prevent OS X from going to sleep with Python?
Question: Is there a way to prevent a computer running OS X from going to sleep from
within a Python script?
Answer: You can call the **caffeinate** command.
subprocess.Popen('caffeinate')
This is how I use it:
import sys
import sub... |
Force importing module from current directory
Question: I have package `p` that has modules `a` and `b`. `a` relies on `b`:
`b.py` contents:
import a
However I want to _ensure_ that `b` imports my `a` module from the same `p`
package directory and not just any `a` module from `PYTHONPATH`.
So I'm... |
python network file writing in a robust manner
Question: I am looking for a robust way to write out to a network drive. I am stuck with
WinXP writing to a share on a Win2003 server. I want to pause writing if the
network share goes down... then reconnect and continue writing once the
network resource is available. With... |
Why is 'import simplejson' failing in Python 2.7.3 code, but not in the interpreter?
Question: There are two instances running uwgsi and nginx servers. Each hosts a Flask
application. Both are running on a Python 2.7.3 path. One of the servers
throws an ImportError for the "import simplejson" statement. The interpreter... |
can python be useful to open multiple tabs in a browser in one shot?
Question: I am looking for a faster way to do my task. i have 40000 file downloadable
urls. I would like to download them in local desktop is.now the thought is
currently what I am doing is placing the link on the browser and then download
them via a ... |
Expose a C++ global variable in Python
Question: I'm trying to access to a C++ global variable in my Python code, using Cython.
Let's say I have the following array in my C++ code:
// Project.cpp
int myArr[2] = { 0, 1 };
So, in Cython to define a pointer to _myArr_ :
cdef extern... |
How to pass a parameter list to another function in Python?
Question: Using `optparse`, I want to separate the list of option list parameters from
the place where I call add_option(). How do I package the stuff up in File A
(and then unpack in file B) so that this will work? The
parser_options.append() lines will not w... |
Python @property in Flask configs?
Question: I'm currently learning Flask and I just set up a config file I load into the
app with:
app.config.from_object('myconfigmodule')
The config module has two classes in it, Config and DebugConfig and
DebugConfig inherits Config. I'd like to use @property get... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.