Python: can’t pickle module objects error

Python’s inability to pickle module objects is the real problem. Is there a good reason? I don’t think so. Having module objects unpicklable contributes to the frailty of python as a parallel / asynchronous language. If you want to pickle module objects, or almost anything in python, then use dill. Python 3.2.5 (default, May 19 … Read more

Why is Python datetime time delta not found?

import time from datetime import datetime, date, time, timedelta dayDates = [] today = datetime.now() dayDates.append(today.strftime(“%m%d%Y”)) for i in range(0,14): day = today + datetime.timedelta(days=i) print day The error that you are getting says, that datetime has no attribute timedelta. It happens, because you have imported from datetime specific things. In order to access timedelta … Read more

How can I access the form submit button value in Django?

Submit is an HTML Form structure… You must use name attribute of form objects as follows… In your template: <form> … <input type=”submit” name=”list” value=”List Objects” /> </form> <form> … <input type=”submit” name=”do-something-else” value=”Do Something Else” /> </form> In your view: if ‘list’ in request.POST: # do some listing… elif ‘do-something-else’ in request.POST: # do … Read more

Please elaborate on the use of `WITH` over `TRY CATCH` in this context

In general, a context manager is free to do whatever its author wants it to do when used. Set/reset a certain system state, cleaning up resources after use, acquiring/releasing a lock, etc. In particular, as Jon already writes, a database connection object creates a transaction when used as a context manager. If you want to … Read more

error code: 521