python

How can I provide safety template for user to modify with python?

I am building a multi-user web application. Each user can have their own site under my application. I am considering how to allow user to modify template without security problem? I have evaluated some python template engine. For example, genshi, it is a pretty wonderful template engine, but however it might be dangerous to allow user to...

py2exe to generate dlls?

Is there a way using py2exe or some other method to generate dll files instead of exe files? I would want to basically create a normal win32 dll with normal functions but these functions would be coded in python instead of c++. ...

Quick primer on implementing a COM object that implement some custom IDLs in python?

Does anyone have experience using python to create a COM object that implements some custom IDLs? Basically I'd like to know if it's extremely simple to do compared to c++, and if it is do you know of a good tutorial? ...

overload print python

Am i able to overload the print function? and call the normal function? What i want to do is after a specific line i want print to call my print which will call the normal print and write a copy to file. Also i dont know how to overload print. I dont know how to do variable length arguments. i'll look it up soon but http://stackoverflo...

Study Objective-C , Ruby OR Python?

hi Guys, I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone. So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC. So my question is which one to study? Which language you guys see the FUTURE...

Favorite Django Tips & Features?

Inspired by the question series 'Hidden features of ...', I am curious to hear about your favorite Django tips or lesser known but useful features you know of. Please, include only one tip per answer. Add Django version requirements if there are any. ...

Cross-platform way to get PIDs by process name in python

Several processes with the same name are running on host. What is the cross-platform way to get PIDs of that processes by name using python or jython? It's like pidof but in python (I don't have pidof anyway). I can't parse /proc because it might be unavailable (on HP-UX). I do not want to run os.popen('ps') and parse the output becaus...

python, dictionary and int error

I have a very frustrating python problem. In this code fixedKeyStringInAVar = "SomeKey" def myFunc(a, b): global sleepTime global fixedKeyStringInAVar varMe=int("15") sleepTime[fixedKeyStringInAVar] = varMe*60*1000 #more code Now this works. BUT sometimes when i run this fuction i get TypeError: 'int' object does...

python runtime error, can dump a file?

I am using libcurl to DL a webpage, then i am scanning it for data and doing something with one of the links. However, once in a while the page is different then i except thus i extract bad data and pycurl throws an exception. I tried finding the exception name for pycurl but had no luck. Is there a way i can get the traceback to execut...

Where are the best lists of existing Django apps?

Django web "projects" are (ideally) composed of several (quasi-)independent "applications"? Where are the best places to find high-quality Django apps? At the moment, I know of: the Pinax collection of apps the Django Plugables list Are there other good resources? ...

"Private" (implementation) class in Python

I am coding a small Python module composed of two parts: some functions defining a public interface, an implementation class used by the above functions, but which is not meaningful outside the module. At first, I decided to "hide" this implementation class by defining it inside the function using it, but this hampers readability and...

Deploying application with Python or another embedded scripting language

I'm thinking about using Python as an embedded scripting language in a hobby project written in C++. I would not like to depend on separately installed Python distribution. Python documentation seems to be quite clear about general usage, but I couldn't find a clear answer to this. Is it feasible to deploy a Python interpreter + standar...

Python or Ruby for a .NET developer ?

I'm a C# .NET developer and I work on mostly ASP.NET projects. I want to learn a new programming language, to improve my programming skills by experiencing a new language, to see something different then microsoft environment, and maybe to think in a different way. I focus on two languages for my goal. Python and Ruby. Which one ...

Getting "global name 'foo' is not defined" with Python's timeit

I'm trying to find out how much time it takes to execute a Python statement, so I looked online and found that the standard library provides a module called timeit that purports to do exactly that: import timeit def foo(): # ... contains code I want to time ... def dotime(): t = timeit.Timer("foo()") time = t.timeit(1) ...

Help me implement Blackjack in Python (updated)

I am in the process of writing a blackjack code for python, and i was hoping someone would be able to tell me how to make it: Recognize what someone has typed i.e. "Hit" or "Stand" and react accordingly. Calculate what the player's score is and whether it is an ace and a jack together, and automatically wins. Ok, this is what i have ...

What stackless programming languages are available?

What stackless programming languages are available? I know of Stackless Python, but are there any other languages which do not rely on a C stack that can be embedded into other applications? List of stackless programming languages: Stackless Python PyPy by climatewarrior Lua by Van Gale Tcl by Martin Drapeau Lisp and Scheme by John F...

"Interfaces" in Python: Yea or Nay?

So I'm starting a project using Python after spending a significant amount of time in static land. I've seen some projects that make "interfaces" which are really just classes without any implementations. Before, I'd scoff at the idea and ignore that section of those projects. But now, I'm beginning to warm up to the idea. Just so we...

What's the best way to make a time from "Today" or "Yesterday" and a time in Python?

Python has pretty good date parsing but is the only way to recognize a datetime such as "Today 3:20 PM" or "Yesterday 11:06 AM" by creating a new date today and doing subtractions? ...

Missing first line when downloading .rar file using urllib2.urlopen()

Okey this is really strange. I have this script which basically downloads bunch of achieve files and extracts them. Usually those files are .zip files. Today I sat down and decided to make it work with rar files and I got stuck. At first I thought that the problem is in my unrar code, but it wasn't there. So I did: f = urllib2.urlopen(f...

How do python classes work?

Hello, I have a code file from the boto framework pasted below, all of the print statements are mine, and the one commented out line is also mine, all else belongs to the attributed author. My question is what is the order in which instantiations and allocations occur in python when instantiating a class? The author's code below is un...