Re: [Tutor] Regex to find files ending with one of a given set of extensions

2010-02-22 Thread Dayo Adewunmi
Steven D'Aprano wrote: On Mon, 22 Feb 2010 04:23:04 am Dayo Adewunmi wrote: Hi all I'm trying use regex to match image formats: Perhaps you should use a simpler way. def isimagefile(filename): ext = os.path.splitext(filename)[1] return (ext.lower() in ('.jpg', '.jpeg', '

[Tutor] Drawing faces

2010-02-22 Thread Olufemi Onanuga
Hello, I am trying to write and test a function to meet the following specifications   drawFace(center,size,win),center is a point,size is an int,and win is a GraphWin.Draws a simple face of the given size in win.   I want the function to be able to draw three differnet faces in a single window,w

Re: [Tutor] Extracting comments from a file

2010-02-22 Thread Kent Johnson
On Mon, Feb 22, 2010 at 1:06 AM, Lao Mao wrote: > Hi, > > I have an html file, with xml style comments in: > > > > I'd like to extract only the comments.  My sense of smell suggests that > there's probably a library (maybe an xml library) that does this already. Take a look at BeautifulSoup: htt

Re: [Tutor] Drawing faces

2010-02-22 Thread Steven D'Aprano
On Mon, 22 Feb 2010 12:49:51 pm Olufemi Onanuga wrote: > Hello, > I am trying to write and test a function to meet the following > specifications > drawFace(center,size,win),center is a point,size is an int,and win is > a GraphWin.Draws a simple face of the given size in win. > I want the functio

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Steven D'Aprano
On Mon, 22 Feb 2010 06:37:21 pm spir wrote: > > It *seems* to work, because \d is left as backlash-d. But then you > > do this, and wonder why you can't open the file: > > I consider this misleading, since it can only confuse newcomers. > Maybe "lonely" single backslashes (not forming a "code" wit

Re: [Tutor] Functions returning multiple values

2010-02-22 Thread Giorgio
Ok, thankyou. So, in other words, i must pay attention to what i set as default value in a function. I should NEVER set empty lists as default values. The guide i've linked says "To learn more about this, you should read the documentation and look for the difference between *identity* and *equali

Re: [Tutor] Functions returning multiple values

2010-02-22 Thread Kent Johnson
On Mon, Feb 22, 2010 at 9:13 AM, Giorgio wrote: > And, i have some difficulties understanding the other "strange" example in > that howto. Just scroll down to: "However, the point is that the value > of x is picked up from the environment at the time when the function is > defined. How is this us

Re: [Tutor] Functions returning multiple values

2010-02-22 Thread Giorgio
Ahah Kent this is amazing. I was reading the ITALIAN http://www.python.it/doc/articoli/instpy-0.html version of that guide that is not updated. But, when i decided to post there i've posted the link of the guide in english, but actually that's not what i've readen. Ok, so in the new python versio

Re: [Tutor] "Two" Card Monty with File Operations--Reading from Wrong Folder (W7?) !!!

2010-02-22 Thread Wayne Watson
Well, it looks very much like my stab in the dark is very much correct ( see end of msg below). I changed the name of the file in the folder from which I copied the file to place elsewhere. When I tried to open the file, it started searching for the file.Properties clearly shows it pointing t

[Tutor] generating coordinates between two pairs

2010-02-22 Thread Jojo Mwebaze
Hello There, I got two pairs of coordinates say (4,5) and (7,9) from these two pairs i would like to generate two lists [4, 4, 4, 4, 4,5, 5, 5, 5, 5,6, 6, 6, 6, 6,7, 7, 7, 7, 7] and [5, 6, 7, 8, 9,5, 6, 7, 8, 9,5, 6, 7, 8, 9, 5, 6, 7, 8, 9] i am actually generating all co

Re: [Tutor] generating coordinates between two pairs

2010-02-22 Thread Jojo Mwebaze
sorry guys, i found a solution, ignore the post cheers Johnson On Mon, Feb 22, 2010 at 4:57 PM, Jojo Mwebaze wrote: > Hello There, > > I got two pairs of coordinates say (4,5) and (7,9) from these two pairs i > would like to generate two lists > > [4, 4, 4, 4, 4,5, 5, 5, 5, 5,6, 6, 6, 6

Re: [Tutor] generating coordinates between two pairs

2010-02-22 Thread Shashwat Anand
>>> [(i,j) for i in range(4, 5+1) for j in range(7, 9+1)] [(4, 7), (4, 8), (4, 9), (5, 7), (5, 8), (5, 9)] On Mon, Feb 22, 2010 at 9:33 PM, Jojo Mwebaze wrote: > sorry guys, i found a solution, ignore the post > > cheers > > Johnson > > > On Mon, Feb 22, 2010 at 4:57 PM, Jojo Mwebaze wrote: > >>

Re: [Tutor] Reading large bz2 Files

2010-02-22 Thread Stefan Behnel
Norman Rieß, 19.02.2010 13:42: > i am trying to read a large bz2 file with this code: > > source_file = bz2.BZ2File(file, "r") > for line in source_file: > print line.strip() > > But after 4311 lines, it stoppes without a errormessage. The bz2 file is > much bigger though. Could you send in

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Sithembewena Lloyd Dube
Wow, thank you Steve. This certainly answers a few questions i've had simmering for a while. On Mon, Feb 22, 2010 at 1:01 AM, Steven D'Aprano wrote: > On Mon, 22 Feb 2010 05:22:10 am Sithembewena Lloyd Dube wrote: > > Hi all, > > > > I'm trying to read a file (Python 2.5.2, Windows XP) as follows

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Sithembewena Lloyd Dube
@spr, thanks for the explanation, especially on representations of strings. To think that i freely used repr(variable_x) without fully understanding the meaning and the power of that function.. On Mon, Feb 22, 2010 at 9:37 AM, spir wrote: > Just a little complement to Steven's excellent explan

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Sithembewena Lloyd Dube
I believe i encountered repr()in the Python tutorial, but i had not kept the relevance of it in my memory.. On Mon, Feb 22, 2010 at 9:35 PM, Sithembewena Lloyd Dube wrote: > @spr, thanks for the explanation, especially on representations of strings. > To think that i freely used repr(variable_x)

[Tutor] Encryption

2010-02-22 Thread Antonio Buzzelli
Hi everyone! I need a simple way to encrypt and decrypt some strings with a key someone can help me?? Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Encryption

2010-02-22 Thread Wayne Werner
On Mon, Feb 22, 2010 at 2:50 PM, Antonio Buzzelli wrote: > Hi everyone! > I need a simple way to encrypt and decrypt some strings with a key > > someone can help me?? I'm sure someone can. -Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe

[Tutor] Searchlight/MVPA/ValueError

2010-02-22 Thread J
Dear all, I am trying to run a very simple searchlight on fMRI data via PyLab (on Mac Leopard). My code is as follows: from mvpa.suite import * import os from matplotlib.pyplot import figure, show from mvpa.misc.io.base import SampleAttributes from mvpa.datasets.nifti import NiftiDataset if __de

Re: [Tutor] Encryption

2010-02-22 Thread Shashwat Anand
how about using base64? base64.encodestring(s) will do. On Tue, Feb 23, 2010 at 2:30 AM, Wayne Werner wrote: > On Mon, Feb 22, 2010 at 2:50 PM, Antonio Buzzelli > wrote: > >> Hi everyone! >> I need a simple way to encrypt and decrypt some strings with a key >> >> someone can help me?? > > > I'

Re: [Tutor] Drawing faces

2010-02-22 Thread Alan Gauld
"Olufemi Onanuga" wrote I am trying to write and test a function to meet the following specifications drawFace(center,size,win),center is a point,size is an int, and win is a GraphWin.Draws a simple face of the given size in win. I want the function to be able to draw three differnet faces

[Tutor] Strange list behaviour in classes

2010-02-22 Thread C M Caine
Or possibly strange list of object behaviour IDLE 2.6.2 >>> class Player(): hand = [] >>> Colin = Player() >>> Alex = Player() >>> >>> Players = [Colin, Alex] >>> >>> def hands(): for player in Players: player.hand.append("A") >>> hands() >>> >>> Colin.ha

Re: [Tutor] Encryption

2010-02-22 Thread Modulok
>> I need a simple way to encrypt and decrypt some strings with a key. Did you have any other requirements? Any specific algorithms or key lengths? If you need real encryption, you might check out a 3rd party module named 'PyCrypto'. It offers an implementation of the AES algorithm. A less eloque

Re: [Tutor] Strange list behaviour in classes

2010-02-22 Thread Wayne Werner
On Mon, Feb 22, 2010 at 4:10 PM, C M Caine wrote: > Or possibly strange list of object behaviour > > IDLE 2.6.2 > >>> class Player(): >hand = [] > > > >>> Colin = Player() > >>> Alex = Player() > >>> > >>> Players = [Colin, Alex] > >>> > >>> def hands(): >for player in Players: >

Re: [Tutor] Strange list behaviour in classes

2010-02-22 Thread Benno Lang
On 23 February 2010 08:16, Benno Lang wrote: > class Hand: >    def __init__(self): >        self.hand = [] Of course, I meant "class Player" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/m

Re: [Tutor] Encryption

2010-02-22 Thread Steven D'Aprano
On Tue, 23 Feb 2010 07:50:12 am Antonio Buzzelli wrote: > Hi everyone! > I need a simple way to encrypt and decrypt some strings with a key > > someone can help me?? > > Thanks. I am the author of this package which might be enough for you: http://pypi.python.org/pypi/obfuscate/ If all you want

Re: [Tutor] Strange list behaviour in classes

2010-02-22 Thread Benno Lang
On 23 February 2010 07:10, C M Caine wrote: > Or possibly strange list of object behaviour > > IDLE 2.6.2 class Player(): >        hand = [] > > Colin = Player() Alex = Player() Players = [Colin, Alex] def hands(): >        for player in Players: >              

[Tutor] list to numpy record array

2010-02-22 Thread Vincent Davis
I must be missing something simple. I have a list of lists data = "[[' 0', ' 0', '234.0', '24.0', ' 25'], [' 1', ' 0', '22428.0', '2378.1', ' 25'],.." and what to make a record array from it but it gets screwed up or I don't get it, maybe both. Notice that at this stage the items are string