Re: [Tutor] Need a solution.

2009-06-12 Thread David
Alan Gauld wrote: This is a bad choice of class. It is a verb which is indicative that its not an object. Objects are nearly always nouns. You could use GuessableNumber. Then it would have a number attribute which is the number to guess. It could have a generate() ,method which produces a new

Re: [Tutor] Need a solution.

2009-06-13 Thread David
Alan Gauld wrote: "David" wrote class GuessError(Exception): pass class GuessedNumber: def __init__(self,tries=None,limits=None):... def generate(self, limits=None):... def __cmp__(self, aNumber): if self.count >= self.tries: raise GuessError Thanks a

Re: [Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread David
Charlie Reddington wrote: Thanks for all the replies, I'll definitely look into it all. Charlie Something else for your consideration; http://commandline.org.uk/python/sftp-python-really-simple-ssh/ -- Powered by Gentoo GNU/Linux http://linuxcrazy.com __

Re: [Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread David
David wrote: Charlie Reddington wrote: Thanks for all the replies, I'll definitely look into it all. Charlie Something else for your consideration; http://commandline.org.uk/python/sftp-python-really-simple-ssh/ almost forgot pexpect #!/usr/bin/python import pexpect

[Tutor] if: else: can not get else to work

2009-07-07 Thread David
Hi Tutors, I have a web cam that saves files in /var/log/motion and it can get quite large so I clean it every few days. I came up with this; #!/usr/bin/python import commands import os from sys import exit def clean_motion(): folder = '/var/log/motion' if os.path.exists(folder):

Re: [Tutor] if: else: can not get else to work

2009-07-07 Thread David
Luke Paireepinart wrote: On Tue, Jul 7, 2009 at 8:36 PM, David <mailto:da...@pythontoo.com>> wrote: Hi Tutors, Hiya david. Cool e-mail address :) Thanks, want l...@pythontoo.com I have a few to spare :) But if there are no files in the directory it never gets to

Re: [Tutor] hitting a wall (not a collision detection question :P)

2009-07-19 Thread David
s at a time and check each one to make sure it works, plus this gives me encouragement to continue. -david -- Powered by Gentoo GNU/Linux http://linuxcrazy.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Pygame

2009-07-20 Thread David
Windows system. Otherwise some of the tools Dawson introduces will not work. So, start here, and move on to McGugan's book thereafter. David ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] mnemonics to better learn Python

2009-07-22 Thread David
as to how to uncloud the thick information fog that any beginning programmer has to wade through, the very first steps in learning Python could be made more easy. What insights can you share? Curious, David ___ Tutor maillist - Tutor@python.org http:

Re: [Tutor] Pygame

2009-07-23 Thread David
Hi, there also is: "Invent Your Own Computer Games with Python", which apparently does not use pygame (like Dawson). http://pythonbook.coffeeghost.net/ I can't comment on the quality. David Mazhar Hussain wrote: > Hello All! My name is Mazhar Hussain, and I am new to pytho

[Tutor] sqlite: don't understand a code snippet

2009-07-25 Thread David
oes a new the director ID come from? Thanks for your directions! David ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] sqlite: don't understand a code snippet

2009-07-26 Thread David
Rich, thanks a lot -- that was the problem. David Rich Lovely wrote: > 2009/7/25 David : > >> Dear tutors, >> >> I am trying to teach myself the way Python's works with databases. >> I decided to start with SQLite, and am looking at Summerfield's >&

[Tutor] concerning help() function

2009-07-28 Thread David
syntax: help(random) help('operator') I figured this by trial and error, and I am keen to find out when the help() function is to be supplied with a string, and when no '' is required. It certainly does not seem intuitive to me!

Re: [Tutor] concerning help() function

2009-07-31 Thread David
Thanks to you all -- good stuff, as always! David Alan Gauld wrote: >> help('operator') >> >> I figured this by trial and error, and I am keen to find out when the > > Oops, always try before posting! And don;t assume... > > I juast vdid and you are r

[Tutor] [pygame] why does my window not close?

2009-08-01 Thread David
the [X] button! Cheers for a hint, David ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] New guy question...

2009-09-14 Thread David
try: number = int(line) except ValueErr as err: print( "BLARGH : ", err ) continue total += number count += 1 else: break if count: print "count =", count, "total =", total, "mean =

Re: [Tutor] Wordscramble.py

2009-09-15 Thread David
help but to make it a python program I have used distutils; http://wiki.python.org/moin/Distutils/Tutorial Now to get it cross platform I have no idea. -david -- Powered by Gentoo GNU/Linux http://linuxcrazy.com ___ Tutor maillist - Tutor@python.org

Re: [Tutor] how to define a function with multple parameters

2009-09-22 Thread David
shellc...@juno.com wrote: I want to know how to use multiple parameters for 1 function def display(message): print message def rate_score(): score = rate_score if rate_score <= 999: print "that's nothing." elif rate_score <= 1: print "ok." elif rate_score >=

Re: [Tutor] Help or Advice on MySQL, Python and test data storage

2009-10-08 Thread David
David Jamieson wrote: Hi All, looking for some advice on using Python with MySQL for test data storage. What builds of Python work well with MySQL and what modules allow the connection to the database and data transfer activities. SQLAlchemy is one option; http://www.rmunn.com/sqlalchemy

Re: [Tutor] writing sample program that zips files and saves in a backup directory

2009-10-14 Thread David
David Eric wrote: On Tue, Oct 13, 2009 at 5:17 PM, Kent Johnson <mailto:ken...@tds.net>> wrote: On Tue, Oct 13, 2009 at 4:38 PM, David Eric mailto:cii...@gmail.com>> wrote: > as far as print zip_command, i would add that to the program however, doesnt &

Re: [Tutor] Any one got any idea

2009-10-18 Thread David
running 'make install' i am getting the following error :- You are on the wrong list, try the Fedora mail list [1] or irc [2] [1] https://www.redhat.com/mailman/listinfo/fedora-list [2] http://fedoraproject.org/wiki/Communicate#IRC -- David Abbot

Re: [Tutor] Learning Python

2009-12-13 Thread David
Hi, Kent Johnson wrote: > Python in a Nutshell is good if you want a compressed but readable > introduction. I am thinking of buying this one, but the topical 2nd edition is from 2006. Does anyone know if a new version, covering Python 3, is coming to market soonish?

Re: [Tutor] Error writing to file...

2009-12-25 Thread David
tring or read-only character buffer, not int Hi Ken, From the docs if you are using 2.6 [snip] To write something other than a string, it needs to be converted to a string first: >>> value = ('the answer', 42) >>> s = str(value) &

[Tutor] my text adventure

2005-11-29 Thread david
hat):    pass    def do(self):    cmd = raw_input('>')    if cmd == 'l':    self.look()    elif cmd in ['n','s','e','w']:       self.move(cmd)    elif cmd == 'quit': 

Re: [Tutor] my text adventure

2005-11-30 Thread david
> You might want to make coords an init parameter for Room, rather than > assigning it separately. You could also have Rooms register themselves > with world as part of their initialization, that would be better than > having to repeat yourself in the definition of world. brilliant! i'll do th

[Tutor] my text adventure

2005-12-02 Thread david
i am attempting to write a dig function that will create rooms. i have succeeded only in getting a headache :) any suggestions on where i am going wrong would be super helpful. thanks, david world = {}class Room:    def __init__(self,name,coords):    self.contents = []    self.name

[Tutor] my text adventure

2005-12-02 Thread david
7;dig':    self.dig(target)    else:    print 'what?'   class Thing:    def __init__(self,name):    self.name = name           p = Player('david')room1 = Room([0,0])room1.name = 'startroom'p.location = room1sword = Thing('

[Tutor] spam, eggs, and my text adventure

2005-12-02 Thread david
hello :) i have some questions that are more about programming in general than python specifically. suppose, for whatever reason, you had a burning desire to write a simple text adventure. how would you start? would you just start writing some code? i knew i wanted a room structure or object

[Tutor] (no subject)

2005-12-03 Thread david
self.describeroom()    else:    print 'what?'   class Thing:    def __init__(self,name):    self.name = name   def opdir(direction):    if direction == 'n':    return 's'    if direction == 's':    return 'n'    i

Re: [Tutor] my text adventure

2005-12-03 Thread david
sorry i forgot a subject line. i have looked at the pickle module and was able to pickle world. but i can't figure how to restore everything. - Original Message - From: david To: tutor@python.org Sent: Saturday, December 03, 2005 8:36 PM Subject: [Tutor

Re: [Tutor] my text adventure

2005-12-04 Thread david
programs state (is that correct usage?) could be important in many different programs. - Original Message - From: Dan Lowe To: david Cc: tutor@python.org Sent: Sunday, December 04, 2005 1:24 AM Subject: Re: [Tutor] my text adventure On Dec 3, 2005,

[Tutor] (no subject)

2005-12-04 Thread david
#x27;:    self.describeroom()    elif verb == 'save':    self.save()    else:    print 'what?'   class Thing:    def __init__(self,name):    self.name = name   def opdir(direction):    if direction == 'n':    re

Re: [Tutor] my text adventure

2005-12-04 Thread david
i fixed this myself ! i think i can get everything working now so please disregard previous messages. if you haven't already. :) - Original Message - From: david To: tutor@python.org Sent: Sunday, December 04, 2005 10:06 AM Subject: [Tutor] (no subject)

[Tutor] my text adventure, saving and restoring

2005-12-04 Thread david
stance at 0x00E7BFD0>]startroom{'n': <__main__.Room instance at 0x00E7BFD0>}nextroom{'s': <__main__.Room instance at 0x00E08EB8>}>world{(0, 1): <__main__.Room instance at 0x00E7BFD0>, (0, 0): <__main__.Room instance at 0x00E08EB8>}>save>quitTraceba

Re: [Tutor] my text adventure, saving and restoring

2005-12-04 Thread david
thanks that was very helpful. i added all that stuff because i was trying to figure out some way of getting at the descriptions and exits. that is the part i'm stuck on. but knowing that world is all i need is good because i can focus my efforts better. thanks. > You could make your save() metho

[Tutor] my text adventure

2005-12-04 Thread david
i.exits    else:    print 'what?'   class Thing:    def __init__(self,name):    self.name = name   def opdir(direction):    if direction == 'n':    return 's'    if direction == 's':    return 'n'    if directi

[Tutor] (no subject)

2005-12-05 Thread david
ielded',self.wielded    print 'on head', self.headwear    for a in self.inventory:    print a.name elif verb == 'wield':    self.wield(target) else:    print 'what?'   class Thing:    def __init__(self,

[Tutor] terminology

2005-12-05 Thread david
suppose you have a list of words and you want to unambiguously identify each word in the list with the shortest number of characters. for instance a list like : kill, kiss, take i would want to get take just by typing t. but you would have to type kil or kis to get kill or kiss. where shoul

Re: [Tutor] terminology

2005-12-06 Thread david
thanks for tries and bisect. this led me to the wikipedia article http://en.wikipedia.org/wiki/Search_algorithm which was where i was looking to start. so, i think the simplest approach to search through a short list would be a brute force algorithm. like so :   get a letter and compare it to

Re: [Tutor] bnf

2005-12-10 Thread david
::= is bnf notation for "is defined as"   please spend that extra minute googling before you bother all the nice people on this list.   - Original Message - From: david To: tutor@python.org Sent: Saturday, December 10, 2005 6:23 AM hello every

[Tutor] (no subject)

2005-12-10 Thread david
hello everyone. i was looking at python docs and i came across this   letter ::= lowercase | uppercase   what does ::= mean?   ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] lowercase, uppercase

2005-12-10 Thread david
i am thinking that string.upper and string.lower may be what you are looking for.   - Original Message - From: vikas mohan To: david Cc: tutor@python.org Sent: Saturday, December 10, 2005 7:19 AM Subject: Re: [Tutor] bnf Hi again   I have a question

[Tutor] empty class methods

2005-12-14 Thread david
    class foo:    def sayhi(self):    print 'hello world'    def saybye(self): ##is there any reason for this to be here?    pass   class bar(foo):    def saybye(self):    print 'bye now'   class baz(foo):    def saybye(self):    print 'later tater'   x = foo()y = bar()z =

[Tutor] coin toss program without using the for/range loop

2007-01-04 Thread David
How to write the coin toss program without using the for/range loop program. Program flips a coin 100 times and then tells you the number of heads and tails. I can only solve it using the for/range loop Import random Heads=0 For 1 in range (100): Heads+=random.randrange(2) pri

Re: [Tutor] Hands-on beginner's project?

2008-06-24 Thread David
On Tue, Jun 24, 2008 at 5:37 PM, nathan virgil <[EMAIL PROTECTED]> wrote: > I'm very new to Python, and (to a slightly lesser extent) programming in > general. I'd like to get some experience by practicing simple-yet-functional > programs, with a bit of an emphasis on games. The first game I'd like

[Tutor] Create file and input text

2008-06-28 Thread David
Hi, I am very new to python and it is my first attempt at programing except for some basic bash scripts. I came up with this; #!/usr/bin/python import os filename = raw_input('Enter the filename: ') fobj = open(filename, 'w') yourname = raw_input('What is your name: ') fobj.write(yourname) fobj.

Re: [Tutor] Create file and input text

2008-06-29 Thread David
ho will be happy to be of assistance when the programs get harder to write. well, like with all functionality, you just have to import the right module: http://xkcd.com/353/ :-) -wesley Thanks for the warm welcome, this is fun, I am sure I will be back. :) david -- Powered

Re: [Tutor] Create file and input text

2008-06-29 Thread David
Dave Kuhlman wrote: On Sat, Jun 28, 2008 at 08:11:03PM -0400, David wrote: Hi, I am very new to python and it is my first attempt at programing except for some basic bash scripts. I came up with this; #!/usr/bin/python import os filename = raw_input('Enter the filename: ') f

Re: [Tutor] Create file and input text

2008-06-29 Thread David
raw_input( 'Warning, file %s exists, overwrite it [y/n] ? ' % filename) if r != 'y' : sys.exit(0) fobj = open(filename, 'w') yourname = raw_input('What is your name: ') fobj.write(yourname) fobj.close() -david -- Powered by Gentoo GNU/LINUX http://www.linuxcraz

Re: [Tutor] Deleting specified files using a python program...help with code?]

2008-06-30 Thread David
;%d files removed' % files_removed else : print 'No files found' Here is the output; [EMAIL PROTECTED] ~ $ ./new_remove_file.py Enter dir: test test/test.ini test/test.db Confirm removal: y removing 'test/test.db' 1 files removed Please point me in th

Re: [Tutor] Deleting specified files using a python program...help with code?]

2008-06-30 Thread David
Alan Gauld wrote: "David" <[EMAIL PROTECTED]> wrote dir_input = raw_input('Enter dir: ') win_trace = ['*.ini', '*.db'] files_removed = 0 for root, dirs, files in os.walk(dir_input): for trace in win_trace: win_trace_path = os.path.join

[Tutor] While loop counter

2008-07-07 Thread David
e = self.__minute % 60 self.__second = self.__second % 60 def print_time(self): print '%02d:%02d:%02d' % (self.__hour, self.__minute, self.__second) Thanks, very new to Python. -david -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com __

Re: [Tutor] While loop counter

2008-07-07 Thread David
Thank you John & Allen, See the loops section of my tutorial for more about for and while loops. Yes, great tutorial, just getting it to sink in, now thats the problem :) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/

Re: [Tutor] Online class/education for Python?

2008-07-19 Thread David
Steve Poe wrote: Anyone taken or know of any online classes teaching Python? I know O'Reilly Press teaches online technical courses, through the University of Illinois, but no Python . Thanks. Steve __

[Tutor] Output never stops

2008-08-02 Thread David
Very new to python and never programed before. Can not figure out why the output never stops when I run this in a terminal #!/usr/bin/python choice = raw_input("Enter the name Lary or Joan (-1 to quit): ") while choice != '-1': person = {'Lary': 43,'Joan': 24} if choice == 'Lary':

Re: [Tutor] Output never stops

2008-08-02 Thread David
David wrote: Very new to python and never programed before. Can not figure out why the output never stops when I run this in a terminal #!/usr/bin/python choice = raw_input("Enter the name Lary or Joan (-1 to quit): ") while choice != '-1': person = {'L

Re: [Tutor] Output never stops

2008-08-03 Thread David
Alan Gauld wrote: "David" <[EMAIL PROTECTED]> wrote the output never stops when I run this in a terminal choice = raw_input("Enter the name Lary or Joan (-1 to quit): ") while choice != '-1': person = {'Lary': 43,'Joan'

[Tutor] MySQLdb simple menu

2008-08-16 Thread David
(0) else: r = raw_input("Login failed, do you want to create an account? [y/n]") if r != 'y' : sys.exit(0) newname = "" data = [] newname = raw_input("Please enter a username: ") newpw = raw_input("Please enter a password: ") tuple = (newname, newpw)

Re: [Tutor] MySQLdb simple menu

2008-08-16 Thread David
David wrote: New to python and programming. This works but I don't like the way it is set up. I would like to have a simple menu like; [code] def options(): print \ """ Options: 'p' Print Options 'l' Login 'c' Cre

[Tutor] syntax error with a simple print command

2008-10-02 Thread David
nt "done!" ^ As far as I understand, the for loop is executed, and once the loop is done Python exits the for loop and continues with the next command (print "done!"). Why is he complaining?? Many thanks for enlightening me! David

[Tutor] dealing with user input whose value I don't know

2008-10-02 Thread David
the numbers separated by a comma: ") average = (ans1 + ans2) / 2.0 But as I say - I don't know how many assignment there have to be, nor do I know how Python could then create these assignments. It would be great if someone could guide me towards the right track!! Thanks, David __

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread David
umber. numbers=int(raw_input("How many number do you want me to calculate? ")) Does that mean input() is obsolete (after all, Zelle's book is not the freshest on the shelf)? Or do they have different uses? Thanks, David ___ Tut

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread David
t numbers = raw_input("Please type the numbers, separated by commas: ") also returns the comma (1,2) and thus the for loop can't cope... So should I therefore retain numbers = input("Please type the numbers, separated by commas: ") ? Otherwise I don't know (yet)

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread David
)) print "You want to know the average of the numbers:", numbers add = 0 for i in numbers: add = add + i print "The sum of your numbers is:", add average = add / float(amount) print "Therefore the average of your numbers is", average David Steve Willoughby wro

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread David
Oh, great, this answers my question! Thanks! David [EMAIL PROTECTED] wrote: I am not sure how you got from the input to your variable i, it is a good idea to post your code as well. That said raw_input will return the user's input as a string which you then need to convert to int

Re: [Tutor] dealing with user input whose value I don't know

2008-10-03 Thread David
bers:", numbers add = 0 for numStr in string.split(numbers, ","): convNum = eval(numStr) # convert digit string to a number add = add + convNum # add number to variable 'add' print "The sum of your numbers is:", add average = add / float

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread David
> Okay, I'm resurrecting this project. Where is this project code? -- Have Fun, David A. Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] some string operations

2008-10-04 Thread David
pam Ni! ' Which is not exactly "Spam Ni! Spam Ni! Spam Ni!" (note the final free space in my outcome). I am at a loss as to how to perfect my answer with regard to this issue. Many thanks for helping me in my pythonic adventures! David ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] bug in exam score conversion program

2008-10-04 Thread David
ot;A") score = raw_input("What's your exam score (0-100)? ") grade = x[int(score)/10] print "Your grade is:", grade I greatly appreciate your comments! David ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread David
turn a letter grade based on a score """ for g in grades: if (score <= g[1]) and (score >= g[0]): return g[2] score = raw_input("What is your exam score: (0-100)? ") print getGrade print getGrade(score) What is your exam score: (0-100)? 66 None -- Have Fun, David A. Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Looking for Clues to Make a Program Produce avi Files Instead ...

2008-10-15 Thread David
David wrote: > You could use mencoder, part of mplayer; > mencoder -oac mp3lame -ovc lavc -vf scale=0:0:0:0:0:0:qpal > somemovfile.mov -o outavifile.avi > > Here is a program to convert ogg theora to avi; > > #!/usr/bin/python > #Filename = ogg_to_avi.py > > impo

Re: [Tutor] python question

2008-11-21 Thread David
Daniel J Kramer wrote: > Hi > > I have just joined this list. I need some help working on a Python > application I am working on. I am working on a quiz game where the > users gain points when the answer questions correctly. I have written > the skeleton of the quiz with If, Elif and Else statem

[Tutor] faulty code (maths)

2008-11-23 Thread David
stake: why does the line q = sqrt(b*b - 4*a*c) cause an error? I was playing around with the code, but got nowhere. Here the entire code: a = 2; b = 1; c = 2 from math import sqrt q = sqrt(b*b - 4*a*c) x1 = (-b + q)/2*a x2 = (-b - q)/2*a print x1, x2 Many thanks for a

Re: [Tutor] faulty code (maths)

2008-11-23 Thread David
Hello Kent, yes, the error message - sorry: When I just run line 3, I get: In [7]: q = sqrt(b*b - 4*a*c) ...: --- Traceback (most recent call last) /home/david/Documents/Python/myCode/Langtangen/py1st/ in

Re: [Tutor] faulty code (maths)

2008-11-23 Thread David
g file: The working code: a = 2; b = 1; c = 2 import math q = math.sqrt(math.fabs(b*b - 4*a*c)) x1 = (-b + q)/2*a x2 = (-b - q)/2*a print x1, x2 Thanks a lot! David Arun Tomar wrote: hi! On Sun, Nov 23, 2008 at 5:07 PM, David <[EMAIL PROTECTED]> wrote: Hello everybody, I

[Tutor] [Fwd: Re: Subprocess module]

2008-11-26 Thread David
-- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com --- Begin Message --- Judith Flores wrote: > Hello, > >A couple of weeks ago I posted a question about what documentation I > should read in order to implement a way to communicate Python and R. I read > about the module 'subprocess

Re: [Tutor] Capturing and parsing over telnet

2008-11-30 Thread David
Stephen Nelson-Smith wrote: > I want to write a program that connects to a TCP port using telnet, > and issues commands, parsing the output the command provides, and then > issuing another command. > > This might look like this: > > $ telnet water.fieldphone.net 7456 > Welcome to water, enter you

Re: [Tutor] Reading gzip files

2008-11-30 Thread David
w') > > for ziparchive in list_zipfiles: > zfile = gzip.GzipFile(zipfolder + ziparchive, "r") > for line in zfile: > fw.write(line) > zfile.close() > fw.close() I am learning also. I came up with this; #!/usr/bin/python import tarfile tFile =

Re: [Tutor] Reading gzip files

2008-11-30 Thread David
David wrote: > #!/usr/bin/python > import tarfile > tFile = tarfile.open("/home/david/zip_files/zip.tar.gz", "r") > for f in tFile.getnames(): > print f > tFile.close() > #fname = "out.txt" > #fobj = open(fname, 'w')

[Tutor] How to exit program without sys.exit()

2008-12-17 Thread David
Hi, I make these silly programs to learn from examples I find on the list. I put a couple together just to practice. I have heard it is not a good idea to use sys.exit() but I can not figure out how to do it. Also any and all comments are welcome. Thanks #!/usr/bin/python import sys _count =

Re: [Tutor] How to exit program without sys.exit()

2008-12-17 Thread David
ook I have it bookmarked :) -david -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
#x27;) print "The Latest Podcast", f.readline() print f.readline() f.close() lname = "podcast_links.txt" L = open(lname, 'r') print "The Latest Link\n" download = L.readline() print download answer = raw_input("Do you want to download the podcast? ") if a

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
This seems to work; download = L.readline() print download download = download[0:-1] What is that last character that is added; .mp3%0A -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] subprocess adds %0A to end of string

2008-12-21 Thread David
Martin Walsh wrote: Welcome! thanks You should probably try to avoid reassigning sys.stdout. This is usually a bad idea, and can cause odd behavior that is difficult to troubleshoot, especially for a beginner. A reasonable approach is to assign the open file object to a name of your own ch

[Tutor] Exception Handling

2008-12-28 Thread David
Hi, Is this the correct way to handle a ValueError exception and should I get in the practice of catching them? Also any suggestions on the program. thanks -david -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor

Re: [Tutor] Exception Handling

2008-12-28 Thread David
David wrote: Hi, Is this the correct way to handle a ValueError exception and should I get in the practice of catching them? Also any suggestions on the program. thanks -david Might help if I included the program :) #!/usr/bin/python import time print "Enter year as " pr

Re: [Tutor] Exception Handling

2008-12-30 Thread David
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote: > On Mon, 29 Dec 2008 09:10:45 - > "Alan Gauld" wrote: > > >> "bob gailer" wrote >> >> > Also IMHO it is bad design to put a lot of code inside a try block. >> > In this case the user might make a mistake on day and then is forced >> > t

Re: [Tutor] Exception Handling

2008-12-30 Thread David
Jervis Whitley wrote: On Wed, Dec 31, 2008 at 8:33 AM, David <mailto:da...@abbottdavid.com>> wrote: On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote: > On Mon, 29 Dec 2008 09:10:45 - > "Alan Gauld" mailto:alan.ga.

[Tutor] Linux tail -f multiple log files

2009-01-06 Thread David
t; tail = "tail" targ = "-f" # output appended data as the file grows sfile = "/var/log/messages" print colored("", "blue") call([sudo, tail, sfile]) Only the first function will print to the screen. thanks in advance, -david -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Linux tail -f multiple log files

2009-01-06 Thread David
) Only the first function will print to the screen. thanks in advance, -david oops should be; def slog(): sudo = "sudo" tail = "tail" targ = "-f" # output appended data as the file grows sfile = "/var/log/messages" print colored("

[Tutor] Simple program with menu to view videos

2009-01-16 Thread David
best way to proceed. I have a lot of code that is just copied from one function to the next. I am new to python and enjoy these little projects because I can see them in action. Here is my starting point; http://dwabbott.com/code/index6.html thanks -david -- Powered by Gentoo GNU/LINUX http

[Tutor] calculator will not multiply

2009-01-18 Thread David
Everything else works + - / but not * why? thanks -david #!/usr/bin/python from __future__ import division import sys def add(x, y): return x + y def sub(x, y): return x - y def dev(x, y): return x / y def mul(x, y): return x * y def compute(arg1, arg2, arg3): if sys.argv

Re: [Tutor] calculator will not multiply

2009-01-18 Thread David
jadrifter wrote: It worked fine for me. Don't forget to put quotes around the * sign or the shell will substitute. so: ./calc.py 2 '*' 9 or: ./calc.py 2 "*" 9 or: ./calc.py 2 \* 9 but not: ./calc.py 2 * 9 John Purser Thanks Kent and jadrifter, that explains that! Also thanks for the tips

Re: [Tutor] calculator will not multiply

2009-01-18 Thread David
Marc Tompkins wrote: It works for me under Windows XP, so I suspect that the hints you've received about * being expanded by your shell are correct. However, I had an idea - rather than requiring your user to put quotes around the "*", why not do this: elif sys.argv[2] in ["*","x","X"]:

Re: [Tutor] MySqldb problem

2009-01-20 Thread David
___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > I am new to python also, here are my notes, it helps me understand how it works, may be of some help; http://asterisklinks.co

Re: [Tutor] lists

2009-01-20 Thread David
Norman Khine wrote: > Hi, > actually what I was trying to do carries from my last post, where my > media files are a list that I want to add to the > > subprocess.call(['sox', ', '.join(media_list), 'list.wav']) Something like this may work; #!/usr/bin/python import subprocess def play(filename):

[Tutor] bruteforce match word in text file

2009-01-21 Thread David
I have to ask for a pointer, not sure what I am doing wrong. thanks -david #!/usr/bin/python password = 'loser' wordlist = '/home/david/Challenge-You/wordlist.txt' try: words = open(wordlist, 'r').readlines() except IOError, e: print "Sorry no

Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread David
bob gailer wrote: David wrote: I have to ask for a pointer, not sure what I am doing wrong. The first thing you are doing "wrong" is failing to tell us what is in the wordlist file and what results you get when you run the program. Please re-post with that information. #!/usr/

Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread David
bob gailer wrote: David wrote: bob gailer wrote: David wrote: I have to ask for a pointer, not sure what I am doing wrong. The first thing you are doing "wrong" is failing to tell us what is in the wordlist file and what results you get when you run the program. Please re-post

Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread David
#!/usr/bin/python import re password = 'loser' wordlist = '/home/david/Challenge-You/wordlist.txt' try: words = open(wordlist, 'r').readlines() except IOError, e: print "Sorry no words" for word in words: word = word.replace("\n&quo

<    1   2   3   4   5   6   7   8   9   10   >