Re: Problem with unpack hex to decimal

2005-04-17 Thread Jonathan Brady

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello,
>
> I was looking at this:
> http://docs.python.org/lib/module-struct.html
> and tried the following
>
 import struct
 struct.calcsize('h')
> 2
 struct.calcsize('b')
> 1
 struct.calcsize('bh')
> 4
>
> I would have expected
>
 struct.calcsize('bh')
> 3
>
> what am I missing ?

Not sure, however I also find the following confusing:
>>> struct.calcsize('hb')
3
>>> struct.calcsize('hb') == struct.calcsize('bh')
False

I could understand aligning to multiples of 4, but why is 'hb' different 
from 'bh'? 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: zipimport

2005-05-04 Thread Jonathan Brady

"Gabriele *Darkbard* Farina" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> I have a zip file structured like this:
>
> mymodule.zip\
>   module1.py
>   submodule\
>submodule1.py
>
> I tried to load submodule.submodule1 using this pice of code:
>
> import zipimport
>
> z = zipimport.zipimporter("mymodule.zip")
> z.load_module("submodule.submodule1")
>
> but it does not work (load_module raises an exception)
>
> why?

try z.load_module("submodule/submodule1") instead.

Or in otherwords replace the dot with a slash, now quoting from the docs 
"'fullname' must be the fully qualified (dotted) module name.".  The dotted 
part of that doesn't seem to be correct, at least with the version of python 
(2.3.4) I'm running.

Anyway personally I find:

import sys
sys.path.insert(0, 'mymodule.zip')
import submodule.submodule1

a much cleaner way of thinking about this.

-- 
Jonathan 


-- 
http://mail.python.org/mailman/listinfo/python-list