The sprit of this newsgroup!
m.faassen at vet.uu.nl
Sat Feb 22 23:47:58 CET 2003
Peter Hansen <peter at engcorp.com> wrote:
> Martijn Faassen wrote:
>> but i figured it out all by myself and soon I can be a senior too:
>> mystring = 'Hello world how are you?"
>> mystring = range(217)
>> mystring = 'F'
>> but now i have a problem printing my string, I get it looking all weird like
>> a lot of numbers and stuff. What is happening?
> Ah, that's called "Unicode". It's a replacement for "bytes" which
> is coming into vogue these days. There's another fellow in this
> newsgroup who posts answers about Unicode and I'm sure he'll
> be along shortly to help you out.
Okay I like unicode if it's coming into vogue and replacing bytes. Personally
I always thought they should replace bytes with something better already,
I mean, everything in computing keeps changing every day, one day it is
I should learn C++ then Java and then Python but they still talk about
bytes after all these years? Even the dot coms didn't replace bytes and
they were all so innovative. Does this also mean you have kilounicode
and megaunicode? Or do they use some different system. I guess I have to
update my system's RAM or install a unicode accelerator?
So how do I change my unicodes into something readable? Is it necessary
to go back to bytes for that? I read I could encode as UTF-8, is that enough
UTF or do I need more?
Anyway I tried something with .encode on my string and first I couldn't
get it to work as it said there was a 'list' object without attibute
'encode'. But I'm really becoming a senior guru already as I fixed
it myself! Well I almost fixed it, something is still not working..
mystring = 'Hello world how are you?"
trick = mystring # a GURU trick here see later
mystring = range(217) # great hack to make changing the string work!
mystring = 'F'
# I read that assertions and testing was good so I put this in and it
# PROVES it worked!
assert mystring == 'F'
assert mystring != 'F'
# unfortunately mystring here is in unicode so I can't print it so I have
# to make it into UTF-8
# so I use object oriented programming here using the factory bridge pattern
# (I wanted to make this a singleton as I heard that was good but I don't know
# how, how do you do a singleton pattern in python?)
mystring = OO()
still something is not going entirely right because the F is not there anymore?
I did an assert before so I don't know what is wrong..
Martijn "Senior OO hacker" Faassen
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?
More information about the Python-list