Mert Nuhoglu's Library tagged → View Popular
Python Encodings and Unicode | One More Blog
Best explanation of unicode in python.
-
>>> import codecs
>>> fh = codecs.open("/tmp/utf-8.txt", "w", "utf-8")
>>> fh.write(u"\u2013")
>>> fh.close() -
- Decode First, Encode Last
- When in doubt, encode as utf-8
- Use codecs with unicode objects to simplify things
- 3 more annotations...
Unicode exception in 'paster shell' (repr versus __repr__) - pylons-discuss | Google Groups
-
>> Does anyone have an explanation why foo.__repr__() and repr(foo) makes suchThanks - you saved my day. I'm now using .encode('utf-8') before I return
>> a difference here? Hints welcome.
> Shouldn't repr return plain string, not unicode one? When calling .__repr__()
> directly you just call a method directly. When called by repr() some ipython
> magic happens, which expects __repr__ to return a string.
the string and now everything works.
Computer Programming for Everybody
-
"What will happen if users can program
their own computer?" -
We compare mass ability to read and write software with mass literac
- 7 more annotations...
Let's talk about WSGI
-
- As an interface for Python applications to speak HTTP, WSGI leaves quite a lot to be desired.
As an interface for Python web developers to implement and work with, WSGI is antiquated and frustrating.
As an interface for composing useful functionality from the various Python web components, WSGI is far from sufficient.
- As an interface for Python applications to speak HTTP, WSGI leaves quite a lot to be desired.
- 4 more annotations...
Introduction to Python/Django testing: Basic Doctests | Surfing in Kansas
-
You can go ahead and put that in a file in your
tests/directory, I named itdoctst.py -
run
./manage.py test APPNAME - 2 more annotations...
Introduction to Python/Django testing: Basic Unit Tests | Surfing in Kansas
-
you should have a basic tests directory, with an
__init__.pyand adoctst.pyfile inside of it. -
import unittest
class TestBasic(unittest.TestCase):
"Basic tests"
def test_basic(self):
a = 1
self.assertEqual(1, a) - 5 more annotations...
DynamicWare: Introduction to Python/Django testing: Doctests
-
You need to go into your init.py file and put some stuff in there.
import doctst
__test__ = {
'Doctest': doctst
}You are importing the doc test module and then adding it to the
__test__dictionary. You have to do this because of the way that python handles looking for doc tests. It looks for a__test__dictionary inside of your module, and if that exists it looks through it, executing all docstrings as doctests.
The Python Property Builtin
-
something = property(something)
-
- @property
- def something(self):
- @property
- 1 more annotations...
Django | 2. Adding __str__() or __unicode__() to models | Django Documentation
-
def __str__(self):
# Caution: this is only safe if you are certain that headline will be
# in ASCII.
return self.headline -
def __unicode__(self):
return self.headline
Does __str__() call decode() method behind scenes? - Stack Overflow
-
Basically,
__str__can only output ascii strings. Since t2 contains unicode codepoints above ascii, it cannot be represented with just a string. -
when dealing with django applications, you should use
__unicode__for everything, and never touch__str__.
Python Unicode Objects
- Best article I have ever read about unicode in python. - mertnuhoglu on 2009-08-12
-
each distinct character has its own
number, the code point. -
Unicode characters don’t have an encoding; each character
is represented by its code - 14 more annotations...
How to Use UTF-8 with Python
-
byte strings and Unicode strings
-
Python uses your computer's default locale to convert the bytes into characters.
- 7 more annotations...
Python instance descriptors: when class descriptors aren't dynamic enough - Brian Beck's Text Adventure
-
redefining
getattr/setattrbehavior (essentially re-implementing your own descriptor protocol
Selected Tags
Related Tags
Sponsored Links
Top Contributors
Groups interested in python
-
development
Items: 88 | Visits: 49
Created by: zou ave
-
Tom's Programming Sites
programming tech sites
Items: 14 | Visits: 96
Created by: Tom McGinnis
-
python
python related resources.
Items: 3 | Visits: 62
Created by: tgkuo1 Kuo
Diigo is about better ways to research, share and collaborate on information. Learn more »
Join Diigo
