[Tutor] converting encoded symbols from rss feed?

2009-06-17 Thread Serdar Tumgoren
Hi everyone, I just tried my hand at parsing an RSS 2.0 feed using Universal Feed Parser and it worked beautifully. My one point of confusion -- I'm not sure how to convert encoded characters back to their human-readable ascii/unicode. Not sure if it matters, but the feed I'm dealing with is usin

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-17 Thread Wayne
On Wed, Jun 17, 2009 at 7:30 AM, Serdar Tumgoren wrote: > Here are some examples of the encoded characters I'm trying to > convert: > > – (symbol as it appears in the original xml file) > – (symbol as it appears in ipython shell after > using Universal Feed Parser) > I'v

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-17 Thread Serdar Tumgoren
> Upon searching for – in google, I came up with this: > http://www.siber-sonic.com/mac/charsetstuff/Soniccharset.html The character table definitely helps. Thanks. Some additional googling suggests that I need to unescape HTML entities. I'm planning to try the below approach from Frederik Lundh.

Re: [Tutor] distutils MANIFEST.in

2009-06-17 Thread spir
No one has a clue about this? Le Tue, 16 Jun 2009 22:59:24 +0200, spir s'exprima ainsi: > Hello, > > a question for people who know how to write MANIFEST.in: > How to tell to simply include all files in the package (and subdirs)? I > tried: > > recursive-include *.* > ==> warning: sdist: MANIF

Re: [Tutor] distutils MANIFEST.in

2009-06-17 Thread Chris Fuller
Use os.path.walk or similar to build the file before you call setup(). Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] distutils MANIFEST.in

2009-06-17 Thread spir
Le Wed, 17 Jun 2009 12:51:09 -0500, Chris Fuller s'exprima ainsi: > > Use os.path.walk or similar to build the file before you call setup(). > > Cheers Thanks, that's what I thought I would end up doing... Denis -- la vita e estrany ___ Tutor ma

[Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

2009-06-17 Thread matthew andriani
Hi Guys, I wrote this program for some practice to get into python..I'm trying to find fun ways to learn the language so if anyone has a challenge on this basic level using loops that sounds exciting please let me know.. If you think this program can be improved please let me know too :) b =

Re: [Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

2009-06-17 Thread vince spicer
Like in any language there any number for ways, heres another b = "bottles of beer" w = "on the wall" bottles = range(1, 101) bottles.reverse() for bottle in bottles: print " %s %s %s if one of those bottles should happen to fall there'll be %s %s %s" % (bottle, b,w, bottle-1, b,w) Vince 200

Re: [Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

2009-06-17 Thread Gregor Lingl
matthew andriani schrieb: Hi Guys, I wrote this program for some practice to get into python..I'm trying to find fun ways to learn the language so if anyone has a challenge on this basic level using loops that sounds exciting please let me know.. If you think this program can be improved ple

Re: [Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

2009-06-17 Thread Emile van Sebille
On 6/17/2009 1:46 PM matthew andriani said... Hi Guys, I wrote this program for some practice to get into python..I'm trying to find fun ways to learn the language so if anyone has a challenge on this basic level using loops that sounds exciting please let me know.. Exciting? How about wri

Re: [Tutor] converting encoded symbols from rss feed?

2009-06-17 Thread Serdar Tumgoren
Hey everyone, For the moment, I opted to use string replacement as my "solution." So for the below string containing the HTML decimal represenation for en dash: >>>x = "The event takes place June 17 – 19" >>>x.replace('–', '-') 'The event takes place June 17 - 19' It works in my case since this

[Tutor] List Splicing

2009-06-17 Thread Robert Berman
Greetings, I am working on a 'simple' algorithm to solve the problem called PRIME1 explained at http://www.spoj.pl/problems/PRIME1/. I do have an algorithm based on the Sieve of Eratosthenes and it does work as I am failing the project not because of a computational error but because of the drea

Re: [Tutor] List Splicing

2009-06-17 Thread Emile van Sebille
On 6/17/2009 3:03 PM Robert Berman said... Greetings, I am working on a 'simple' algorithm to solve the problem called PRIME1 explained at http://www.spoj.pl/problems/PRIME1/. I do have an algorithm based on the Sieve of Eratosthenes and it does work as I am failing the project not because of

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Emile, Thank your for your comments. I do have a list running from 0-101. Yes, it is true, I only needed 0 - 10 and yes I will change it. However, if you use primearray as a sieve of all primes 2-100 you will see it works quite well. Printing a range, say primearray[21] through primear

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Emille, Thank you for the example of list splicing. Do you know if this is faster than a more conventional loop statement as in my code for primearray which is in my original post (reprinted here) The code is as follows: def BuildSieve(itemsin): TheSieve=list() TheSieve = range(0,itemsi

Re: [Tutor] List Splicing

2009-06-17 Thread Emile van Sebille
On 6/17/2009 4:48 PM Robert Berman said... Emile, Thank your for your comments. I do have a list running from 0-101. Yes, it is true, I only needed 0 - 10 and yes I will change it. However, if you use primearray you haven't posted the primearray code... However, for the time being

Re: [Tutor] List Splicing

2009-06-17 Thread Wayne
On Wed, Jun 17, 2009 at 7:11 PM, Robert Berman wrote: > Emille, > > Thank you for the example of list splicing. Do you know if this is faster > than a more conventional loop statement as in my code for primearray which > is in my original post (reprinted here) > > The code is as follows: > > d

Re: [Tutor] List Splicing

2009-06-17 Thread Emile van Sebille
On 6/17/2009 5:11 PM Robert Berman said... Emille, Thank you for the example of list splicing. Do you know if this is faster than a more conventional loop statement Faster can be exactly determined using timeit. (for some definition of exact -- the one we use mostly around here anyway)

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Wayne, Thank you for the suggestion. I will let you know how well this plays out. Robert On Wed, 2009-06-17 at 19:26 -0500, Wayne wrote: > On Wed, Jun 17, 2009 at 7:11 PM, Robert Berman > wrote: > Emille, > > Thank you for the example of list splicing. Do you know i

Re: [Tutor] List Splicing

2009-06-17 Thread Robert Berman
Emille, Thank you very much for the information on timeit. I will investigate and use it. >>... but this isn't what BuildSieve yields: >>> BuildSieve(20) >>[0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0] >>So I still don't know what primearray is/does. If you look at or pr

[Tutor] Fast way to access items in a dictionary

2009-06-17 Thread Elisha Rosensweig
Hi, Till now, when I receive a dictionary that I'm not sure contains a certain key, I would use the following template to access a given key: if 'someKey' in dict.keys(): someData = dict['someKey'] is there a faster way to do this? accessing a key that does not exist will through an exception

Re: [Tutor] List Splicing

2009-06-17 Thread bob gailer
Robert Berman wrote: Greetings, I am working on a 'simple' algorithm to solve the problem called PRIME1 explained at http://www.spoj.pl/problems/PRIME1/. I do have an algorithm based on the Sieve of Eratosthenes and it does work as I am failing the project not because of a computational error

Re: [Tutor] Fast way to access items in a dictionary

2009-06-17 Thread Wayne
On Wed, Jun 17, 2009 at 7:39 PM, Elisha Rosensweig wrote: > Hi, > > Till now, when I receive a dictionary that I'm not sure contains a certain > key, I would use the following template to access a given key: > > if 'someKey' in dict.keys(): >someData = dict['someKey'] > > is there a faster way

Re: [Tutor] Fast way to access items in a dictionary

2009-06-17 Thread Emile van Sebille
On 6/17/2009 5:39 PM Elisha Rosensweig said... Hi, Till now, when I receive a dictionary that I'm not sure contains a certain key, I would use the following template to access a given key: if 'someKey' in dict.keys(): someData = dict['someKey'] is there a faster way to do this? Looks l

Re: [Tutor] List Splicing

2009-06-17 Thread Luke Paireepinart
Robert Berman wrote: Emille, Thank you for the example of list splicing. Do you know if this is faster than a more conventional loop statement as in my code for primearray which is in my original post (reprinted here) As has been mentioned, you will want to profile your code to know what is

Re: [Tutor] Fast way to access items in a dictionary

2009-06-17 Thread Luke Paireepinart
Looks like a simple 'in' is faster both when it's there... >>> Timer("'D' in {'D':123}.keys()").timeit() 0.93669924584355613 >>> Timer("'D' in {'D':123}").timeit() 0.34678047105990117 ... and when it isn't... >>> Timer("'E' in {'D':123}.keys()").timeit() 0.99194670371434768 >>> Timer("'E'

[Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-17 Thread Karen Palen
I am an experienced C/C++/C# programmer who is just starting out with Python. My first attempt at IDLE worked great with the tutorial, but seems to have a problem with my first real app! I am trying to get the Python subprocess/Popen module working with the example from the Python 3 documentat

Re: [Tutor] Apparent incosistency with Python interperter in IDLE

2009-06-17 Thread Luke Paireepinart
Karen Palen wrote: Which appears to be merely the return code, not the stdout! It looks like I need to set some variable in IDLE, but I can't figure out exactly what is needed here. Can anyone point me to an answer? Well, Karen, according to my IDLE (admittedly it's 2.6 not 3.0 so it may