473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

struct.pack returns nothing

If I build a strict with:

import struct
print struck.pack ('i', 1)

it returns a '\n'.
What's wrong with it???
:(

--
Andrés M.
---------------------------------------------
Mar 19 '07 #1
5 1711
<an******@gmail.comwrote:
If I build a strict with:

import struct
print struck.pack ('i', 1)

it returns a '\n'.
What's wrong with it???
:(
You're trying to print a binary string that's hardly printable as-is.
Try printing its repr(...) and you'll see all the binary zeros and one
you crave!-)
Alex

Mar 19 '07 #2
On Mar 19, 1:12 am, andma...@gmail.com wrote:
If I build a strict with:

import struct
print struck.pack ('i', 1)

it returns a '\n'.
What's wrong with it???
:(

--
Andrés M.
---------------------------------------------
Looks like you spelled struct wrong in the code :)

Mar 19 '07 #3
On Sun, Mar 18, 2007 at 10:22:45PM -0700, AW********@gmail.com wrote:
On Mar 19, 1:12 am, andma...@gmail.com wrote:
If I build a strict with:

import struct
print struck.pack ('i', 1)

it returns a '\n'.
What's wrong with it???
:(

--
Andrés M.
---------------------------------------------

Looks like you spelled struct wrong in the code :)
You're right. I meant struct there too. heh.
--
Andrés M.
---------------------------------------------
Mar 19 '07 #4
On Sun, Mar 18, 2007 at 10:22:32PM -0700, Alex Martelli wrote:
<an******@gmail.comwrote:
If I build a strict with:

import struct
print struck.pack ('i', 1)

it returns a '\n'.
What's wrong with it???
:(

You're trying to print a binary string that's hardly printable as-is.
Try printing its repr(...) and you'll see all the binary zeros and one
you crave!-)
Im getting nothing as well.
The unpack seems to work fine though.

--
Andrés M.
---------------------------------------------
Mar 19 '07 #5
En Mon, 19 Mar 2007 02:39:01 -0300, <an******@gmail.comescribió:
On Sun, Mar 18, 2007 at 10:22:32PM -0700, Alex Martelli wrote:
><an******@gmail.comwrote:
import struct
print struck.pack ('i', 1)

it returns a '\n'.
What's wrong with it???
:(

You're trying to print a binary string that's hardly printable as-is.
Try printing its repr(...) and you'll see all the binary zeros and one
you crave!-)

Im getting nothing as well.
The unpack seems to work fine though.
Works fine for me:

pyimport struct
pyprint repr(struct.pack('i',1))
'\x01\x00\x00\x00'

--
Gabriel Genellina

Mar 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gordon Scott | last post by:
Hi All, I've got a problem I'm seeing when trying to use the struct module to send data to a different machine. Actually I'm making a condensed file that gets transferred to and read on a BREW...
10
by: Giovanni Bajo | last post by:
Hello, given the ongoing work on struct (which I thought was a dead module), I was wondering if it would be possible to add an API to register custom parsing codes for struct. Whenever I use it...
1
by: andmarti | last post by:
On Mon, Mar 19, 2007 at 02:12:39AM -0300, andmarti@gmail.com wrote: Sorry, I meant script. -- Andrés M. ---------------------------------------------
7
by: aurora00 | last post by:
I have a program that generates a number of files that will be packaged into a tarball. Can I stream the content into TarFile without first writing them out to the file system? All add(), addfile()...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.