Re: [Tutor] digging more into metaclasses

2006-07-14 Thread Alan Gauld
are metaclasses like templates in C++ thanks for your explanations No, there is no direct concept of metaclasses in C++. You need to ook to languages like Lisp and Smaltalk for those. The nearest you get to meta-classes in C++ is static members and methods. But they don't allow you to alter

[Tutor] error when installing sip-4.4.5

2006-07-14 Thread kakada
Hello list, I am on the way of learning QT design. I need to have pyQT installed. In the meanwhile, It needs sip-4.4.5 before proceed. I went across with the steps: python configure.py ...ok make In this step, I got alot of errors as follow and some more: siplib.c: In function

[Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Steve Nelson
Hello, I am reading the Regular Expression HOWTO at http://www.amk.ca/python/howto/regex/ I am at the bit where greediness is discussed with respect to metacharacters enabling repetition of sections of a RE. I understand the concept. The author gives a step by step example of how the matching

Re: [Tutor] Python Programming Books

2006-07-14 Thread Matthew Webber
It depends a lot on what your prior programming experience in other languages is. I have a large amount of prior programming experience, and I found Learning Python very good. The Python Cookbook (Martelli et. al., also O'Reilly) is very useful for learning the idioms. -Original

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread John Fouhy
On 14/07/06, Steve Nelson [EMAIL PROTECTED] wrote: What I don't understand is how in the end the RE *does* actually match - which may indicate a serious misunderstanding on my part. re.match(a[bcd]*b, abcbd) _sre.SRE_Match object at 0x186b7b10 I don't see how abcbd matches! It ends with a

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Steve Nelson
On 7/14/06, John Fouhy [EMAIL PROTECTED] wrote: It doesn't have to match the _whole_ string. Ah right - yes, so it doesn't say that it has to end with a b - as per your comment about ending with $. If you look at the match object returned, you should se that the match starts at position 0

[Tutor] Help with strings and lists.

2006-07-14 Thread János Juhász
Dear Alan, Probably you will be interested about list comprehension and zip(), as it can simplify all the similar tasks. s = ('Monday 7373 3663657 2272 547757699 reached 100%','Tuesday 7726347 552 766463 2253 under-achieved 0%','Wednesday 9899898 8488947 6472 77449 reached 100%','Thursday

[Tutor] I cant find link

2006-07-14 Thread devayani barve
Hi I'm a begginner in python,tried the link pythonchallenge.comsolved the first level,but i dont know how to go to the next one. Can somebody tell me how? Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] digging more into metaclasses

2006-07-14 Thread Kent Johnson
anil maran wrote: hi guys are metaclasses like templates in C++ No. Templates are a way to make generic functions that will work with a variety of types of data. Because Python is dynamically typed, all functions are generic in this sense and templates are not needed. See

Re: [Tutor] hi

2006-07-14 Thread Kent Johnson
anil maran wrote: hi you wonderful energetic pygurus i need to send out lot of emails and sms messages from a python program please let me know if you know of any library like java sms library or possible solutions smtplib will help with sending emails. I hope they are not spam! Kent

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Kent Johnson
Steve Nelson wrote: On 7/14/06, John Fouhy [EMAIL PROTECTED] wrote: It doesn't have to match the _whole_ string. Ah right - yes, so it doesn't say that it has to end with a b - as per your comment about ending with $. The matched portion must end with b, but it doesn't have to

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread John Fouhy
On 14/07/06, Steve Nelson [EMAIL PROTECTED] wrote: How does one query a match object in this way? I am learning by fiddling interactively. If you're fiddling interactively, try the dir() command -- ie: m = re.match(...) dir(m) It will tell you what attributes the match object has. Or you

Re: [Tutor] Help with strings and lists.

2006-07-14 Thread Kent Johnson
Alan Collins wrote: Hi, I do a far bit of data manipulation and decided to try one of my favourite utilities in Python. I'd really appreciate some optimization of the script. I'm sure that I've missed many tricks in even this short script. Let's say you have a file with this data:

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Steve Nelson
On 7/14/06, John Fouhy [EMAIL PROTECTED] wrote: m = re.match(...) dir(m) It will tell you what attributes the match object has. Useful - thank you. I am now confuse on this: I have a file full of lines beginning with the letter b. I want a RE that will return the whole line if it begins

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Luke Paireepinart
I have a file full of lines beginning with the letter b. I want a RE that will return the whole line if it begins with b. I find if I do eg: m = re.search(^b, b spam spam spam) m.group() 'b' How do I get it to return the whole line if it begins with a b? S. for line in

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Kent Johnson
Steve Nelson wrote: On 7/14/06, John Fouhy [EMAIL PROTECTED] wrote: m = re.match(...) dir(m) It will tell you what attributes the match object has. Useful - thank you. I am now confuse on this: I have a file full of lines beginning with the letter b. I want a RE

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Steve Nelson
On 7/14/06, Kent Johnson [EMAIL PROTECTED] wrote: But for this particular application you might as well use line.startswith('b') instead of a regex. Ah yes, that makes sense. Incidentally continuing my reading of the HOWTO I have sat and puzzled for about 30 mins on the difference the

Re: [Tutor] I cant find link

2006-07-14 Thread devayani barve
On 7/14/06, Jason Massey [EMAIL PROTECTED] wrote: Devayani,What answer did you get? One of the things to rember on the challenge is to take your answer and put .html (no qutoes) on the end of it in the url.So for the first problem the url would be: http://www.pythonchallenge.com/pc/def/ your

Re: [Tutor] Regular Expression Misunderstanding

2006-07-14 Thread Kent Johnson
Steve Nelson wrote: Incidentally continuing my reading of the HOWTO I have sat and puzzled for about 30 mins on the difference the MULTILINE flag makes. I can't quite see the difference. I *think* it is as follows: Under normal circumstances, ^ matches the start of a line, only. On a line

[Tutor] dynamically executing a statement

2006-07-14 Thread Emily Fortuna
Hello all, I am writing a function in which (in its simplified form) I am trying to return a list of a specified attribute, given a list of objects. It is best if I write some hypothetical code to explain: class foo: def __init__(self, name, data): self.name = name

Re: [Tutor] dynamically executing a statement

2006-07-14 Thread Fabrizio Milo aka misto
Did you considered getattr? def getAttrs(fooObjs, attr): return map(lambda item: getattr(item, attr), fooObjs) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] dynamically executing a statement

2006-07-14 Thread Kent Johnson
Emily Fortuna wrote: Hello all, I am writing a function in which (in its simplified form) I am trying to return a list of a specified attribute, given a list of objects. It is best if I write some hypothetical code to explain: class foo: def __init__(self, name, data):

Re: [Tutor] Python Programming Books

2006-07-14 Thread Carroll, Barry
Greetings: Like Matthew, I have a been programming for several years, mostly in C-like languages and various assembly languages. I started using Python about two years ago. Learning Python is my text book; Python in a Nutshell is my language reference. Both are excellent. I use one or both

Re: [Tutor] Python Programming Books

2006-07-14 Thread Terry Carroll
On Thu, 13 Jul 2006, Grady Henry wrote: I have three books on Python programming, Learning Python by O'Reilly, Beginning Python by Hetland, and Python in a Nutshell by O'Reilly. Are these good (recommended) books? Any others that might be recommended? I don't know the Hetland book. I

Re: [Tutor] Python Programming Books

2006-07-14 Thread Andre Roberge
On 7/14/06, Terry Carroll [EMAIL PROTECTED] wrote: On Thu, 13 Jul 2006, Grady Henry wrote: I have three books on Python programming, Learning Python by O'Reilly, Beginning Python by Hetland, and Python in a Nutshell by O'Reilly. Are these good (recommended) books? Any others that might be

Re: [Tutor] Help with strings and lists

2006-07-14 Thread Alan Collins
Date: Fri, 14 Jul 2006 12:12:42 +0200 From: J?nos Juh?sz [EMAIL PROTECTED] Subject: [Tutor] Help with strings and lists. To: [EMAIL PROTECTED], tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-2 Dear Alan, Probably you will be interested

Re: [Tutor] Help with strings and lists.

2006-07-14 Thread Alan Collins
Date: Fri, 14 Jul 2006 16:43:32 +1200 From: John Fouhy [EMAIL PROTECTED] Let me attempt to be the first to say: String substitutions!!! The docs are here: http://docs.python.org/lib/typesseq-strings.html snip Thanks John, that looks way better. I'll also check out the page. Alan.

[Tutor] Basic QT query

2006-07-14 Thread Dave S
Hi all, I am trying to get to grips with QT, putting a friendly face on some of my apps :) Its early days and my first attempt but I expected the following to print 'hi it works' every second. There problem I am stuck with is ... The debugged program raised the exception unhandled

Re: [Tutor] Python Programming Books

2006-07-14 Thread wesley chun
I have three books on Python programming, Learning Python by O'Reilly, Beginning Python by Hetland, and Python in a Nutshell by O'Reilly. Are these good (recommended) books? Any others that might be recommended? Learning is a good book to learn from if you already know C. Beginning is a good

Re: [Tutor] Python Programming Books

2006-07-14 Thread Andre Roberge
On 7/14/06, wesley chun [EMAIL PROTECTED] wrote: while it would be a conflict-of-interest for me to give *my* opinion of the book, it appears to be pretty well-received (mostly by word-of-mouth) based on comments i've seen so far. :-) I don't know about others, but I think it might be of

[Tutor] Mysterious syntax errors and file-reading issues

2006-07-14 Thread Jeremiah Hill
I'm trying to write a program that will read a text file and return a random subset of the words contained therein. (Its purpose is to generate lists of words for spelling bees. I'm a teacher.) Here's what I have so far: CODE STARTS ***L1 = []# create an empty

Re: [Tutor] Python Programming Books

2006-07-14 Thread Alan Gauld
I don't know about others, but I think it might be of benefit if you could give an assessment that would include a description of the weaknesses of the book [I could be in a minority opinion here. People like Kent, Alan, Danny, etc. should probably comment.] I'm no expert since I've only

Re: [Tutor] Mysterious syntax errors and file-reading issues

2006-07-14 Thread Alan Gauld
def exists('/Users/username/Documents/python/word_bank.txt'): return os.access('/Users/usernameDocuments/python/word_bank.txt', 1. I get a syntax error message at the line that starts with def exists, but I don't see the mistake. You are defining a function with a constant as an

Re: [Tutor] Basic QT query #2

2006-07-14 Thread Dave S
On Friday 14 July 2006 19:21, Dave S wrote: Hi all, I am trying to get to grips with QT, putting a friendly face on some of my apps :) Its early days and my first attempt but I expected the following to print 'hi it works' every second. There problem I am stuck with is ... The debugged

Re: [Tutor] Python Programming Books

2006-07-14 Thread johnsonv3
I also am a novice. Nearly finished with the first book listed below... If learning Python for the fun of it I have found this one enjoyable (pasted below is listing at Amazon): Python Programming for the Absolute Beginner, Second Edition (For the Absolute Beginner) by Michael Dawson

Re: [Tutor] Python Programming Books

2006-07-14 Thread wesley chun
(LONG... you've been warned ;-) ) andre wrote: I don't know about others, but I think it might be of benefit if you could give an assessment that would include a description of the weaknesses of the book I'm no expert since I've only browsed Wesley's book in a store a few times but

[Tutor] create 1000 000 variables

2006-07-14 Thread Сергій
supposeI need to create 1000 000 variables var_1, var_2, var_100 how to do this using for? (something like for i in range(100): ___var_ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] create 1000 000 variables

2006-07-14 Thread Etienne Robillard
--- ÁÕàÓöÙ [EMAIL PROTECTED] wrote: suppose I need to create 1000 000 variables var_1, var_2, var_100 how to do this using for? (something like for i in range(100): ___var_ How would you consider NOT creating 100,000 variables ?? Answer that question and you should be

Re: [Tutor] create 1000 000 variables

2006-07-14 Thread Kent Johnson
Сергій wrote: suppose I need to create 1000 000 variables var_1, var_2, var_100 how to do this using for? (something like for i in range(100): ___var_ Rather than creating 100 variables, create a list with 100 values. data = [] for i in range(100): data.append(i*i)

[Tutor] Hi, need help on zip commands for windows

2006-07-14 Thread Ramakrishnan, Shashikanth
Thanks guys for all your inputs so far. Unfortunately, I still cant get it to work using the methods below. Attached is the code from my python shell, and the output is still Backup failed when I run it. Can somebody explain what Im doing wrong? Thanks, Shashi Email : [EMAIL

[Tutor] Needing to create a program that will search my hard drive for certain folders

2006-07-14 Thread Bobby J. Howerton Jr.
Hello,I am new to programming in Python, but I am very excited about the possibilities that it (Python) has.I maybe jumping the gun a little bit here, but this is what I would like to do:I would like to