[Tutor] Mysql BLOB strangeness?

Hugo González Monteverde hugonz-lists at h-lab.net
Mon Mar 20 05:40:34 CET 2006

> However, there is still a learning point that might be missed here -
> how does Python grab BLOB data-types, and how do you manipulate them?
> If it were a file, would you just be able to grab the file without the
> array?

The basic issue is: what form is used for representing arbitrary byte 
data of arbitrary length.

     1) strings: strings in python are arbitrarily large and can store 
any byte values (compare this with other languages like C where the 
number 0 signals the end of a string)  Strings are OK, and that's what 
the standard library writes to files.

     2) arrays: there is but one problem with strings, and that they are 
inmutable: you have to create a new string everytime you want to change 
an old one. Long data chunks are inefficiently worked when using 
strings, so you may use arrays (array.array) which can be changed in place.

Of course there are many more options, like a tuple or a list of 255 or 
less ints, but these are the main contenders for byte valued sequences.

Hope that clears thing a bit,


> --
> http://www.monkeez.org
> PGP key: 0x7111B833
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list