From: Joel VanderWerf Date: 2006-07-30T00:44:43+09:00 Subject: Re: How can I parse binary files? Fabio Vitale wrote: > This time I'm trying to write a binary file. > > Q1: why does the structure MRKMessageFlags does not get the apropriate > values? The problem is, unfortunately, not something that can easily be fixed in bit-struct's nested fields. When you do assignments like the following: > msg.flags.flagSeen = 1 > msg.flags.flagAnswered = 0 > msg.flags.flagFlagged = 1 you are operating on a *copy* of the flags structure. The reason is that msg.flags returns a copy of that structure. It doesn't return a reference to a subfield of msg. It might be possible to return an object that delegates back to the msg structure, but I think that might actually be more confusing than the way it is now. Your best bet is, as Daniel suggested: flags = msg.flags flags.flagSeen = 1 flags.flagAnswered = 0 flags.flagFlagged = 1 msg.flags = flags I will try to add a warning about this in the docs. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407