text stringlengths 226 34.5k |
|---|
How to remove two chars from the beginning of a line
Question: I'm a complete Python noob. How can I remove two characters from the beginning
of each line in a file? I was trying something like this:
#!/Python26/
import re
f = open('M:/file.txt')
lines=f.readlines()
i=0;
... |
exec() bytecode with arbitrary locals?
Question: Suppose I want to execute code, for example
value += 5
inside a namespace of my own (so the result is essentially `mydict['value'] +=
5`). There's a function `exec()`, but I have to pass a string there:
exec('value += 5', mydic... |
wxPython: Items in BoxSizer don't expand horizontally, only vertically
Question: I have several buttons in various sizers and they expand in the way that I
want them to. However, when I add the parent to a new wx.BoxSizer that is used
to add a border around all the elements in the frame, the sizer that has been
added f... |
models.py with ManyToMany and progmatically adding data via a shell script
Question: First post to stackoverflow I did do a search and came up dry. I also own the
django book (Forcier,Bissex,Chun) and they don't explain how to do this. In
short I can't figure out how to progmatically add a data via a python shell
scrip... |
Can't get Beaker sessions to work (KeyError)
Question: I'm a newb to the Python world and am having the dangest time with getting
sessions to work in my web frameworks. I've tried getting Beaker sessions to
work with the webpy framework and the Juno framework. And in both frameworks I
always get a KeyError when I try t... |
How useful would be a Smalltalk source code browser for other programming languages?
Question: I'm working on an IDE for python, ruby and php.
Never having used Smallltalk myself (even it was very popular when I was at
university) I wonder if the classic Smalltalk Browser which displays only one
method is really an im... |
Python re question - sub challenge
Question: I want to add a href links to all words prefixed with # or ! or @ If this is
the text
Check the #bamboo and contact @Fred re #bamboo #garden
should be converted to:
Check the <a href="/what/bamboo">#bamboo</a> and contact <a href="/who/fred">@Fred</a> re <a ... |
relevent query to how to fetch public key from public key server
Question:
import urllib
response = urllib.urlopen('http://pool.sks-keyservers.net/')
print 'RESPONSE:', response
print 'URL :', response.geturl()
headers = response.info()
print 'DATE :', headers['date']
print... |
Python socket error occured
Question: I wrote this code.
import socket
host = 'localhost'
port = 3794
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.bind((h... |
Calculating a SHA hash with a string + secret key in python
Question: Amazon Product API now requires a signature with every request which I'm
trying to generate ushing Python.
The step I get hung up on is this one:
"Calculate an RFC 2104-compliant HMAC with the SHA256 hash algorithm using the
string above with our "... |
Is this a bug in Django formset validation?
Question: Manual example:
<http://docs.djangoproject.com/en/1.0/topics/forms/formsets/#formset-
validation> (I'm using Django 1.0.3 to run on Google App Engine)
Code:
from django import forms
from django.forms.formsets import formset_factory
class... |
Does a UDP service have to respond from the connected IP address?
Question: [Pyzor](http://pyzor.org) uses UDP/IP as the communication protocol. We
recently switched the public server to a new machine, and started getting
reports of many timeouts. I discovered that I could fix the problem if I
changed the IP that was q... |
What is the oldest time that can be represented in python?
Question: I have written a function comp(time1, time2) which will return true when time1
is lesser than time2. I have a scenario where time1 should always be lesser
than time2. I need time1 to have the least possible value(date). How to find
this time and how t... |
Python: what kind of literal delimiter is "better" to use?
Question: What is the best literal delimiter in Python and why? Single ' or double "?
And most important, why?
I'm a beginner in Python and I'm trying to stick with just one. I know that in
PHP, for example " is preferred, because PHP does not try to search fo... |
gotchas where Numpy differs from straight python?
Question: Folks,
is there a collection of gotchas where Numpy differs from python, points that
have puzzled and cost time ?
> "The horror of that moment I shall never never forget !"
> "You will, though," the Queen said, "if you don't make a memorandum of it."
For... |
Python/Suds: Type not found: 'xs:complexType'
Question: I have the following simple python test script that uses
[Suds](https://fedorahosted.org/suds/) to call a SOAP web service (the service
is written in ASP.net):
from suds.client import Client
url = 'http://someURL.asmx?WSDL'
client ... |
Why does weakproxy not always preserve equivalence in python?
Question: MySQLDb uses weak proxy to prevent circular dependencies between cursors and
connections.
But you would expect from the documentation on weakref that you could still
tests for equivalence. Yet:
In [36]: interactive.cursor.connection... |
Running doctests through iPython and pseudo-consoles
Question: I've got a fairly basic doctestable file:
class Foo():
"""
>>> 3+2
5
"""
if __name__ in ("__main__", "__console__"):
import doctest
doctest.testmod(verbose=True)
which works as ex... |
python variable scope
Question: I have started to learn about python and is currently reading through a script
written by someone else. I noticed that globals are scattered throughout the
script (and I don't like it).. Besides that, I also noticed that when I have
code like this
def some_function():
... |
Share Python Interpreter in Apache Prefork / WSGI
Question: I am attempting to run a Python application within Apache (prefork) with WSGI
in such a way that a single Python interpreter will be used. This is necessary
since the application uses thread synchronization to prevent race conditions
from occurring. Since Apac... |
Using Regexp to replace math expression inside Latex File
Question: I am trying to replace characters inside a math environment with their
boldface versions. Unfortunately, these characters occur inside the rest of
the text, as well.
My text:
text text text text Gtext G G text ....
\begin{align}
... |
Multiprocessing debug techniques
Question: I'm having trouble debugging a multi-process application (specifically using a
process pool in python's multiprocessing module). I have an apparent deadlock
and I do not know what is causing it. The stack trace is not sufficient to
describe the issue, as it only displays code ... |
How does this Python code work?
Question: I don't know if it is feasable to paste all of the code here but I am looking
at the code in [this git
repo](http://github.com/cloudkick/libcloud/tree/master).
If you look at the example they do:
ec2 = EC2('access key id', 'secret key')
...but there is no ... |
Cubic root of the negative number on python
Question: Can someone help me to find a solution on how to calculate a cubic root of the
negative number using python?
>>> math.pow(-3, float(1)/3)
nan
it does not work. Cubic root of the negative number is negative number. Any
solutions?
Answer: A ... |
How can I impersonate the current user with IronPython?
Question: I am trying to manage an IIS7 installation remotely using the
Microsoft.Web.Administration library.
I'm doing this in IronPython:
import Microsoft.Web.Administration
from Microsoft.Web.Administration import ServerManager
mana... |
Python generating Python
Question: I have a group of objects which I am creating a class for that I want to store
each object as its own text file. I would really like to store it as a Python
class definition which subclasses the main class I am creating. So, I did some
poking around and found a Python Code Generator o... |
How to count possibilities in python lists
Question: Given a list like this:
num = [1, 2, 3, 4, 5]
There are 10 three-element combinations:
[123, 124, 125, 134, 135, 145, 234, 235, 245, 345]
How can I generate this list?
Answer: Use
[itertools.combinations](http://docs.python... |
File open: Is this bad Python style?
Question: To read contents of a file:
data = open(filename, "r").read()
The open file immediately stops being referenced anywhere, so the file object
will eventually close... and it shouldn't affect other programs using it,
since the file is only open for readin... |
How to extract a string between 2 other strings in python?
Question: Like if I have a string like `str1 = "IWantToMasterPython"`
If I want to extract `"Py"` from the above string. I write:
extractedString = foo("Master","thon")
I want to do all this because i am trying to extract lyrics from an ht... |
Code organization in Python: Where is a good place to put obscure methods?
Question: I have a class called `Path` for which there are defined about 10 methods, in
a dedicated module `Path.py`. Recently I had a need to write 5 more methods
for `Path`, however these new methods are quite obscure and technical and 90%
of ... |
Serving file download with python
Question: Hey gang, I'm trying to convert a legacy php script over to python and not
having much luck.
The intent of the script is to serve up a file while concealing it's origin.
Here's what's working in php:
<?php
$filepath = "foo.mp3";
$filesize = filesi... |
PIL: Image resizing : Algorithm similar to firefox's
Question: I'm getting about the same _bad looking_ resizing from all the 4 algorithms of
PIL
>>> data = utils.fetch("http://wavestock.com/images/beta-icon.gif")
>>> image = Image.open(StringIO.StringIO(data)); image.save("/home/ptarjan/www/tmp/meta... |
Python: Automatically initialize instance variables?
Question: I have a python class that looks like this:
class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
followed by:
self.PID=PID
self.PPID=PPID
self.cmd=cmd
... |
Application Structure for GUI & Functions
Question: I'm starting a basic application using Python and PyQt and could use some
experienced insight. Here's the structure I was thinking. This is
understandably subjective, but is there a better way?
myApp/GUI/__init__.py
mainWindow.py
... |
apt like column output - python library
Question: Debian's apt tool outputs results in uniform width columns. For instance, try
running "aptitude search svn" .. and all names appear in the first column of
the same width.
Now if you resize the terminal, the column width is adjusted accordingly.
Is there a Python libra... |
Downloading file using IE from python
Question: I'm trying to download file with Python using IE:
from win32com.client import DispatchWithEvents
class EventHandler(object):
def OnDownloadBegin(self):
pass
ie = DispatchWithEvents("InternetExplorer.Application", EventH... |
Python: copy.deepcopy produces an error
Question: I have been using this copy method for quite a while, in lots of classes that
needed it.
class population (list):
def __init__ (self):
pass
def copy(self):
return copy.deepcopy(self)
It has suddenly started producing thi... |
Python decorate a class to change parent object type
Question: Suppose you have two classes X & Y. You want to decorate those classes by
adding attributes to the class to produce new classes X1 and Y1.
For example:
class X1(X):
new_attribute = 'something'
class Y1(Y):
new_attribute ... |
Showing an image from console in Python
Question: What is the easiest way to show a `.jpg` or `.gif` image from Python console?
I've got a Python console program that is checking a data set which contains
links to images stored locally. How should I write the script so that it would
display images pop-up graphical win... |
To Ruby or not to Ruby
Question: I know that this is a difficult question to answer, but I thought I would try
anwyays....
I am just starting at a new company where they have a minimal existing code
base. It probably has a month of man effort invested at this point. It is
currently written in Ruby.
It is also current... |
How to extract and then refer to variables defined in a python module?
Question: I'm trying to build a simple environment check script for my firm's test
environment. My goal is to be able to ping each of the hosts defined for a
given test environment instance. The hosts are defined in a file like this:
... |
Just installed QtOpenGL but cannot import it (from Python)
Question: I just installed it with apt-get on debian linux with
apt-get install libqt4-opengl
the rest of PyQt4 is available, but I cant get to this new module.
from PyQt4 import QtOpenGL
raises ImportError. any idea wh... |
Accessing a Python variable in a list
Question: I think this is probably something really simple, but I'd appreciate a hint:
I am using a python list to hold some some database insert statements:
list = [ "table_to_insert_to" ],["column1","column2"],[getValue.value1],["value2"]]
The problem is one... |
How to install MySQLdb package? (ImportError: No module named setuptools)
Question: I am trying to install MySQLdb package. I found the source code
[here](https://sourceforge.net/projects/mysql-python/files/).
I did the following:
gunzip MySQL-python-1.2.3c1.tar.gz
tar xvf MySQL-python-1.2.3c1.tar
... |
How to set ignorecase flag for part of regular expression in Python?
Question: Is it possible to implement in Python something like this simple one:
#!/usr/bin/perl
my $a = 'Use HELLO1 code';
if($a =~ /(?i:use)\s+([A-Z0-9]+)\s+(?i:code)/){
print "$1\n";
}
Letters of token in the... |
Python Eval: What's wrong with this code?
Question: I'm trying to write a very simple Python utility for personal use that counts
the number of lines in a text file for which a predicate specified at the
command line is true. Here's the code:
import sys
pred = sys.argv[2]
if sys.argv[1] == "... |
Can Python encode a string to match ASP.NET membership provider's EncodePassword
Question: I'm working on a Python script to create hashed strings from an existing
system similar to that of ASP.NET's MembershipProvider. Using Python, is there
a way to take a hexadecimal string and convert it back to a binary and then d... |
Python serializable objects json
Question:
class gpagelet:
"""
Holds 1) the pagelet xpath, which is a string
2) the list of pagelet shingles, list
"""
def __init__(self, parent):
if not isinstance( parent, gwebpage):
raise Exception("Par... |
How can I protect myself from a zip bomb?
Question: I just read about [zip bombs](http://en.wikipedia.org/wiki/Zip%5Fbomb), i.e.
zip files that contain very large amount of highly compressible data
(00000000000000000...).
When opened they fill the server's disk.
How can I detect a zip file is a zip bomb **before** un... |
How do I get this program to start over in python?
Question: I believe the word is "recurse" instead of 'start over.' I've created this
program to hone my multiplication skills in the morning. I can get it to give
me a multiplication problem, but how do I get it to ask me another one?
from random import ... |
multiline checkbox in wxpython
Question: I'm working with wxpython (2.8) with python 2.5. is it possible to force a
wx.CheckBox to display its label on multiple lines? I'd like to be able to do
the same as wx.StaticText.Wrap(width)
See the attached example: the wx.CheckBox is 200 px wide, but it's label does
not fit i... |
Python CreateFile Cannot Find PhysicalMemory
Question: I am trying to access the Physical Memory of a Windows 2000 system (trying to
do this without a memory dumping tool). My understanding is that I need to do
this using the CreateFile function to create a handle. I have used an older
version of [win32dd](http://www.m... |
Why can't I import the 'math' library when embedding python in c?
Question: I'm using the example in python's 2.6 docs to begin a foray into embedding
some python in C. The [example
C-code](http://docs.python.org/extending/embedding.html#pure-embedding) does
not allow me to execute the following 1 line script:
... |
Eclipse+PyDev+GAE memcache error
Question: I've started using Eclipe+PyDev as an environment for developing my first app
for Google App Engine. Eclipse is configured according to [this
tutorial](http://code.google.com/appengine/articles/eclipse.html).
Everything was working until I start to use memcache. PyDev reports... |
Why is the WindowsError while deleting the temporary file?
Question: 1. I have created a temporary file.
2. Added some data to the file created.
3. Saved it and then trying to delete it.
But I am getting `WindowsError`. I have closed the file after editing it. How
do I check which other process is accessing t... |
Twisted network client with multiprocessing workers?
Question: So, I've got an application that uses Twisted + Stomper as a STOMP client
which farms out work to a multiprocessing.Pool of workers.
This appears to work ok when I just use a python script to fire this up, which
(simplified) looks something like this:
... |
tail -f in python with no time.sleep
Question: I need to emulate "tail -f" in python, but I don't want to use time.sleep in
the reading loop. I want something more elegant like some kind of blocking
read, or select.select with timeout, but python 2.6 "select" documentation
specifically says: "it cannot be used on regul... |
Why I cannot build a chain of methods? (method1.method2.method3)
Question: If I have the following code:
import sqlite
sqlite.connect('tmp.db').cursor().close()
I get the following error message:
Traceback (most recent call last):
File "searchengine2.py", line 13, in ?
... |
`xrange(2**100)` -> OverflowError: long int too large to convert to int
Question: `xrange` function doesn't work for large integers:
>>> N = 10**100
>>> xrange(N)
Traceback (most recent call last):
...
OverflowError: long int too large to convert to int
>>> xrange(N, N+10)
Traceba... |
Python Script to find instances of a set of strings in a set of files
Question: I have a file which I use to centralize all strings used in my application.
Lets call it Strings.txt;
TITLE="Title"
T_AND_C="Accept my terms and conditions please"
START_BUTTON="Start"
BACK_BUTTON="Back"
...
... |
Combining Dictionaries Of Lists In Python
Question: I have a very large collection of (p, q) tuples that I would like to convert
into a dictionary of lists where the first item in each tuple is a key that
indexes a list that contains q.
Example:
Original List: (1, 2), (1, 3), (2, 3)
Resultant Dict... |
Web Service client in Python using ZSI - "Classless struct didn't get dictionary"
Question: I am trying to write a sample client in Python using ZSI for a simple Web
Service. The Web Service WSDL is following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http:/... |
Parsing out data using BeautifulSoup in Python
Question: I am attempting to use BeautifulSoup to parse through a DOM tree and extract
the names of authors. Below is a snippet of HTML to show the structure of the
code I'm going to scrape.
<html>
<body>
<div class="list-authors">
<span class="d... |
How to pick certain elements of x-tuple returned by a function?
Question: I am a newbie to Python. Consider the function `str.partition()` which returns
a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is
the best way to pick only certain elements out of such a tuple?
I can currently do eithe... |
How to use export with Python on Linux
Question: I need to make an export like this in Python :
# export MY_DATA="my_export"
I've tried to do :
# -*- python-mode -*-
# -*- coding: utf-8 -*-
import os
os.system('export MY_DATA="my_export"')
But when I list export, "M... |
how to run both python 2.6 and 3.0 on the same windows XP box?
Question: What kind of setup do people use to run both python 2.6 and python 3.0 on the
same windows machine?
Answer: No problem, each version is installed in its own directory. On my Windows box,
I have `C:\Python26\` and `C:\Python31\`. The _Start Menu_... |
map string position to line number in regex output
Question: I'm working on a "grep-like" utility in Python for searching Oracle source
code files. Coding standards have changed over time, so trying to find
something like "all deletes from table a.foo" could span multiple lines, or
not, depending on the age of that pie... |
How to print a list in Python "nicely"
Question: In PHP, I can do this:
echo '<pre>'
print_r($array);
echo '</pre>'
In Python, I currently just do this:
print the_list
However, this will cause a big jumbo of data. Is there any way to print it
nicely into a readable tree... |
Does anyone know a way to scramble the elements in a list?
Question:
thelist = ['a','b','c','d']
How I can to scramble them in Python?
Answer:
>>> import random
>>> thelist = ['a', 'b', 'c', 'd']
>>> random.shuffle(thelist)
>>> thelist
['d', 'a', 'c', 'b']
Your result will (hopef... |
How do I change my float into a two decimal number with a comma as a decimal point separator in python?
Question: I have a float: 1.2333333
How do I change it into a two decimal number with a comma as a decimal point
separator, eg 1,23?
Answer: The [locale module](http://docs.python.org/library/locale.html) can help... |
How to read lines from a file into a multidimensional array (or an array of lists) in python
Question: I have a file with a format similar to this:
a,3,4,2,1
3,2,1,a,2
I want to read the file and create an array of lists
in a way that:
array[0] = ['a','3','4','2','1']
array[... |
Why Does List Argument in Python Behave Like ByRef?
Question: This may be for most languages in general, but I'm not sure. I'm a beginner at
Python and have always worked on copies of lists in C# and VB. But in Python
whenever I pass a list as an argument and enumerate through using a "for i in
range," and then change ... |
(strongly vs weakly) typed AND (statically vs dynamically) typed languages and Moore's law
Question: I do not know how many faces this problem. If I do programming in
weakly/dynamically typed language like python,php,javascript for few days I
lose touch with strongly typed languages like c++,Java,.net. I recently heard... |
Python 3.1.1 with --enable-shared : will not build any extensions
Question: Summary: Building Python 3.1 on RHEL 5.3 64 bit with `--enable-shared` fails
to compile all extensions. Building "normal" works fine without any problems.
**Please note** that this question may seem to blur the line between
programming and sys... |
Python for C++ or Java Programmer
Question: I have a background in C++ and Java and Objective C programming, but i am
finding it hard to learn python, basically where its "Main Function" or from
where the program start executing. So is there any tutorial/book which can
teach python to people who have background in C++ ... |
Why doesn't memcache work in my Django?
Question:
from django.core.cache import cache
def testcache():
cache.set('test','I am putting this message in',3333)
print cache.get('test')
It just prints "**None** "
This is in "ps aux":
dovr 2241 0.0 0.8 57824 ... |
Python sqlite3 version
Question:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.version
'2.4.1'
Questions:
* Why is the version of the sqlite**3*... |
python: interact with the session in cgi scripts
Question: Can python cgi scripts write and read data to the session? If so how? Is there
a high-level API or must I roll my own classes?
Answer: There's no "_session_ " on `cgi`. You must roll your own session handling code
if you're using raw `cgi`.
Basically, sessio... |
How can I build the Boost.Python example on Ubuntu 9.10?
Question: I am using Ubuntu 9.10 beta, whose repositories contain boost 1.38. I would
like to build the hello-world example. I followed the instructions here
(<http://www.boost.org/doc/libs/1%5F40%5F0/libs/python/doc/tutorial/doc/html/python/hello.html>),
found t... |
In Python, how do I transform a string into a file?
Question: There is a read-only library function that takes a file as an argument. But I
have a string.
How do I convert a string to a file, that if you read the file it will return
this string? I don't want to write to disk.
Answer: The `StringIO` module:
... |
How do I request data securely via Google OAuth?
Question: Until recently users of my site were able to import data from Google, via
OAuth. However, recently they have received the warning below, in a yellow
box, when authorising (although the import still works).
I've also noticed this same warning on Facebook's GMai... |
syntax error on `If` line
Question: My code:
#!/usr/bin/env python
def Runaaall(aaa):
Objects9(1.0, 2.0)
def Objects9(aaa1, aaa2):
If aaa2 != 0: print aaa1 / aaa2
The error I receive:
$ python test2.py
File "test2.py", line 7
If aaa2 != 0:... |
Has anyone found that UIWebView fails for some URLS?
Question: I have been working on an iPhone App for a couple of weeks now and one of the
earlier features I added was a _UIWebView_ that loaded context sensitive
Wikipedia page topics. This was pretty trivial to implement and has been
working fine for some time.
Toda... |
Running Tests From a Module
Question: I am attempting to run some unit tests in python from what I believe is a
module. I have a directory structure like
TestSuite.py
UnitTests
|__init__.py
|TestConvertStringToNumber.py
In testsuite.py I have
import unittest
... |
Apache2 + RewriteMap + Python -- when returning 'NULL', apache hangs
Question: [SOLVED: See solution below.]
I'm having a problem writing a `RewriteMap` program (using Python). I have a
`RewriteMap` directive pointing to a Python script which determines if the
requested URL needs to be redirected elsewhere.
When the ... |
How do I make these relative imports work in Python 3?
Question: I have a directory structure that looks like this:
project/
__init__.py
foo/
__init.py__
first.py
second.py
third.py
plum.py
In `proje... |
edit text file using Python
Question: I need to update a text file whenever my IP address changes, and then run a
few commands from the shell afterwards.
1. Create variable LASTKNOWN = "212.171.135.53" This is the ip address we have while writing this script.
2. Get the current IP address. It will change on a dai... |
Python binary data reading
Question: A urllib2 request receives binary response as below:
00 00 00 01 00 04 41 4D 54 44 00 00 00 00 02 41
97 33 33 41 99 5C 29 41 90 3D 71 41 91 D7 0A 47
0F C6 14 00 00 01 16 6A E0 68 80 41 93 B4 05 41
97 1E B8 41 90 7A E1 41 96 8F 57 46 E6 2E 80 00
00 01 1... |
How can I get an accurate UTC time with Python?
Question: I wrote a desktop application and was using `datetime.datetime.utcnow()` for
timestamping, however I've recently noticed that some people using the
application get wildly different results than I do when we run the program at
the same time. Is there any way to g... |
Python problem executing popen in cron
Question: I use `popen` to execute commands in a Python script, and I call it via cron.
Cron calls out this script but the behavior isn't the same if I call it by
hand.
### Source:
from subprocess import Popen, PIPE
pp = Popen('/usr/bin/which iptables', ... |
Interacting with SVN from appengine
Question: I've got a couple of projects where it would be useful to be able to interact
with an SVN server from appengine.
* Pull specific files from the svn (fairly easy, since there is a web interface which I can grab the data off automatically, but how do I authenticate)
* Co... |
How can I grab the color of a pixel on my desktop? (Linux)
Question: I want to grab the color of a pixel with known coordinates on my Linux
desktop.
Until now, I've used `"import -window SomeWindow -crop 1x1+X+Y /tmp/grab.jpg"`
then extracting the pixel value using Python and
[PIL](http://en.wikipedia.org/wiki/Python%... |
Load different modules without changing the logic file
Question: Suppose I've got 2 different modules which have the uniform(same) interfaces.
The files list like this:
root/
logic.py
sns_api/
__init__.py
facebook/
pyfacebook.py
__init__.py
... |
How import Pydev project into interactive console?
Question: Newbie question (I'm just getting started with Python and Pydev):
I've created a project "Playground" with (standard?) src/root sub-folder. In
there I've created example.py.
How do I import my "example" module into Pydev's interactive console? ">>>
import e... |
Storing Images on App Engine using Django
Question: I'm trying to upload and save a resized image in a db.BlobProperty field on
Google App Engine using Django.
the relevant part of my view that process the request looks like this:
image = images.resize(request.POST.get('image'), 100, 100)
recipe.lar... |
dynamically adding functions to a Python module
Question: Our framework requires wrapping certain functions in some ugly boilerplate
code:
def prefix_myname_suffix(obj):
def actual():
print 'hello world'
obj.register(actual)
return obj
I figured this might be sim... |
Python - RegExp - Modify text files
Question: Newbie to Python.... help requested with the following task :-)
I have tree of various files, some of them are C source code. I would like to
modify these C files with python script.
The C code has 4 defines -
#define ZR_LOG0(Id, Class, Seveity, Format)
... |
Using the same handler for multiple wx.TextCtrls?
Question: I'm having a bit of trouble with a panel that has two wxPython TextCtrls in
it. I want either an EVT_CHAR or EVT_KEY_UP handler bound to both controls,
and I want to be able to tell which TextCtrl generated the event. I would
think that event.Id would tell me ... |
Terminate a multi-thread python program
Question: How to make a multi-thread python program response to Ctrl+C key event?
**Edit:** The code is like this:
import threading
current = 0
class MyThread(threading.Thread):
def __init__(self, total):
threading.Thread.__init__(... |
Unable to query from entities loaded onto the app engine datastore
Question: I am a newbie to python. I am not able to query from the entities- UserDetails
and PhoneBook I loaded to the app engine datastore. I have written this UI
below based on the youtube video by Brett on "Developing and Deploying
applications on GA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.