On Wed, Apr 24, 2013 at 4:21 PM, Prasad, Ramit
wrote:
> Your struct.pack() line seems fine, but you might want to specify
> endian-ness as the default value may vary by architecture.
> (See http://en.wikipedia.org/wiki/Endian )
>
struct.pack('>HBB', 1234,1,0 )
> '\x04\xd2\x01\x00' # note loca
sparkle Plenty wrote:
> On Wed, Apr 24, 2013 at 4:21 PM, Prasad, Ramit
> wrote:
[snip]
> >
> > Here is my function as it stands now:
> >
> > def conCatNumbers(numOne, numTwo, numThree):
> > global instanceGroup, lengthCounter, instanceCounter
> > print("Pre Pack: ", numOne, " ", numTwo
On Wed, Apr 24, 2013 at 4:21 PM, Prasad, Ramit wrote:
> Thank you for not replying above, but please continue to CC the tutor list.
>
> sparkle Plenty wrote:
> >
> > On Wed, Apr 24, 2013 at 2:45 PM, Prasad, Ramit <
> ramit.pra...@jpmorgan.com> wrote:
> > Please post your response *after* the quote
Thank you for not replying above, but please continue to CC the tutor list.
sparkle Plenty wrote:
>
> On Wed, Apr 24, 2013 at 2:45 PM, Prasad, Ramit
> wrote:
> Please post your response *after* the quoted context.
>
> sparkle Plenty wrote:
> >
> > Thanks to both of you for your assistance.
> >
On Wed, Apr 24, 2013 at 2:23 PM, sparkle Plenty
wrote:
> I will have an unknown number of instances, each of which consists of 3
> numeric values. I tried packing each instance using struct.pack, then
> converting to a tuple, then concatenating. This ran, but introduced
> errors: in some insta
On 24/04/13 17:52, sparkle Plenty wrote:
What is the best way to concatenate packed numeric data?
There are lots of options but one way to produce a byte string from
(semi) arbitrary values is to use the struct module.
It uses a format string to define the data format and lengths and then
su
Please post your response *after* the quoted context.
sparkle Plenty wrote:
>
> Thanks to both of you for your assistance.
> Since the completed message must be in hex, I also have an issue with losing
> high order zeros during
> conversions, although the binary shift works well for adding on to
n.org
> > Subject: [Tutor] Concatenating numeric data in Python 3.3
> >
> > What is the best way to concatenate packed numeric data? I am building
> a message to send to a device
> > and it has a very specific header format and variable length payload.
> Conver
sparkle Plenty wrote:
> Sent: Wednesday, April 24, 2013 11:52 AM
> To: Tutor@python.org
> Subject: [Tutor] Concatenating numeric data in Python 3.3
>
> What is the best way to concatenate packed numeric data? I am building a
> message to send to a device
> and it has a
On 04/24/2013 12:52 PM, sparkle Plenty wrote:
What is the best way to concatenate packed numeric data? I am building a
message to send to a device and it has a very specific header format and
variable length payload. Converting to string, concatenating, and then
converting back to numeric intro
So, for example, you'd be trying to concatenate the binary data
01010101 and 10101010, and get 0101010110101010? You can do that by
shifting the bits:
>>> (0b01010101 << 8) + 0b10101010
21930
which is equivalent to:
>>> 0b0101010110101010
21930
You can also do it with numerical data:
>>> 0b101
What is the best way to concatenate packed numeric data? I am building a
message to send to a device and it has a very specific header format and
variable length payload. Converting to string, concatenating, and then
converting back to numeric introduced errors. The tuple() function also
introdu
12 matches
Mail list logo