Re: [Tutor] 'slice', etc

2013-12-14 Thread eryksun
On Fri, Dec 13, 2013 at 6:24 PM, Mark Lawrence wrote: > On 07/12/2013 10:41, spir wrote: >> On 12/07/2013 02:45 AM, Mark Lawrence wrote: >>> >>> The good news is there is a memoryview in Python, see >>> http://docs.python.org/3/library/functions.html#func-memoryview. >>> The bad news is it doesn't

Re: [Tutor] Thanks a bunch (was Re: Tutor Digest, Vol 118, Issue 64)

2013-12-14 Thread eryksun
On Sat, Dec 14, 2013 at 10:16 AM, Walter Prins wrote: > > Gmail matches the format of the sender. If I reply to a text format > email, the reply is text format. If the original is HTML mail, it > replies in HTML format. In that sense it talks back and respects the > sender on their terms. Also

Re: [Tutor] Quantum computing

2013-12-14 Thread William Ray Wing
On Dec 14, 2013, at 1:22 PM, Mark Lawrence wrote: > On 14/12/2013 17:14, Alan Gauld wrote: >> On 14/12/13 15:37, Mark Lawrence wrote: >>> >>> I believe that quantum computing is way OT for the Python tutor mailing >>> list. >> >> Yeah, you are probably right. Although there are precedents where

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Dave Angel
On Sun, 15 Dec 2013 09:22:09 +1100, Steven D'Aprano wrote: I cannot reproduce that error. Perhaps you have inadvertently corrupted Another approach to narrow the problem might be to compare md5 hashes for your files. If you and the op have different hashes then he's probably got a corrupt fi

Re: [Tutor] Coding for a Secret Message in a Game

2013-12-14 Thread Sky blaze
Thank you for the answers! Unfortunately, I haven't had the time to test them out, but these answers make a lot of sense, and I'm sure they'd work. Again, thanks! *See ya!* -Skyblaze101 On Fri, Dec 13, 2013 at 2:20 PM, Danny Yoo wrote: > Whoops, made a small typo in the program I

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Steven D'Aprano
On Sat, Dec 14, 2013 at 09:29:00AM -0500, bruce wrote: > Hi. > > Looking at a file -->> > http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml > > The file is generated via online/web url, and appears to be XML. > > However, when I use elementtree: > document = E

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Steven D'Aprano
On Sat, Dec 14, 2013 at 04:03:09PM +0100, spir wrote: > On 12/14/2013 03:29 PM, bruce wrote: [...] > >Anyone have any python suggestions as to how to proceed to parse out the > >data! > > You do not tell us what you actually want to do. Since the input is invalid > (as XML), obviously you cannot

Re: [Tutor] Quantum computing

2013-12-14 Thread Mark Lawrence
On 14/12/2013 17:14, Alan Gauld wrote: On 14/12/13 15:37, Mark Lawrence wrote: I believe that quantum computing is way OT for the Python tutor mailing list. Yeah, you are probably right. Although there are precedents where we have discussed general topics about the future of computing and whe

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Felix Dietrich
bruce writes: > Looking at a file -->> > http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml> > > However, when I use elementtree: > > document = ElementTree.parse( '/apps/parseapp2/testxml.xml' ) > > I get an invalid error : not well-formed (invalid token): > >

Re: [Tutor] Quantum computing

2013-12-14 Thread Alan Gauld
On 14/12/13 15:37, Mark Lawrence wrote: I believe that quantum computing is way OT for the Python tutor mailing list. Yeah, you are probably right. Although there are precedents where we have discussed general topics about the future of computing and where/whether Python fits in. But QC is

Re: [Tutor] Quantum computing

2013-12-14 Thread Mark Lawrence
On 14/12/2013 04:36, David Hutto wrote: Recently, after having some personal problems, I've returned to looking at the future of not only prototyping languages like python, but also the more advanced/older(refinement of your computers resources) languages. My main question/topic, is what is to

Re: [Tutor] pass argument from python to powershell

2013-12-14 Thread Alan Gauld
On 14/12/13 12:57, phanidhar wrote: Have a code which is powershell script and i want to execute this script using python . example of powershell script content is : get-aduser $args[0] Python script : import subprocess import os a = subprocess.Popen([r'C:\WINDOWS\system32\WindowsPowerShell

Re: [Tutor] Thanks a bunch (was Re: Tutor Digest, Vol 118, Issue 64)

2013-12-14 Thread Walter Prins
Hi, On 14 December 2013 03:31, Steven D'Aprano wrote: > On Fri, Dec 13, 2013 at 02:24:15PM -0500, eryksun wrote: >> On Fri, Dec 13, 2013 at 12:47 PM, Mark Lawrence >> wrote: >> > Did you really have to send an entire digest, without changing the title, >> > just to send this one line? >> >> Gma

[Tutor] pass argument from python to powershell

2013-12-14 Thread phanidhar
Hi All , I am very new to python and really like to learn it . Have a code which is powershell script and i want to execute this script using python . example of powershell script content is : get-aduser $args[0] Python script : import subprocess import os a = subprocess.Popen([r'C:\WINDOWS\

Re: [Tutor] Quantum computing (Alan Gauld)

2013-12-14 Thread Bo Morris
ster or is it > merely a preference? Again, thank you. > > AngryNinja > > > On Fri, Dec 13, 2013 at 9:24 PM, Amit Saha wrote: > > > On Sat, Dec 14, 2013 at 11:03 AM, Bo Morris wrote: > > > i have the following simple function that iterates over the list. It >

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread spir
On 12/14/2013 03:29 PM, bruce wrote: Hi. Looking at a file -->> http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml The file is generated via online/web url, and appears to be XML. However, when I use elementtree: document = ElementTree.parse( '/apps/parseapp

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Stefan Behnel
bruce, 14.12.2013 15:29: > Looking at a file -->> > http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml That file looks ok to me. > The file is generated via online/web url, and appears to be XML. > > However, when I use elementtree: > document = ElementTree.pa

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread spir
On 12/14/2013 12:37 PM, Alan Gauld wrote: I must admit I'd never even thought of checking the __name__ attribute of a lambda, I'd kind of just assumed it would be empty (or maybe 'anonymous')! You are right, Alan, in my view. any_lambda_func.__name__ == "" would be a better choice. (And

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread spir
On 12/14/2013 03:28 PM, spir wrote: This 'cols' is not even defined in the piece of code you posted (which is not all reproduced above). Oops! did not see it as param of the enclosing func. Sorry for the error, Denis ___ Tutor maillist - Tutor@pytho

[Tutor] trying to parse an xml file

2013-12-14 Thread bruce
Hi. Looking at a file -->> http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml The file is generated via online/web url, and appears to be XML. However, when I use elementtree: document = ElementTree.parse( '/apps/parseapp2/testxml.xml' ) I get an invalid error

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread spir
On 12/14/2013 03:14 AM, Michael Crawford wrote: I found this piece of code on github mkdict = lambda row: dict((col, row[col]) for col in cols) #<< Apart form the "lambda" part, explained by others, one point I would note that makes the whole expression weird and hard to

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread spir
On 12/14/2013 10:12 AM, Bo Morris wrote: Thank you for your assistance. Based on your direction, I figured it out. *This... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10', '12'] [add(item) for item in x] *Is the same as... * def add(number): print 1 +

Re: [Tutor] Thanks a bunch (was Re: Tutor Digest, Vol 118, Issue 64)

2013-12-14 Thread spir
On 12/14/2013 04:31 AM, Steven D'Aprano wrote: To err is human, to forgive is humane. Nicely said. To the Original Poster, whoever you are... I hope you'll hang around here and [...] If it were me, he would probably not; too bad. Denis ___ Tutor

Re: [Tutor] 'slice', etc

2013-12-14 Thread spir
On 12/14/2013 12:24 AM, Mark Lawrence wrote: I've just remembered that one distinct disadvantage of memoryviews is that you can't use them anywhere if you want to do any sorting, as you can't compare them :( Not a blocker in my case (matching/parsing), thankfully. Denis __

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread Alan Gauld
On 14/12/13 10:12, Steven D'Aprano wrote: On Sat, Dec 14, 2013 at 09:27:17AM +, Alan Gauld wrote: Sorry, I don't think that is precise. lambda is not the name of the function. No. But *including the angle brackets* is the name of the function: py> (lambda x: x).__name__ '' Ah, OK. I'll

Re: [Tutor] Quantum computing

2013-12-14 Thread Steven D'Aprano
On Fri, Dec 13, 2013 at 11:36:37PM -0500, David Hutto wrote: > My main question/topic, is what is to become of languages like python with > the emergence of quantum computing? Almost certainly no change. I expect that quantum computing is still decades away from becoming common in high-end super

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread eryksun
On Fri, Dec 13, 2013 at 11:21 PM, Steven D'Aprano wrote: > >> >>> l = lambda x: x**2 >> >>> apply(l, (3,)) >> 9 > > The built-in function apply is deprecated in Python 2 and removed in > Python 3. Possibly using apply() was meant to be similar to pandas DataFrame.apply, but the latter applies a f

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread eryksun
On Sat, Dec 14, 2013 at 4:27 AM, Alan Gauld wrote: > Sorry, I don't think that is precise. lambda is not the name of the > function. You can't use lambda to access the function(s) or treat it > like any other kind of name in Python. In fact if you try to use it as a > name you'll likely get a synt

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread Steven D'Aprano
On Sat, Dec 14, 2013 at 09:27:17AM +, Alan Gauld wrote: > On 14/12/13 04:19, Steven D'Aprano wrote: > > >Lambda is just syntactic sugar for a function. It is exactly the same as > >a def function, except with two limitations: > > > >- there is no name, or to be precise, the name of all lambda

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread Peter Otten
Alan Gauld wrote: > On 14/12/13 04:19, Steven D'Aprano wrote: > >> Lambda is just syntactic sugar for a function. It is exactly the same as >> a def function, except with two limitations: >> >> - there is no name, or to be precise, the name of all lambda functions >> is the same, ""; > > Sorry,

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread Peter Otten
Bo Morris wrote: > Thank you for your assistance. Based on your direction, I figured it out. > > *This... * > > def add(number): > print 1 + int(number) > > x = ['2', '4', '6', '8', '10', '12'] > > [add(item) for item in x] > > *Is the same as... * > > > def add(number): > print

Re: [Tutor] Quantum computing

2013-12-14 Thread Alan Gauld
On 14/12/13 04:36, David Hutto wrote: My main question/topic, is what is to become of languages like python with the emergence of quantum computing? Nothing, I suspect, since by the time quantum computing hits the mainstream we will all have progressed to other languages anyhow. These kinds

Re: [Tutor] weird lambda expression -- can someone help me understand how this works

2013-12-14 Thread Alan Gauld
On 14/12/13 04:19, Steven D'Aprano wrote: Lambda is just syntactic sugar for a function. It is exactly the same as a def function, except with two limitations: - there is no name, or to be precise, the name of all lambda functions is the same, ""; Sorry, I don't think that is precise. lambda

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread Bo Morris
Thank you for your assistance. Based on your direction, I figured it out. *This... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10', '12'] [add(item) for item in x] *Is the same as... * def add(number): print 1 + int(number) x = ['2', '4', '6', '8', '10', '1

Re: [Tutor] Tutor Digest, Vol 118, Issue 62

2013-12-14 Thread Keith Winston
> > Message: 6 > Date: Thu, 12 Dec 2013 23:10:31 -0500 > From: Sky blaze > To: tutor@python.org > Subject: [Tutor] Coding for a Secret Message in a Game > > it'd be amusing to have the message change after the player types something > other than "start" at least 10 times. I've attempted numerous

[Tutor] Quantum computing

2013-12-14 Thread David Hutto
Recently, after having some personal problems, I've returned to looking at the future of not only prototyping languages like python, but also the more advanced/older(refinement of your computers resources) languages. My main question/topic, is what is to become of languages like python with the e