On Mar 16, 9:19 pm, jo <[email protected]> wrote:

> [(u'33', 2009, 1, 212, Decimal("2.000"), Decimal("24.000")), (u'33',
> 2009, 1, 6, Decimal("43.000"),Decimal("5289.000"))],f)
>
> and now take a look at this:
>
> pickle.dump((data, expiration_time), f)
> *** TypeError: can't pickle module objects
>
> pickle.dump(( [(u'33', 2009, 1, 212, Decimal("2.000"),
> Decimal("24.000")), (u'33', 2009, 1, 6, Decimal("43.000"),
> Decimal("5289.000"))], expiration_time),f)
> *** NameError: name 'Decimal' is not defined
>
> I'm confusing about this behavior. If I pass data to pickle.dump it
> says: TypeError: can't pickle module objects
> instead if I pass the value of data to pickle.dump it says: NameError:
> name 'Decimal' is not defined
>
> why this difference?
> what can I do about Decimals and pickle?
>
> j

In the 2nd instance you are trying to use pickle with Decimal objects
without Decimal being imported into your name space.

This will work:

from decimal import Decimal
.
.
.
pickle.dump(( [(u'33', 2009, 1, 212, Decimal("2.000"), Decimal
("24.000")), (u'33', 2009, 1, 6, Decimal("43.000"), Decimal
("5289.000"))], expiration_time),f)

Chris Guest
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to