I am having a funny issue with ctypes; while it seems to work in regular python scripts, when I use it in the interpreter with printf() it prints the length of the string after the string itself. A demo:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more info...
Hello,
I am using NetBeans while using python. In NetBeans, i have class like this:
class Test:
Var = 'Val'
In python i can access this Var variable with this (using Test class for ENUM):
print Test.Var
NetBens does not auto complete after dot(.). But whenever i instance Test class, it auto completes. Here is example.
test = Te...
Hi,
I am using Pydev on Eclipse to write python code. I am new to Pydev and to Eclipse. I love the feature where by I can use rightClick -> Refactoring -> Rename... to rename a variable.
I was wondering if there is something similar to change a function everywhere in the project, if I change its definition.
For example, suppose I ini...
I am writing a python function with the following:
class myObj(object):
def __init__(self, args):
# there is code here
def newO(self, name, description):
if type(name)==str:
self.oname.append(name)
self.o.append(description)
elif type(name)==list:
for n in name:
...
Hi,
I have a line like this:
filter(lambda x: x == 1, [1, 1, 2])
Pylint is showing a warning:
W: 3: Used builtin function 'filter'
Why is that? is a list comprehension the recommended method?
Of course I can rewrite this like this:
[x for x in [1, 1, 2] if x == 1]
And I get no warnings, but I was wondering if there's a PEP fo...
I need help parsing out some text from a page with lxml. I tried beautifulsoup and the html of the page I am parsing is so broken, it wouldn't work. So I have moved on to lxml, but the docs are a little confusing and I was hoping someone here could help me.
Here is the page I am trying to parse: http://bit.ly/bf1T12. I need to get ...
I'm using twisted API and was going through this example.
I inserted one print statement print "in getdummydata" with correct indentation. code is as below:
from twisted.internet import reactor, defer
def getDummyData(x):
"""
This function is a dummy which simulates a delayed result and
returns a Deferred which will fire wi...
The below python code takes a list of files and zips them up. The only File Geodatabase (File based database) that I need to have is called "Data" so how can I modify the loop to only include the File based database called Data? To be more specific a File Geodatabase is stored as a system folder that contains binary files that store an...
This is more a question of coding style, but I have a script that processes a particular file (or set of files). It would be nice to allow the user to provide those files as command-line arguments. Of course, it's possible that the user forgets to provide these or the filenames are invalid, so I have to introduce a try/except here.
Prob...
Specifically for Twisted, I would like to be able to determine whether the server I am connected to supports active or passive mode.
http://twistedmatrix.com/documents/10.1.0/api/twisted.protocols.ftp.FTPClient.html
If somebody could explain or give example in FTP protocol how you can determine whether the server supports active or pas...
I'm sorry to have to ask something like this but python's mechanize documentation seems to really be lacking and I can't figure this out.. they only give one example that I can find for following a link:
response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1)
But I don't want to use a regex, I just want to follow a link based on...
I have a few different XML documents that I'm trying to combine into one using lxml. The problem is that I need the result to preserve the namespaces on each of the sub-documents' root nodes. Lxml seems to want to push any namespace declarations used more than once to the root of the new document, which breaks in my application (it is ...
I'm tasked with creating a model of a cage of hardware. Each cage contains N slots, each slot may or may not contain a card.
I would like to model the cage using a list. Each list index would correspond to the slot number. cards[0].name="Card 0", etc.
This would allow my users to query the model via simple list comprehensions. For e...
How can I count related objects in Django (in less than N queries, where N is number of object).
To clarify, let's say I have tables A and B. Every B is connected to exactly one A. Approach I tried:
A.objects.select_related().filter(attr=val)
A[i].B_set.count()
Of course, for every A[i] I want to find out number of B objects Django e...
Hi,
I'm testing my app with the development server.
When I manually interrupt a request, it sometimes clears the datastore.
This clears even models that are not modified by my request, like users, etc.
Any idea why is this?
Thanks
...
I can bind an event to a textctrl box np. The problem is I have to be clicked inside of the textctrl box to "catch" this event. I am hoping to be able to catch anytime someone presses the Arrow keys while the main window has focus.
NOT WORKING:
wx.EVT_KEY_DOWN(self, self.OnKeyDown)
WORKING:
self.NudgeTxt = wx.TextCtrl(self.panel, s...
I have a file which contains (I believe) latin-1 encoding.
However, I cannot match regexes against this file.
If I cat the file, it looks fine:
However, I cannot find the string:
In [12]: txt = open("b").read()
In [13]: print txt
<Vw_IncidentPipeline_Report>
In [14]: txt
Out[14]: '\x00 \x00 \x00<\x00V\x00w\x00_\x00I\x00n\x0...
I'm adapting an application that makes heavy use of generators to produce its results to provide a web.py web interface.
So far, I could wrap the call to the for-loop and the output-producing statements in a function and call that using cProfile.run() or runctx(). Conceptually:
def output():
for value in generator():
print(...
This feels like a really basic question, but I haven't been able to find an answer.
I would like to read data from an url, for example GET data from a querystring. I am using the webapp framework in Python. I tried the following code, but since I've a total beginner at Python/appengine, I've certainly done something wrong.
class MainPa...
I'm trying to implement mobile browser detection in appengine, using WURFL. However, it appears to be impossible to implement it w/o causing a crazy amount of CPU usage, as well as page loading latency. Any ideas on how I can speed it up?
...