[Tutor] RegEx query

2005-12-17 Thread Liam Clarke
Hi all, Using Beautiful Soup and regexes.. I've noticed that all the examples used regexes like so - anchors = parseTree.fetch("a", {"href":re.compile("pattern")} ) instead of precompiling the pattern. Myself, I have the following code - >>> z = [] >>> x = q.findNext("a", {"href":re.compile(".*?

Re: [Tutor] RegEx query

2005-12-17 Thread Kent Johnson
Liam Clarke wrote: > Hi all, > > Using Beautiful Soup and regexes.. I've noticed that all the examples > used regexes like so - anchors = parseTree.fetch("a", > {"href":re.compile("pattern")} ) instead of precompiling the pattern. > > Myself, I have the following code - > z = [] x = q.f

[Tutor] How do I fix this Invalid Mode?

2005-12-17 Thread Nathan Pinno
Here is the latest error: The Currency Exchange ProgramBy Nathan Pinno   Traceback (most recent call last):  File "D:\Python24\exchange.py", line 27, in -toplevel-    store = open('exch.txt', 'b')#loadIOError: invalid mode: b   and the latest code: import picklerates = {'can_us' : 0.80276

Re: [Tutor] How do I fix this Invalid Mode?

2005-12-17 Thread Dan Lowe
On Dec 17, 2005, at 2:00 PM, Nathan Pinno wrote: Here is the latest error: The Currency Exchange ProgramBy Nathan Pinno   Traceback (most recent call last):  File "D:\Python24\exchange.py", line 27, in -toplevel-    store = open('exch.txt', 'b')#loadIOError: invalid mode: b[snip...] store = open('e

[Tutor] mysterious object

2005-12-17 Thread Christopher Spears
I'm working on Exercise 4 from Part 4 from Learning Python. I'm trying to write a function using **args. I want to create a function that adds its arguments together. Here is what I have written: def adder(**args): for x in args.keys(): print x print adder() print "---" print adder

Re: [Tutor] mysterious object

2005-12-17 Thread Brian van den Broek
Christopher Spears said unto the world upon 2005-12-17 17:42: > I'm working on Exercise 4 from Part 4 from Learning > Python. I'm trying to write a function using **args. > I want to create a function that adds its arguments > together. Here is what I have written: > > def adder(**args): >

Re: [Tutor] mysterious object

2005-12-17 Thread Alan Gauld
> def adder(**args): >for x in args.keys(): >print x A function which doesn't return a value returns None by default. > print adder() You are asking Python to print the return value of the function, which is None. As a general rule its better to do the printing outside of the functi

[Tutor] design advice for function

2005-12-17 Thread Christopher Spears
I got my function to work! It takes arguments and adds them: def adder(**args): argsList = args.values() sum = argsList[0] for x in argsList[1:]: sum = sum + x return sum print adder() print "---" print adder(a=5) print "---" print adder(a=5,b=6) print "---" print adder(a