Re: [Tutor] New to this

2010-06-20 Thread Alex Hall
On 6/20/10, Steven D'Aprano wrote: > On Mon, 21 Jun 2010 09:02:55 am Alex Hall wrote: >> On 6/20/10, Neil Thorman wrote: > [...] >> inp = file("menu.txt", "r") >> > >> > *What is inp? What does it now contain?* >> >> It is now a reference to the location of the txt file. > > [pedantic] > No,

Re: [Tutor] New to this

2010-06-20 Thread Steven D'Aprano
On Mon, 21 Jun 2010 09:02:55 am Alex Hall wrote: > On 6/20/10, Neil Thorman wrote: [...] > inp = file("menu.txt", "r") > > > > *What is inp? What does it now contain?* > > It is now a reference to the location of the txt file. [pedantic] No, it's actually an abstract data structure that wrap

Re: [Tutor] Data exchange formats...

2010-06-20 Thread Steven D'Aprano
On Mon, 21 Jun 2010 09:01:12 am Modulok wrote: > List, > > What's the best format to send data across the wire between > processes? Consider json or yaml. json comes in the standard library, at least in version 2.6; yaml does not. I don't know if they are secure, but it's worth checking. If you

Re: [Tutor] New to this

2010-06-20 Thread Alan Gauld
"Neil Thorman" wrote This is from Alan Gauld's Learning to Program: Handling Files. http://www.freenetpages.co.uk/hp/alan.gauld/ One other thing. That page is now quite old and out of date. You should switch to the current web site: http://www.alan-g.me.uk/ inp = file("menu.txt", "r")

Re: [Tutor] Data exchange formats...

2010-06-20 Thread Alan Gauld
"Modulok" wrote What's the best format to send data across the wire between processes? That depends on what you measure as 'best' - data volume, speed of transmission, security, data complexity, flexibility, ease of decoding etc etc. a server via a TCP socket. Things like 'count = 10, nam

Re: [Tutor] New to this

2010-06-20 Thread Alan Gauld
"Neil Thorman" wrote inp = file("menu.txt", "r") *What is inp? What does it now contain?* print inp.readlines() ['spam & eggs\n', 'spam & chips\n', 'spam & spam'] but if I do it again I get: print inp.readlines() [] I'm baffled, why is inp now empty? OK, I've been asked thios before

Re: [Tutor] New to this

2010-06-20 Thread Adam Bark
On 20 June 2010 19:38, Neil Thorman wrote: > I'm picking this up as a hobby really, not having done any programming > since Acorn I'm pretty much starting form scratch (and even back in the > BASIC day I never really got to grips with files). > This is from Alan Gauld's Learning to Program: Handl

Re: [Tutor] Converting audio samples from 16-bit signed int to float?

2010-06-20 Thread Adam Bark
On 20 June 2010 23:52, Joe Veldhuis wrote: > Hello all. I'm writing a program that needs to capture audio from a > soundcard and run FFTs to determine peak frequency for further processing. > The soundcard's native capture format is 16-bit little-endian signed integer > samples (values 0-65535),

Re: [Tutor] New to this

2010-06-20 Thread Alex Hall
On 6/20/10, Neil Thorman wrote: > I'm picking this up as a hobby really, not having done any programming since > Acorn I'm pretty much starting form scratch (and even back in the BASIC day > I never really got to grips with files). > This is from Alan Gauld's Learning to Program: Handling Files. >

[Tutor] Data exchange formats...

2010-06-20 Thread Modulok
List, What's the best format to send data across the wire between processes? I have some simple 'insensitive' data I need to send from a client, to a server via a TCP socket. Things like 'count = 10, name="foo"' and so forth. Basic values. I would use something like the 'pickle' module to pack th

[Tutor] New to this

2010-06-20 Thread Neil Thorman
I'm picking this up as a hobby really, not having done any programming since Acorn I'm pretty much starting form scratch (and even back in the BASIC day I never really got to grips with files). This is from Alan Gauld's Learning to Program: Handling Files. http://www.freenetpages.co.uk/hp/alan.gaul

[Tutor] Converting audio samples from 16-bit signed int to float?

2010-06-20 Thread Joe Veldhuis
Hello all. I'm writing a program that needs to capture audio from a soundcard and run FFTs to determine peak frequency for further processing. The soundcard's native capture format is 16-bit little-endian signed integer samples (values 0-65535), and of course the FFT function requires floating-

Re: [Tutor] How to add extra Vbox fields dynamically

2010-06-20 Thread Lang Hurst
OK, figured that was probably bad etiquette, but there doesn't seem to be close to the same traffic. Mea culpa. I won't do it again. I think most of my issues have to do with the gtk part, so I'll post there for the most part. Thanks. Timo wrote: On 20-06-10 04:04, Lang Hurst wrote: OK, I

Re: [Tutor] Question

2010-06-20 Thread Alan Gauld
"Payal" wrote Hijacking the thread a bit. What about learning Jython and Python? Do I need to know Java to learn Jython? No, but you will need to know the class heirarchy and reading the documentation will be difficulty without at least a basic knowledge of the Java syntax. Also you will pro

Re: [Tutor] Question

2010-06-20 Thread Alan Gauld
"Mark Lawrence" wrote ...I take issue with this "learn a language in five minutes" bit. It took me five years to get to grips with plain old C. C is non trivial but not hard (certainly compared to C++) But 5 years is enough to do a lot more than "get to grips with" a language, that's what I'd

Re: [Tutor] Extracting xml text

2010-06-20 Thread Stefan Behnel
T.R. D., 20.06.2010 16:04: I decided to go with iterparse but trying the simple example in the python interpreter led to an error (see below) and when I tried this with a much larger xml sample, it seemed to print the full elements, not the specific values of the element. For example, given what

Re: [Tutor] Extracting xml text

2010-06-20 Thread T.R. D.
Thanks all for your help. I decided to go with iterparse but trying the simple example in the python interpreter led to an error (see below) and when I tried this with a much larger xml sample, it seemed to print the full elements, not the specific values of the element. For example, given what I

Re: [Tutor] Question

2010-06-20 Thread Alan Gauld
"Steven D'Aprano" wrote Yea I took an intro to comp sci class(like 2 years ago) and a computer programming logic class(also like 2 years ago) both using pseudocode Good grief! How do they teach a class in computer programming using pseudocode??? Yes, doing that 2 years ago seems odd. OTOH W

Re: [Tutor] Question

2010-06-20 Thread bob gailer
On 6/20/2010 5:59 AM, Payal wrote: On Sat, Jun 19, 2010 at 11:24:44AM +, ALAN GAULD wrote: Actually that's a point. I favour learning two languages that are semantically similar buut syntactically different. Thats why I chose JavaScript and VBScript as my tutorial languages, because the

Re: [Tutor] Tutor Digest, Vol 76, Issue 57

2010-06-20 Thread Edward Lang
e tutor-requ...@python.org wrote: >Send Tutor mailing list submissions to > tutor@python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor >or, via email, send a message with subject or body 'help' to > tutor-requ...

[Tutor] (no subject)

2010-06-20 Thread Edward Lang
A ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] re.sub() query

2010-06-20 Thread Mark Lawrence
On 20/06/2010 10:54, Payal wrote: Hi, Is it possible to solve the below, w/o making a re object? a 'Mary Had a Little Lamb' p=re.compile('l',re.I) re.sub(p,'-',a) 'Mary Had a -itt-e -amb' I cannot figure how to se re.I w/o involving p. Thanks. With warm regards, -Payal You can do this.

Re: [Tutor] re.sub() query

2010-06-20 Thread Payal
On Sun, Jun 20, 2010 at 12:03:47PM +0200, Evert Rol wrote: > >>> re.sub('(?i)l', '-', a) > > See http://docs.python.org/library/re.html#regular-expression-syntax , search > for iLmsux, which provide flags inside the regex. Goodness that was fast. Thanks a lot Evert. For records, >>> re.sub('l(

Re: [Tutor] re.sub() query

2010-06-20 Thread Evert Rol
> Is it possible to solve the below, w/o making a re object? > a > 'Mary Had a Little Lamb' p=re.compile('l',re.I) re.sub(p,'-',a) > 'Mary Had a -itt-e -amb' > > I cannot figure how to se re.I w/o involving p. Would this work? >>> re.sub('(?i)l', '-', a) See http://docs.python.o

Re: [Tutor] Question

2010-06-20 Thread Payal
On Sat, Jun 19, 2010 at 11:24:44AM +, ALAN GAULD wrote: > Actually that's a point. I favour learning two languages that are > semantically > similar buut syntactically different. Thats why I chose JavaScript and > VBScript > as my tutorial languages, because the syntax of each is so differe

[Tutor] re.sub() query

2010-06-20 Thread Payal
Hi, Is it possible to solve the below, w/o making a re object? >>> a 'Mary Had a Little Lamb' >>> p=re.compile('l',re.I) >>> re.sub(p,'-',a) 'Mary Had a -itt-e -amb' I cannot figure how to se re.I w/o involving p. Thanks. With warm regards, -Payal --

Re: [Tutor] How to add extra Vbox fields dynamically

2010-06-20 Thread Timo
On 20-06-10 04:04, Lang Hurst wrote: OK, I just did the ugliest hack, from someone who only seems to do ugly hacks. I set up a bunch of textview areas and defaulted them to 'not visible'. Then as I loop through my query results, I make them visible one at a time. Well, it works perfect, but

Re: [Tutor] Extracting xml text

2010-06-20 Thread Stefan Behnel
Hi, please don't top-post, it makes your replies hard to read in context. Karim, 20.06.2010 10:24: On 06/20/2010 10:14 AM, Stefan Behnel wrote: Use ElementTree's iterparse: from xml.etree.cElementTree import iterparse >> [...] > I know you are promoting Etree and I am very interesting in it

Re: [Tutor] Extracting xml text

2010-06-20 Thread Karim
Hello Stefan, I know you are promoting Etree and I am very interesting in it. Is there any chance to have it integrated in future standard Python version? Regards Karim On 06/20/2010 10:14 AM, Stefan Behnel wrote: T.R. D., 20.06.2010 08:03: I'm trying to parse a list of xml strings and so fa

Re: [Tutor] Extracting xml text

2010-06-20 Thread Karim
In fact you must initialize the handler before parsing the xml doc and it should work. Regards Karim France On 06/20/2010 10:12 AM, Karim wrote: Hello, The following is an example which works for me to count opening tags in a xml doc, if it can help: # -*- coding: iso-8859-1 -*- import

Re: [Tutor] Extracting xml text

2010-06-20 Thread Stefan Behnel
T.R. D., 20.06.2010 08:03: I'm trying to parse a list of xml strings and so far it looks like the xml.parsers.expat is the way to go but I'm not quite sure how it works. I'm trying to parse something similar to the following. I'd like to collect all headings and bodies and associate them in a v

Re: [Tutor] Extracting xml text

2010-06-20 Thread Karim
Hello, The following is an example which works for me to count opening tags in a xml doc, if it can help: # -*- coding: iso-8859-1 -*- import sys from xml.parsers.expat import ParserCreate n = 0 def start_element(name, attrs): # callback declaration global n n += 1 parser =

[Tutor] Extracting xml text

2010-06-20 Thread T.R. D.
Hi, I'm trying to parse a list of xml strings and so far it looks like the xml.parsers.expat is the way to go but I'm not quite sure how it works. I'm trying to parse something similar to the following. I'd like to collect all headings and bodies and associate them in a variable (dictionary for