Is it possible in python to create a property with the same name as the member variable name of the class. e.g.
Class X:
...
self.i = 10 # marker
...
property(fget = get_i, fset = set_i)
Please tell me how I can do so. Because if I do so, for the statement at marker I get stack overflow for the assingm
...
I have not found a way to load an RSA private key from a PEM file to use it in python-crypto (signature).
python-openssl can load a PEM file but the PKey object can't be used to retrieved key information (p, q, ...) to use with Crypto.PublicKey.construct().
...
I have heard it many times that garbage collection in PyS60 is not up to to the mark. This imposes a lot of limits on writing cleaner code. Can I at least rely that the non cyclic references are cleaned up after a function exists.
...
Symbian has a stack limit of 8kB. Does this also apply to the function calling in PyS60 apps?
...
How do i get the path of a the python script i am running in? i was doing dirname(sys.argv[0]) however on mac i got only the filename and not the full path as i do on windows.
No matter where my application is launched from, i want to open files that are relative to my script file(s) which is why i need the directory path.
...
Python's sum() function returns the sum of numbers in an iterable.
sum([3,4,5]) == 3 + 4 + 5 == 12
I'm looking for the function that returns the product instead.
somelib.somefunc([3,4,5]) == 3 * 4 * 5 == 60
I'm pretty sure such a function exists, but I can't find it.
...
Here's a small sample section of some code I'm writing with python and pygame, for some reason it seems to be claiming that some seemingly very simple and apparently accurate things are syntax errors. Here's possibly the most annoying example.
def Draw():
Surface.fill((255,255,255))
for square in squares:
pygame.draw.rec...
I am new to Python. I am writing an application using wxPython and I currently my code that generates a toolbar looks like this:
class Window(wx.Frame)
def __init__(self, parent, plot):
wx.Frame.__init__(self, parent, wx.ID_ANY, "Name", size =(900, 600))
self.Centre()
self.toolbar = self.CreateToolBar(style=(wx.TB_HORZ_LAYO...
I have used XSLT for a few different things over the years. I got used to it, but never felt like I really understood it all the way through. It always seems like I have to experiment to get the result I want, and the outcome isn't necessarily a logical conclusion in hindsight.
On top of that, the one or two times I had to turn over som...
I know the various frameworks have their benefits, but I personally want my web development in python to be as straight-forward as possible: less writing to the framework, more writing python.
The only thing I have found so far that lets me do this in the most obvious way possible is web.py but I have slight concerns on its performance....
Update: My current question is how can I get my code to read to the EOF starting from the beginning with each new search phrase.
This is an assignment I am doing and currently stuck on. Mind you this is a beginner's programming class using Python.
jargon = open("jargonFile.txt","r")
searchPhrase = raw_input("Enter the search phrase: ")...
I'm able to get the value in the image tag (see XML below), but not the Category tag. The difference is one is a CDATA section and the other is just a string. Any help would be appreciated.
from xml.dom import minidom
xml = """<?xml version="1.0" ?>
<ProductData>
<ITEM Id="0471195">
<Category>
<![CDATA[Homogenizer...
Lets say I have a library function that I cannot change that produces an object of class A, and I have created a class B that inherits from A.
What is the most straightforward way of using the library function to produce an object of class B?
edit- I was asked in a comment for more detail, so here goes:
PyTables is a package that han...
I'm wondering if anyone knows about a working command line tool for linux to download using premium account on rapidshare. I've seen a python solution, which does not work for me -- returns urllib2 error message
urlopen error unknown url type: https
and my knowledge of python is not yet deep enough to figure out why: might be a recent...
How do you get a socket to receive packets destined for the IPv6 Subnet-Routers Anycast address?
I haven't been able to find any informationn on how to do this.
In a fit of desparation, I've tried using socket.setsockopt as you would to join a multicast group:
# 7 is the interface number
s = socket(AF_INET6, SOCK_DGRAM)
packed_iface_...
I'm trying to jury-rig the Amazon S3 python library to allow chunked handling of large files. Right now it does a "self.body = http_response.read()", so if you have a 3G file you're going to read the entire thing into memory before getting any control over it.
My current approach is to try to keep the interface for the library the same ...
I have google as much as I possible, checked stackoverflow several times, and yet I can not find a good html to pdf converter that can handle css. Is there a free and open source solution (even for commercial usage)? There are many solutions, with huge variety of price ranges, but I was looking for something open source and free. I ha...
As I see it, there are two ways to handle mouse events to draw a picture.
The first is to detect when the mouse moves and draw a line to where the mouse is, shown here. However, the problem with this is that with a large brush size, many gaps appear between each "line" that is not straight since it is using the line's stroke size to c...
My dilemma: I'm passing my function a string that I need to then perform numerous regex manipulations on. The logic is if there's a match in the first regex, do one thing. If no match, check for a match with the second and do something else, if not check the third, and so forth. I could do something like this:
if re.match('regex1', st...
I've been playing recently with Jython and decided to do some quick and dirty benchmarking with pystone. In order to have a reference, I first tested cPython 2.6, with an increasing numbers of loops (I thought this may be relevant as Jython should start to profit from the JIT only after some time).
(richard garibaldi):/usr/local/src/pyb...