Re: [Tutor] Raw Bits! (Control characters ahoy!)

2006-04-17 Thread Hugo González Monteverde
doug shawhan wrote: > I am in the middle of a project that requires me to send and retrieve > information from a machine connected to a serial port. My problems are > these: > > 1. I cannot send control characters > 2. I cannot read data streaming from the serial port > > > I have been doing f

[Tutor] Python programmer needs to learn Java

2006-04-17 Thread Justin Ezequiel
Greetings. I am seeking book recommendations or preferrably online tutorials to help me learn Java. Company under new management and most likely would be moving to Java and .NET I came from Visual Basic 6 to Python and had little problems which is why I love Python.

Re: [Tutor] Changing lists in place

2006-04-17 Thread Alan Gauld
> I have a list that I want to change in a for loop. Thats nearly always a bad thing to do. Its like the old cartoon of the guy vcutting off the branch of the tree while sitting on it. Python can get very confused. Either make a copy and change the copy or use a while loop and an index. Howe

[Tutor] Raw Bits! (Control characters ahoy!)

2006-04-17 Thread doug shawhan
I am in the middle of a project that requires me to send and retrieve information from a machine connected to a serial port. My problems are these: 1. I cannot send control characters 2. I cannot read data streaming from the serial port I have been doing fine with: os.system("echo '5' >/dev/tty

Re: [Tutor] functions in Python

2006-04-17 Thread Alan Gauld
Wow! I checked the list at lunchtime and there were only a few things here, then I check again now and lots of stuff from my tutor! Fortunately most of it has been answered already - thanks folks - but I feel honour bound to contribute something... > What is the difference between, > def

Re: [Tutor] Tutor Digest, Vol 26, Issue 55

2006-04-17 Thread Carroll, Barry
Payal: > -Original Message- > Date: Mon, 17 Apr 2006 13:24:31 -0400 > From: Payal Rathod <[EMAIL PROTECTED]> > Subject: Re: [Tutor] functions in Python > To: Steve Nelson <[EMAIL PROTECTED]> > Cc: "Python\[Tutor\]" > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=us-a

Re: [Tutor] Changing lists in place

2006-04-17 Thread Paul D. Eden
Very true. Paul Kent Johnson wrote: > Paul D. Eden wrote: > >>Lists are mutable, you are right. >> >>But the code you gave does not change the list. It changes the variable >>element which is separate from the list myList. >> >>If you want to change the list try something like this: >> >>mylis

Re: [Tutor] Changing lists in place

2006-04-17 Thread Kent Johnson
Paul D. Eden wrote: > Lists are mutable, you are right. > > But the code you gave does not change the list. It changes the variable > element which is separate from the list myList. > > If you want to change the list try something like this: > > mylist = [ 'One', ' two', ' three ' ]

Re: [Tutor] Meaning of %g ?

2006-04-17 Thread Terry Carroll
On Mon, 17 Apr 2006, Alan Gauld wrote: > a = 123456.78 > print "%g\n%e\n%f" % (a,a,a) > > 123457 > > 1.234568e+005 > > 123456.78 > > >Float number loses digits and becomes integer in the output ? > > Yep, I am rapidly coming to the comnclusion that %g is broken > in Python. I must

Re: [Tutor] Changing lists in place

2006-04-17 Thread Bob Gailer
Paul D. Kraus wrote: > I have a list that I want to change in a for loop. It changes in the > loop but the changes are not persistant outside of the loop. > I thought lists were mutuable objects They are. > so I am a bit confused. > > Sample Code > #!/usr/bin/env python > """ Testing lists ""

Re: [Tutor] Changing lists in place

2006-04-17 Thread Paul D. Eden
Lists are mutable, you are right. But the code you gave does not change the list. It changes the variable element which is separate from the list myList. If you want to change the list try something like this: mylist = [ 'One', ' two', ' three ' ] print mylist newlist = [] for elemen

[Tutor] Changing lists in place

2006-04-17 Thread Paul D. Kraus
I have a list that I want to change in a for loop. It changes in the loop but the changes are not persistant outside of the loop.I thought lists were mutuable objects so I am a bit confused.Sample Code#!/usr/bin/env python """ Testing lists """mylist = [ 'One    ', '   two', '   three   ' ]prin

Re: [Tutor] functions in Python

2006-04-17 Thread Paul D. Eden
This only happens because the python interactive command-line (what you get when you just type 'python' in a terminal window) prints return values automatically for you. If you were executing f(4) in a program/script, the return value would be lost. Paul Payal Rathod wrote: > On Mon, Apr 17,

Re: [Tutor] functions in Python

2006-04-17 Thread Danny Yoo
On Mon, 17 Apr 2006, Payal Rathod wrote: > What is the difference between, > def f(x): > ... return x > ... f(4) > 4 > def f(x): > ... print x > ... f(4) > 4 > > Both give same results. Clarification. Both "show" the same results from the interpreter. From what yo

Re: [Tutor] functions in Python

2006-04-17 Thread Danny Yoo
> Sorry, but you have confused me more ;) Can you give an simple example > of just function() ? Where can it be useful? > > And when you say it returns a value, what do you mean by that? return to > whom and what exactly? One view that's common is the idea that a function is a box that takes an

Re: [Tutor] functions in Python

2006-04-17 Thread Payal Rathod
On Mon, Apr 17, 2006 at 05:42:05PM +0100, Steve Nelson wrote: > When you define a function, you are writing a block of code which you > can ask to perform a task. The task may be simple, and not require > any additional information, or it may be more complex and need > information. What is the di

Re: [Tutor] functions in Python

2006-04-17 Thread Payal Rathod
On Mon, Apr 17, 2006 at 05:10:51PM +0100, Robert Schumann wrote: > You could say "I kick" (which is like func(), because you're not > specifying an object to operate on) or your could say "I kick the > ball" (in which case x = "the ball"). > Sorry, but you have confused me more ;) Can you give

Re: [Tutor] functions in Python

2006-04-17 Thread Robert Schumann
Payal Rathod wrote: > Hi, > I am now reading Alan's tut on Python, before that I have read a few other > tuts too. > But I am not getting functions exactly. I mean what is the difference between, > > def func(): > > > and > > def func(x): > > > When to use which? (please

Re: [Tutor] functions in Python

2006-04-17 Thread Payal Rathod
On Mon, Apr 17, 2006 at 05:02:07PM +0100, Adam wrote: > The x is a name for a value that you pass in to the function. To call > the first function you would do > >>> func() > > and the second function: > >>> func(5) # 5 is just an example it could be any value depending on > the function. Sorry b

[Tutor] functions in Python

2006-04-17 Thread Steve Nelson
Sorry - including list. On 4/17/06, Payal Rathod <[EMAIL PROTECTED]> wrote: > what is the difference between, > > def func(): > > > and > > def func(x): > When you define a function, you are writing a block of code which you can ask to perform a task. The task may be si

Re: [Tutor] functions in Python

2006-04-17 Thread Adam
On 17/04/06, Payal Rathod <[EMAIL PROTECTED]> wrote: > Hi, > I am now reading Alan's tut on Python, before that I have read a few other > tuts too. > But I am not getting functions exactly. I mean what is the difference between, > > def func(): > > > and > > def func(x): > ...

[Tutor] functions in Python

2006-04-17 Thread Payal Rathod
Hi, I am now reading Alan's tut on Python, before that I have read a few other tuts too. But I am not getting functions exactly. I mean what is the difference between, def func(): and def func(x): When to use which? (please do not say "returns a value" for I do not un

Re: [Tutor] Stack Diagrams

2006-04-17 Thread Alan Gauld
> I am referring to Stack Diagrams from> http://www.ibiblio.org/obp/thinkCSpy/chap03.htm#11>> I did not understood this, please explain me with an exampleThe diagram he goives is an example but I'll try to reiterate slightly differently.   First the context:   def printTwice(bruce):   print

Re: [Tutor] Meaning of %g ?

2006-04-17 Thread Alan Gauld
a = 123456.78 print "%g\n%e\n%f" % (a,a,a) > 123457 > 1.234568e+005 > 123456.78 >Float number loses digits and becomes integer in the output ? Yep, I am rapidly coming to the comnclusion that %g is broken in Python. I must do some tests with gcc to see what it does with %g, it may

Re: [Tutor] Didn't take long to hit my next wall!

2006-04-17 Thread Alan Gauld
>> query = '''UPDATE cost_grid >>SET cost_1 = %s >>WHERE cost_grid_id = %s >>AND finish_dro = %s % ( a,c,b) >> c.execute(query) > > Yikes! Alan! Certainly you know what an SQL injection attack is? And what > if the data contains special characte

[Tutor] Meaning of %g ?

2006-04-17 Thread Sean Lee
> >>> print "%14.3g\n%14.3e\n%14.3f" % (bignum,bignum,bignum)> 1.23e+009 >1.235e+009> 1234567898.235>> But in practice, we do not know how big is the data in advance when> doing scientific computation in a compiled program.That is irrelevant, the format you display the data in has no b

[Tutor] Stack Diagrams

2006-04-17 Thread Kaushal Shriyan
Hi All I am referring to Stack Diagrams from http://www.ibiblio.org/obp/thinkCSpy/chap03.htm#11 I did not understood this, please explain me with an example Thanks in Advance Regards Kaushal ___ Tutor maillist - Tutor@python.org http://mail.python.

Re: [Tutor] School Boy Error - Update

2006-04-17 Thread Liam Clarke
Dude, you've still got your trailing comma in stat. Get rid of it. If I jump into MySQL, here's an example - create table a (a int, b int); OK insert into a values (5, 4); OK insert into a values(5, 4,); Syntax error Try something like this - it's more scalable too. def generateSQL(data):