python

How to install python-dateutil on Windows?

I'm trying to convert some date/times to UTC, which I thought would be dead simple in Python - batteries included, right? Well, it would be simple except that Python (2.6) doesn't include any tzinfo classes. No problem, a quick search turns up python-dateutil which should do exactly what I need. The problem is that I need to install it ...

How to ignore deprecation warnings in Python

I keep getting this : DeprecationWarning: integer argument expected, got float How do I make this message go away? Is there a way to avoid warnings in Python? ...

Serializing a Python Object to XML (Apple .plist)

Hello Pythonistas, I need to read and serialize objects from and to XML, Apple's .plist format in particular. What's the most intelligent way to do it in Python? Are there any ready-made solutions? ...

Python learning environment

I'm looking to get up to speed on Python, is it worth working locally via the ActivePython interface, then progressing to a website that supports one of the standard frameworks (Django or Pylons) OR utilize the Google Apps environment? I want to stay as interactive as possible - making feedback/learning easier. ...

logging with filters

i'm using logging (import logging) to log messages; within 1 single module, i am logging messages at the debug level (my_logger.debug('msg')); some of these debug messages come from function_a() and others from function_b(); i'd like to be able to enable/disable logging based on whether they come from a or from b; i'm guessing tha...

How do you know when looking at the list of attributes and methods listed in a dir which are attributes and which are methods?

I am working through trying to learn to program in Python and am focused on getting a better handle on how to use Standard and other modules. The dir function seems really powerful in the interpreter but I wonder if I am missing something because of my lack of OOP background. Using S.Lotts book I decided to use his Die class to learn m...

How to strip html/javascript from text input in django

What is the easiest way to strip all html/javascript from a string? ...

Should I learn python 2.x or start learning python 3

Exact Duplicate: 1. To learn python 2 then 3, or 3 from the start? 2. Python 2 vs Python 3 and Tutorial 3. If I’m going to learn Python, should I learn 2.x or just jump into 3.0? 4. Is Python 3 a good starting point when you want to learn Python? 5. Is it worth learning Python 2.6 with 3.0 coming? 6. Is it required to lear...

Can Python modules have properties the same way that objects can?

With python properties, I can make it such that x.y calls a function rather than just returning a value. Is there a way to do this with modules? I have a case where I want m.y to call a function rather than just returning the value stored there. C ...

cxxTestgen.py throw a syntax error

I've follow the tutorial on http://cxxtest.com/index.php?title=Visual_Studio_integration and I've looked on google but found nothing. When I try to lunch a basic test with cxxtest and visual studio I get this error : 1>Generating main code for test suite 1> File "C:/cxxtest/cxxtestgen.py", line 60 1> print usageString() 1> ...

Should I implement the mixed use of BeautifulSoup and REGEXs or rely solely on BS

I have some data I need to extract from a collection of html files. I am not sure if the data resides in a div element, a table element or a combined element (where the div tag is an element of a table. I have seen all three cases. My files are large-as big as 2 mb and I have tens of thousands of them. So far I have looked at the td ...

Why do dynamic language newbies seem to default to Ruby instead of Python?

NOTE: This is NOT flame bait. I'm generally curious, so please, don't start any wars! Whenever I read a Ruby blog it goes something like: I used to be a devout PHP or Perl developer until one day I decided to start using Ruby. Now I love it. Considering that without Rails, Ruby would be just another obscure dynamic language,...

Applications of Python

Hi, What are some applications for Python that relative amateur programmers can get into? For example, Ruby has Rails for building web applications. What are some cool applications of Python? Thanks. ...

How to redirect the output of .exe to a file in python?

In a script , I want to run a .exe with some command line parameters as "-a",and then redirect the standard output of the program to a file? How can I implement that? ...

Pythonic URL Parsing

There are a number of questions about how to parse a URL in Python, this question is about the best or most Pythonic way to do it. In my parsing I need 4 parts: the network location, the first part of the URL, the path and the filename and querystring parts. http://www.somesite.com/base/first/second/third/fourth/foo.html?abc=123 ...

Error when trying to migrate django application with south

Hi all, I am getting this error when running "./manage.py migrate app_name" While loading migration 'whatever.0001_initial': Traceback (most recent call last): File "manage.py", line 14, in <module> execute_manager(settings) ...tons of other stuff.. raise KeyError("The model '%s' from the app '%s' is not available in this migrat...

Apple Event Handler Failure (Python/AppScript)

I have written the following really simple python script to change the desktop wallpaper on my mac (based on this thread): from appscript import app, mactypes import sys fileName = sys.argv[1:] app('Finder').desktop_picture.set(mactypes.File(fileName)) However when I run it I get the following output: Traceback (most recent cal...

Google App Engine self.redirect post

I have a form that POSTs information to one of my handlers. My handler verifies the information and then needs to POST this information to a third party AND redirect the user to that page. Example of the class ExampleHandler(BaseRequestHandler): """DocString here... """ def post(self): day = int(self.request.get('day')) ...

How to suppress the carriage return in python 2?

myfile = open("wrsu"+str(i)+'_'+str(j)+'_'+str(TimesToExec)+".txt",'w') sys.stdout = myfile p1 = subprocess.Popen([pathname,"r", "s","u",str(i),str(j),str(runTime)],stdout=subprocess.PIPE) output = p1.communicate()[0] print output, When I use this to redirect the output of a exe to my own file, i...

how to send email in python

import smtplib SERVER = "localhost" FROM = "[email protected]" TO = ["[email protected]"] SUBJECT = "Hello!" TEXT = "This message was sent with Python's smtplib." server = smtplib.SMTP(SERVER) server.sendmail(FROM, TO, message) server.quit() This is giving the error: '**The debugged program raised the exception unhandled Attribute...