Extracting a short using struct - won't print.

Graham Nicholls graham at rockcons.co.uk
Thu Aug 7 12:13:35 EDT 2003


Richard Brodie wrote:

> 
> "Graham Nicholls" <graham at rockcons.co.uk> wrote in message
> news:3f32779d$0$10780$afc38c87 at auth.uk.news.easynet.net...
> 
>> >>         seg_stru=">BHH"
>> >>         seg_data=self.fhand.read(struct.calcsize(seg_stru))
>> >>         data=struct.unpack(seg_stru,seg_data)
>> >>         x=seg_data[1]
>> >>         y=seg_data[2]
>> >
>> > Why are you unpacking the struct if you aren't going to use the
>> > unpacked data?
>>
>> Err, I'm trying to extract two shorts - the x and y size in pixels of an
>> image, which I'll use to scale it to fit another pair of parameters. 
>> What makes you think I'm not using the data? Am I not - I thought I was!
> 
> You aren't using the returned value from struct.unpack() anywhere.
> You need something like x, y = struct.unpack(seg_stru,seg_data)

I told you it'd be something stupid!
I mean 
        x=data[1]
        y=data[2]
don't I!
Thanks!!!!
Graham
-- 
Graham Nicholls
Rock Computer Consultancy





More information about the Python-list mailing list