3 Suggestions to Make Python Easier For Children

2014-08-01 Thread Mark Summerfield
Last week I spent a couple of days teaching two children (10 and 13 -- too big an age gap!) how to do some turtle graphics with Python. Neither had programmed Python before -- one is a Minecraft ace and the other had done Scratch. Suggestion #1: Make IDLE start in the user's home directory. Sug

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Marko Rauhamaa
Chris Angelico : > On Sat, Aug 2, 2014 at 7:42 AM, Terry Reedy wrote: >> For mercurial, with no treat model, a 160 bit hash is used. Internet >> applications need more bits and carefully vetted algorithms to >> hopefully make the actual principle true. > > Ditto git, which also has no threat mod

Re: Python 3 is killing Python

2014-08-01 Thread Glenn Linderman
On 7/16/2014 7:27 AM, Frank Millman wrote: I just tried an experiment in my own project. Ned Batchelder, in his Pragmatic Unicode presentation, http://nedbatchelder.com/text/unipain.html, suggests that you always have some unicode characters in your data, just to ensure that they are handled corr

eval [was Re: dict to boolean expression, how to?]

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 17:44:27 +0200, Peter Otten wrote: > Alex van der Spek wrote: > > >> I do know eval() lends itself to code injection but can't say I am >> fully aware of its dangers. It seemed like a handy tool to me. > > In a lab if you don't need to protect your script against attacks fro

Re: converting ISO8601 date and time string representations to datetime

2014-08-01 Thread Akira Li
Wolfgang Maier writes: > On 08/01/2014 01:30 AM, Roy Smith wrote: >> In article , >> Albert-Jan Roskam wrote: >> In article , Wolfgang Maier wrote: > Hi, > I'm trying to convert ISO8601-compliant strings representing dates or > dates and times into datetime.datetime

Re: Bug with help (was Re: Getting a list of all modules)

2014-08-01 Thread Akira Li
Mark Lawrence writes: > On 31/07/2014 19:55, Akira Li wrote: >> Steven D'Aprano writes: >> >>> I'm looking for a programmatic way to get a list of all Python modules >>> and packages. Not just those already imported, but all those which >>> *could* be imported. >> ... >>> Is this problem already

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Chris Angelico
On Sat, Aug 2, 2014 at 11:47 AM, Steven D'Aprano wrote: > - It relies on the checksum being unpredictable, to prevent substitution > attacks: you're expecting object x with checksum a, but somebody > substitutes object y with checksum a instead. Note that this requirement is only an issue when th

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Chris Angelico : > >>> but hash(x) == hash(y) does NOT imply that x == y. >> >> Hello, pigeonhole principle :) If this were false - that is, if equal >> hashes DID imply equal objects - it would be necessary to completely >> encode an object's state in its hash, and hashes

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Chris Angelico
On Sat, Aug 2, 2014 at 10:00 AM, Gregory Ewing wrote: > MRAB wrote: >> in MacOS, even if I had a directory window open, I had to navigate to the >> directory in the Save dialog. > > Yes, that was annoying. It wasn't a problem to begin with, > because the original Mac was strictly single-tasking --

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Gregory Ewing
MRAB wrote: I'd heard people say how user-friendly Apple Macs were, but when I got to use one I was somewhat disappointed. Well, they were compared to MS-DOS and the like, which was all that was within reach of the general public when the first Mac appeared. RISCOS came along somewhat later.

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Chris Angelico
On Sat, Aug 2, 2014 at 7:42 AM, Terry Reedy wrote: > For mercurial, with no treat model, a 160 bit hash is used. Internet > applications need more bits and carefully vetted algorithms to hopefully > make the actual principle true. Ditto git, which also has no threat model. I don't know of any sit

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Chris Angelico
On Sat, Aug 2, 2014 at 9:14 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> The installer has basically three choices. >> 1) Install libnettle inside the application directory >> 2) Install libnettle to some system library directory >> 3) Don't install libnettle, and demand that someone els

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Chris Angelico
On Sat, Aug 2, 2014 at 6:22 AM, Michael Torrie wrote: > On 08/01/2014 08:39 AM, Chris Angelico wrote: >> The installer has basically three choices. >> 1) Install libnettle inside the application directory >> 2) Install libnettle to some system library directory >> 3) Don't install libnettle, and d

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Gregory Ewing
Chris Angelico wrote: The installer has basically three choices. 1) Install libnettle inside the application directory 2) Install libnettle to some system library directory 3) Don't install libnettle, and demand that someone else (perhaps the user, or the system package manager) install it. Opti

Re: dict to boolean expression, how to?

2014-08-01 Thread Terry Reedy
On 8/1/2014 11:02 AM, Steven D'Aprano wrote: On Fri, 01 Aug 2014 09:32:36 -0400, Roy Smith wrote: In article <53db95e6$0$29986$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: eval is almost never the right solution to any problem, and in the very few exceptions, it needs carefu

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Terry Reedy
On 8/1/2014 11:39 AM, Marko Rauhamaa wrote: Chris Angelico : but hash(x) == hash(y) does NOT imply that x == y. Hello, pigeonhole principle :) If this were false - that is, if equal hashes DID imply equal objects - it would be necessary to completely encode an object's state in its hash, and

Re: Creating a 2s compliment hex string for negitive numbers

2014-08-01 Thread bSneddon
On Friday, August 1, 2014 4:47:20 PM UTC-4, MRAB wrote: > On 2014-08-01 21:35, bSneddon wrote: > > > I need to calculate an error correction code for an old protocol. > > > > > > I calculate the integer 4617 and want to code the 2s compliment in ASCII > > > hex EDF7. When issue the following.

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread MRAB
On 2014-08-01 18:16, Dietmar Schwertberger wrote: Am 01.08.2014 13:10, schrieb Wolfgang Keller: Because on such operating systems, each and every application is an entirely self-contained package that doesn't need any "packages" or "installers" to use it. For people who have never used such a s

Re: Creating a 2s compliment hex string for negitive numbers

2014-08-01 Thread MRAB
On 2014-08-01 21:35, bSneddon wrote: I need to calculate an error correction code for an old protocol. I calculate the integer 4617 and want to code the 2s compliment in ASCII hex EDF7. When issue the following. hex(-4617) '-0x1209' Does anyone know a clean way to get to the desired results?

Creating a 2s compliment hex string for negitive numbers

2014-08-01 Thread bSneddon
I need to calculate an error correction code for an old protocol. I calculate the integer 4617 and want to code the 2s compliment in ASCII hex EDF7. When issue the following. >>> hex(-4617) '-0x1209' Does anyone know a clean way to get to the desired results? My ECC will always be 16 bit (4

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Michael Torrie
On 08/01/2014 08:39 AM, Chris Angelico wrote: > The installer has basically three choices. > 1) Install libnettle inside the application directory > 2) Install libnettle to some system library directory > 3) Don't install libnettle, and demand that someone else (perhaps the > user, or the system pa

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Dietmar Schwertberger
Am 01.08.2014 13:10, schrieb Wolfgang Keller: Because on such operating systems, each and every application is an entirely self-contained package that doesn't need any "packages" or "installers" to use it. For people who have never used such a system it's probably difficult to see the advantage

Re: dict to boolean expression, how to?

2014-08-01 Thread Peter Pearson
On 01 Aug 2014 14:26:38 GMT, Alex van der Spek wrote: [snip] > This newsgroup scares me, it appears to be for professional computer > scientists only, the theoretical part is sometimes too much for this > practical physicist with an old background in FORTRAN. > > Is there a better place to ask q

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 16:50:51 +0100, Mark Lawrence wrote: >> which can be simplified to: >> >> flag = any( cond[c] == 1 and cond[c.upper()] for c in ['a', 'b', 'c'] ) >> >> > Shouldn't that be cond[c.upper()] == 0 ? Yes it should be, thank you! -- Steven -- https://mail.python.org/mailman/list

Re: dict to boolean expression, how to?

2014-08-01 Thread Mark Lawrence
On 01/08/2014 15:26, Alex van der Spek wrote: On Fri, 01 Aug 2014 12:45:12 +, Alex van der Spek wrote: With a dict like so: cond = {'a': 1, 'b': 1, 'c': 1, 'A': 0, 'B', 0, 'C':0} how would you make a boolean expression like this: bool = (('a' == 1) & ('A' == 0) | ('b' =

Re: dict to boolean expression, how to?

2014-08-01 Thread Mark Lawrence
On 01/08/2014 16:24, Steven D'Aprano wrote: I don't know of anyone here who is an expert in pandas, so if you ask questions which are specific to pandas, we may run into the limits of our knowledge. If you can find a dedicated pandas mailing list or other forum, they may help too, but I don't kno

Re: dict to boolean expression, how to?

2014-08-01 Thread Mark Lawrence
On 01/08/2014 14:28, Steven D'Aprano wrote: On Fri, 01 Aug 2014 12:45:12 +, Alex van der Spek wrote: With a dict like so: cond = {'a': 1, 'b': 1, 'c': 1, 'A': 0, 'B', 0, 'C':0} how would you make a boolean expression like this: bool = (('a' == 1) & ('A' == 0) | ('b' ==

Re: Getting a list of all modules

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 14:39:09 +0100, Robert Kern wrote: > Take a look at what has already been implemented in IPython: > > https://github.com/ipython/ipython/blob/master/IPython/core/ completerlib.py#L208 Awesome! Thank you! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: dict to boolean expression, how to?

2014-08-01 Thread Peter Otten
Alex van der Spek wrote: > I do know eval() lends itself to code injection but can't say I am > fully aware of its dangers. It seemed like a handy tool to me. In a lab if you don't need to protect your script against attacks from outside eval() (and exec()) is fine. If the data fed to eval() is

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Marko Rauhamaa
Chris Angelico : >> but hash(x) == hash(y) does NOT imply that x == y. > > Hello, pigeonhole principle :) If this were false - that is, if equal > hashes DID imply equal objects - it would be necessary to completely > encode an object's state in its hash, and hashes would be impossibly > large. Th

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 14:26:38 +, Alex van der Spek wrote: [...] > bool = ((df['a'] == 1) & (df['A'] == 0) | > (df['b'] == 1) & (df['B'] == 0) | > (df['c'] == 1) & (df['C'] == 0)) > > I do know eval() lends itself to code injection but can't say I am fully > aware of its dange

Re: Python and IDEs

2014-08-01 Thread Marko Rauhamaa
Steven D'Aprano : > Marko Rauhamaa wrote: >> If you have ten Python apps, you'll have ten Python installations. > > A horrible thought. Hard drives are cheap, but not that cheap Well, iPhones aren't *that* expensive... >> Also the applications have no way to communicate outside their >> respect

Re: dict to boolean expression, how to?

2014-08-01 Thread marco . nawijn
Hi, Are you aware of the Python operator module? It provides function equivalents of all (most?) python operator. So instead of a==b, you can state operator.eq(a,b). As a result, you can loop over the key/value pairs in the dict and built your logic with the operator.eq, operator.and_, and operat

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 09:32:36 -0400, Roy Smith wrote: > In article <53db95e6$0$29986$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> eval is almost never the right solution to any problem, and in the very >> few exceptions, it needs careful handling by an expert to ensure you'

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Chris Angelico
On Sat, Aug 2, 2014 at 12:28 AM, Nicholas Cole wrote: > Actually, that's not right. RiscOS had and OS X has (I'm sure the > others do as well) a concept that is similar to a shared library. But > the joy of an application bundle is that installing an application > does not scatter its own files

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Ian Kelly
On Thu, Jul 31, 2014 at 9:28 PM, Terry Reedy wrote: > On 7/31/2014 5:15 PM, Ian Kelly wrote: >> >> On Thu, Jul 31, 2014 at 5:24 AM, Dilu Sasidharan >> wrote: >>> >>> Hi, >>> >>> I am wondering why the dictionary in python not returning multi value key >>> error when i define something like >>> >>

Re: dict to boolean expression, how to?

2014-08-01 Thread Ned Batchelder
On 8/1/14 8:45 AM, Alex van der Spek wrote: With a dict like so: cond = {'a': 1, 'b': 1, 'c': 1, 'A': 0, 'B', 0, 'C':0} how would you make a boolean expression like this: bool = (('a' == 1) & ('A' == 0) | ('b' == 1) & ('B' == 0) | ('c' == 1) & ('C' == 0)) The fact t

Re: dict to boolean expression, how to?

2014-08-01 Thread Alex van der Spek
On Fri, 01 Aug 2014 12:45:12 +, Alex van der Spek wrote: > With a dict like so: > > cond = {'a': 1, 'b': 1, 'c': 1, > 'A': 0, 'B', 0, 'C':0} > > how would you make a boolean expression like this: > > bool = (('a' == 1) & ('A' == 0) | > ('b' == 1) & ('B' == 0) | > ('c

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Nicholas Cole
On Fri, Aug 1, 2014 at 12:22 PM, Chris Angelico wrote: > On Fri, Aug 1, 2014 at 9:10 PM, Wolfgang Keller wrote: >> Thankfully, all actually user-friendly operating systems (MacOS, >> TOS, RiscOS, probably AmigaOS, MacOS X) spare(d) their users the >> bottomless cesspit of "package management" and

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Chris Angelico
On Fri, Aug 1, 2014 at 11:31 PM, Steven D'Aprano wrote: > Yes. Although Python promises (at least for classes in the standard > library) that x == y should imply that hash(x) == hash(y), it says > nothing about the other way: > > x == y implies that hash(x) == hash(y) This is the entire point of

Re: Getting a list of all modules

2014-08-01 Thread Robert Kern
On 2014-07-31 11:41, Steven D'Aprano wrote: On Wed, 30 Jul 2014 21:22:18 +0800, Leo Jay wrote: On Wed, Jul 30, 2014 at 3:43 PM, Steven D'Aprano wrote: I'm looking for a programmatic way to get a list of all Python modules and packages. Not just those already imported, but all those which *cou

Re: dict to boolean expression, how to?

2014-08-01 Thread Roy Smith
In article <53db95e6$0$29986$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > eval is almost never the right solution to any problem, and in the very > few exceptions, it needs careful handling by an expert to ensure you're > not introducing serious security bugs. Corollary to th

Re: Dict when defining not returning multi value key error

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 14:17:41 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thu, 31 Jul 2014 20:12:12 -0700, Dan Stromberg wrote: >> >> > I removed some quotes, and noticed that 1 and 1.0 hash the same. >> > That's a bit unexpected, but I suppose it's not completely >> > unreasonable

Re: Python and IDEs

2014-08-01 Thread Chris Angelico
On Fri, Aug 1, 2014 at 11:10 PM, Steven D'Aprano wrote: > Marko Rauhamaa wrote: > >> I'm guessing he's referring to the modern fad of application sandboxing. >> Each application is installed with everything it needs on top of the >> basic OS. >> >> If you have ten Python apps, you'll have ten Pyth

Re: dict to boolean expression, how to?

2014-08-01 Thread Steven D'Aprano
On Fri, 01 Aug 2014 12:45:12 +, Alex van der Spek wrote: > With a dict like so: > > cond = {'a': 1, 'b': 1, 'c': 1, > 'A': 0, 'B', 0, 'C':0} > > how would you make a boolean expression like this: > > bool = (('a' == 1) & ('A' == 0) | > ('b' == 1) & ('B' == 0) | > ('c

Re: dict to boolean expression, how to?

2014-08-01 Thread Roy Smith
In article <53db8bd8$0$2976$e4fe5...@news2.news.xs4all.nl>, Alex van der Spek wrote: > With a dict like so: > > cond = {'a': 1, 'b': 1, 'c': 1, > 'A': 0, 'B', 0, 'C':0} > > how would you make a boolean expression like this: > > bool = (('a' == 1) & ('A' == 0) | > ('b' == 1) &

Re: Python and IDEs

2014-08-01 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Chris Angelico : > >> On Fri, Aug 1, 2014 at 9:10 PM, Wolfgang Keller wrote: >>> Because on such operating systems, each and every application is an >>> entirely self-contained package that doesn't need any "packages" or >>> "installers" to use it. >> >> You mean everyone

Re: dict to boolean expression, how to?

2014-08-01 Thread Chris Angelico
On Fri, Aug 1, 2014 at 10:45 PM, Alex van der Spek wrote: > how would you make a boolean expression like this: > > bool = (('a' == 1) & ('A' == 0) | > ('b' == 1) & ('B' == 0) | > ('c' == 1) & ('C' == 0)) Not sure what the use of this is, because 'a' will never be equal to 1. Are y

dict to boolean expression, how to?

2014-08-01 Thread Alex van der Spek
With a dict like so: cond = {'a': 1, 'b': 1, 'c': 1, 'A': 0, 'B', 0, 'C':0} how would you make a boolean expression like this: bool = (('a' == 1) & ('A' == 0) | ('b' == 1) & ('B' == 0) | ('c' == 1) & ('C' == 0)) The fact that lowercase and uppercase keys are stringed tog

Re: Python and IDEs

2014-08-01 Thread Chris Angelico
On Fri, Aug 1, 2014 at 10:19 PM, Marko Rauhamaa wrote: > I'm guessing he's referring to the modern fad of application sandboxing. > Each application is installed with everything it needs on top of the > basic OS. > > If you have ten Python apps, you'll have ten Python installations. Also > the app

Re: Python and IDEs

2014-08-01 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Aug 1, 2014 at 9:10 PM, Wolfgang Keller wrote: >> Because on such operating systems, each and every application is an >> entirely self-contained package that doesn't need any "packages" or >> "installers" to use it. > > You mean everyone has to reinvent the proverbial w

Re: What is best way to learn Python for advanced developer?

2014-08-01 Thread Rustom Mody
On 07/30/2014 02:20 PM, guirec corbel wrote: > Hello, > I am a Ruby developer and I want to program in Python. I know how to > do simple things like create classes, methods, variables and all the > basics. I want to know more. I want to know what is the Python > philosophy, how to test, how to crea

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Chris Angelico
On Fri, Aug 1, 2014 at 9:10 PM, Wolfgang Keller wrote: > Thankfully, all actually user-friendly operating systems (MacOS, > TOS, RiscOS, probably AmigaOS, MacOS X) spare(d) their users the > bottomless cesspit of "package management" and/or "installers". > > Because on such operating systems, each

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Wolfgang Keller
> Windows and OS X users, sadly, miss out on the power of an integrated > package manager. Thankfully, all actually user-friendly operating systems (MacOS, TOS, RiscOS, probably AmigaOS, MacOS X) spare(d) their users the bottomless cesspit of "package management" and/or "installers". Because on