Re: [Tutor] Convert values in a list back and forth from ints

2009-01-07 Thread prasad rao
. class Value:def __init__(self, vs = ""): >... self.vs = vs >... self.v = self.asInt() >...def asInt(self): >... try: self.v = int(self.vs) >... except: self.v = None >... return self.v >...def asString(self): >...vs = str(self.vs) >...

Re: [Tutor] Getting multi-line input from user

2009-01-07 Thread Alan Gauld
"wormwood_3" wrote On point 2, say I enter: Enter text, 'done' on its own line to quit: I am a sentence. I am another sentence. I am a new paragraph. done What I get out is: I am a sentence. I am another sentence. I am a new paragraph. But that just shows the double new lines of my new par

Re: [Tutor] Getting multi-line input from user

2009-01-07 Thread Alan Gauld
"Andre Engels" wrote The newline character is written \n in Python, so if you replace ' '.join(user_input) by '\n'.join(user_input) Yep, that's better than my suggestion of adding the \n at append time. :-) Alan G. ___ Tutor maillist - Tu

[Tutor] SMTP Module Help

2009-01-07 Thread Marco Petersen
I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send an email through my Gmail account but it keeps saying that the connection was refused. This is the code that I used : import smtplib msg = 'Test' server = smtplib.SMTP('smtp.gmail.com') server.set_debuglevel(1) serv

Re: [Tutor] Convert values in a list back and forth from ints

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 9:45 AM, prasad rao wrote: > hello > Sorry to interject. > This class seems asymmetric. > Class Value: > def __init__(self,inte='',stri=''): > self.inte=inte > self.stri=stri > def setvalue(inte='',stri=''): > self.stri=str(self.inte) >

[Tutor] re

2009-01-07 Thread prasad rao
Hello I am trying to get a value as integer and a string. >>> class Value: def __init__(self,inte='',stri=''): self.inte=inte self.stri=stri def setvalue(self,inte='',stri=''): self.stri=str(self.inte) self.inte=int(self.stri) >>> v=Value(45) >>>

[Tutor] good day

2009-01-07 Thread Kgotlelelo Legodi
good day I just started using python and i want to know how can i solve a boundary value problem for ordinary differential equations using shooting method in python.use the general equation to demonstrate the python code. Thank you -- This message is subject to the CSIR's copyright terms and

Re: [Tutor] re

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 10:57 AM, prasad rao wrote: > Hello > I am trying to get a value as integer and a string. class Value: > def __init__(self,inte='',stri=''): > self.inte=inte > self.stri=stri > def setvalue(self,inte='',stri=''): > self.stri=str(

Re: [Tutor] Interactive programming.

2009-01-07 Thread A.T.Hofkamp
WM. wrote: Norman Khine wrote: >>> i = 5 >>> j = 7 >>> if i <= j: ... print 'nudge', 'nudge' ... else: ... print 'whatever' ... nudge nudge >>> Yes, I understand how your program works. What I do not understand is how you got it. My program came out in IDLE as you see it. No ..

Re: [Tutor] good day

2009-01-07 Thread A.T.Hofkamp
Kgotlelelo Legodi wrote: good day I just started using python and i want to know how can i solve a boundary value problem for ordinary differential equations using shooting method in python.use the general equation to demonstrate the python code. I have no background in numeric calculations,

Re: [Tutor] SMTP Module Help

2009-01-07 Thread A.T.Hofkamp
Marco Petersen wrote: I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send an email through my Gmail account but it keeps saying that the connection was refused. This is the code that I used : import smtplib msg = 'Test' server = smtplib.SMTP('smtp.gmail.com') server

[Tutor] linked list with cycle structure

2009-01-07 Thread David Hláčik
Hello guys, I have a linked list where *number of elements is unlimited* and **last element points on random (can be first, last, in middle , anywhere) element within linked list** - this is important . My goals is to create an architecture /scheme for **algoritmus which will count total number of

[Tutor] Brand new to python have simple problem

2009-01-07 Thread mickth
I'm brand new to python and every time i start to learn it i get the same problem and end up giving up and moving on to another language. the print statement doesn't work in either the comand line or IDLE i get this in IDLE: SyntaxError: invalid syntax (, line 1) and just SyntaxError: invalid sy

Re: [Tutor] Opening a window to fit an image

2009-01-07 Thread Michael Lam
I got a similar problem, except that calling it twice wouldn't work for me. I tried looking everywhere and I seemed to be doing everything exactly like other people. After fiddling around, I got this order: pygame.init() pygame.display.set_icon(pygame.image.load("image.bmp")) window

Re: [Tutor] Interactive programming.

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 5:28 AM, A.T.Hofkamp wrote: > WM. wrote: >> >> Norman Khine wrote: >>> >>> >>> i = 5 >>> >>> j = 7 >>> >>> if i <= j: >>> ... print 'nudge', 'nudge' >>> ... else: >>> ... print 'whatever' >>> ... >>> nudge nudge >>> >>> > >> Yes, I understand how your program wor

[Tutor] shooting method in python code

2009-01-07 Thread Kgotlelelo Legodi
good day I just started using python and i want to know how can i solve a boundary value problem for ordinary differential equations using shooting method in python.use the general equation to demonstrate the python code. Thank you Kgotlelelo Legodi Natural Resources and the Environment CSIR 0

Re: [Tutor] linked list with cycle structure

2009-01-07 Thread A.T.Hofkamp
David Hláčik wrote: Hello guys, I have a linked list where *number of elements is unlimited* and **last element points on random (can be first, last, in middle , anywhere) element within linked list** - this is important . My goals is to create an architecture /scheme for **algoritmus which will

Re: [Tutor] Brand new to python have simple problem

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 7:06 AM, mickth wrote: > > I'm brand new to python and every time i start to learn it i get the same > problem and end up giving up and moving on to another language. > > the print statement doesn't work in either the comand line or IDLE i get > this in IDLE: > SyntaxError:

Re: [Tutor] good day

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 4:46 AM, Kgotlelelo Legodi wrote: > good day > > I just started using python and i want to know how can i solve a boundary > value problem for ordinary differential equations using shooting method in > python.use the general equation to demonstrate the python code. Googli

Re: [Tutor] SMTP Module Help

2009-01-07 Thread Kent Johnson
On Tue, Jan 6, 2009 at 4:45 AM, Marco Petersen wrote: > I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send > an email through my Gmail account but it keeps saying that the connection > was refused. > > This is the code that I used : > > import smtplib > msg = 'Test' > > >

Re: [Tutor] Interactive programming.

2009-01-07 Thread A.T.Hofkamp
Kent Johnson wrote: On Wed, Jan 7, 2009 at 5:28 AM, A.T.Hofkamp wrote: WM. wrote: Norman Khine wrote: >>> i = 5 >>> j = 7 >>> if i <= j: ... print 'nudge', 'nudge' ... else: ... print 'whatever' ... nudge nudge >>> Yes, I understand how your program works. What I do not understa

Re: [Tutor] linked list with cycle structure

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 5:59 AM, David Hláčik wrote: > Hello guys, > > I have a linked list where *number of elements is unlimited* and > **last element points on random (can be first, last, in middle , > anywhere) element within linked list** - this is important . My goals > is to create an archit

Re: [Tutor] Brand new to python have simple problem

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 1:06 AM, mickth wrote: > > I'm brand new to python and every time i start to learn it i get the same > problem and end up giving up and moving on to another language. > > the print statement doesn't work in either the comand line or IDLE i get > this in IDLE: > SyntaxError:

Re: [Tutor] Getting multi-line input from user

2009-01-07 Thread wormwood_3
Joining with newline works perfectly. Thanks everyone! ___ Samuel Huckins Homepage - http://samuelhuckins.com Tech blog - http://dancingpenguinsoflight.com/ Photos - http://www.flickr.com/photos/samuelhuckins/ AIM - samushack | Gtalk - samushack | Skype - shuckins

Re: [Tutor] SMTP Module Help

2009-01-07 Thread Ole Henning Jensen
Marco Petersen wrote: I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send an email through my Gmail account but it keeps saying that the connection was refused. This is the code that I used : import smtplib msg = 'Test' server = smtplib.SMTP('smtp.gmail.com') server

[Tutor] New to tkSnack

2009-01-07 Thread CHATURVEDI ALPANA
Hi All, I am very new to tkSnack. Trying to understand it. Please help me out. I thought of a very simple scenario. I would like to play a audio from line-in and then check if the audio is present. If there is no audio for 20 seconds then i need to raise an error. Is it possible to do this wi

Re: [Tutor] SMTP Module Help

2009-01-07 Thread Damon Timm
On 1/6/09, Marco Petersen wrote: > I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send > an email through my Gmail account but it keeps saying that the connection > was refused. I used this example to get emailing from python through gmail smtp to work: http://codecommen

Re: [Tutor] SMTP Module Help

2009-01-07 Thread Chris Babcock
On Wed, 07 Jan 2009 15:47:25 +0100 Ole Henning Jensen wrote: > Marco Petersen wrote: > > I'm using Python 2.5.4. I wanted to try out the SMTP module. I > > tried to send an email through my Gmail account but it keeps saying > > that the connection was refused. > > error: (10061, 'Connection refu

[Tutor] df type function in python

2009-01-07 Thread Spencer Parker
I am looking for a function in python that would operate similar to df. I would use df, but I am unable to parse the data that it gives me from there. If it would give me a single line I could then split it out if I needed to, but I can't see how to actually do that. What I am trying to do is ge

Re: [Tutor] Interactive programming.

2009-01-07 Thread WM.
IDLE 2.6 >>> i = 1 >>> j = 11 >>> if j > 1: print j else: SyntaxError: invalid syntax >>> I am getting a little dizzy here. I know about text editor, code, save, F5. Many tutorials say that it is funner and faster to test an idea 'interactively', using IDLE.

Re: [Tutor] good day

2009-01-07 Thread Luke Paireepinart
On Wed, Jan 7, 2009 at 4:35 AM, A.T.Hofkamp wrote: > Kgotlelelo Legodi wrote: >> >> good day >> >> I just started using python and i want to know how can i solve a boundary > > value problem for ordinary differential equations using shooting method in > python.use the general equation to demonstra

Re: [Tutor] Interactive programming.

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 11:46 AM, WM. wrote: > IDLE 2.6 i = 1 j = 11 if j > 1: >print j >else: > > SyntaxError: invalid syntax > > I am getting a little dizzy here. > > I know about text editor, code, save, F5. > > Many tutorials say that it is funner and faster

Re: [Tutor] Interactive programming.

2009-01-07 Thread Edwin Boyette
--- On Wed, 1/7/09, WM. wrote: From: WM. Subject: Re: [Tutor] Interactive programming. To: "A.T.Hofkamp" Cc: tutor@python.org Date: Wednesday, January 7, 2009, 11:46 AM IDLE 2.6 >>> i = 1 >>> j = 11 >>> if  j > 1:     print j     else:         SyntaxError: invalid syntax >>> I am getting

Re: [Tutor] df type function in python

2009-01-07 Thread Spencer Parker
Is there anyway to get rid of the header information? I just want the output that it gives me for the device. On Wed, Jan 7, 2009 at 11:02 AM, Stuart Sears wrote: > On 07/01/09 16:42, Spencer Parker wrote: > >> I am looking for a function in python that would operate similar to df. >> I would

Re: [Tutor] df type function in python

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 1:08 PM, Spencer Parker wrote: > Is there anyway to get rid of the header information? I just want the > output that it gives me for the device. If you know how to get the output of df into Python (e.g. with the subprocess module or a pipe) then you can use the str.splitli

Re: [Tutor] df type function in python

2009-01-07 Thread Spencer Parker
What I did was just grep for anything starting with "/" It then just outputs it to a single line now...and I can split it as needed. Thanks again!!1 On Wed, Jan 7, 2009 at 11:33 AM, Kent Johnson wrote: > On Wed, Jan 7, 2009 at 1:08 PM, Spencer Parker > wrote: > > Is there anyway to get rid of

Re: [Tutor] df type function in python

2009-01-07 Thread Stuart Sears
Redirecting to the list as I seem to have replied off-list rather inadvertently... headers...> On 07/01/09 16:42, Spencer Parker wrote: I am looking for a function in python that would operate similar to df. I would use df, but I am unable to parse the data that it gives me from there. If it

Re: [Tutor] df type function in python

2009-01-07 Thread Stuart Sears
On 07/01/09 18:08, Spencer Parker wrote: Is there anyway to get rid of the header information? I just want the output that it gives me for the device. parse the output and junk the first line? I'm no subprocess expert, but a bit of playing about suggests this would work: from subprocess impo

Re: [Tutor] df type function in python

2009-01-07 Thread Roel Schroeven
Spencer Parker schreef: > I am looking for a function in python that would operate similar to df. > I would use df, but I am unable to parse the data that it gives me from > there. If it would give me a single line I could then split it out if I > needed to, but I can't see how to actually do tha

[Tutor] Opsware Global Shell Scripting

2009-01-07 Thread Kayvan Sarikhani
Hi there...I'm new to Python scripting, with maybe 3 days under my belt thus far. Besides the occasional shell script, the last time I ever touched a programming language was probably at least 12 years ago, if that gives you any indication of my experience. :) I don't know if this is the proper pl

Re: [Tutor] Interactive programming.

2009-01-07 Thread WM.
Norman Khine wrote: >>> i = 5 >>> j = 7 >>> if i <= j: ... print 'nudge', 'nudge' ... else: ... print 'whatever' ... nudge nudge The above is just what the tutorials said would happen. Can anyone give me a step-by-step in IDLE 2.6 that would make this happen? __

Re: [Tutor] Opsware Global Shell Scripting

2009-01-07 Thread Sander Sweers
On Wed, Jan 7, 2009 at 22:04, Kayvan Sarikhani wrote: > #!/usr/bin/python > import os, sys > sys.stdout = open('timecheck.txt','w') > for servername in os.listdir('/opsw/Server/@'): > print '---', servername > os.system('rosh -n $SERVER_NAME -l $LOGNAME') > os.system('date') > sys.stdo

Re: [Tutor] linked list with cycle structure

2009-01-07 Thread David Hláčik
Hi, so okay, i will create a helping set, where i will be adding elements ID, when element ID will be allready in my helping set i will stop and count number of elements in helping set. This is how long my cycled linked list is. But what if i have another condition , and that is *i can use only h

Re: [Tutor] Interactive programming.

2009-01-07 Thread Sander Sweers
On Wed, Jan 7, 2009 at 22:45, WM. wrote: > Norman Khine wrote: >> >> >>> i = 5 >> >>> j = 7 >> >>> if i <= j: >> ... print 'nudge', 'nudge' >> ... else: >> ... print 'whatever' >> ... >> nudge nudge > > The above is just what the tutorials said would happen. > Can anyone give me a step-

Re: [Tutor] Interactive programming.

2009-01-07 Thread WM.
IDLE 2.6 >>> i = 1 >>> if i > 1: print 'x' else: print 'y' y >>> Last post on this topic, I guess. I think that the script looks pretty lame, though. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinf

Re: [Tutor] Interactive programming.

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 4:45 PM, WM. wrote: > Norman Khine wrote: >> >> >>> i = 5 >> >>> j = 7 >> >>> if i <= j: >> ... print 'nudge', 'nudge' >> ... else: >> ... print 'whatever' >> ... >> nudge nudge > > The above is just what the tutorials said would happen. > Can anyone give me a ste

Re: [Tutor] Interactive programming.

2009-01-07 Thread Kent Johnson
On Wed, Jan 7, 2009 at 5:36 PM, WM. wrote: > IDLE 2.6 i = 1 if i > 1: >print 'x' > else: >print 'y' > > > y > Last post on this topic, I guess. > I think that the script looks pretty lame, though. It was always lame :-) but you got it to work... Kent __

Re: [Tutor] Opsware Global Shell Scripting

2009-01-07 Thread Kayvan Sarikhani
On Wed, Jan 7, 2009 at 4:57 PM, spir wrote: > Le Wed, 7 Jan 2009 16:04:28 -0500, > "Kayvan Sarikhani" a écrit : > > > #!/bin/bash > > # > > # This script checks the dates on all managed systems. > > OUTFILE="/home/ksarikhani/public/bin/timecheck.txt" > > rm -f $OUTFILE > > cd "/opsw/Server/@/" >

Re: [Tutor] Opsware Global Shell Scripting

2009-01-07 Thread Kayvan Sarikhani
On Wed, Jan 7, 2009 at 5:09 PM, Sander Sweers wrote: > On Wed, Jan 7, 2009 at 22:04, Kayvan Sarikhani > wrote: > > > > This is of course not a Python error, but as you might guess from looking > at > > the script, the whole $SERVER_NAME piece is probably wrong. > > Indeed the variables are wrong

Re: [Tutor] Interactive programming.

2009-01-07 Thread Edwin Boyette
Don't try to make interactive programming something its not. It's handy if you have something short to try out, want to evaluate a function at some value etc.  Don't rage at the hammer for not being an allen wrench get an allen wrench. --- On Wed, 1/7/09, Kent Johnson wrote: From: Kent

[Tutor] Can subprocess run functions ?

2009-01-07 Thread Damon Timm
Hi everyone - I was playing with subprocess (with some success, I might add) to implement threading in my script (audio conversion). My goal is to be able to spawn off threads to make use of my multiprocessor system (and speed up encoding). With your help, I was successful. Anyhow, subprocess is

Re: [Tutor] linked list with cycle structure

2009-01-07 Thread Robert Kern
Terry Reedy wrote: David Hláčik wrote: But what if i have another condition , and that is *i can use only helping memory with constant size* ? This means i am not able to create any set and adding elements there. I need to have a constant size variables . This is complication a complication for

Re: [Tutor] Can subprocess run functions ?

2009-01-07 Thread wesley chun
> Anyhow, subprocess is working -- but I wonder if there is a way I can > send the entire *function* into its own subprocess ? this has been a highly-desired feature for quite awhile. starting in 2.6, you can use the new multiprocessing module (originally called pyprocessing): http://docs.python

Re: [Tutor] Can subprocess run functions ?

2009-01-07 Thread Damon Timm
On Wed, Jan 7, 2009 at 7:36 PM, wesley chun wrote: > this has been a highly-desired feature for quite awhile. > > starting in 2.6, you can use the new multiprocessing module > (originally called pyprocessing): > http://docs.python.org/library/multiprocessing.html > > there is a backport to 2.4 and

Re: [Tutor] Interactive programming.

2009-01-07 Thread Alan Gauld
"Edwin Boyette" wrote Don't try to make interactive programming something its not. It's handy if you have something short to try out, want to evaluate a function at some value etc. Don't rage at the hammer for not being an allen wrench But in this case it is a valid complaint. Almost every

Re: [Tutor] Opsware Global Shell Scripting

2009-01-07 Thread Alan Gauld
"Kayvan Sarikhani" wrote For the record, $LOGNAME works fine as a variable...it's a standard env variable in Linux to display the current user's username. In that case os.getenv('LOGNAME') should retrieve it for you HTH, -- Alan Gauld Author of the Learn to Program web site http://www.al

[Tutor] simple array access

2009-01-07 Thread Artie Ziff
Hello, I used python list comprehension to create a grid (list of lists) of Objects (instances of MyItem class). Can anyone make recommendations to achieve a simple access to the elements. My attempt at array access (like this: array[1,2] ) does not work. What am I overlooking? Thanks in advance!

Re: [Tutor] simple array access

2009-01-07 Thread jadrifter
On Wed, 2009-01-07 at 18:12 -0800, Artie Ziff wrote: > Hello, > > I used python list comprehension to create a grid (list of lists) of > Objects (instances of MyItem class). Can anyone make recommendations to > achieve a simple access to the elements. My attempt at array access > (like this: array

Re: [Tutor] simple array access

2009-01-07 Thread wesley chun
> My attempt at array access (like this: array[1,2] ) does not work. What am > I overlooking? Thanks in advance! :) > : > pprint (grid.data[1,2]) is that really your name?!? you're famous! ;-) welcome to python! i'd try... pprint(grid.data[0][1]) ... as many languages start counting at 0

[Tutor] variable number of inputs

2009-01-07 Thread Mr Gerard Kelly
How can you make a function accept a variable number of inputs without any particular limit? Like when you define a function you usually go: def func(a,b,c,d,e) and if you want to give a default value for e you can use e=0 for example. But what if you want to be able to call the function and pu

Re: [Tutor] variable number of inputs

2009-01-07 Thread bob gailer
Mr Gerard Kelly wrote: How can you make a function accept a variable number of inputs without any particular limit? Like when you define a function you usually go: def func(a,b,c,d,e) and if you want to give a default value for e you can use e=0 for example. But what if you want to be able to

Re: [Tutor] variable number of inputs

2009-01-07 Thread wesley chun
On Wed, Jan 7, 2009 at 7:01 PM, bob gailer wrote: > Mr Gerard Kelly wrote: >> >> How can you make a function accept a variable number of inputs without >> any particular limit? >>: >> But what if you want to be able to call the function and put in as many >> arguments as you want. > > def

Re: [Tutor] simple array access

2009-01-07 Thread Edwin Boyette
--- On Wed, 1/7/09, Artie Ziff wrote: From: Artie Ziff Subject: [Tutor] simple array access To: Tutor@python.org Date: Wednesday, January 7, 2009, 9:12 PM Hello, I used python list comprehension to create a grid (list of lists) of Objects (instances of MyItem class). Can anyone make recomm