Where can I find sample "beginner" programs to study?

2005-01-28 Thread Todd_Calhoun
I'm trying to learn Python (and programming), and I'm wondering if there are 
any places where I can find small, simple programs to study.

Thanks. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where can I find sample "beginner" programs to study?

2005-01-28 Thread Todd_Calhoun
Thanks for the great links.  The cookbook page has some smaller stuff that 
looks great.


"JanC" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Todd_Calhoun schreef:
>
>> I'm trying to learn Python (and programming), and I'm wondering if
>> there are any places where I can find small, simple programs to study.
>
> Try:
> <http://www.uselesspython.com/>
> <http://aspn.activestate.com/ASPN/Python/Cookbook/>
>
> -- 
> JanC
>
> "Be strict when sending and tolerant when receiving."
> RFC 1958 - Architectural Principles of the Internet - section 3.9 


-- 
http://mail.python.org/mailman/listinfo/python-list


Beginner Question - Very Easy I'm Sure...

2005-03-24 Thread Todd_Calhoun
I'm trying to generate a random number, and then concetate it to a word to 
create a password.

I get the number and assign it to a variable:

+
word = "dog"

import random
rannum = random.randrange(100,999)

str(rannum)

word + rannum
+

But when I try to concetate the two, I get an error saying:


Traceback (most recent call last):
  File "", line 1, in -toplevel-
list[1] + rannum
TypeError: unsubscriptable object


Any suggestions? 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner Question - Very Easy I'm Sure...

2005-03-25 Thread Todd_Calhoun
Thanks for the tip.  I knew it was something easy like that.


"Brian van den Broek" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Todd_Calhoun said unto the world upon 2005-03-24 16:13:
>> I'm trying to generate a random number, and then concetate it to a word 
>> to create a password.
>>
>> I get the number and assign it to a variable:
>>
>> +
>> word = "dog"
>>
>> import random
>> rannum = random.randrange(100,999)
>>
>> str(rannum)
>>
>> word + rannum
>> +
>>
>> But when I try to concetate the two, I get an error saying:
>>
>> 
>> Traceback (most recent call last):
>>   File "", line 1, in -toplevel-
>> list[1] + rannum
>> TypeError: unsubscriptable object
>> 
>>
>> Any suggestions?
>
> Hi,
>
> you call str(rannum) but don't store it. Try it like this:
>
> >>> import random
> >>> word = "dog"
> >>> rannum = random.randrange(100,999)
> >>> str(rannum)
> '773'
> >>> type(rannum)
> 
> >>> rannum = str(rannum)
> >>> new_word = word + rannum
> >>> print new_word
> dog773
>
> or,
>
> >>> rannum = str(random.randrange(100,999))
> >>> word + rannum
> 'dog287'
> >>>
>
> HTH,
>
> Brian vdB
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


[Newbie] Search-and-delete text processing problem...

2005-04-01 Thread Todd_Calhoun
I'm trying to learn about text processing in Python, and I'm trying to 
tackle what should be a simple task.

I have long text files of books with a citation between each paragraph, 
which might be like "Bill D. Smith, History through the Ages, p.5".

So, I need to search for every line that starts with a certain string (in 
this example, "Bill D. Smith"), and delete the whole line.

I've tried a couple of different things, but none seem to work.  Here's my 
latest try.  I apologize in advance for being so clueless.

##
#Text search and delete line tool

theInFile = open("test_f.txt", "r")
theOutFile = open("test_f_out.txt", "w")

allLines = theInFile.readlines()

for line in allLines:
if line[3] == 'Bill':
line == ' '


theOutFile.writelines(allLines)
#

I know I could do it in Word fairly easily, but I'd like to learn the Python 
way to do things.

Thanks for any advice. 


-- 
http://mail.python.org/mailman/listinfo/python-list