I have created a Python file to generate a Mandelbrot set image. The original maths code was not mine, so I do not understand it - I only heavily modified it to make it about 250x faster (Threads rule!).
Anyway, I was wondering how I could modify the maths part of the code to make it render one specific bit. Here is the maths part:
for...
Exact duplicate: http://stackoverflow.com/questions/79968/split-a-string-by-spaces-in-python
I want to take in a string and return a list, dictionary or tuple of values as separated by spaces. However, I want to not match spaces that are somehow between quote marks, i.e.
apple orange "banana tree" green
Should come back as three...
In my Python application, I need to write a regular expression that matches a C++ for or while loop that has been terminated with a semi-colon (;). For example, it should match this:
for (int i = 0; i < 10; i++);
... but not this:
for (int i = 0; i < 10; i++)
This looks trivial at first glance, until you realise that the text betwe...
I have a series of Python classes in a file. Some classes reference others.
My code is something like this:
class A():
pass
class B():
c = C()
class C():
pass
Trying to run that, I get NameError: name 'C' is not defined. Fair enough, but is there any way to make it work, or do I have to manually re-order my classes to a...
How can i find out if the obj returned by a func is a int or something else (like a sqlite cursor)
...
I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database.
Then in the...
In PHP I can do the following:
$myVar = 'name';
print $myClass->$myVar;
// Identical to $myClass->name
I wish to do this in Python but can't find out how
...
I'm trying to add two images together using numpy and PIL. The way I would do this in matlab would be something like:
>> M1 = imread('_1.jpg');
>> M2 = imread('_2.jpg');
>> resM = M1 + M2;
>> imwrite(resM, 'res.jpg');
I get something like this:
Using a compositing program and adding the images the matlab result seems to be right.
...
I'm tooling around with Django and I'm wondering if there is a simple way to create a "back" link to the previous page using the template system.
I figure that in the worst case I can get this information from the request object in the view function, and pass it along to the template rendering method, but I'm hoping I can avoid all this...
Implementing a 'sandbox' environment in Python used to be done with the rexec module (http://docs.python.org/library/rexec.html). Unfortunately, it has been deprecated/removed due to some security vulnerabilities. Is there an alternative?
My goal is to have Python code execute semi-trusted Python scripts. In a perfect world, calls to...
Python is pretty clean, and I can code neat apps quickly.
But I notice I have some minor error someplace and I dont find the error at compile but at run time. Then I need to change and run the script again. Is there a way to have it break and let me modify and run?
Also, I dislike how python has no enums. If I were to write code that ne...
In my python script i am parsing a user created file and typically there will be some errors and there are cases were i warn the user to be more clear. In c i would have an enum like eAssignBad, eAssignMismatch, eAssignmentSignMix (sign mixed with unsigned). Then i would look the value up to print an error or warning msg. I link having t...
curl_unescape doesnt seem to be in pycurl, what do i use instead?
...
I have an application that reads lines from a file and runs its magic on each line as it is read. Once the line is read and properly processed, I would like to delete the line from the file. A backup of the removed line is already being kept. I would like to do something like
file = open('myfile.txt', 'rw+')
for line in file:
process...
Hello,
I've been trying to embed an icon (.ico) into my "compyled" .exe with py2exe.
Py2Exe does have a way to embed an icon:
windows=[{
'script':'MyScript.py',
'icon_resources':[(1,'MyIcon.ico')]
}]
And that's what I am using. The icon shows up fine on Windows XP or lower, but doesn't show at all on Vista. I suppose this is...
in C do return -1 when i want to cancel the download in either the header or the write function. In pycurl i get this error
pycurl.error: invalid return value for write callback -1 17
I dont know what the 17 means but what am i not doing correctly?
...
Can a regular expression match whitespace or the start of a string?
I'm trying to replace currency the abbreviation GBP with a £ symbol. I could just match anything starting GBP, but I'd like to be a bit more conservative, and look for certain delimiters around it.
>>> import re
>>> text = u'GBP 5 Off when you spend GBP75.00'
>>> re.s...
So I am a long time .Net developer looking to branch into something new to further my professional development. I have reduced the next language to learn as one of c++, Python or Ruby and want to hear everyone's thoughts on what I should pick, and why?
What trials and tribulations have others found when moving from c# onto one of these...
How can I accept cookies in a python script?
...
Here is the dictionary I have
propertyList = {
"id": "int",
"name": "char(40)",
"team": "int",
"realOwner": "int",
"x": "int",
"y": "int",
"description": "char(255)",
"port": "bool",
"secret": "bool",
"dead": "bool",
"nomadic": "bool",
"population": "int",
"slaves": "int",
}
But when I print it out w...