Hello all:
I have found a useful module in IPython, named 'from IPython.ipstruc t
import Struct".
So I can use it as follows:
############### ############### ######
from IPython.ipstruc t import Struct
mystruct = Struct(echo = 1,
verb = 'Verbose',
filedir = 'C:/temp',
)
print mystruct.filedi r
############### ############### #######
I have two following questions:
1Does Python provide such Struct in this standard libary.
Python has "4.3 struct -- Interpret strings as packed binary data", but
it looks like different
from what I really want to get.
2Is it safe to use IPython's modules in my python program?
I will pack all my code into an executable application by using py2exe.
The clients would like to use this application without any python
intallation.
What should I pay attention if I include the IPython modules into my
python code and
convert it into executable application by using py2exe?
The setup.py for my application is as follows:
############### ############### #############
from distutils.core import setup
import py2exe
options = {
"bundle_fil es": 1,
# "ascii": 1, # to make a smaller executable, don't include the
encodings
"compressed ": 1, # compress the library archive
}
setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = "1.0",
description = "mycode",
name = "mycode",
options = {"py2exe": options},
zipfile = None, # append zip-archive to the executable.
# targets to build
console=['mycode.py'],
)
############### ############### ############### ######
Does I need to make any modification if I include IPython module in my
code?
Thank you for your helps
-Daniel 4 4410
Daniel Mark wrote:
I have found a useful module in IPython, named 'from IPython.ipstruc t
import Struct".
So I can use it as follows:
############### ############### ######
from IPython.ipstruc t import Struct
mystruct = Struct(echo = 1,
verb = 'Verbose',
filedir = 'C:/temp',
)
print mystruct.filedi r
############### ############### #######
Does 'Bunch' fit the bill? http://aspn.activestate.com/ASPN/Coo...n/Recipe/52308
....
jay graves
Daniel Mark wrote:
I have two following questions:
1Does Python provide such Struct in this standard libary.
Python has "4.3 struct -- Interpret strings as packed binary
data", but it looks like different from what I really want to get.
Yes, that module is used when you want to deal with C structs in
binary form (e.g. useful at networking with binary protocols).
Try using dictionaries or custom, field-only class instances
as "struct".
Regards,
Björn
--
BOFH excuse #374:
It's the InterNIC's fault.
Hi Daniel,
To avoid problems you could vendor the ipython file you require, but an
easier solution may just be to implement your own version of the class
(it's extreemly easy):
class struct():
def __init__(self, *args, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
mystruct = struct(echo = 1,
verb = 'Verbose',
filedir = 'C:/temp')
print mystruct.filedi r
Regards,
Jordan
Daniel Mark wrote:
>
1Does Python provide such Struct in this standard libary.
Python has "4.3 struct -- Interpret strings as packed binary data", but
it looks like different
from what I really want to get.
I like the following version:
class Struct(dict):
def __getattr__(sel f,name):
try:
val=self[name]
except KeyError:
val=super(Struc t,self).getattr (self,name)
return val
def __setattr__(sel f,name,val):
l=dir(self)
if name in self:
super(Struct,se lf).setattr(sel f,name,val)
else:
self[name]=val
it has the added benefit of having all of the dict methods too.
bb
--
----------------- bb****@bryant.e du http://web.bryant.edu/~bblais This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: R. Rajesh Jeba Anbiah |
last post by:
Recently I've done a project to fiddle WAV (format) files. To read the
headers, I've used something like:
fseek($fp, 40); //Data length is at offset 40
$data_len = fread($fp, 4); //4 bytes
This method is really hectic as you know. By Googling, I couldn't
find any better solution. In C, we can do it easily with struct like:
typedef struct tagFILEHEADER
|
by: Pablo Gutierrez |
last post by:
I have a C# method that reads Binary data (BLOB type) from a database
and returns the data an array of bytes
(i.e byte outbyte = new byte;).
The BLOB column is saved into the database by a C program (UNIX) as an
array of "struct point" where
struct point //C structure
{
int Time; //32 bits
|
by: Steve Teeples |
last post by:
I don't understand why I cannot use a property to modify data within a
struct. Can someone tell me why I get the error "Cannot modify the return
value of "myData.TheData" because it is not a variable.
Here is what breaks.
struct Data
{
public Data(){}
private int someData;
|
by: Pantokrator |
last post by:
Hi,
Is there any way to "overload" a struct?
e.g.
having already
struct stA1
{
int i_ID;
int i_Type;
};
|
by: hobbes992 |
last post by:
Howdy folks,
I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or deleted, however it must be initialized by a function during run-time to contain so many users which each contain so many directories of which each contain so many files. I've completed the program and have it running flawlessly without implementing...
| |
by: angshuman.agarwal |
last post by:
Structure in C DLL
----------------------------
typedef struct IrData
{
unsigned short uiFormat;
unsigned short uiLength;
unsigned char* pchData;
} tagIrData;
Function in C DLL
|
by: Mohammad Omer Nasir |
last post by:
Hi,
i made a structure in header file "commonstructs.h" is:
typedef struct A
{
int i;
A( )
{
|
by: cman |
last post by:
What does this kind of typedef accomplish?
typedef struct { unsigned long pte_low; } pte_t;
typedef struct { unsigned long pgd; } pgd_t;
typedef struct { unsigned long pgprot; } pgprot_t
I am familiar with "typedef int NUMBER", but how does it work with
structures.
Tilak
|
by: Francine.Neary |
last post by:
People seem to have different views as to where the C reserved word
"struct" comes from. One explanation is that it is a shortening of
"structure", and another is that it is an acronym for "single type
representing useful compound types".
Does anyone here know the history of the word?
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |