Re: [Tutor] If tuple cannot be sorted, then why sorted() on a tuple is fine?

2017-08-10 Thread Peter Otten
C W wrote: > This is a follow up. I actually ran into this today: > > import numpy as np > xArray = np.ones((3, 4)) > >> xArray.shape > (3, 4) >> np.shape(xArray) > (3, 4) > > It was confusing to see that both xArray.shape and np.shape() worked. Are > they equivalent? >>> print(inspect.getsour

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-10 Thread Chris Warrick
On 9 August 2017 at 23:15, Steven D'Aprano wrote: > On Tue, Aug 08, 2017 at 12:56:56PM +0200, Chris Warrick wrote: > >> While setuptools is not officially part of the stdlib, > > This is the critical factor. How can you use *by default* something that > is *NOT* supplied by default? > > Obviously

Re: [Tutor] What exactly does the three dots do? Why such as thing?

2017-08-10 Thread Steven D'Aprano
On Wed, Aug 09, 2017 at 12:06:37PM -0400, C W wrote: > Dear Python experts, > > What exactly does the three dots do? > > aList = ... ... is literal syntax for the Ellipsis singleton object. Ellipsis was added to the language at the express request of the numpy developers. Although numpy is a th

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread Steven D'Aprano
On Mon, Aug 07, 2017 at 10:04:21PM -0500, Zachary Ware wrote: > Next, take a dive into the wonderful* world of Unicode: > > https://nedbatchelder.com/text/unipain.html > https://www.youtube.com/watch?v=7m5JA3XaZ4k Another **Must Read** resource for unicode is: The Absolute Minimum Every Softwar

Re: [Tutor] What exactly does the three dots do? Why such as thing?

2017-08-10 Thread Steven D'Aprano
On Thu, Aug 10, 2017 at 09:39:02AM -0400, C W wrote: > What's a literal? The only other time I heard about it was studying > Shakespare. ;) A "literal" is syntax that creates a value, without the programmer needing to call a function. The syntax stands for the LITERAL value as shown. For examp

Re: [Tutor] What exactly does the three dots do? Why such as thing?

2017-08-10 Thread C W
What's a literal? The only other time I heard about it was studying Shakespare. ;) I don't know what literal is. So, it won't help me to understand ellipsis, I really thought it was that oval shaped figure. Wiki says: "Literals are often used to initialize variables" https://en.wikipedia.org/wik

Re: [Tutor] What exactly does the three dots do? Why such as thing?

2017-08-10 Thread Alan Gauld via Tutor
On 10/08/17 14:39, C W wrote: > I suppose it's just a place holder, though I don't know when I would use it > in my every day life. Probably never. Like most programming languages Python has a load of rarely used, obscure features. Most Python programmers never use ellipses, metaclasses(*), the

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread boB Stepp
On Thu, Aug 10, 2017 at 8:01 AM, Steven D'Aprano wrote: > > Another **Must Read** resource for unicode is: > > The Absolute Minimum Every Software Developer Absolutely Positively Must > Know About Unicode (No Excuses!) > > https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-softwa

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread boB Stepp
On Thu, Aug 10, 2017 at 8:40 PM, boB Stepp wrote: > On Thu, Aug 10, 2017 at 8:01 AM, Steven D'Aprano wrote: >> Python 3 makes Unicode about as easy as it can get. To include a unicode >> string in your source code, you just need to ensure your editor saves >> the file as UTF-8, and then insert (

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread Cameron Simpson
On 10Aug2017 20:40, boB Stepp wrote: (By the way, it is nearly 14 years later, and PHP still believes that the world is ASCII.) I thought you must surely be engaging in hyperbole, but at http://php.net/manual/en/xml.encoding.php I found: "The default source encoding used by PHP is ISO-8859-1.

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-10 Thread eryk sun
On Fri, Aug 11, 2017 at 2:34 AM, Cameron Simpson wrote: > > In files however, the default encoding for text files is 'utf-8': Python > will read the file's bytes as UTF-8 data and will write Python string > characters in UTF-8 encoding when writing. The default encoding for source files is UTF-8.