Re: [Tutor] laying out frames

2006-05-16 Thread Alan Gauld
> I want to create a basic quadrant of frames but am not able to > follow the > logic to do so, whats the right way or an easier way to control > layout of > frames and wigets. A pixel approach would be nice (where by you can > specify pixel locations for a frame or a widget to be located) > ins

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread Kent Johnson
Terry Carroll wrote: > I want to see if I'm reinventing a wheel here, or maybe doing it > unpythonically. > > I need to extract from a byte (i.e., a one-character string) a field of an > certain number of bits. For example, a certain byte of an MP3 frame > header has the format xxxVVxxx, where t

Re: [Tutor] laying out a menu widget inside a frame

2006-05-16 Thread Michael Lange
On Mon, 15 May 2006 18:47:16 -0400 (EDT) "Zubin Wadia" <[EMAIL PROTECTED]> wrote: Hi Zubin, > root.config(relief=RIDGE, bg="lightblue", bd=3) doesn't seem to work it works for me (linux), maybe a platform issue? > I'm not sure if the menu() widget can be packed in a frame container?? > I don'

Re: [Tutor] Treeview

2006-05-16 Thread Liam Clarke
Sometimes it's your own problem that is hardest to solve, as you're too familiar with the code. :) Congratulations on making sense of pyGTK, the documentation isn't overly helpful... ...I'm used to the wxPython docs and still got confused with the pyGTK ones. Regards, Liam Clarke On 5/14/06, Joh

[Tutor] Python new comer

2006-05-16 Thread kieran flanagan
Hey I am currently learning Python to start scripting automated tests. A lot of these tests require me to strip out values from xml docs using the minidom feature. So really I am just looking for any good articles to start learning Python as a whole and to learn about using Python as a node iterat

Re: [Tutor] Python new comer

2006-05-16 Thread Kent Johnson
kieran flanagan wrote: > Hey > > I am currently learning Python to start scripting automated tests. A lot > of these tests require me to strip out values from xml docs using the > minidom feature. So really I am just looking for any good articles to > start learning Python as a whole and to lea

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread Alan Gauld
Terry, Your approach is fine. Personally however I'd just have defined some constants and done a direct bitwise and - this is the approach used in the stat module: VMASK = 0x14 # 00011000 VER00 = 0x00 VER01 = 0x04 VER10 = 0x10 VER11 = 0x14 version = byte & VMASK if version == VER00: #do somethi

[Tutor] Question on option parser

2006-05-16 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Everyone, I have a program that I'd would like to enhance flexibility in calling. Is there a way to leverage optionparser so it can accept input from both command line and a configuration file? Current code block is: # # Parse command li

Re: [Tutor] Question on option parser

2006-05-16 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Kent, If I understood correctly, you meant something like this? # # Parse command line options and automatically build help/usage # display # if len(sys.argv) == 2: infile= open(sys.argv[1],"rb").read()

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread Terry Carroll
On Tue, 16 May 2006, Alan Gauld wrote: > Your approach is fine. Personally however I'd just have defined > some constants and done a direct bitwise and - this is the > approach used in the stat module: > > VMASK = 0x14 # 00011000 > VER00 = 0x00 > VER01 = 0x04 > VER10 = 0x10 > VER11 = 0x14 > > v

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread Terry Carroll
On Tue, 16 May 2006, Kent Johnson wrote: > You might be interested in Construct, it aims to make it easy to parse > and create structures based on bit fields: > http://pyconstruct.wikispaces.com/ Thanks, I'll have a look at it. ___ Tutor maillist -

Re: [Tutor] Question on option parser

2006-05-16 Thread Karl Pflästerer
On 16 Mai 2006, [EMAIL PROTECTED] wrote: > Is there a way to leverage optionparser so it can accept input from both > command line and a configuration file? > > Current code block is: > > # > # Parse command line options and automatically build > # help/usage display > # > pars

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread S W Collier
On Tuesday 16 May 2006 16:01, Alan Gauld wrote: > Terry, > > Your approach is fine. Personally however I'd just have defined > some constants and done a direct bitwise and - this is the > approach used in the stat module: > > VMASK = 0x14 # 00011000 > VER00 = 0x00 > VER01 = 0x04 > VER10 = 0x10 > V

Re: [Tutor] Running Java process doesn't return to subprocess.call (fwd)

2006-05-16 Thread Danny Yoo
-- Forwarded message -- Date: Tue, 16 May 2006 11:50:32 -0700 (PDT) From: Jerome Jabson <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: [Tutor] Running Java process doesn't return to subprocess.call Hi Danny, I actually changed that just before I sent the email to tutor,

[Tutor] Division operation

2006-05-16 Thread Miguel Estrada
Hi there, I'm new to Python and programming in general. This is the function I am writing: def function(): x = int(raw_input("Enter value of x: ")) y = int(raw_input("Enter value of y: ")) z = x / y print "The value of z is", z, "unit of measurement" Now, say, user input: x =

Re: [Tutor] Division operation

2006-05-16 Thread Terry Carroll
On Tue, 16 May 2006, Miguel Estrada wrote: > def function(): > x = int(raw_input("Enter value of x: ")) > y = int(raw_input("Enter value of y: ")) > z = x / y > print "The value of z is", z, "unit of measurement" > > > Now, say, user input: > > x = 200 > y = 1000 > > The value

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread Alan Gauld
> Heh, you and me both. I cut my teeth on IBM System/370 assembler. > Last > time I had a job where I actually did programming as part of it, it > was > System/390 machine code. That's right, machine code, not assembler; > I'd > directly type my hexadecimal programs into low storage at the >

Re: [Tutor] How do I create the equivalent of a Java class in Python?

2006-05-16 Thread Orri Ganel
Alan Gauld wrote: > > How do I create the equivalent of a Java class in Python? I've been > looking > > at the reference, and it's been confusing to me at least. > > Adapted from my book: > > Java code: > > class Msg{ >private String txt; >public Msg(String s){ > this.txt = s;

Re: [Tutor] Division operation

2006-05-16 Thread Alan Gauld
> You can include the following in your program (I often do) if you > want > division to operate the way you expect: > from __future__ import division > Or you can do an explicit float conversion inside your function if you don't want the import effect. def f(x,y): returm float(x)/y Thi

Re: [Tutor] Bit-level field extraction

2006-05-16 Thread Alan Gauld
>> VMASK = 0x14 # 00011000 > > Whoops, a typo I think. VMASK = 0x18 #00011000 > orVMASK = 0x14 #00010100 A typo is being kind. A mistake in reality, that's what happens when I don't have a Python session handy! :-) Fortunately Terry knew what I meant. Alan G.

[Tutor] New programmer, need some help getting started on my first project

2006-05-16 Thread Chris Delgado
Hello all, I have been studying python tutorials and have a couple beginning python books that I have worked through. I have a very specific project in mind and I want to ask a couple questions. The project in question is this:I am making a Hand History converter for online poker players. This take

Re: [Tutor] Running Java process doesn't return to subprocess.call (fwd)

2006-05-16 Thread Danny Yoo
> I actually changed that just before I sent the email to tutor, cause I'd > seen a reference on the web about a Java process in Zope hanging. And > the fix was to have errfile set to None. It did NOT fix the problem. It > actually cause a Java Expection now! :-( Hi Jerome, [Please keep tutor@

Re: [Tutor] How do I create the equivalent of a Java class in Python?

2006-05-16 Thread Alan Gauld
> Erm. Shouldn't that be the following? > > class Msg: > def __init__(self,s): > self.s = s > def say(self): > if *not *self.s: print "No message" > else: print self.s Yep, its my week for making mistakes. Although this one was just a typo... My only excuse is that I'm really

Re: [Tutor] New programmer, need some help getting started on my first project

2006-05-16 Thread Alan Gauld
> I am making a Hand History converter for online poker players. > This takes the textual record of how a hand played and turns > into a more readable format suitable for posting at various websites > where people discuss how the hand was played. Id like to start > with the converter working for on

[Tutor] Solution found for option parser

2006-05-16 Thread Andrew Robert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi everyone, Just to be complete, I figured I would share the solution to use option parser for both command line and configuration file option passing. I hope it may be of use to someone in the future. parser = OptionParser() if len(sys.argv) ==

Re: [Tutor] New programmer, need some help getting started on my first project

2006-05-16 Thread Chris Delgado
Alan, First off, thanks for the detailed reply, it is much appreciated. On to your message:>I don't know anything about poker but in general terms this is>a text format conversion tool. since you know the source can>be in different formats I'd adopt an OOP approach with a generic>hand object which

[Tutor] python simulations - saving state

2006-05-16 Thread sarahjm
Hi, I am fairly new to programming in python, but for work I am running a simulation of a distribution center. What I am trying to do now is to save the state of the simulation (i.e. the event list and any other necessary variables) so that it can be "restored" later. I eventually want to be abl

Re: [Tutor] python simulations - saving state

2006-05-16 Thread Carlos Daniel Ruvalcaba Valenzuela
Depends, you can pickle the list, but all objects need to be pickleable, maybe you can put up with this requeriment by changing your events to be pickleable?, but i don't know what data you store in a event or what kind of data is it. Regards On 5/16/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrot

[Tutor] about calling external program in Python

2006-05-16 Thread Mu Mu
Dear all,   I'm trying to call an executable program in Python. I did the following, but it doesn't work. Any help is appreciated.   os.system('C:\Program Files\EPANET2\epanet2d.exe  C:\simulation test\Network3_1.inp  C:\simulation test\Network3_1.out')     Thanks.   J. _