When I try to run the python koans, I don't get the colors, instead I get the ANSI color codes. I want to get the colors. It seems to be using colorama under the hood. I try to run colorama sample code in the interpeter and get syntax errors and/or assert errors.
Second if can't fix first: How do I get to strip out the ansi color codes...
Hi all,
I have a Ring structure implemented as follows (based on a cookbook recipe I found):
class Ring(list):
def turn(self):
last = self.pop(0)
self.append(last)
def setTop(self, objectReference):
if objectReference not in self:
raise ValueError, "object is not in ring"
while sel...
Good afternoon
How can I open an a chm help file in a particular section using python? Actually I'am opening the file with the following function:
def help(self):
# Open the help file
os.startfile( os.getcwd()+"/config/help.chm")
Many thanks
German
...
I'm trying to figure out some C code so that I can port it into python. The code is for reading a proprietary binary data file format. It has been straightforward thus far -- it's mainly been structs and I have been using the struct library to ask for particular ctypes from the file. However, I just came up on this bit of code and I'm at...
the pages have only one variable which changes, and each page only holds one image.
(example: http://www.example.com/photos/ooo1.jpg ...http://www.example.com/photos/1745.jpg)
I'm currently building the script with python and beautfulSoup but am having a problem creating a loop with the changing variable. I just getting started with ...
I'm trying to do an exercise in John Zelle's "Python Programming: An Introduction to Computer Science". I downloaded a special graphics package for his book (graphics.py, which is on the linked website). The question reads as follows:
Write a program that converts a color image to grayscale. The user supplies the name of a file containi...
I have installed PythonWin installed..
I can read and write to Excel from Python, not a problem. Not the usage I need.
All examples I have found are more complex than I need. Since, I'm moving away
from Excel, I need a half steps for testing.
Whats the simplest way to fire off python scripts from Excel. I dont need gui.
Usage: On ope...
Novice programmer here. I'm writing a program that analyzes the relative spatial locations of points (cells). The program gets boundaries and cell type off an array with the x coordinate in column 1, y coordinate in column 2, and cell type in column 3. It then checks each cell for cell type and appropriate distance from the bounds. I...
Intrigued by this question about infinite loops in perl: http://stackoverflow.com/questions/885908/while-1-vs-for-is-there-a-speed-difference, I decided to run a similar comparison in python. I expected that the compiler would generate the same byte code for while(True): pass and while(1): pass, but this is actually not the case in pytho...
I've got a stack of Models something like this (I'm typing it out in relative shorthand):
class User:
pass
class ItemList:
pass
# A User can have more than one ItemList
# An ItemList can have more than one User
# Classic M2M
class ItemListOwnership:
user = fk(User)
itemlist = fk(ItemList)
# An ItemList has multipl...
hi,
is there a simple way to encrypt/decrypt a string with a key.
somthing like:
key = '1234'
string = 'hello world'
encrypted_string = encrypt(key, string)
decrypt(key, encrypted_string)
i couldn't find anything simple to do that.
...
Basically, I'd like to run a script (versus typing python program.py) or even have a shortcut that I could click on and start the program. Any ideas?
...
Possible Duplicates:
Terminating a Python script
Terminating a Python Program
My question is how to exit out in Python main function? I have tried 'return' but it gave the error SyntaxError: 'return' outside function. Can anyone help? Thanks.
if __name__ == '__main__':
try:
if condition:
(I want to exit here)
...
I have a list of text to be added to a reportlab frame
style = getSampleStyleSheet()['Normal']
style.wordWrap = 'LTR'
style.leading = 12
for legend in legends:
elements.append(Paragraph(str(legend),style))
If the legend is too long, the text at the end is not visible at all.
How to introduce line breaks in this situation.
...
For some reason i am unable to instantiate the set_cookie outside of the MainHandler..
This is a little code to show what im wanting to do..
Can Anyone help??
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
from GenCookie import *
class MainHandler(t...
i want to create an object with different key-value as attributes, for example:
animal
id
name
attribute
id
name
and mapping
animal_attribute
animal_id
attribute_id
so i can have a entry "duck", which has multiple attribute "flying", "swimming", etc. Each attribute type would have its own table defining so...
Hello,
For an internationalised project, I have to validate the global syntax for a name (first, last) with Python. But the lack of unicode classes support is really maling things harder.
Is there any regex / library to do that ?
Examples:
Björn, Anne-Charlotte, توماس, 毛, or מיק must be accepted.
-Björn, Anne--Charlotte, Tom_ or entr...
i am using setuptools to create and upload a sdist package to PyPI.
however everytime i run python setup.py sdist, it includes the dist/ folder and its contents, which i dont want . this behavoir does NOT happen when i use distutils.
here is my file structure:
/
-myModule/
--__init_.py,
-- ...
-docs/
-examples/
-dist/
setup.py
thi...
I have a python script, that generates kml files. Now I want to upload this kml file within the script (not per hand) to the "my maps" section of google maps. Does anybody have a python or other script/code to do so?
...
Hi
I will have alot of similar objects with similar parameters. Example of an object parameters would be something like :
name, boolean, number and list.
The name must be unique value among all the objects while values for boolean, number and list parameters must not.
I could store the data as list of dictionaries i guess. Like tha...