Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reload(sys)
- From: steven.bethard at gmail.com (Steven Bethard)
- Subject: reload(sys)
- Date: Thu, 30 Aug 2007 19:24:11 -0600
S?nmez Kartal wrote:
> I've had an encoding issue and solved it by
> "sys.setdefaultencoding('utf-8')"...
>
> My first try wasn't successful since setdefaultencoding is not named
> when I imported sys module. After, I import sys module, I needed to
> write "reload(sys)" also.
>
> I wonder why we need to call "reload(sys)" to get setdefaultencoding
> named?
sys.setdefaultencoding is purposely deleted from the sys module after
it's loaded because you really shouldn't be using it. The reload() call
restores the deleted attribute.
If you'd like a less brittle solution to your encoding issue, explain
what the issue was, and people here can probably help you find a better
solution.
STeVe
- Follow-Ups:
- reload(sys)
- From: Sönmez Kartal
- reload(sys)
- References:
- reload(sys)
- From: Sönmez Kartal
- reload(sys)
- Prev by Date: Setting a read-only attribute
- Next by Date: status of Programming by Contract (PEP 316)?
- Previous by thread: reload(sys)
- Next by thread: reload(sys)
- Index(es):