Re: [Tutor] input with default value option

2006-04-10 Thread Danny Yoo
> With raw_input(), it allows to input value. Can it be used to input > value with default value option? Hi Phon, We can build your own function to do this. Bob showed how to set up code so that the default's taken if the user just presses enter in his reply. Let's take a look at it again:

Re: [Tutor] input with default value option

2006-04-10 Thread Bob Gailer
Keo Sophon wrote: > Hi, > > With raw_input(), it allows to input value. Can it be used to input value > with default value option? > response = raw_input("Enter some data:") if not response: response = "default value" ___ Tutor maillist - Tutor@pyt

[Tutor] input with default value option

2006-04-10 Thread Keo Sophon
Hi, With raw_input(), it allows to input value. Can it be used to input value with default value option? Phon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] failing to learn python

2006-04-10 Thread Greg Lindstrom
Paypal- I do a lot of system admin type work with Python.  If you'd like, drop me a line and let me know what you're interested in learning...perhaps I could help you work through a project or two. Greg Lindstrom [EMAIL PROTECTED] ___ Tutor maillist -

[Tutor] Python for sysadmins (Was: failing to learn python)

2006-04-10 Thread Carroll, Barry
Payal: I agree with Kent: the Python Cookbook is an excellent resource. And, it has a whole section on System Administration. try this URL: http://aspn.activestate.com/ASPN/Cookbook/Python?kwd=System You can also try Google. I entered 'Python sysadmin'. Here are just a few potentially in

Re: [Tutor] failing to learn python

2006-04-10 Thread Danny Yoo
> I am a parttime sys admin so I want system admin problem which usually I > do through shell scripts like parsing logs, generating reports, greping > with regexes etc. Hi Payal, You might also find David Mertz's book "Text Processing With Python" to be useful for you: http://gnosis.cx/T

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- Matthew White <[EMAIL PROTECTED]> wrote: > Hi Hoffman, > > It is often useful to use the "for" construct to > process items in a list. > e.g.: > > >>> list1 = [ 'spam!', 2, ['Ted', 'Rock']] > >>> for item in list: > ...print item > spam! > 2 > ['Ted', 'Rock'] > > If you pass a list to

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- Terry Carroll <[EMAIL PROTECTED]> wrote: > On Mon, 10 Apr 2006, Hoffmann wrote: > > > Hello, > > > > I have a list: list1 = [ 'spam!', 2, ['Ted', > 'Rock'] > > ] > > and I wrote the script below: > > > > i = 0 > > while i < len(list1): > > print list1[i] > > i += 1 > > > > Ok. Thi

Re: [Tutor] Question about list

2006-04-10 Thread Danny Yoo
On Mon, 10 Apr 2006, Hoffmann wrote: > I also would like to print the length of each element > of that list: > > spam! = 1 element > 2 = 1 element > ['Ted', 'Rock'] = 2 elements > > Could anyone, please, give me some hints? The problem is slightly weird, just because you need to clarify what i

Re: [Tutor] Question about list

2006-04-10 Thread Terry Carroll
On Mon, 10 Apr 2006, Hoffmann wrote: > Hello, > > I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] > ] > and I wrote the script below: > > i = 0 > while i < len(list1): > print list1[i] > i += 1 > > Ok. This script will generate as the output each > element of the original list, on

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- John Fouhy <[EMAIL PROTECTED]> wrote: > Hi Hoffmann, > > On 11/04/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > I have a list: list1 = [ 'spam!', 2, ['Ted', > 'Rock'] ] > > and I wrote the script below: > > > > i = 0 > > while i < len(list1): > > print list1[i] > > i += 1 > > Have you

Re: [Tutor] Question about list

2006-04-10 Thread Matthew White
Hi Hoffman, It is often useful to use the "for" construct to process items in a list. e.g.: >>> list1 = [ 'spam!', 2, ['Ted', 'Rock']] >>> for item in list: ...print item spam! 2 ['Ted', 'Rock'] If you pass a list to the len() function, it will return the number of elenents in the list. e.g

Re: [Tutor] Question about list

2006-04-10 Thread Hoffmann
--- Adam <[EMAIL PROTECTED]> wrote: > On 10/04/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I have a list: list1 = [ 'spam!', 2, ['Ted', > 'Rock'] > > ] > > and I wrote the script below: > > > > i = 0 > > while i < len(list1): > > print list1[i] > > i += 1 > > > > Ok. This s

Re: [Tutor] Question about list

2006-04-10 Thread Adam
On 10/04/06, Hoffmann <[EMAIL PROTECTED]> wrote: > Hello, > > I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] > ] > and I wrote the script below: > > i = 0 > while i < len(list1): > print list1[i] > i += 1 > > Ok. This script will generate as the output each > element of the original

Re: [Tutor] Question about list

2006-04-10 Thread John Fouhy
Hi Hoffmann, On 11/04/06, Hoffmann <[EMAIL PROTECTED]> wrote: > I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] > and I wrote the script below: > > i = 0 > while i < len(list1): > print list1[i] > i += 1 Have you read about "for" loops? The pythonic way of looping through a list

[Tutor] Question about list

2006-04-10 Thread Hoffmann
Hello, I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ] and I wrote the script below: i = 0 while i < len(list1): print list1[i] i += 1 Ok. This script will generate as the output each element of the original list, one per line: spam! 2 ['Ted', 'Rock'] I also would like to print

Re: [Tutor] Decorators

2006-04-10 Thread Kent Johnson
Greg Lindstrom wrote: > Hello- > > For some reason I have decided to learn about decorators; I heard them > talked up at Pycon the past two years and want to know what all the > fuss is about. I might even use them in my code :-) > > My problem, and this is after reading PEP 318 and other ite

[Tutor] Decorators

2006-04-10 Thread Greg Lindstrom
Hello-For some reason I have decided to learn about decorators; I heard them talked up at  Pycon the past two years and want to know what all the fuss is about.  I might even use them in my code :-)My problem, and this is after reading PEP 318 and other items found when I "Googled" for decorators,

Re: [Tutor] failing to learn python

2006-04-10 Thread Kent Johnson
Payal Rathod wrote: >> What kind of real life problems are you interested in? You might like > > I am a parttime sys admin so I want system admin problem which usually I > do through shell scripts like parsing logs, generating reports, greping > with regexes etc. > The only thing I don't want i

Re: [Tutor] failing to learn python

2006-04-10 Thread Bob Gailer
Payal Rathod wrote: > On Mon, Apr 10, 2006 at 10:05:45AM -0400, Kent Johnson wrote: > >> You might like to look at "Python Programming for the absolute >> beginner". It is oriented to beginners and has many examples and >> exercises. >> > > I might not be able to afford another book, due

Re: [Tutor] failing to learn python

2006-04-10 Thread Payal Rathod
On Mon, Apr 10, 2006 at 10:05:45AM -0400, Kent Johnson wrote: > You might like to look at "Python Programming for the absolute > beginner". It is oriented to beginners and has many examples and > exercises. I might not be able to afford another book, due to high dollar-to-ruppee rate. > What k

Re: [Tutor] failing to learn python

2006-04-10 Thread Kent Johnson
Payal Rathod wrote: > Hi, > I am trying to learn Python seriously for almost 2 months but have not > gotten far at all. Infact, it seems I have not understood even the basic > concepts itself. I know some shell, sed and awk programming. > I have tried reading Learning Python - Mark Lutz > Think C

[Tutor] failing to learn python

2006-04-10 Thread Payal Rathod
Hi, I am trying to learn Python seriously for almost 2 months but have not gotten far at all. Infact, it seems I have not understood even the basic concepts itself. I know some shell, sed and awk programming. I have tried reading Learning Python - Mark Lutz Think C Spy A byte of Python Non-Progr