Re: Multi meaning of label: Doc bug

2019-02-26 Thread Rustom Mody
On Wednesday, February 27, 2019 at 11:12:28 AM UTC+5:30, Rustom Mody wrote:
> Ref: This stackexchange post:
> https://unix.stackexchange.com/q/503241/323121
> 
> Context: Theres this guy who's really struggling with disk partitioning LVM 
> etc concepts.  That point is not directly relevant to this question.
> 
> My answer on that post tries to clarify that 'label' can mean 3 things at 
> least; 
> and that just in the context of disks, partitions etc. Quite confusing!!
> 
> My question: In his parted output he has
> 
> Error: /dev/mapper/lubuntu--vg-home: unrecognised disk label
> 
> In which sense is this 'label' used??
> 
> Is it the Open/Free-BSD sense? Or the partition label sense?

OOps wrong list! Sorry!
-- 
https://mail.python.org/mailman/listinfo/python-list


Multi meaning of label: Doc bug

2019-02-26 Thread Rustom Mody
Ref: This stackexchange post:
https://unix.stackexchange.com/q/503241/323121

Context: Theres this guy who's really struggling with disk partitioning LVM etc 
concepts.  That point is not directly relevant to this question.

My answer on that post tries to clarify that 'label' can mean 3 things at 
least; 
and that just in the context of disks, partitions etc. Quite confusing!!

My question: In his parted output he has

Error: /dev/mapper/lubuntu--vg-home: unrecognised disk label

In which sense is this 'label' used??

Is it the Open/Free-BSD sense? Or the partition label sense?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [RELEASED] Python 3.4.9rc1 and Python 3.5.6rc1 are now available

2018-07-22 Thread Rustom Mody
On Friday, July 20, 2018 at 7:51:22 AM UTC+5:30, Larry Hastings wrote:
…
> the availability of Python 3.4.9rc1 and Python 3.5.6rc1.



> Python's entrenched bureaucracy soldiers on,
> //arry/



And ² at 325 posts of customary inanity at the recent events but nary a squeak 
of regret
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Rustom Mody
Marko wrote:
> When typing in code (in various languages), I have a habit of typing 
> "..." at places that need to be implemented

Quite a research area actually
https://wiki.haskell.org/GHC/Typed_holes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to fill in a dictionary with key and value from a string?

2018-04-01 Thread Rustom Mody
On Saturday, March 31, 2018 at 4:30:04 PM UTC+5:30, bartc wrote:
> On 30/03/2018 21:13, C W wrote:
> > Hello all,
> > 
> > I want to create a dictionary.
> > 
> > The keys are 26 lowercase letters. The values are 26 uppercase letters.
> > 
> > The output should look like:
> > {'a': 'A', 'b': 'B',...,'z':'Z' }
> 
> > I know I can use string.ascii_lowercase and string.ascii_uppercase, but how
> > do I use it exactly?
> > I have tried the following to create the keys:
> > myDict = {}
> >  for e in string.ascii_lowercase:
> >  myDict[e]=0
> 
> If the input string S is "cat" and the desired output is {'c':'C', 
> 'a':'A', 't':'T'}, then the loop might look like this:
> 
> D = {}
> for c in S:
> D[c] = c.upper()
> 
> print (D)
> 
> Output:
> 
> {'c': 'C', 'a': 'A', 't': 'T'}

As does…
>>> {c: c.upper() for c in s}
{'a': 'A', 'c': 'C', 't': 'T'} : dict

[Recent pythons; not sure when dict-comprehensions appeared]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting list of tuple to list

2018-03-29 Thread Rustom Mody
On Thursday, March 29, 2018 at 8:42:39 PM UTC+5:30, Ganesh Pal wrote:
> Hello Team,
> 
> 
> 
> I have a list of tuple say   [(1, 2, 1412734464L, 280), (2, 5, 1582956032L,
> 351), (3, 4, 969216L, 425)] .  I need to convert the above as
> ['1,2,1412734464:280',
> '2,5,1582956032:351', '3,4,969216:425']
> 
> 
> 
> Here is my Solution , Any  suggestion or optimizations are welcome .
> 
> 
> 
> Solution 1:
> 
> 
> 
> >>> list_tuple = [(1, 2, 1412734464L, 280), (2, 5, 1582956032L, 351), (3,
> 4, 969216L, 425)]
> 
> >>> expected_list = []
> 
> >>> for elements in list_tuple:
> 
> ... element = "%s,%s,%s:%s" % (elements)
> 
> ... expected_list.append(element)
> 
> ...
> 
> >>> expected_list
> 
> ['1,2,1412734464:280', '2,5,1582956032:351', '3,4,969216:425']
> 

>>> ["%s,%s,%s:%s" % tuple for tuple in list_tuple]
['1,2,1412734464:280', '2,5,1582956032:351', '3,4,969216:425'] : list


> 
> 
> 
> 
> Solution 2:
> 
> >>> list_tuple = [(1, 2, 1412734464L, 280), (2, 5, 1582956032L, 351), (3,
> 4, 969216L, 425)]
> 
> >>> expected_list = []
> 
> >>> for i in range(len(list_tuple)):
> 
> ... element = list_tuple[i]
> 
> ... ex_element = "%s,%s,%s:%s" % (element[0], element[1], element[2],
> element[3])
> 
> ... expected_list.append(ex_element)
> 
> ...
> 
> >>> expected_list
> 
> ['1,2,1412734464:280', '2,5,1582956032:351', '3,4,969216:425']
> 
> I know I should have not used len(range()) in  Solution 2, any more error
> please let me know  , I am a Linux user on Python 2.7

Dont get the point…
Not just of the len
But also the fact that element is a tuple whose components you extract and
immediately put together back into the the same old tuple
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Entering a very large number

2018-03-25 Thread Rustom Mody
On Monday, March 26, 2018 at 12:55:43 AM UTC+5:30, Peter J. Holzer wrote:
> On 2018-03-25 19:18:23 +0200, ast wrote:
> > Le 25/03/2018 à 03:47, Steven D'Aprano a écrit :
> > > The Original Poster (OP) is concerned about saving, what, a tenth of a
> > > microsecond in total? Hardly seems worth the effort, especially if you're
> > > going to end up with something even slower.
> > > 
> > > 
> > 
> > I regret that many answers are malicious, as your.

tl;dr:

I plead guilty with my almost first post in this thread containing: «In case 
there is a religious commitment to PEP 8 dicta… »

Apologies!

> 
> I just looked up "malicious" in Merriam-Webster, just in case it has
> some meaning I wasn't previously aware of.
> 
> Nope. It says: 
> 
> : having or showing a desire to cause harm to someone
> : given to, marked by, or arising from malice
> 
> and malice is defined as:
> 
> : desire to cause pain, injury, or distress to another
> : intent to commit an unlawful act or cause harm without legal
> justification or excuse
> 

O come! The OP is apparently not an English speaker; just do
s/malicious/gratuitously unkind/
or just
s/malicious/rude/

My excuse if any is that I was using “religious” in a precise way as
“belief-system” and the over-rigorous commitment to 72 (or whatever) length
lines can be a belief→commitment that produces egregious results

The deeper difficulty is that it is impossible to be human and not have some
non-verifiable beliefs. And yet when these beliefs harden into ossified
religions the results can be unimaginably pernicious

In particular, the complement set: belief-system - classic-religion
can contain the most pernicious examples:  Just compare the number killed in
the name of Islam or Christianity with those killed by communism and divide by
the number of years these 'religions' held sway

Some other examples:

1. Irreligion is a more pernicious belief-system than (classic) religion:
https://youtu.be/6PbYoQw8M48

2. Science as a delusional belief-system:
https://youtu.be/JKHUaNAxsTg

3. New-Atheism as a colonialist project: 
https://aquasanju.wordpress.com/2015/08/08/new-atheists-are-privilege-deniers-sushant-taing/

It is particularly striking that 2 above was banned! Shows how identical are the
subconscious psychological drivers of medieval popes and today's scientists 
(so-called)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Entering a very large number

2018-03-23 Thread Rustom Mody
On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote:
> Hi
> 
> I found this way to put a large number in
> a variable.

What stops you from entering the number on one single (v long) line?

In case there is a religious commitment to PEP 8 dicta, the recommended 
meditation is this line (also from PEP8):

"However, know when to be inconsistent -- sometimes style guide recommendations 
just aren't applicable"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Style Q: Instance variables defined outside of __init__

2018-03-21 Thread Rustom Mody
On Wednesday, March 21, 2018 at 5:37:48 AM UTC+5:30, Paul Rubin wrote:
> Ben Finney  writes:
> > Any program which needs to interact with systems outside itself – which
> > is to say, any program which performs useful work, ultimately – must
> > have side effects. So it's absurd to advocate removing *all* side
> > effects.
> 
> The way it (conceptually) works in Haskell is you write a purely
> functional program that returns a pure value of type "I/O action".  

Saw this coincidentally adjacent to this thread

https://youtu.be/ROor6_NGIWU

Its a view 'from the other side': a big name in functional programming
(not haskell) musing on how the world of IO, more generally world interaction,
could be cleaned up
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Treatment of NANs in the statistics module

2018-03-18 Thread Rustom Mody
On Saturday, March 17, 2018 at 3:22:46 PM UTC+5:30, Léo El Amri wrote:
> On 17/03/2018 00:16, Steven D'Aprano wrote:
> > The bug tracker currently has a discussion of a bug in the median(), 
> > median_low() and median_high() functions that they wrongly compute the 
> > medians in the face of NANs in the data:
> > 
> > https://bugs.python.org/issue33084
> > 
> > I would like to ask people how they would prefer to handle this issue:
> 
> TL;DR: I choose (5)

Just like to point out that 5 is really 5a and 5b
5a One can give the option at the function call point
5b One can set a module level flag:
See how pandas sets 'pandas.options. ...' for similar choices
https://pandas.pydata.org/pandas-docs/stable/missing_data.html

I guess I'd go for 5b even though it makes the code less 'functional' in the 
sense of FP — ie the same (looking) function call can have different effects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: Proposal: Deterministic Object Destruction

2018-03-01 Thread Rustom Mody
On Friday, March 2, 2018 at 10:05:41 AM UTC+5:30, Steven D'Aprano wrote:
> On Thu, 01 Mar 2018 16:26:47 -0800, ooomzay wrote:
> 
> >> >> When does the destination file get closed?
> >> >
> >> > When you execute:-
> >> >
> >> >del dst
> >> >
> >> > or:-
> >> >
> >> >dst = something_else
> >> 
> >> What if you don't?
> > 
> > Then the resource will remain open until your script exits at which
> > point it is probably not very well defined exactly when or even if the
> > destructor/__del__ will be called.
> > 
> > I.e. Don't do this! Did you have some realistic case in mind or are you
> > just probing the behaviour?
> 
> 
> If you're going to *require* the programmer to explicitly del the 
> reference:
> 
> f = open("file")
> text = f.read()
> del f
> 
> then you might as well require them to explicitly close the file:
> 
> f = open("file")
> text = f.read()
> f.close()
> 
> which we know from many years experience is not satisfactory except for 
> the simplest scripts that don't need to care about resource management.
> 
> That's the fatal flaw in RAII: for resources that you care about their 
> *timely* release, the problem is that the lifespan of the resource may 
> not be the same as the lifetime of the object. Especially for files, the 
> problem is that the lifespan of resource (the time you are actually using 
> it) may be significantly less than the lifespan of the object holding 
> onto that resource. Since there's no way for the interpreter to know 
> whether or not you have finished with the resource, you have a choice:
> 
> - close the resource yourself (either explicitly with file.close(), 
>   or implicitly with a context manager);
> 
> - or keep the resource open indefinitely, until such eventual time
>   that the object is garbage collected and the resource closed.

Please excuse if this has been addressed above and/or its too basic:
What's the difference between RAII and python's with/context-managers?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help me ? (Posting On Python-List Prohibited)

2018-03-01 Thread Rustom Mody
On Thursday, March 1, 2018 at 5:37:28 AM UTC+5:30, Steven D'Aprano wrote:
> On Wed, 28 Feb 2018 09:58:24 -0800, Aktive wrote:
> 
> > what the hell do you care about cheating..
> > 
> > the world doest care about cheating.
> > 
> > its about skill.
> 
> Because cheaters don't have skill. That's why they cheat.
> 
> 
> > You guys been too much in school
> 
> Ah, spoken like a cheater.

And in case you happen to want to ‘get real’
http://www.latimes.com/opinion/op-ed/la-oe-caplan-education-credentials-20180211-story.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread Rustom Mody
On Thursday, February 1, 2018 at 1:11:50 AM UTC+5:30, Victor Porton wrote:
> wxjmfauth wrote:
> 
> > Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
> >> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton  wrote:
> >> > LibComCom is a C library which passes a string as stdin of an OS
> >> > command and stores its stdout in another string.
> >> 
> >> Something like the built-in subprocess module does?
> >> 
> >> ChrisA
> > 
> > Do you mean the buggy subprocess module (coding of characters) ?
> > Yes, there is a working workaround : QtCore.QProcess().
> 
> Please elaborate: which bugs it has? in which versions?
> 

jmf is a pillar of the community who runs a campaign for equity and justice

In particular that a $ costs just 0x24  (6 significant bits)
whereas a € costs 0x20AC (14 bits) and (3 bytes in UTF-8 n0xE2 0x82 0xAC)
is highly unacceptable to him and he is taking it up with the UN.

We must heartily support him in this noble endeavour

[And when you get a chance to get your word in edgeways do ask him what this
has to do with python]


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-31 Thread Rustom Mody
On Wednesday, January 31, 2018 at 11:17:45 PM UTC+5:30, Adriaan Renting wrote:
> I am Dutch and after googling the term, I can confirm that the "Dutch
> Reach" is taught in driving school here.
> I was taught this maneuvre when getting my licence 20 years ago.

 

> And in the Netherlands, we largely solve this problem by just having
> everyone on a bike. ;-)
> (We do ride cars as well)

Good to have an existence proof for civilization

Topic remains wildly OT until somebody adds one more piece to the jigsaw:
"…statistical evidence that the practice of 'dutch-reach' has significantly
reduced the instances of dooring…"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Rustom Mody
On Tuesday, January 30, 2018 at 1:02:12 PM UTC+5:30, Steven D'Aprano wrote:
> On Mon, 29 Jan 2018 21:32:11 -0800, Rustom Mody wrote:
> 
> > On Sunday, January 28, 2018 at 8:37:11 PM UTC+5:30, Steven D'Aprano
> > wrote:
> >> I'm seeing this annoying practice more and more often. Even for trivial
> >> pieces of text, a few lines, people post screenshots instead of copying
> >> the code.
> >> 
> >> Where has this meme come from? It seems to be one which inconveniences
> >> *everyone* involved:
> > 
> > Have you heard of the “Dutch Reach¨?
> > http://www.telegraph.co.uk/travel/news/the-dutch-reach-how-opening-car-
> door-like-the-dutch-could-save-lives-cycling/
> 
> Ah, yes, the Dutch Reach. That would be like the French Pox (which isn't 
> French), the Spanish Flu (that didn't start in Spain), the Jerusalem 
> artichoke (which is neither an artichoke nor from Jerusalem), and the 
> turkey (the bird, which has nothing to do with Turkey, the country).
> 
> This technique is neither taught nor commonly used used by the Dutch: 
> apparently some Americans decided that because the Netherlands has a lot 
> of cyclists, they'll say its Dutch.

reference please But before we wander far afield OT please also read below
> 
> https://en.wikipedia.org/wiki/Dooring
> 
> So let me see if I understand the logic... 
> 
> Rather than teach people to *explicitly* check their mirror to make sure 
> it is safe before opening the car door, teach them a difficult, awkward 
> maneuver which they're guaranteed to stop using the second the driving 
> test is over, that merely points their head more-or-less vaguely in the 
> right direction to *maybe* notice on-coming cyclists *if and only if* 
> they're actually paying attention.

You have interpreted my example/analogy/allegory in the opposite sense from the 
intention.  The example is really far OT for this list so let me back up the abc
hierarchy:


> 
> I can see this falls under the problem solving technique, "We must do 
> something, this is something, therefore we must do it!"

…to wit: Small changes of convenience expecially when habitualized can yield 
large benefits
In this (OT) case using the 'wrong hand' can save lives

If this example does not work for you lets not labour it but find others that 
do!

> 
> The sorts of people who can't remember to check their mirror before 
> opening the car door aren't the sort who will remember to use this 
> awkward technique. And for those who can remember to do so, it is simpler 
> and more effective to explicitly check your mirror (as the Dutch actually 
> do).
> 
> 
> > Presumably it goes beyond the 'inconvenience' of images-instead-of-text
> > to the saving-of-lives…
> 
> I have no idea what connection you think is between this and emailing 
> pictures of source code in place of source code.

There is this slippery slope:
1. Action A is suboptimal (only makes sense wrt action B)
2. Action A is silly
3. You are doing a silly action A
4. You are silly for doing action A
5. You are silly
6. You are  

How close you are to 6 is for you to say
What I want to say is I'd like to be closer to 1

Text is a highly stylized unnatural medium
Its an extreme digitization of something (do you remember?) called handwriting…
At least I remember… being an unwilling school boy… using something called 
fountain pens… filled with something called ink… that for some reason had 
greater affinity for our school uniforms than for our notebooks

That people who have not been cultured in a certain way can do aggravating 
things
like talking with pics instead of text — I wont dispute
That people who have gone from the nature to nurture process conveniently forget
this process is more aggravating
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread Rustom Mody
On Sunday, January 28, 2018 at 8:37:11 PM UTC+5:30, Steven D'Aprano wrote:
> I'm seeing this annoying practice more and more often. Even for trivial 
> pieces of text, a few lines, people post screenshots instead of copying 
> the code.
> 
> Where has this meme come from? It seems to be one which inconveniences 
> *everyone* involved:

Have you heard of the “Dutch Reach¨?
http://www.telegraph.co.uk/travel/news/the-dutch-reach-how-opening-car-door-like-the-dutch-could-save-lives-cycling/

Presumably it goes beyond the 'inconvenience' of images-instead-of-text to the
saving-of-lives…
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: xpath prob, was Re: Why is there no functional xml?

2018-01-25 Thread Rustom Mody
On Wednesday, January 24, 2018 at 2:31:22 PM UTC+5:30, Peter Otten wrote:
> Rustom Mody wrote:
> 
> > With
> > # Read above xml
> >>>> with open('soap_response.xml') as f: inp = etree.parse(f)
> > # namespace dict
> >>>> nsd = {'soap': "http://schemas.xmlsoap.org/soap/envelope/;, 'locns':
> >>>> "http://example.com/"}
> > 
> > The following behavior is observed — actual responses elided in the
> > interest of brevity
> > 
> >>>> inp.xpath('//soap:Body', namespaces = nsd)
> > finds/reaches the node
> > 
> >>>> inp.xpath('//locns:blobRetrieveResponse', namespaces = nsd)
> > finds
> > 
> >>>> inp.xpath('//locns:dtCreationDate', namespaces = nsd)
> > does not find
> > 
> >>>> inp.xpath('//dtCreationDate', namespaces = nsd)
> > finds
> > 
> >>>> inp.xpath('//dtCreationDate')
> > also finds
> > 
> > 
> > Doesnt this contradict the fact that dtCreationDate is under the locns
> > namespace??
> > 
> > Any explanations??
> 
> Can you rewrite that question as a simple self-contained demo, similar to 
> the snippet shown under
> 
> http://lxml.de/xpathxslt.html#namespaces-and-prefixes
> 
> ?

I guess Dieter has cleared [thanks Dieter] that namespaces dont inherit to 
child 
tags. I need to wrap my head around the concepts and the syntax
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why is there no functional xml?

2018-01-23 Thread Rustom Mody
On Tuesday, January 23, 2018 at 8:23:43 PM UTC+5:30, Peter Otten wrote:
> Rustom Mody wrote:
> > [I find the OO/imperative style of making a half-done node and then
> > [throwing
> > piece-by-piece of contents in/at it highly aggravating]
> 
> What I meant is that once you throw a bit of introspection at it much of the 
> tedium vanishes. Here's what might become of the DOM-creation as part of an 
> actual script:


«snipped named-tuple magic»

> To generalize that to handle arbitrarily nested lists and namedtuples a bit 
> more effort is needed, but I can't see where lxml.objectify could make that 
> much easier.

You really mean that??
Well sure in the programming world and even more so in the python world
“Flat is better than nested” is a maxim

But equally programmers need to satisfy requirements…

And right now I am seeing things like this
---
http://schemas.xmlsoap.org/soap/envelope/;>

http://example.com/;>

  
AGGREGATION_ANALYSIS
  
  

  
  

  
  



  
  

  «Big base64 blob»

  





---
Thats 7 levels of nesting (assuming I can count right!)


Speaking of which another followup question:


With
# Read above xml
>>> with open('soap_response.xml') as f: inp = etree.parse(f)
# namespace dict
>>> nsd = {'soap': "http://schemas.xmlsoap.org/soap/envelope/;, 'locns': 
>>> "http://example.com/"}

The following behavior is observed — actual responses elided in the interest of
brevity

>>> inp.xpath('//soap:Body', namespaces = nsd)
finds/reaches the node

>>> inp.xpath('//locns:blobRetrieveResponse', namespaces = nsd)
finds

>>> inp.xpath('//locns:dtCreationDate', namespaces = nsd)
does not find

>>> inp.xpath('//dtCreationDate', namespaces = nsd)
finds

>>> inp.xpath('//dtCreationDate')
also finds


Doesnt this contradict the fact that dtCreationDate is under the locns 
namespace??

Any explanations??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why is there no functional xml?

2018-01-22 Thread Rustom Mody
On Sunday, January 21, 2018 at 4:51:34 PM UTC+5:30, Peter Otten wrote:
> Personally I'd probably avoid the extra layer and write a function that 
> directly maps dataclasses or database records to xml using the conventional 
> elementtree API.

Would appreciate your thoughts/comments Peter!

I find that you can get 'E' from lxml.objectify as well as lxml.builder
builder seems better in that its at least sparsely documented
objectify seems to have almost nothing beyond the original David Mertz' docs

builder.E seems to do what objectify.E does modulo namespaces

builder.E and objectify.E produce types that are different and look backwards
(at least to me — Elementbase is less base than _Element)

You seem to have some reservation against objectify, preferring the default 
Element — I'd like to know what

Insofar as builder seems to produce the same type as Element unlike objectify
which seems to be producing a grandchild type, do you have the same reservations
against builder.E?
--
$ python3
Python 3.5.3 (default, Nov 23 2017, 11:34:05) 
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from lxml.etree import Element, tostring
>>> from lxml.builder import E as Eb
>>> from lxml.objectify import E as Eo

>>> e = Element("tag")
>>> tostring(e)
b''
>>> o = Eb.tag()
>>> o

>>> tostring(o)
b''
>>> o = Eo.tag()
>>> tostring(o)
b'http://codespeak.net/lxml/objectify/pytype; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>'
>>> b = Eb.tag()
>>> tostring(b)
b''
>>> type(b)

>>> type(b).__bases__
(,)
>>> type(e)

>>> type(o)

>>> type(o).__bases__
(,)
>>> type(o).__bases__[0].__bases__
(,)
>>> 

--
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why is there no functional xml?

2018-01-21 Thread Rustom Mody
On Sunday, January 21, 2018 at 4:51:34 PM UTC+5:30, Peter Otten wrote:
> Rustom Mody wrote:
> 
> > Looking around for how to create (l)xml one sees typical tutorials like
> > this:
> > 
> > https://www.blog.pythonlibrary.org/2013/04/30/python-101-intro-to-xml-parsing-with-elementtree/
> > 
> > 
> > 
> > Given the requirement to build up this xml:
> > 
> > 
> > 1181251680
> > 04008200E000
> > 1181572063
> > 
> > 
> > 1800
> > Bring pizza home
> > 
> > 
> > 
> > 
> > 
> > the way I would rather do it is thus:
> > 
> > [Note in actual practice the 'contents' such as 1181251680 etc would come
> > from suitable program variables/function-calls
> > ]
> > 
> > 
> > ex = Ea("zAppointments",  {'reminder':'15'},
> > E("appointment",
> >   En("begin", 1181251680),
> >   Et("uid", "04008200E000"),
> >   En("alarmTime", 1181572063),
> >   E("state"),
> >   E("location"),
> >   En("duration",1800),
> >   Et("subject", "Bring pizza home")))
> > 
> > 
> > with the following obvious definitions:
> > 
> > [The function names are short so that the above becomes correspondingly
> > [readable]
> > 
> > 
> > from lxml.etree import Element
> > 
> > def Ea(tag, attrib=None, *subnodes):
> > "xml node constructor"
> > root = Element(tag, attrib)
> > for n in subnodes:
> > root.append(n)
> > return root
> > 
> > def E(tag, *subnodes):
> > "Like E but without attributes"
> > root = Element(tag)
> > for n in subnodes:
> > root.append(n)
> > return root
> > 
> > def Et(tag, text):
> > "A pure text node"
> > root = E(tag)
> > root.text = text
> > return root
> > 
> > def En(tag, text):
> > "A node containing a integer"
> > root = E(tag)
> > root.text = str(text)
> > return root
> > 
> > 
> > This approach seems so obvious that I find it hard to believe its not
> > there somewhere… Am I missing something??
> 
> lxml.objectify?
> 
> >>> from lxml import etree
> >>> from lxml.objectify import E
> >>> appointments = E.appointments(
> ... E.appointment(
> ... E.begin(1181251680),
> ... E.uid("04008200E000"),
> ... E.alarmTime(1181572063),
> ... E.state(),
> ... E.location(),
> ... E.duration(1800),
> ... E.subject("Bring pizza home")
> ... ),
> ... reminder="15"
> ... )
> >>> print(etree.tostring(appointments, pretty_print=True, encoding=str))
> http://codespeak.net/lxml/objectify/pytype; 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; reminder="15">
>   
> 1181251680
> 04008200E000
> 1181572063
> 
> 
> 1800
> Bring pizza home
>   
> 
> 
> >>> 

Nice!
I almost liked it… Then noticed that the attribute dict is in the wrong place
Here's the same without any namespace malarky:

>>> E = objectify.ElementMaker(annotate=False,namespace=None,nsmap=None)
>>> appointments = E.appointments(
E.appointment(
E.begin(1181251680),
E.uid("04008200E000"),
E.alarmTime(1181572063),
E.state(),
E.location(),
E.duration(1800),
E.subject("Bring pizza home")
),
reminder="15"
) 

>>> print(et.tostring(appointments,pretty_print=1).decode('ascii'))

  
1181251680
04008200E000
1181572063


1800
Bring pizza home
  


>>> 

Its obviously easier in python to put optional/vararg parameters on the
right side rather than on the left of a parameter list.
But its not impossible to get it in the desired order — one just has to 
'hand-parse' the parameter list received as a *param
Thusly:

appointments = E.appointments(
   {"reminder":"15"},
   E.appointment(
E.begin(1181251680),
E.uid("04008200E000"),
E.alarmTime(1181572063),
E.state(),
E.location(),
E.duration(1800),
E.subject("Bring pizza home")
) 
)

> 
> Personally I'd probably avoid the extra layer and write a function that 
> directly maps dataclasses or database records to xml using the conventional 
> elementtree API.

I dont understand…
[I find the OO/imperative style of making a half-done node and then throwing
piece-by-piece of contents in/at it highly aggravating]


-- 
https://mail.python.org/mailman/listinfo/python-list


Why is there no functional xml?

2018-01-20 Thread Rustom Mody
Looking around for how to create (l)xml one sees typical tutorials like this:

https://www.blog.pythonlibrary.org/2013/04/30/python-101-intro-to-xml-parsing-with-elementtree/



Given the requirement to build up this xml:


1181251680
04008200E000
1181572063


1800
Bring pizza home





the way I would rather do it is thus:

[Note in actual practice the 'contents' such as 1181251680 etc would come
from suitable program variables/function-calls
]


ex = Ea("zAppointments",  {'reminder':'15'},
E("appointment",
  En("begin", 1181251680),
  Et("uid", "04008200E000"),
  En("alarmTime", 1181572063),
  E("state"),
  E("location"),
  En("duration",1800),
  Et("subject", "Bring pizza home")))


with the following obvious definitions:

[The function names are short so that the above becomes correspondingly 
readable]


from lxml.etree import Element

def Ea(tag, attrib=None, *subnodes):
"xml node constructor"
root = Element(tag, attrib)
for n in subnodes:
root.append(n)
return root

def E(tag, *subnodes):
"Like E but without attributes"
root = Element(tag)
for n in subnodes:
root.append(n)
return root

def Et(tag, text):
"A pure text node"
root = E(tag)
root.text = text
return root

def En(tag, text):
"A node containing a integer"
root = E(tag)
root.text = str(text)
return root


This approach seems so obvious that I find it hard to believe its not there 
somewhere…
Am I missing something??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas printing in jupyter

2018-01-16 Thread Rustom Mody
On Tuesday, January 16, 2018 at 6:04:06 PM UTC+5:30, Rustom Mody wrote:
Had missed the mtd element

ie changing
elemfmt = """%d
"""
to 

elemfmt = """%d
"""
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas printing in jupyter

2018-01-16 Thread Rustom Mody
On Tuesday, January 16, 2018 at 5:10:14 PM UTC+5:30, Rustom Mody wrote:
> On Sunday, January 14, 2018 at 3:28:02 AM UTC+5:30, bo...@questa.la.so wrote:
> > Rustom Mody  writes:
> > 
> > > Specifically and for starters, I want a numpy array — lets say 2D to
> > > start with — to be displayed(displayable) as elegantly as sympy does
> > > to (its) matrices
> > 
> > import numpy as np
> > from IPython.display import Latex
> > 
> > def prmat(mat):
> > return (r'\begin{bmatrix}' +
> > r'\\'.join('&'.join('%f'%x for x in row) for row in mat) +
> > r'\end{bmatrix}'
> > 
> > a = np.arange(12).reshape((3, 4))+1
> > display(Latex(prmat(a)))
> > 
> > you could add optional arguments to modify the type of brackets and the
> > formatting string
> 
> Thanks
> 
> Well I had to tiny-tweak the code (import the display)
> ---
> 
> import numpy as np
> from IPython.display import Latex, display
> 
> def prmat(mat):
> return (r'\begin{bmatrix}' +
> r'\\'.join('&'.join('%f'%x for x in row) for row in mat) +
> r'\end{bmatrix}' )
> 
> a = np.arange(12).reshape((3, 4))+1
> display(Latex(prmat(a)))
> ---
> 
> After that it works… for 5 seconds!!
> 
> ie it shows a nice centered matrix like a math-display in latex
> Then it goes away and I see a left aligned bunch of unicode boxes!

Inspired by this I tried this
It works… kinda… but the matrix columns dont align

def prmat(mat):
return (r'\begin{bmatrix}' +
r'\\'.join('&'.join('%d'%x for x in row) for row in mat) +
r'\end{bmatrix}' )

matprefix = """
  

  [
  
"""
rowprefix = """
"""
elemfmt = """%d
"""
rowsuffix  = """
"""
matsuffix = """  
  ]

  
"""
def prmht(mat):
return (matprefix + "".join(prmhtrow(r) for r in mat) + matsuffix)

def prmhtrow(row):
return rowprefix + "".join(elemfmt%x for x in row) + rowsuffix

display(HTML(prmht(a)))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas printing in jupyter

2018-01-16 Thread Rustom Mody
On Sunday, January 14, 2018 at 3:28:02 AM UTC+5:30, bo...@questa.la.so wrote:
> Rustom Mody  writes:
> 
> > Specifically and for starters, I want a numpy array — lets say 2D to
> > start with — to be displayed(displayable) as elegantly as sympy does
> > to (its) matrices
> 
> import numpy as np
> from IPython.display import Latex
> 
> def prmat(mat):
> return (r'\begin{bmatrix}' +
> r'\\'.join('&'.join('%f'%x for x in row) for row in mat) +
> r'\end{bmatrix}'
> 
> a = np.arange(12).reshape((3, 4))+1
> display(Latex(prmat(a)))
> 
> you could add optional arguments to modify the type of brackets and the
> formatting string

Thanks

Well I had to tiny-tweak the code (import the display)
---

import numpy as np
from IPython.display import Latex, display

def prmat(mat):
return (r'\begin{bmatrix}' +
r'\\'.join('&'.join('%f'%x for x in row) for row in mat) +
r'\end{bmatrix}' )

a = np.arange(12).reshape((3, 4))+1
display(Latex(prmat(a)))
---

After that it works… for 5 seconds!!

ie it shows a nice centered matrix like a math-display in latex
Then it goes away and I see a left aligned bunch of unicode boxes!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pandas printing in jupyter

2018-01-11 Thread Rustom Mody
On Thursday, January 11, 2018 at 2:49:27 PM UTC+5:30, Thomas Jollans wrote:
> On 2018-01-11 09:59, Rustom Mody wrote:
> > On Thursday, January 11, 2018 at 2:13:46 PM UTC+5:30, Paul  Moore wrote:
> >> The HTML representation is supplied by the object's _repr_html_
> >> method. See https://ipython.org/ipython-doc/3/config/integrating.html
> >> for some details.
> >>
> >>>>> import pandas as pd
> >>>>> df = pd.DataFrame()
> >>>>> df._repr_html_()
> >> '\n

Re: Pandas printing in jupyter

2018-01-11 Thread Rustom Mody
On Thursday, January 11, 2018 at 2:13:46 PM UTC+5:30, Paul  Moore wrote:
> The HTML representation is supplied by the object's _repr_html_
> method. See https://ipython.org/ipython-doc/3/config/integrating.html
> for some details.
> 
> >>> import pandas as pd
> >>> df = pd.DataFrame()
> >>> df._repr_html_()
> 

Pandas printing in jupyter

2018-01-10 Thread Rustom Mody
If I make a data-frame in pandas in jupyter notebook it prints very nicely
ie it looks quite like a spreadsheet

How does it do it?
Who does it?

The data-frame does not seem to have str/repr methods…
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy and Terabyte data

2018-01-02 Thread Rustom Mody
On Wednesday, January 3, 2018 at 1:43:40 AM UTC+5:30, Paul  Moore wrote:
> On 2 January 2018 at 17:24, Rustom Mody wrote:
> > Someone who works in hadoop asked me:
> >
> > If our data is in terabytes can we do statistical (ie numpy pandas etc)
> > analysis on it?
> >
> > I said: No (I dont think so at least!) ie I expect numpy (pandas etc)
> > to not work if the data does not fit in memory
> >
> > Well sure *python* can handle (streams of) terabyte data I guess
> > *numpy* cannot
> >
> > Is there a more sophisticated answer?
> >
> > ["Terabyte" is a just a figure of speech for "too large for main memory"]
> 
> You might want to look at Dask (https://pypi.python.org/pypi/dask,
> docs at http://dask.pydata.org/en/latest/).

Thanks
Looks like what I was asking about
-- 
https://mail.python.org/mailman/listinfo/python-list


Numpy and Terabyte data

2018-01-02 Thread Rustom Mody
Someone who works in hadoop asked me:

If our data is in terabytes can we do statistical (ie numpy pandas etc)
analysis on it?

I said: No (I dont think so at least!) ie I expect numpy (pandas etc)
to not work if the data does not fit in memory

Well sure *python* can handle (streams of) terabyte data I guess
*numpy* cannot

Is there a more sophisticated answer?

["Terabyte" is a just a figure of speech for "too large for main memory"]

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: emacsclient does not select frame?

2017-12-31 Thread Rustom Mody
On Sunday, December 31, 2017 at 9:00:53 PM UTC+5:30, Rustom Mody wrote:
> With a lot of jumping through hoops Ive managed to get firefox to
> call emacs(client) and save links+description(title)+selection(in firefox; 
> optional) into an org mode capture buffer.
> 
> However the call to emacsclient does not raise the frame... At least not 
> consistently?
> 
> Currently my hack is to write my own shell wrapper to emacsclient doing
> 
> wmctrl -c emacs
> emacsclient -c $*
> wmctrl -a emacs
> 
> Is there some other thing I dont know to raise the emacs frame?
> 
> Also the -c I am forced to use because without it, if there is not an 
> existing 
> frame (emacs started in --daemon mode) it does not work
> 
> 
> Emacs 25.1.1
> Gnome-Unity

Oops
Wrong list
Apologies
And happy new year!
-- 
https://mail.python.org/mailman/listinfo/python-list


emacsclient does not select frame?

2017-12-31 Thread Rustom Mody
With a lot of jumping through hoops Ive managed to get firefox to
call emacs(client) and save links+description(title)+selection(in firefox; 
optional) into an org mode capture buffer.

However the call to emacsclient does not raise the frame... At least not 
consistently?

Currently my hack is to write my own shell wrapper to emacsclient doing

wmctrl -c emacs
emacsclient -c $*
wmctrl -a emacs

Is there some other thing I dont know to raise the emacs frame?

Also the -c I am forced to use because without it, if there is not an existing 
frame (emacs started in --daemon mode) it does not work


Emacs 25.1.1
Gnome-Unity
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto (Posting On Python-List Prohibited)

2017-12-29 Thread Rustom Mody
On Saturday, December 30, 2017 at 8:35:27 AM UTC+5:30, Lawrence D’Oliveiro 
wrote:
> On Saturday, December 30, 2017 at 12:12:23 PM UTC+13, bartc wrote:
> > Looking at 14 million lines of Linux kernel sources, which are in C, 
> > over 100,000 of them use 'goto'. About one every 120 lines.
> 
> That kind of thing leads to spaghetti code.
> 
> Here  is an example I like to bring 
> up: writing a Python extension module in C. As you know, this requires a lot 
> of careful memory management to cope with errors and avoid either memory 
> leaks or double-frees. The coding convention I came up with looks like this:
> 
> ... initialize pointers to allocated storage to NULL ...
> do /*once*/
>   {
> ... processing ...
> allocate some storage;
> if (error)
> break;
> ... more processing ...
> allocate more storage;
> if (error)
> break;
> ... even more processing ...
>   }
> while (false);
> ... free allocated storage ...
> 
> Basically, it becomes possible to satisfy yourself, by inspection, that every 
> possible control path through the above code will pass once, and only once, 
> through the storage deallocation.
> 
> Things get slightly more complicated where allocation has to happen in a 
> loop. Actually, that’s where the interesting cases happen. My technique can 
> be adapted to cope elegantly with this, too--see the code.

Bizarre how religions proliferate…
I wonder how many people who quote Dijkstra have read "goto statement considered
harmful". 
And that short letter was negative, aka "Don’t use goto!”

The more positive answer to the question: “Ok so then how to program?”
was "Structured Programming"
I am ready to bet that an even tinier percentage has ever seen that tome

And if one really got the gist of structuredness:
mapping an automaton with
state = label
transition = goto
is really the most clean structured mapping

One can do almost as well with a switch and (case) labels

You can make a virtue of the fact that python has neither
I call it blind religious genuflecting

BTW there can be quite good reasons for not putting¹ goto into a language
especially interpreted ones is that gotos tend to make semantics non 
compositional:

ie Say S₁ S₂ are two statements in the source language composed together into
a larger source statement S₁ □ S₂ which translates into T₁ ▽ T₂
Egs of S₁ □ S₂ could be ifthenelse sequencing etc
T₁ ▽ T₂ could be assembly code for S₁ followed by code for S₂ (for a compiler)
Or action of S₁ followed by action of S₂ (for interpreter)

Now if S₁ , S₂ has gotos jumping into each other this 
"homomorphic tree transforming model" becomes messed up

However in the face of exceptions² that are quite close to gotos I dont
think this logic would apply

Finally I would like to quote my teacher of programming who made a statement
that altered my next 30 years of programming life:

“What the goto does to control structure, the assignment does to data structure”

¹ The most important decisions for a language designer are what to leave out —
Nicklaus Wirth

² The original objectives of the language (Ada) included reliability,
readability of programs, formality of language definition, and even
simplicity. Gradually these objectives have been sacrificed in favor
of power, supposedly achieved by a plethora of features and notational
conventions, many of them unnecessary and some of them, like exception
handling, even dangerous
C.A.R. Hoare Turing lecture: 
https://amturing.acm.org/award_winners/hoare_4622167.cfm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-21 Thread Rustom Mody
On Friday, December 22, 2017 at 12:12:58 AM UTC+5:30, Python wrote:
> On Fri, Dec 15, 2017 at 04:51:09PM -0500, Bill wrote:
> > >I'm new to programming, can anyone guide me, how to start learning python 
> > >programming language,...plz suggest some books also.
> > >
> > >Thanks all
> > 
> > Are you sure you want to learn Python first?
> > Python does enough things "behind the scene"
> > that it makes me question the wisdom of that.
> > Other points of view are welcome, of course.
> > Learning the primitives of C++ first, may make for an easier transition.
> 
> This suggestion seems completely backwards to me.

In the locution "computer programming" there are two words
One can choose which one emphasizes I guess??

My own teacher of programming used to relate that when his teacher taught him
assembly language was "programming" and Fortran as "advanced"
Obviously the world today is different from the 1960s

But Gödel's theorem remains true as ever: No formal system (aka language)
is complete (suitable) for expressing everything
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to edit a function in an interactive python session?

2017-12-20 Thread Rustom Mody
On Thursday, December 21, 2017 at 7:12:24 AM UTC+5:30, Peng Yu wrote:
> Hi,
> 
> R has the function edit() which allows the editing of the definition
> of a function. Does python have something similar so that users can
> edit python functions on the fly? Thanks.
> 
> https://www.rdocumentation.org/packages/utils/versions/3.4.3/topics/edit

Dunno What exactly you are asking
And I suspect an “impedance mismatch” between the answers you are receiving and
what you seek.


Firstly on briefly looking at the R-docs that you quote I see that it does not
guarantee a faithful 'deparsing'… which I interpret as saying that R may
present to you a different (looking) function on (re) editing than what you 
typed

The real problem is that in the scale of religious dogmas python community
puts inter-OS portability/stability etc over and above development environment
This means that the tutorial is woefully inadequate (mostly by omission) in
terms of recommending a suitable dev environment.
And almost suggests that the basic interactive python shell is enough for 
writing/trying out python code.

This is patently false

An experienced programmer either:
-  Writes scripts (or GUI programs or web-apps or ...) using a full-featured 
editor like vim
Or 
- Uses a dev-environment — IDLE, emacs, pycharm, pydev, jupyter, org-babel… 
probably a dozen reasonable choices and hundreds of less reasonable ones

In either of these cases the question that you ask does not arise because the
code you are working on is always there "in another window"
- one click away from being tried out
- one click away from being edited (in its actual and not "deparsed" form)


I tend to use emacs
My students suffer me and my habits
As an editor its really clunky obsolete and asinine
But its not an editor; its an OS and in that sphere there is nothing else for 
competition
However I would not make this recommendation for emacs over the net
[Learning a dev-environment is like learning a musical instrument : not 
convenient over the net]


To a beginner I would recommend IDLE by default unless there is significant 
data 
pushing another choice

And if you try that you will see your question becomes automatically answered
(or irrelevant)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [META] Are the list admins honouring Posting Prohibited demands?

2017-12-20 Thread Rustom Mody
FYI:

On Wednesday, December 20, 2017 at 11:22:52 AM UTC+5:30, Steve D'Aprano wrote:
> This is possibly a question for the list admins...
> 
> I notice that Lawrence D’Oliveiro has taken up labelling his posts with a
> demand that his posts are not to be posted to the Python-List mailing list.


Lawrence D’Oliveiro was banned on 30 Sept 2016
https://groups.google.com/d/msg/comp.lang.python/5dNmgPvXR7U/iRSEp4LrBQAJ


> 
> I also see that his posts are not showing up on the mailing list archive. Is
> this a coincidence or a direct consequence of his demand?


Ban is supposed to have ended as of June 23 2017 (end of thread). Evidently 
not??

https://groups.google.com/d/msg/comp.lang.python/yQEarGwOl6M/1e-mJg3FBQAJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Python and Excel

2017-12-19 Thread Rustom Mody
On Tuesday, December 19, 2017 at 4:38:17 AM UTC+5:30, Les Cargill wrote:
> oliver wrote:
> > That would be amazing. I still have nightmares of when I had to create this
> > big options analysis VBA program in Excel 2007.
> > 
> 
> 
> Odd - I haven't found VBA itself to be all that horrible. Yeah, it's got 
> some serious weaknesses but it jut hasn't bit me badly, yet. Then again,
> it's not something I do a lot of.

In the era of Windows 95-98 I did some VBA — I quite liked the experience
Coming to libreoffice I find it boasts many languages which can program it
But Ive never managed to make any headway

Evidently documentation matters more than fancy language features [at least to 
me]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-17 Thread Rustom Mody
On Saturday, December 16, 2017 at 6:11:31 PM UTC+5:30, Marko Rauhamaa wrote:
> Stefan Ram:
> 
> > Varun R writes:
> >>I'm new to programming, can anyone guide me, how to start
> >>learning python programming language
> >
> >   As a start, one should learn:
> >
> > 1.) how to install Python
> > (if not already installed)
> >
> > 2.) how to start the Python console
> > (if not already started)
> >
> > 3.) how to type characters into a line of the
> > console and how to submit the line (using
> > the Enter key) (if this is not already known)
> 
> A good list. Even more important, though, is the installation, use and
> understanding of a text editor. What is the difference of MS Word,
> Notepad and a Python-aware text editor? 

This is a useful 3-way classification
Just now dealing with a class in which students write python resolutely 
- using gedit
- on linux VMs
- on Windows hosts

So I wonder where on the spectrum
MS Word → notepad → Programmer’s editor
would you place gedit??
[If you know what that is ]


> What text editors are there?
Seriously?!?
Does that list ever end?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-17 Thread Rustom Mody
In response to

> Rustom Mody wrote:
>> On Saturday, December 16, 2017 at 9:45:17 AM UTC+5:30, Bill wrote:
>>> so it really doesn't make that much difference where one starts, just
>>> "Do It!".  :  )
>> Really ¿?
>> https://en.wikipedia.org/wiki/Principles_of_learning#Primacy


On Sunday, December 17, 2017 Bill wrote:
> You would give precedence to something written on a wikipedia page over
> your experience?

Bill also wrote:
> …in college, the prerequisite of "at least co-enrolled in pre-calc",
> turned out to be the right one (based upon quite a lot of teaching
> experience).

So… I dont understand where you are coming from:
Is there such a thing as a “learning curve” or not?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning (Posting On Python-List Prohibited)

2017-12-17 Thread Rustom Mody
On Sunday, December 17, 2017 at 6:39:41 AM UTC+5:30, Lawrence D’Oliveiro wrote:
> On Sunday, December 17, 2017 at 2:26:43 AM UTC+13, Marko Rauhamaa wrote:
> 
> > Unfortunately, Python's indentation mechanism makes the REPL too
> > frustrating an environment to type in even the simplest of function
> > definitions, let alone a whole class.
> 
> Let me suggest using a Jupyter notebook as an introductory program editor.

Um… Well…
At first I did not take jupyter seriously
“browser is the universal OS” — Sounds like the usual empty fluff

But now seeing things like this:
http://www.leouieda.com/blog/scipy-on-android.html
I guess I am going to be force
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-15 Thread Rustom Mody
On Saturday, December 16, 2017 at 9:45:17 AM UTC+5:30, Bill wrote:
> Chris Angelico wrote:
> > On Sat, Dec 16, 2017 at 8:51 AM, Bill wrote:
> >> Varun R wrote:
> >>> Hi All,
> >>>
> >>> I'm new to programming, can anyone guide me, how to start learning python
> >>> programming language,...plz suggest some books also.
> >>>
> >>> Thanks all
> >>
> >> Are you sure you want to learn Python first?
> >> Python does enough things "behind the scene"
> >> that it makes me question the wisdom of that.
> >> Other points of view are welcome, of course.
> >> Learning the primitives of C++ first, may make for an easier transition.
> >> Surely this has been discussed before?
> > On the contrary, that makes Python an *excellent* first language. We
> > don't force people to learn about the chemistry of petrochemical
> > combustion before letting them learn how to drive a car; we don't make
> > people understand TCP/IP networking before they're allowed to type
> > something into Google. And if you DO want people to start off with a
> > lower-level language, why C++? Why not machine code (or at least
> > assembly code), since that's what the CPU actually executes?
> 
> Most decent introductions to C++ discuss machine language (it helps make 
> sense of compilation).
> As you indirectly suggest, learning is something of a circular process, 
> so it really doesn't make that much difference where one starts, just 
> "Do It!".  :  )

Really¿? 
https://en.wikipedia.org/wiki/Principles_of_learning#Primacy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Answers to homework questions [WAS]: Re: Python homework

2017-12-14 Thread Rustom Mody
On Thursday, December 14, 2017 at 7:02:56 PM UTC+5:30, Rustom Mody wrote:
> On Thursday, December 14, 2017 at 3:53:21 PM UTC+5:30, Lorenzo Sutton wrote:
> > Hi Roger,
> > 
> > On 13/12/17 23:31, ROGER GRAYDON CHRISTMAN wrote:
> > > On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
> > >>
> > > On 05/12/17 06:33, nick martinez2 via Python-list wrote:
> > >>> I have a question on my homework. 
> > [...]
> > >> For this kind of problem I think the collections module [1] can be very
> > >> useful. In this case in particular have a look at the Counter package ;)
> > [...]
> > > 
> > > A nice answer at face value, and for general questions, but
> > > perhaps not the best given the subject line and the first sentence
> > > in the OP's note.
> >  >
> > [...]
> > > When I teach my course, I have no desire to have
> > > all my students turn into cargo cultists.
> > > 
> > > At least this particular student did post his intended solution,
> > > instead of outright begging for code.  And most of the responses
> > > I see did attempt to work within the perceived constraints
> > > regarding what language tools the student was expected to use.
> > 
> > I see your point as a teacher, but after all this *is* a Python mailing 
> > list and not a python-homework-support mailing list.
> > 
> > Plus, the OP had already received various good answers specifically 
> > helping them solve the problem along the lines of his proposed code, so 
> > I guessed hinting to a standard library module which is interesting and 
> > potentially relevant in this case might be useful to both the OP and 
> > other people on the ML while enriching the discussion ;-)
> 
> Somebody has already pointed out that some setting in Roger Christman's 
> mail client(?) breaks discussion threads.
> Now either Lorenzo is also breaking threads…
> Or else something in Roger's post makes the next person (in this case Lorenzo)
> break the thread¿?

Didn't notice that Lorenzo had renamed the subject line
Sorry for noise
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Answers to homework questions [WAS]: Re: Python homework

2017-12-14 Thread Rustom Mody
On Thursday, December 14, 2017 at 3:53:21 PM UTC+5:30, Lorenzo Sutton wrote:
> Hi Roger,
> 
> On 13/12/17 23:31, ROGER GRAYDON CHRISTMAN wrote:
> > On Wed, Dec 13, 2017, Lorenzo Sutton wrote:
> >>
> > On 05/12/17 06:33, nick martinez2 via Python-list wrote:
> >>> I have a question on my homework. 
> [...]
> >> For this kind of problem I think the collections module [1] can be very
> >> useful. In this case in particular have a look at the Counter package ;)
> [...]
> > 
> > A nice answer at face value, and for general questions, but
> > perhaps not the best given the subject line and the first sentence
> > in the OP's note.
>  >
> [...]
> > When I teach my course, I have no desire to have
> > all my students turn into cargo cultists.
> > 
> > At least this particular student did post his intended solution,
> > instead of outright begging for code.  And most of the responses
> > I see did attempt to work within the perceived constraints
> > regarding what language tools the student was expected to use.
> 
> I see your point as a teacher, but after all this *is* a Python mailing 
> list and not a python-homework-support mailing list.
> 
> Plus, the OP had already received various good answers specifically 
> helping them solve the problem along the lines of his proposed code, so 
> I guessed hinting to a standard library module which is interesting and 
> potentially relevant in this case might be useful to both the OP and 
> other people on the ML while enriching the discussion ;-)

Somebody has already pointed out that some setting in Roger Christman's 
mail client(?) breaks discussion threads.
Now either Lorenzo is also breaking threads…
Or else something in Roger's post makes the next person (in this case Lorenzo)
break the thread¿?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double

2017-12-11 Thread Rustom Mody

This thread is getting like a mini hologram of our current surreal time…
If we can put aside who is right and wrong for a moment we see the more 
frightening spectacle that Repubs and democrats, Remainers and Brexiters and so 
on all over — by getting more and more shrill are not talking to each other but 
past each other

So…

On Tuesday, December 12, 2017 at 2:45:32 AM UTC+5:30, Rick Johnson wrote:
> Rustom Mody wrote:
> 
> [...]
> 
> > Whether there was nothing wrong in what I did, the "wrong-
> > right" was de facto, or de jureâ | I will leave to more wise
> > persons than myself
> 
> A file with no extension (regardless of the OS or desktop enviroment that it
> was created on), is like a sealed box with no label to indicate the contents.

So to Rick:

Not if you use something like file (magic)
My (unschooled) estimate is it gets its detection right 80% of the time

And to Chris and others who think file(magic) is a replacement for 
file-associations. Even assuming that magic works 100% :

Say I have an html file.
That means its ALSO a text file.
So its equally legitimate to set defaults to use…
- a plain text editor (of which there are hundreds)
- to open it in browser of choice (also plural nowadays)
- some sort of html composer
- etc

Which means we are beyond the nature of the file per se to the pattern of its 
usage

Yeah… magic… in the category of mind-reading? sooth-saying?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

2017-12-10 Thread Rustom Mody
On Sunday, December 10, 2017 at 11:15:15 AM UTC+5:30, Frank Millman wrote:
> "Rustom Mody"  wrote in message 
> 
> 
> 
> I was sending some files to some students.
> Since it was more than one, the natural choice was a tarball.
> [I believe that since it was a very tiny total space I did not compress the
> tarball… but I dont remember this part exactly]
> The point is that instead of sending a stuff.tgz or stuff.tar file I sent a 
> file
> called just stuff; ie I must have done:
> $ tar xvf stuff directory
> rather than the more normal
> $ tar xvf stuff.tar directory
> 
> I got a return mail soon enough: “Your file is corrupt; it wont open”
> (in file-roller or whatever tar-GUI the kids nowadays use)
> 
> I could have given them the answer: There are no associations in
> Linux. Just
> $ mv stuff stuff.tar
> and it will work
> As it happens I am lazy; easier to believe that my file was "wrongly" named;
> did the mv myself, and resent the now "correct" tarball; problem solved.
> 
> 
> 
> I had a similar experience a few years ago, but the recipient was not a 
> student, but a bank's IT department!
> 
> I had to send them an encrypted document, and their spec specified PGP. I 
> used GPG instead, which produces exactly the same result, but with a .gpg 
> file extension.
> 
> I was told that my file did not work. After much time trying to figure out 
> what was wrong, I spoke to one of their staff over the phone, and asked him 
> to right-click on the file, select 'rename', and change '.gpg' to '.pgp'. He 
> did so, tried again, and said 'Ah, now it works'.

Inspired by this thread, I added

alias o="xdg-open"

to my ~/.bash_aliases

And as best as I can see, now
$ o foo.png
$ o bar.mp3
$ o baz.pdf
and 
$ o http://python.org

all do the “Right Thing”

My main attraction for this is that I often end up doing evince foo.png instead 
of eog foo.png

The one thing that does not work (yet) is
$ o foo.py
starts up gedit (instead of emacs)

PS. As it happens I had figured out something for my students some years ago:
https://bitbucket.org/rustom/vit-projects/wiki/emacsasdefault

I’ll have to reread and recheckout what I wrote back then 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

2017-12-09 Thread Rustom Mody
On Sunday, December 10, 2017 at 10:12:38 AM UTC+5:30, Rustom Mody wrote:

> I was sending some files to some students. 
> Since it was more than one, the natural choice was a tarball.
> [I believe that since it was a very tiny total space I did not compress the 
> tarball… but I dont remember this part exactly]
> The point is that instead of sending a stuff.tgz or stuff.tar file I sent a 
> file 
> called just stuff; ie I must have done:
> $ tar xvf stuff directory
> rather than the more normal
> $ tar xvf stuff.tar directory

Er… Not xvf of course but cvf
[And yeah the v is not necessary]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

2017-12-09 Thread Rustom Mody
On Friday, December 8, 2017 at 6:40:17 AM UTC+5:30, Python wrote:
> On Thu, Dec 07, 2017 at 01:29:11PM +1100, Steve D'Aprano wrote:
> > On Thu, 7 Dec 2017 08:22 am, Python wrote:
> > >> > Linux doesn’t do “OS file associations”.
> > >> 
> > >> Then how does my Linux box know that when I double-click on a text file, 
> > >> it
> > >> launches kwrite rather than (say) the Gimp or LibreOffice?
> > > 
> > > The answer to that is (sadly) complicated.
> > 
> > Actually, no, the answer to my question is very simple: Lawrence is mistaken
> > about Linux not doing file associations. It does -- it is merely handled by
> > the desktop environment (if there is one).
> 
> Pedantically speaking, this is only *probably true*, not certainly
> true (e.g. running Linux on a text console with something like
> midnight commander, some unrelated file manager while running a
> particular desktop environment, etc.).  
> 
> But more importantly, practically speaking, it still doesn't really
> provide much more help to the OP than Lawrence's answer.  He may well
> know already that the desktop environment is what does the job (and
> probably does even, in broad terms, if he's familiar with computers in
> general), but have no idea how to configure it.  A reasonably helpful
> answer would be one that mentioned a few of the likely possibilities
> (Gnome, KDE, Unity, /etc/mime.types, "other"), and gave hints for how
> to find out the answer for each.  A thoroughly helpful answer would
> be, well, outside the scope of this list/group.
> 
> Pedantry has its place, FWIW. In the computer field, as with other
> science and engineering disciplines, often precision is much more
> essential than in other fields.  I personally find such precision is
> especially warranted if you take it upon yourself to criticize what
> someone else has said.  Though, providing such precision via natural
> language often turns out to be more challenging than one would hope...


I was sending some files to some students. 
Since it was more than one, the natural choice was a tarball.
[I believe that since it was a very tiny total space I did not compress the 
tarball… but I dont remember this part exactly]
The point is that instead of sending a stuff.tgz or stuff.tar file I sent a 
file 
called just stuff; ie I must have done:
$ tar xvf stuff directory
rather than the more normal
$ tar xvf stuff.tar directory

I got a return mail soon enough: “Your file is corrupt; it wont open”
(in file-roller or whatever tar-GUI the kids nowadays use)

I could have given them the answer: There are no associations in
Linux. Just
$ mv stuff stuff.tar
and it will work
As it happens I am lazy; easier to believe that my file was "wrongly" named;
did the mv myself, and resent the now "correct" tarball; problem solved.


Whether there was nothing wrong in what I did, the "wrong-right" was de facto,
or de jure… I will leave to more wise persons than myself
-- 
https://mail.python.org/mailman/listinfo/python-list


repeating posts

2017-12-08 Thread Rustom Mody
Repeating old posts again appearing

[No not complaining… I know people are working on it. Thanks Skip and whoever 
else]

Just thought I'd mention they are now mildly mojibaked
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: we want python software

2017-12-08 Thread Rustom Mody
On Wednesday, December 6, 2017 at 3:10:24 AM UTC+5:30, Igor Korot wrote:
> Hi, Tony,
>
> On Tue, Dec 5, 2017 at 11:10 AM, Tony van der Hoff  wrote:
> > On 05/12/17 16:55, Igor Korot wrote:
> >> Hi,
> >>
> >> On Tue, Dec 5, 2017 at 9:10 AM, Jyothiswaroop Reddy wrote:
> >>> Sir,
> >>> I am b.tech student I would like to learn python. So please send
the python software.
> >> Sorry, we don't send anything. You will have to go get it yourself. -)
> >>
> > Well, at least try to be helpful:
> > https://www.python.org/downloads/
>
> This is LMGIFY.
> If they say they are tech students - they should know how to work with
Google.
>
> And I even tried to be polite. I should have probably write something like:
>
> 1. Open the Web browser.
> 2. In the "Address Bar" type "www.pyton.org".
> 3. Find the link which reads "Downloads". Click on it.
> 4. Carefully read what version you need to install for your OS.
> 5. Apply the acquired knowledge and download the appropriate version.
> 6. Click on the installer (if on Windows).
> 7. Follow all the prompts.
> 8. Enjoy.
>
> but this is too much for the tech student.

You are assuming that the strangeness of the request is about 'tech'
[engineering/tech existed centuries before computers]

Do remember one can be a tech-{student,professional} without
- ever having encountered free-software
- internet/USENET culture

â | from which pov the request would not look so odd

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Anything similar to __END__ in perl

2017-12-08 Thread Rustom Mody
On Friday, December 8, 2017 at 3:13:56 PM UTC+5:30, Karsten Hilbert wrote:
> On Thu, Dec 07, 2017 at 11:55:48PM -0600, Peng Yu wrote:
> 
> > Hi, perl has __END__ which ignore all the lines below it.
> > 
> > Is there anything similar to __END__ in python? Thanks.
> 
> Something similar is:
> 
>   import sys
>   sys.exit()

That will give syntax (or something) errors for what follows

I'd say something similar is """

eg

$ cat xyz.py
def f():
print("hello world")

f()

"""
Tyger Tyger burning bright
In the forests of the night
What immortal hand or eye
Dare frame thy fearful symmetry
"""
-- 
https://mail.python.org/mailman/listinfo/python-list


Lies (was: we want python software)

2017-12-06 Thread Rustom Mody
On Wednesday, December 6, 2017 at 3:05:33 PM UTC+5:30, Steve D'Aprano wrote:
> (By the way Rustom, if you're reading, thank you for that link to the video a
> few weeks ago about teaching 2 + 2 = 22. My blood pressure just about doubled
> watching it.)

[Ref: https://youtu.be/Zh3Yz3PiXZw ]

Yes… Lies are a big problem today.
[For myself] Between being nice and being truthful, latter should have priority.

I was at first surprised and even a bit shocked when people called me 
right-wing.
Over time Ive come to accept that lies (left-wing) is upstream of hate 
(right-wing).  And to the extent that effects must be stemmed from causes, the 
world
is probably safer with the right than the left

Coming to this thread, I am surprised that you took to task Abhiram R for his
(minor) slips of posting,
neglecting to mention that the repeated vituperative posts of "KM" are 
chock-full of 
- grammatical errors
- spelling errors
- top-posting
- Indianisms like “lakh” “coolie” which are unlikely decipherable by an 
international audience 
And that in a post critical of Indians!
-- 
https://mail.python.org/mailman/listinfo/python-list


Politeness (was: we want python software)

2017-12-06 Thread Rustom Mody
On Wednesday, December 6, 2017 at 4:05:43 PM UTC+5:30, Steve D'Aprano wrote:
> On Wed, 6 Dec 2017 02:49 pm, Rustom Mody wrote:
> 
> > You are assuming that the strangeness of the request is about 'tech'
> > [engineering/tech existed centuries before computers]
> > 
> > Do remember one can be a tech-{student,professional} without
> > - ever having encountered free-software
> > - internet/USENET culture
> > 
> > … from which pov the request would not look so odd
> 
> So you're suggesting that rather than being unwilling to google for "Download
> Python" because he doesn't understand free software culture, the OP is
> unwilling to google for "Download Python" because he thinks it is proprietary
> software and wants a bunch of strangers on the Internet to send him a pirate
> copy?
> 
> I'm not entirely sure that's better...

Dunno anything about OP so no 'suggesting'…
I did hint one point above which can be restated more explicitly.

An engineering degree (aka “B.Tech”) can be in any of
- IT, CS, Computer Engineering etc
- aeronautics, civil, electrical, mechanical… classical, non-computer related
- bioinformatics, statistics, "scientific computing" etc ie heavy-duty *users*
  of computers

For the latter two classes it would be normal/natural for the student to have
little knowledge/interest in computer-related stuff except as a user.

Are you interested in the latest disk-drive technology? power-supplies?
 kernel? systemd-vs-sysv?  We use these all the time. Likewise these other 
fields are *users* of computers.

Inter alia I will mention: I have a colleague working on ACM's next curriculum
And the inter-disciplinarity of CS is the next big deal it would appear.

ie "unwilling to google" could well be "ignorant of google (usage/practices)"
Do consider the possibility that a student could be a non-owner of a computer
and/or studying in a college in a poor/non networked location.

So…

So while the specific slurs/attacks on some country are of near-zero interest 
to me — to support or oppose — the deeper divisions and inequities are (IMHO) 
more important.

So here's a little statistical exercise for you:
- Take any demographic of your choice containing programmers.
- Compute the male/female programmers in that population
- Now come to this list and work out the same ratio
- How do these ratios compare?
[When's the last time a woman appeared here?]

IOW I would wish Ethan's "control yourself" to be imperated — preferably
by oneself, if not then forcibly.
And especially when the vitriol is flung at a first-time poster.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: we want python software

2017-12-05 Thread Rustom Mody
On Wednesday, December 6, 2017 at 3:10:24 AM UTC+5:30, Igor Korot wrote:
> Hi, Tony,
> 
> On Tue, Dec 5, 2017 at 11:10 AM, Tony van der Hoff  wrote:
> > On 05/12/17 16:55, Igor Korot wrote:
> >> Hi,
> >>
> >> On Tue, Dec 5, 2017 at 9:10 AM, Jyothiswaroop Reddy wrote:
> >>> Sir,
> >>> I am b.tech student I would like to learn python. So please send 
> >>> the python software.
> >> Sorry, we don't send anything. You will have to go get it yourself. -)
> >>
> > Well, at least try to be helpful:
> > https://www.python.org/downloads/
> 
> This is LMGIFY.
> If they say they are tech students - they should know how to work with Google.
> 
> And I even tried to be polite. I should have probably write something like:
> 
> 1. Open the Web browser.
> 2. In the "Address Bar" type "www.pyton.org".
> 3. Find the link which reads "Downloads". Click on it.
> 4. Carefully read what version you need to install for your OS.
> 5. Apply the acquired knowledge and download the appropriate version.
> 6. Click on the installer (if on Windows).
> 7. Follow all the prompts.
> 8. Enjoy.
> 
> but this is too much for the tech student.

You are assuming that the strangeness of the request is about 'tech'
[engineering/tech existed centuries before computers]

Do remember one can be a tech-{student,professional} without
- ever having encountered free-software
- internet/USENET culture

… from which pov the request would not look so odd

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

2017-12-05 Thread Rustom Mody
On Tuesday, December 5, 2017 at 2:28:44 PM UTC+5:30, Lawrence D’Oliveiro wrote:
> On Tuesday, December 5, 2017 at 3:39:26 AM UTC+13, Rick Johnson wrote:
> > 
> > Sounds like your OS file associations are all botched-up ...
> 
> Linux doesn’t do “OS file associations”.

From a strict pov thats right

But then from a strict pov linux is not an OS, its just one component of an OS
https://www.howtogeek.com/177213/linux-isnt-just-linux-8-pieces-of-software-that-make-up-linux-systems/

The more pragmatic answer to this question is to run
$ man xdg-mime
$ man xdg-open
etc

(terrible documentation like everything else gnome… but thats another story)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why won't slicing lists raise IndexError?

2017-12-04 Thread Rustom Mody
On Tuesday, December 5, 2017 at 12:40:01 AM UTC+5:30, Jason Maldonis wrote:
> I was extending a `list` and am wondering why slicing lists will never
> raise an IndexError, even if the `slice.stop` value if greater than the
> list length.
> 
> Quick example:
> 
> my_list = [1, 2, 3]
> my_list[:100]  # does not raise an IndexError, but instead returns the full
> list
> 
> Is there any background on why that doesn't raise an IndexError? Knowing
> that might help me design my extended list class better. For my specific
> use case, it would simplify my code (and prevent `if isinstance(item,
> slice)` checks) if the slicing raised an IndexError in the example I gave.


Data Structures have invariants.
Some of these are just side-notes… interesting, cute
Some are more fundamental, the raison d'être for the data structure

Whether the following inv is that fundamental or not I wont offer an opinion
It certainly seems important (to me)

Python slice inv:   (∀ n:ℤ, l:sequence | l[:n] + l[n:] == l)

Your preferred inv:   (∀ n:ℤ, l:sequence ∧ jason_caveat(n) | l[:n] + l[n:] == l)
  where
   def jason_caveat(n,l):
  return 0 ≤ n ≤ len(l)

Do you consider it arguable that your preferred invariant is at least
more heavy-weight if not downright clunkier?

Note I am not offering a view on this.

eg for zip python does this

>>> zip([1,2,3], [4,5,6,7,8])
[(1, 4), (2, 5), (3, 6)]

I find myself sometimes needing this

Sometimes needing it extended to the longer (with what??)

Sometimes needing your preferred behavior — an exception

On a more fundamental note:
def const(x): return 42

has the invariant that const(x) == 42 when x is well-defined
This is true for most mainstream languages

Lazy functional languages (like Haskell) make a big deal of not having the
definedness caveat.
People (like me) not quite on the FP bandwagon are conflicted on whether the
mathematical elegance is worth the computational mess
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-27 Thread Rustom Mody
On Monday, November 27, 2017 at 10:49:35 PM UTC+5:30, Skip Montanaro wrote:
> > I strongly suspect that any recent emacs will have M-x insert-char
> > (earlier it was called ucs-insert) default bound C-x 8 RET (yeah thats 
> > clunky)
> > which will accept at the minibuffer input
> 
> I tried C-x 8 e acute TAB
> 
> and was prompted with "E-acute". I don't know why it would have
> capitalized the "e". 

Unicode codepoint names are (evidently) ALLCAPS-ASCII

Still, I plowed ahead and hit RET
> 
> which yielded an "Invalid character" message in the minibuffer.

Unicode is a million+ codepoints
Hundred thousand+ of which are assigned
This means that (as an analogy) emacs is fishing around in a 100,000 line file
which contains lines like
LATIN SMALL LETTER A:a:0x61
LATIN CAPITAL LETTER A:A:0x41
DIGIT ONE:1:0x31
... 100,000 such lines… one of which is
LATIN SMALL LETTER E WITH ACUTE:é:0xe9

[Just now fishing around I find its worse than that C-u C-x = tells me:

  character: é (displayed as é) (codepoint 233, #o351, #xe9)
  name: LATIN SMALL LETTER E WITH ACUTE
  old-name: LATIN SMALL LETTER E ACUTE
  general-category: Ll (Letter, Lowercase)

So those hundred thousand chars can have multiple names!!
And that constitutes the search space
]

So now coming to your attempt:

[ Writing this mail, Ive finally done:
(global-set-key (kbd "") 'insert-char)
which allows me to use F9 instead of the clunky C-x 8 RET
I'll assume that binding following
]

If I type
F9*e acuteTAB
I get 121 possibilities:

CANADIAN SYLLABICS FINAL DOUBLE ACUTE (ᐥ)
COMBINING DOTTED ACUTE ACCENT (᷁)
COMBINING DOUBLE ACUTE ACCENT (̋)
CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE (Ӳ)
CYRILLIC SMALL LETTER U WITH DOUBLE ACUTE (ӳ)
DEVANAGARI ACUTE ACCENT (॔) DOUBLE ACUTE ACCENT (˝)
GREEK UPSILON WITH ACUTE AND HOOK SYMBOL (ϓ)
LATIN CAPITAL LETTER A ACUTE (Á)
LATIN CAPITAL LETTER A WITH ACUTE (Á)
LATIN CAPITAL LETTER A WITH BREVE AND ACUTE (Ắ)
LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE (Ấ)
LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE (Ǻ)
LATIN CAPITAL LETTER AE WITH ACUTE (Ǽ)
LATIN CAPITAL LETTER C ACUTE (Ć)
LATIN CAPITAL LETTER C WITH ACUTE (Ć)
LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE (Ḉ)
LATIN CAPITAL LETTER E ACUTE (É)
LATIN CAPITAL LETTER E WITH ACUTE (É)
LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE (Ế)
LATIN CAPITAL LETTER E WITH MACRON AND ACUTE (Ḗ)
LATIN CAPITAL LETTER G WITH ACUTE (Ǵ)
LATIN CAPITAL LETTER I ACUTE (Í)
LATIN CAPITAL LETTER I WITH ACUTE (Í)
LATIN CAPITAL LETTER I WITH DIAERESIS AND ACUTE (Ḯ)
LATIN CAPITAL LETTER K WITH ACUTE (Ḱ)
LATIN CAPITAL LETTER L ACUTE (Ĺ)
LATIN CAPITAL LETTER L WITH ACUTE (Ĺ)
LATIN CAPITAL LETTER M WITH ACUTE (Ḿ)
LATIN CAPITAL LETTER N ACUTE (Ń)
LATIN CAPITAL LETTER N WITH ACUTE (Ń)
LATIN CAPITAL LETTER O ACUTE (Ó)
LATIN CAPITAL LETTER O DOUBLE ACUTE (Ő)
LATIN CAPITAL LETTER O WITH ACUTE (Ó)
LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE (Ố)
LATIN CAPITAL LETTER O WITH DOUBLE ACUTE (Ő)
LATIN CAPITAL LETTER O WITH HORN AND ACUTE (Ớ)
LATIN CAPITAL LETTER O WITH MACRON AND ACUTE (Ṓ)
LATIN CAPITAL LETTER O WITH STROKE AND ACUTE (Ǿ)
LATIN CAPITAL LETTER O WITH TILDE AND ACUTE (Ṍ)
LATIN CAPITAL LETTER P WITH ACUTE (Ṕ)
LATIN CAPITAL LETTER R ACUTE (Ŕ)
LATIN CAPITAL LETTER R WITH ACUTE (Ŕ)
LATIN CAPITAL LETTER S ACUTE (Ś)
LATIN CAPITAL LETTER S WITH ACUTE (Ś)
LATIN CAPITAL LETTER S WITH ACUTE AND DOT ABOVE (Ṥ)
LATIN CAPITAL LETTER U ACUTE (Ú)
LATIN CAPITAL LETTER U DIAERESIS ACUTE (Ǘ)
LATIN CAPITAL LETTER U DOUBLE ACUTE (Ű)
LATIN CAPITAL LETTER U WITH ACUTE (Ú)
LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE (Ǘ)
LATIN CAPITAL LETTER U WITH DOUBLE ACUTE (Ű)
LATIN CAPITAL LETTER U WITH HORN AND ACUTE (Ứ)
LATIN CAPITAL LETTER U WITH TILDE AND ACUTE (Ṹ)
LATIN CAPITAL LETTER W WITH ACUTE (Ẃ)
LATIN CAPITAL LETTER Y ACUTE (Ý)
LATIN CAPITAL LETTER Y WITH ACUTE (Ý)
LATIN CAPITAL LETTER Z ACUTE (Ź)
LATIN CAPITAL LETTER Z WITH ACUTE (Ź)
LATIN SMALL LETTER A ACUTE (á)
LATIN SMALL LETTER A WITH ACUTE (á)
LATIN SMALL LETTER A WITH BREVE AND ACUTE (ắ)
LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE (ấ)
LATIN SMALL LETTER A WITH RING ABOVE AND ACUTE (ǻ)
LATIN SMALL LETTER AE WITH ACUTE (ǽ)
LATIN SMALL LETTER C ACUTE (ć)
LATIN SMALL LETTER C WITH ACUTE (ć)
LATIN SMALL LETTER C WITH CEDILLA AND ACUTE (ḉ)
LATIN SMALL LETTER E ACUTE (é)
LATIN SMALL LETTER E WITH ACUTE (é)
LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE (ế)
LATIN SMALL LETTER E WITH MACRON AND ACUTE (ḗ)
LATIN SMALL LETTER G WITH ACUTE (ǵ)
LATIN SMALL LETTER I ACUTE (í)
LATIN SMALL LETTER I WITH ACUTE (í)
LATIN SMALL LETTER I WITH DIAERESIS AND ACUTE (ḯ)
LATIN SMALL LETTER K WITH ACUTE (ḱ)
LATIN SMALL LETTER L ACUTE (ĺ)
LATIN SMALL LETTER L WITH ACUTE (ĺ)
LATIN SMALL LETTER M WITH ACUTE (ḿ)
LATIN SMALL LETTER N ACUTE (ń)
LATIN SMALL LETTER N WITH ACUTE (ń)
LATIN SMALL LETTER O ACUTE (ó)
LATIN SMALL LETTER O DOUBLE ACUTE (ő)
LATIN SMALL LETTER O WITH ACUTE (ó)
LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE (ố)
LATIN SMALL LETTER O WITH DOUBLE ACUTE 

Re: Increasing the diversity of people who write Python (was:

2017-11-27 Thread nospam . Rustom Mody
On Monday, November 27, 2017 at 8:07:47 PM UTC+5:30, Chris Angelico wrote:
> On Tue, Nov 28, 2017 at 1:25 AM, Rustom Mody wrote:
> > You could go one step more sophisticated and use TeX-input method
> > (C-x RET C-\)
> > After which \'e will collapse as ÄC
> > â £Yeah ok but how the ^)*^$# am I to remember the mantra \'e?!â Ø you may
ask
> > Trueâ | So as you rightly do,
> > - pick it up from google
> > - put emacs into tex input mode
> > - paste from google into emacs
> > - place point on the new char and type C-u C-x =
> >   Among other things emacs will helpfully inform you (among other things)
> >   to input: type "\'{e}" or "\'e" with TeX input method
>
> Which is closely related to the Compose key input method that I use.
> First, you assign a key on your keyboard to be Compose (at least on
> all my systems, there isn't one by default); I use the key between
> left Ctrl and left Alt.

Ha Ha So you wont speak the unspeakable?â¿!â¡

I also have my compose set (to Capslock) And I entered those chars above with
C?? and C!! where C is Capslock

I most frequently use that for âçÆ (C=>) âåÆ (C->) â1 (C^1) âéü (C_1) etc One
can find other goodies at /usr/share/X11/locale/en_US.UTF-8/Compose

I didn't start with mentioning that to Skip because his basic requirement (as I
 got it) was that
- input method should be OS-neutral
- emacs can be assumed

And so the only OS-non-neutrality that I am aware of is that sometimes Alt
works as Meta (gui-emacsen) and sometimes not terminal/text emacsen (typically,
 though I believe some ppl successfully tweak this also) And so M-x can mean
Alt-x (chord) or ESC-x (sequence) and a few such anomalies But beyond that
emacsen should be same for all OSes (modulo versions)

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Increasing the diversity of people who write Python (was:

2017-11-27 Thread nospam . Rustom Mody
On Friday, November 24, 2017 at 10:11:24 PM UTC+5:30, Skip Montanaro wrote:
> > Because if I already can't understand the words, it will be more useful
> > to me to be able to type them reliably at a keyboard, for replication,
> > search, discussion with others about the code, etc.
>
> I am probably not alone in my Americo-centric world where I can't even
> easily type accented Latin-1 characters. I happen to be using Linux as
> I type this, but type at a Windows keyboard at work (ugh) and have
> long been a user of Macs (still have one or two at home). Might the
> problem be further multiplied by the number of different ways I have
> of entering text? Would Emacs running on Linux, but displaying on
> Windows be different than Chrome running directly on Linux?

I strongly suspect that any recent emacs will have M-x insert-char (earlier it
was called ucs-insert) default bound C-x 8 RET (yeah thats clunky) which will
accept at the minibuffer input

At which point the hex for ÄC which is e9 can be entered â ö yeah its
unreasonable to expect to remember that! Its more reasonable to remember that
that is an e acute; And e itself is a latin lower case letter All of which
becomes entering (in the minibuffer) LATIN SMALL LETTER E ACUTE
- upper case not required; emacs will upcase it for you
- And will also provide some tab/star expansion help
ie *letter e acuteTAB
expands to
LATIN *L LETTER E ACUTE
Further TAB-prodding will give you these choices LATIN CAPITAL LETTER E ACUTE
(Äë)   LATIN CAPITAL LETTER E WITH ACUTE (Äë)
LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE (áº1)
LATIN CAPITAL LETTER E WITH MACRON AND ACUTE (á,û)
LATIN SMALL LETTER E ACUTE (ÄC) LATIN SMALL LETTER E WITH ACUTE (ÄC)
LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE (ế)
LATIN SMALL LETTER E WITH MACRON AND ACUTE (á,ù)

You could go one step more sophisticated and use TeX-input method (C-x RET C-\)
After which \'e will collapse as ÄC
â £Yeah ok but how the ^)*^$# am I to remember the mantra \'e?!â Ø you may ask
Trueâ | So as you rightly do,
- pick it up from google
- put emacs into tex input mode
- paste from google into emacs
- place point on the new char and type C-u C-x =
  Among other things emacs will helpfully inform you (among other things)
  to input: type "\'{e}" or "\'e" with TeX input method

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator

2017-11-27 Thread nospam . Rustom Mody
On Monday, November 27, 2017 at 6:48:56 PM UTC+5:30, Rustom Mody wrote:
> Having said that I should be honest to mention that I saw your post first on
> my phone where the î, showed but the gØÜ« showed as a rectangle something
like âî$
>
> I suspect that îö OTOH would have workedâ | dunno

Yeah îö shows whereas gØÜ« doesn't (on my phone) And âî$ does show but much
squatter than the replacement char the phone shows when it cant display a char

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator

2017-11-27 Thread nospam . Rustom Mody
On Monday, November 27, 2017 at 3:43:20 PM UTC+5:30, Antoon Pardon wrote:
> Op 23-11-17 om 19:42 schreef Mikhail V:
> > Chris A wrote:
> >
> >>> On Fri, Nov 24, 2017 at 1:10 AM, Mikhail V wrote:
> >>>
>  Chris A wrote:
> 
>  Fortunately for the world, you're not the one who decided which
>  characters were permitted in Python identifiers. The ability to use
>  non-English words for function/variable names is of huge value; the
>  ability to use a hyphen is of some value, but not nearly as much.
> >>> Fortunately for the world we have Chris A. Who knows what is
> >>> fortunate and of huge values.
> >>> So is there any real world projects example of usage of non-latin scripts
> >>> in identifiers? Or is it still only a plan for the new world?
> >
> >> Yes, I've used them personally. And I know other people who have.
> >
> > Oh, I though it would be more impressive showcase for 'huge value'.
> > If we drop the benefit of the bare fact that you can do it, or you just
> > don't know English, how would describe the practical benefit?
> > If you don't know english, then programming at all will be just too hard.
> > (or one must define a new whole language specially for some local script)
>
> Well maybe the value is not huge, but I really appreciate the possibility.
> Being able to write something like below, makes things a lot more clear
> for me.
>
> Po = Pc + R * Vec(cos(î,o), sin(î,o))
> Pe = Pc + R * Vec(cos(î,e), sin(î,e))
> gØÜ«î, = î,e - î,o
> gØÜ«P = Pe - Po

Yeahâ | This is important
And Ive tried to elaborate such suggestions here
http://blog.languager.org/2014/04/unicoded-python.html
[includes some of your suggestions!] I should emphasize that the details there
range between straightforward and facetious.  The general sense of going beyond
 ASCII is not facetious at all In fact its ridiculous in the reverse direction:
 just as FORTRAN and COBOL believed that programming IN ALL UPPERCASE was
somehow kosher, likewise a 2017 language believing that sticking to ASCII is
sound is faintly ridiculous.

But that brings me to the opposite point: I feel its important to distinguish â
 ÿparochial/sectarian unicodeâ Ö from
â ÿuniversal unicodeâ Ö.
More on the distinction http://blog.languager.org/2015/03/whimsical-unicode.htm
 l
More on the universal aspect: http://blog.languager.org/2015/02/universal-unico
 de.html

Having said that I should be honest to mention that I saw your post first on my
 phone where the î, showed but the gØÜ« showed as a rectangle something like
âî$

I suspect that îö OTOH would have workedâ | dunno

So yes, there can be non-trivial logistic problems going beyond ASCII As there
are problems with errant mail-clients transmitting indentation-sensitive
languages and so on!

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-27 Thread nospam . Rustom Mody
On Monday, November 27, 2017 at 12:12:24 PM UTC+5:30, Chris Angelico wrote:
> On Mon, Nov 27, 2017 at 3:04 PM, Rustom Mody  wrote:
> >> Aviators have pinned down the best solution to this, I think. A pilot
> >> is not expected to be perfect; he is expected to follow checklists. A
> >> preflight checklist. A departure checklist. A landing checklist.
> >> Everything that needs to be done right is mentioned on the list, and
> >> you just go through the list and make sure you've done everything.
> >
> > And thats where the analogy breaks down.
> > Presumably a 50 person short-flight and a 600-person transcontinental may
have
> > at least something in common in their pilot-checklists
> > What common will you find in a multi-million line OS, a thousand line
script
> > and a student prime-numbers first-program?
>
> You locate a pure function. I can pretty much guarantee that the first
> two will have a number of them, and the third one may or may not, but
> almost certainly should. Pure functions are the easiest to unit-test.
> Then you build up from there.
>
> > No I am not dissing on testing and TDD; just that universalityâ1 of
computing devices
> > is something that our civilization is nowhere near understanding, leave
alone
> > dealing with â ö two programs can be more far apart than a bullock cart and
a jet.
> > And yet they are both programs
>
> ... so?

I know how to drive a carâ | and various two-wheelers. I not so sure of a
bus/truckâ | I suppose I could get one from here to there at a pinchâ | without
 killing someoneâ | though not quite sure of that! Doesn't translate into
knowing how to 'drive' planes or bullock-carts


gcc is tested with dejagnu. Do you imagine that knowing python's unittest or
nose directly translates into dejagnu expertise? And even if we stay with
industry-strength programs â ö gcc, linux-kernel, CPython, KDE â ö do you
imagine that testing one helps in testing the other? I doubt it (though I am
hardly an expert with testing frameworks)

Once again let me end by saying that testing and TDD are good ideas And it
would be nice if there was more of it in/for python [See
http://osherove.com/tdd-kata-1/ one of the first hits that google gives (me)
for TDD python, and you find the python example actually shows Ruby!]

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-27 Thread nospam . Rustom Mody
On Monday, November 27, 2017 at 9:08:42 AM UTC+5:30, Chris Angelico wrote:
> On Mon, Nov 27, 2017 at 1:55 PM, Michael Torrie  wrote:
> > On 11/26/2017 07:11 AM, bartc wrote:
> >>> You may argue that testing doesn't matter for his small game, written
> >>> for his own education and amusement.  The fact is that software in
> >>> general is of abysmal quality across the boards, and promoting a habit
> >>> of unit testing is good, even for trivial, home-grown stuff.
> >>
> >> I thought people were being hard on the OP.
> >
> > I wasn't being hard on the OP. My observation is about the state of
> > *all* software.  My software especially, your software, Microsoft's
> > software.  It all is of rather poor quality compared to the rigors of
> > other industries like civil engineering, manufacturing, etc.
>
> Not all software is poor quality compared to all examples of those
> industries. You'll find the equivalent of software bugs in a lot of
> hardware situations; the difference with software is that we have 100%
> perfect reproduction in the end-user products, so we call it a design
> flaw instead of a production artifact. (How often do you buy a box of
> something and find that a couple of them just break?) Even in
> large-scale civil engineering projects, there are plenty of
> stupidities. The house I'm living in has a place where the tiled floor
> doesn't quite align with the wall that it meets, and I can't figure
> out why; somewhere, two things that ought to have been parallel just
> aren't. Bridges have been known to crack, cars break down for no good
> reason, your hamburger just doesn't taste right today.
>
> Aviators have pinned down the best solution to this, I think. A pilot
> is not expected to be perfect; he is expected to follow checklists. A
> preflight checklist. A departure checklist. A landing checklist.
> Everything that needs to be done right is mentioned on the list, and
> you just go through the list and make sure you've done everything.

And thats where the analogy breaks down. Presumably a 50 person short-flight
and a 600-person transcontinental may have at least something in common in
their pilot-checklists What common will you find in a multi-million line OS, a
thousand line script and a student prime-numbers first-program?

No I am not dissing on testing and TDD; just that universalityâ1 of computing
devices
is something that our civilization is nowhere near understanding, leave alone
dealing with â ö two programs can be more far apart than a bullock cart and a
jet.
And yet they are both programs

â1 Ive seen CS PhDs ask a student why a student didnt incorporate some
error-checking
  into his compiler which amounted to solving the halting problem.
  More mundanely I see students have a hard time seeing their phones and their
  laptops as 'the same'

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [META] Why are duplicate posts coming through?

2017-11-27 Thread nospam . Rustom Mody
On Monday, November 27, 2017 at 5:35:09 AM UTC+5:30, Skip Montanaro wrote:
> Chris,
>
> Please forward one or two to me. Mark Sapiro and I have been banging on the
> SpamBayes instance which supports the Usenet gateway. I suppose it's
> possible some change caused the problem you're seeing.
>
> Skip
>
> On Nov 26, 2017 5:22 PM, "Chris Angelico" wrote:
>
> Not sure whether this is an issue for -owner or not; apologies if not.
>
> I'm seeing a whole lot of reasonably-recent posts getting re-sent,
> with "nospam" attached to the posters' names. And they're getting
> re-sent multiple times. Sometimes the posts have encoding problems
> (small amounts of mojibake).
>
> What's going on? Is there something going haywire with the news/mail
> gateway? Is there a rogue client re-posting a bunch of news? Somebody
> testing something?

And the spam continues unabated
Except that the subject lines are changed

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-27 Thread nospam . nospam . nospam . Rustom Mody
Mody)

On Sunday, November 26, 2017 at 3:43:29 AM UTC+5:30, Chris Angelico wrote:
> On Sun, Nov 26, 2017 at 9:05 AM,  wojtek.mula wrote:
> > Hi, my goal is to obtain an interpreter that internally
> > uses UCS-2. Such a simple code should print 65535:
> >
> >   import sys
> >   print sys.maxunicode
> >
> > This is enabled in Windows, but I want the same in Linux.
> > What options have I pass to the configure script?
>
> Why do you want to? What useful value do you have in creating this
> buggy interpreter?

I see that you are familiar with this bug: https://bugs.python.org/issue13153

And I see it or something very close is still buggy in python 3.5 [No it does
not allow me to paste an SMP char but if I open a file containing one it
crashes and rather messily â ö no way to close the idle other than killing the
shell]

No thats not a diatribe against idle; just that its reasonable to want python
to support work-arounds for reasonably common bugs in the current
unicode-ecosystem

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-27 Thread Rustom Mody
On Monday, November 27, 2017 at 8:07:47 PM UTC+5:30, Chris Angelico wrote:
> On Tue, Nov 28, 2017 at 1:25 AM, Rustom Mody wrote:
> > You could go one step more sophisticated and use TeX-input method
> > (C-x RET C-\)
> > After which \'e will collapse as é
> > “Yeah ok but how the ^)*^$# am I to remember the mantra \'e?!” you may ask
> > True… So as you rightly do,
> > - pick it up from google
> > - put emacs into tex input mode
> > - paste from google into emacs
> > - place point on the new char and type C-u C-x =
> >   Among other things emacs will helpfully inform you (among other things)
> >   to input: type "\'{e}" or "\'e" with TeX input method
> 
> Which is closely related to the Compose key input method that I use.
> First, you assign a key on your keyboard to be Compose (at least on
> all my systems, there isn't one by default); I use the key between
> left Ctrl and left Alt. 

Ha Ha So you wont speak the unspeakable?¿!¡

I also have my compose set (to Capslock)
And I entered those chars above with C?? and C!! where C is Capslock

I most frequently use that for ⇒ (C=>) → (C->) ¹ (C^1) ₁ (C_1) etc
One can find other goodies at /usr/share/X11/locale/en_US.UTF-8/Compose

I didn't start with mentioning that to Skip because his basic requirement
(as I got it) was that
- input method should be OS-neutral
- emacs can be assumed

And so the only OS-non-neutrality that I am aware of is that sometimes
Alt works as Meta (gui-emacsen) and sometimes not terminal/text emacsen 
(typically, though I believe some ppl successfully tweak this also)
And so M-x can mean Alt-x (chord) or ESC-x (sequence) and a few such anomalies
But beyond that emacsen should be same for all OSes (modulo versions)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-27 Thread Rustom Mody
On Friday, November 24, 2017 at 10:11:24 PM UTC+5:30, Skip Montanaro wrote:
> > Because if I already can't understand the words, it will be more useful
> > to me to be able to type them reliably at a keyboard, for replication,
> > search, discussion with others about the code, etc.
> 
> I am probably not alone in my Americo-centric world where I can't even
> easily type accented Latin-1 characters. I happen to be using Linux as
> I type this, but type at a Windows keyboard at work (ugh) and have
> long been a user of Macs (still have one or two at home). Might the
> problem be further multiplied by the number of different ways I have
> of entering text? Would Emacs running on Linux, but displaying on
> Windows be different than Chrome running directly on Linux? 

I strongly suspect that any recent emacs will have M-x insert-char
(earlier it was called ucs-insert) default bound C-x 8 RET (yeah thats clunky)
which will accept at the minibuffer input

At which point the hex for é which is e9 can be entered — yeah its unreasonable 
to expect to remember that!
Its more reasonable to remember that that is an e acute; 
And e itself is a latin lower case letter
All of which becomes entering (in the minibuffer)
LATIN SMALL LETTER E ACUTE
- upper case not required; emacs will upcase it for you
- And will also provide some tab/star expansion help
ie *letter e acuteTAB 
expands to
LATIN *L LETTER E ACUTE
Further TAB-prodding will give you these choices
LATIN CAPITAL LETTER E ACUTE (É)LATIN CAPITAL LETTER E WITH ACUTE (É)
LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE (Ế)
LATIN CAPITAL LETTER E WITH MACRON AND ACUTE (Ḗ)
LATIN SMALL LETTER E ACUTE (é)  LATIN SMALL LETTER E WITH ACUTE (é)
LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE (ế)
LATIN SMALL LETTER E WITH MACRON AND ACUTE (ḗ)

You could go one step more sophisticated and use TeX-input method
(C-x RET C-\)
After which \'e will collapse as é
“Yeah ok but how the ^)*^$# am I to remember the mantra \'e?!” you may ask
True… So as you rightly do, 
- pick it up from google
- put emacs into tex input mode
- paste from google into emacs
- place point on the new char and type C-u C-x =
  Among other things emacs will helpfully inform you (among other things)
  to input: type "\'{e}" or "\'e" with TeX input method
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-27 Thread Rustom Mody
On Monday, November 27, 2017 at 6:48:56 PM UTC+5:30, Rustom Mody wrote:
> Having said that I should be honest to mention that I saw your post first on
> my phone where the θ showed but the 횫 showed as a rectangle something like ⌧
> 
> I suspect that Δ OTOH would have worked… dunno

Yeah Δ shows whereas 횫 doesn't (on my phone)
And ⌧ does show but much squatter than the replacement char the phone shows
when it cant display a char
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-27 Thread Rustom Mody
On Monday, November 27, 2017 at 12:12:24 PM UTC+5:30, Chris Angelico wrote:
> On Mon, Nov 27, 2017 at 3:04 PM, Rustom Mody  wrote:
> >> Aviators have pinned down the best solution to this, I think. A pilot
> >> is not expected to be perfect; he is expected to follow checklists. A
> >> preflight checklist. A departure checklist. A landing checklist.
> >> Everything that needs to be done right is mentioned on the list, and
> >> you just go through the list and make sure you've done everything.
> >
> > And thats where the analogy breaks down.
> > Presumably a 50 person short-flight and a 600-person transcontinental may 
> > have
> > at least something in common in their pilot-checklists
> > What common will you find in a multi-million line OS, a thousand line script
> > and a student prime-numbers first-program?
> 
> You locate a pure function. I can pretty much guarantee that the first
> two will have a number of them, and the third one may or may not, but
> almost certainly should. Pure functions are the easiest to unit-test.
> Then you build up from there.
> 
> > No I am not dissing on testing and TDD; just that universality¹ of 
> > computing devices
> > is something that our civilization is nowhere near understanding, leave 
> > alone
> > dealing with — two programs can be more far apart than a bullock cart and a 
> > jet.
> > And yet they are both programs
> 
> ... so?

I know how to drive a car… and various two-wheelers.
I not so sure of a bus/truck… I suppose I could get one from here to there
at a pinch… without killing someone… though not quite sure of that!
Doesn't translate into knowing how to 'drive' planes or bullock-carts


gcc is tested with dejagnu. Do you imagine that knowing python's unittest or
nose directly translates into dejagnu expertise?
And even if we stay with industry-strength programs — gcc, linux-kernel, 
CPython, KDE — do you imagine that testing one helps in testing the other?
I doubt it (though I am hardly an expert with testing frameworks)

Once again let me end by saying that testing and TDD are good ideas
And it would be nice if there was more of it in/for python
[See http://osherove.com/tdd-kata-1/ one of the first hits that google
gives (me) for TDD python, and you find the python example
actually shows Ruby!]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-27 Thread Rustom Mody
On Monday, November 27, 2017 at 3:43:20 PM UTC+5:30, Antoon Pardon wrote:
> Op 23-11-17 om 19:42 schreef Mikhail V:
> > Chris A wrote:
> >
> >>> On Fri, Nov 24, 2017 at 1:10 AM, Mikhail V wrote:
> >>>
>  Chris A wrote:
> 
>  Fortunately for the world, you're not the one who decided which
>  characters were permitted in Python identifiers. The ability to use
>  non-English words for function/variable names is of huge value; the
>  ability to use a hyphen is of some value, but not nearly as much.
> >>> Fortunately for the world we have Chris A. Who knows what is
> >>> fortunate and of huge values.
> >>> So is there any real world projects example of usage of non-latin scripts
> >>> in identifiers? Or is it still only a plan for the new world?
> >
> >> Yes, I've used them personally. And I know other people who have.
> >
> > Oh, I though it would be more impressive showcase for 'huge value'.
> > If we drop the benefit of the bare fact that you can do it, or you just
> > don't know English, how would describe the practical benefit?
> > If you don't know english, then programming at all will be just too hard.
> > (or one must define a new whole language specially for some local script)
> 
> Well maybe the value is not huge, but I really appreciate the possibility.
> Being able to write something like below, makes things a lot more clear
> for me.
> 
> Po = Pc + R * Vec(cos(θo), sin(θo))
> Pe = Pc + R * Vec(cos(θe), sin(θe))
> 횫θ = θe - θo
> 횫P = Pe - Po

Yeah… This is important
And Ive tried to elaborate such suggestions here
http://blog.languager.org/2014/04/unicoded-python.html
[includes some of your suggestions!]
I should emphasize that the details there range between straightforward and
facetious.  The general sense of going beyond ASCII is not facetious at all
In fact its ridiculous in the reverse direction: just as FORTRAN and COBOL
believed that programming IN ALL UPPERCASE was somehow kosher, likewise
a 2017 language believing that sticking to ASCII is sound is faintly ridiculous.

But that brings me to the opposite point:
I feel its important to distinguish ‘parochial/sectarian unicode’ from 
‘universal unicode’.
More on the distinction http://blog.languager.org/2015/03/whimsical-unicode.html
More on the universal aspect: 
http://blog.languager.org/2015/02/universal-unicode.html

Having said that I should be honest to mention that I saw your post first on
my phone where the θ showed but the 횫 showed as a rectangle something like ⌧

I suspect that Δ OTOH would have worked… dunno

So yes, there can be non-trivial logistic problems going beyond ASCII
As there are problems with errant mail-clients transmitting 
indentation-sensitive languages and so on!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-26 Thread Rustom Mody
On Monday, November 27, 2017 at 9:08:42 AM UTC+5:30, Chris Angelico wrote:
> On Mon, Nov 27, 2017 at 1:55 PM, Michael Torrie  wrote:
> > On 11/26/2017 07:11 AM, bartc wrote:
> >>> You may argue that testing doesn't matter for his small game, written
> >>> for his own education and amusement.  The fact is that software in
> >>> general is of abysmal quality across the boards, and promoting a habit
> >>> of unit testing is good, even for trivial, home-grown stuff.
> >>
> >> I thought people were being hard on the OP.
> >
> > I wasn't being hard on the OP. My observation is about the state of
> > *all* software.  My software especially, your software, Microsoft's
> > software.  It all is of rather poor quality compared to the rigors of
> > other industries like civil engineering, manufacturing, etc.
> 
> Not all software is poor quality compared to all examples of those
> industries. You'll find the equivalent of software bugs in a lot of
> hardware situations; the difference with software is that we have 100%
> perfect reproduction in the end-user products, so we call it a design
> flaw instead of a production artifact. (How often do you buy a box of
> something and find that a couple of them just break?) Even in
> large-scale civil engineering projects, there are plenty of
> stupidities. The house I'm living in has a place where the tiled floor
> doesn't quite align with the wall that it meets, and I can't figure
> out why; somewhere, two things that ought to have been parallel just
> aren't. Bridges have been known to crack, cars break down for no good
> reason, your hamburger just doesn't taste right today.
> 
> Aviators have pinned down the best solution to this, I think. A pilot
> is not expected to be perfect; he is expected to follow checklists. A
> preflight checklist. A departure checklist. A landing checklist.
> Everything that needs to be done right is mentioned on the list, and
> you just go through the list and make sure you've done everything.

And thats where the analogy breaks down.
Presumably a 50 person short-flight and a 600-person transcontinental may have
at least something in common in their pilot-checklists
What common will you find in a multi-million line OS, a thousand line script
and a student prime-numbers first-program?

No I am not dissing on testing and TDD; just that universality¹ of computing 
devices
is something that our civilization is nowhere near understanding, leave alone
dealing with — two programs can be more far apart than a bullock cart and a jet.
And yet they are both programs

¹ Ive seen CS PhDs ask a student why a student didnt incorporate some 
error-checking 
  into his compiler which amounted to solving the halting problem.
  More mundanely I see students have a hard time seeing their phones and their
  laptops as 'the same'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [META] Why are duplicate posts coming through?

2017-11-26 Thread Rustom Mody
On Monday, November 27, 2017 at 5:35:09 AM UTC+5:30, Skip Montanaro wrote:
> Chris,
> 
> Please forward one or two to me. Mark Sapiro and I have been banging on the
> SpamBayes instance which supports the Usenet gateway. I suppose it's
> possible some change caused the problem you're seeing.
> 
> Skip
> 
> On Nov 26, 2017 5:22 PM, "Chris Angelico" wrote:
> 
> Not sure whether this is an issue for -owner or not; apologies if not.
> 
> I'm seeing a whole lot of reasonably-recent posts getting re-sent,
> with "nospam" attached to the posters' names. And they're getting
> re-sent multiple times. Sometimes the posts have encoding problems
> (small amounts of mojibake).
> 
> What's going on? Is there something going haywire with the news/mail
> gateway? Is there a rogue client re-posting a bunch of news? Somebody
> testing something?

And the spam continues unabated
Except that the subject lines are changed
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread nospam . nospam . Rustom Mody
On Sunday, November 26, 2017 at 3:43:29 AM UTC+5:30, Chris Angelico wrote:
> On Sun, Nov 26, 2017 at 9:05 AM,  wojtek.mula wrote:
> > Hi, my goal is to obtain an interpreter that internally
> > uses UCS-2. Such a simple code should print 65535:
> >
> >   import sys
> >   print sys.maxunicode
> >
> > This is enabled in Windows, but I want the same in Linux.
> > What options have I pass to the configure script?
>
> Why do you want to? What useful value do you have in creating this
> buggy interpreter?

I see that you are familiar with this bug: https://bugs.python.org/issue13153

And I see it or something very close is still buggy in python 3.5 [No it does
not allow me to paste an SMP char but if I open a file containing one it
crashes and rather messily â ö no way to close the idle other than killing the
shell]

No thats not a diatribe against idle; just that its reasonable to want python
to support work-arounds for reasonably common bugs in the current
unicode-ecosystem

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-26 Thread nospam . Rustom Mody
On Sunday, November 26, 2017 at 3:43:29 AM UTC+5:30, Chris Angelico wrote:
> On Sun, Nov 26, 2017 at 9:05 AM,  wojtek.mula wrote:
> > Hi, my goal is to obtain an interpreter that internally
> > uses UCS-2. Such a simple code should print 65535:
> >
> >   import sys
> >   print sys.maxunicode
> >
> > This is enabled in Windows, but I want the same in Linux.
> > What options have I pass to the configure script?
>
> Why do you want to? What useful value do you have in creating this
> buggy interpreter?

I see that you are familiar with this bug: https://bugs.python.org/issue13153

And I see it or something very close is still buggy in python 3.5 [No it does
not allow me to paste an SMP char but if I open a file containing one it
crashes and rather messily â ö no way to close the idle other than killing
the shell]

No thats not a diatribe against idle; just that its reasonable to want python
to support work-arounds for reasonably common bugs in the current
unicode-ecosystem

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-25 Thread Rustom Mody
On Sunday, November 26, 2017 at 3:43:29 AM UTC+5:30, Chris Angelico wrote:
> On Sun, Nov 26, 2017 at 9:05 AM,  wojtek.mula wrote:
> > Hi, my goal is to obtain an interpreter that internally
> > uses UCS-2. Such a simple code should print 65535:
> >
> >   import sys
> >   print sys.maxunicode
> >
> > This is enabled in Windows, but I want the same in Linux.
> > What options have I pass to the configure script?
> 
> Why do you want to? What useful value do you have in creating this
> buggy interpreter?

I see that you are familiar with this bug: https://bugs.python.org/issue13153

And I see it or something very close is still buggy in python 3.5
[No it does not allow me to paste an SMP char but if I open a file containing
one it crashes and rather messily — no way to close the idle other than killing
the shell]

No thats not a diatribe against idle; just that its reasonable to want python
to support work-arounds for reasonably common bugs in the current 
unicode-ecosystem
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-25 Thread Rustom Mody
On Friday, November 24, 2017 at 10:52:47 PM UTC+5:30, Rick Johnson wrote:
> Furthermore, if we are to march headlong onto the glorious
> battlefields of diversity and equality…

Obligatory viewing for those who underappreciate diversity, equality and such

https://youtu.be/Zh3Yz3PiXZw

[My old colleague, a numerical analyst pointed out to me today that the 
'correct 
answer' is not twenty two thousand but twenty million two thousand]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pros and cons of Python sources?

2017-11-25 Thread Rustom Mody
On Saturday, November 25, 2017 at 9:45:07 PM UTC+5:30, Michael Torrie wrote:
> On 11/25/2017 02:20 AM, Martin Schöön wrote:
> > Some time ago I was advised that having a Python installation
> > based on several sources (pip and Debian's repos in my case)
> > is not a good idea. I need to tidy up my installation and I
> > don't know what to opt for and what to opt out.
> > 
> > What are the pros and cons of the alternatives including the
> > ones I haven't mentioned? Completeness, currency, bugs...
> 
> The problem with mixing repository-installed packages with pip-installed
> packages is that there's always a chance a Debian update will overwrite
> a pip package, possibly with an older version.  Or a pip-installed
> package might bring in a new version that's not compatible with some
> debian-installed package, breaking something.

On (recent?) debian/ubuntu pip seems to use the 'user-scheme'
which means pip runs without sudo and installs in ~/.local/lib
So I dont believe literal overwriting would occur
What could occur is shadowing — two versions of package foo and an unclarity of 
which is in use…


Alister's suggestion is what I always try first.
Doesnt always work because OS packages could be stale and/or non-existent
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-25 Thread Rustom Mody
On Saturday, November 25, 2017 at 6:03:52 PM UTC+5:30, Rustom Mody wrote:
> On Friday, November 24, 2017 at 12:20:29 AM UTC+5:30, Mikhail V wrote:
> > Ok, I personally could find some practical usage for that, but
> > merely for fun. I doubt though that someone with less
> > typographical experience and overall computer literacy could
> > really make benefits even for personal usage.
> > 
> > So - fun is one benefit. And fun is important. But is that the
> > idea behind it?
> 
> Are you under-estimating the fun-value? 
> 
> Python 3.5.3 (default, Sep 14 2017, 22:58:41) 
> [GCC 6.3.0 20170406] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> python.el: native completion setup loaded
> >>> A = 1
> >>> Α = 2
> >>> А = 3
> >>> (A, Α, А)
> (1, 2, 3)
> >>> # And there are 5 other variations on this magic trick
> >>> # Or if you prefer…
> >>> A == Α
> False
> >>> 
> 
> Now compare with the boring spoilsport called python 2:
> 
> Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
> [GCC 6.3.0 20170118] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> python.el: native completion setup loaded
> >>> A = 1
> >>> Α = 2
>   File "", line 1
> Α = 2
> ^
> SyntaxError: invalid syntax
> >>> 
> 
> Personally I feel that there should be a law against languages that disallow 
> the creation of magic tricks!¡!

I should mention also that some languages are even more advanced in their
jovialness regarding unicode tricks

Haskell:
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> let flag = 1
Prelude> let flag = 2
Prelude> flag == flag
False
Prelude> (flag, flag)
(2,1)
Prelude> 

Python3 is quite boring by contrast:

Python 3.5.3 (default, Sep 14 2017, 22:58:41) 
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> flag = 1
>>> flag = 2
>>> flag == flag
True
>>> (flag, flag)
(2, 2)
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-25 Thread Rustom Mody
On Friday, November 24, 2017 at 12:20:29 AM UTC+5:30, Mikhail V wrote:
> Ok, I personally could find some practical usage for that, but
> merely for fun. I doubt though that someone with less
> typographical experience and overall computer literacy could
> really make benefits even for personal usage.
> 
> So - fun is one benefit. And fun is important. But is that the
> idea behind it?

Are you under-estimating the fun-value? 

Python 3.5.3 (default, Sep 14 2017, 22:58:41) 
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> A = 1
>>> Α = 2
>>> А = 3
>>> (A, Α, А)
(1, 2, 3)
>>> # And there are 5 other variations on this magic trick
>>> # Or if you prefer…
>>> A == Α
False
>>> 

Now compare with the boring spoilsport called python 2:

Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> A = 1
>>> Α = 2
  File "", line 1
Α = 2
^
SyntaxError: invalid syntax
>>> 

Personally I feel that there should be a law against languages that disallow 
the creation of magic tricks!¡!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Rustom Mody
On Tuesday, November 21, 2017 at 7:06:18 PM UTC+5:30, Rustom Mody wrote:
> On Tuesday, November 21, 2017 at 5:27:42 PM UTC+5:30, Ned Batchelder wrote:
> > On 11/20/17 9:50 AM, Stefan Ram wrote:
> > > Ned Batchelder  writes:
> > >> Also, why set headers that prevent the Python-List mailing list from
> > >> archiving your messages?
> > >I am posting to a Usenet newsgroup. I am not aware of any
> > >"Python-List mailing list".
> > >
> > >I am posting specifically to the Usenet, because I am aware
> > >of it's rules and I like it and wish to support it.
> > >
> > >I do not post to a "mailing list" because I do not know which
> > >rules apply for mailing lists and whether mailing lists in
> > >general or any specific mailing list is an environment that I
> > >like or wish to support.
> > >
> > 
> > The dual nature of this online community has long been confusing and 
> > complicated.  It's both a newsgroup and a mailing list.  Add in Google 
> > Groups, and you really have three different faces of the same content.
> > 
> > The fact is, posting to comp.lang.python means that your words are also 
> > being distributed as a mailing list. Because of your messages' headers, 
> > they are not in the archive of that list 
> > (https://mail.python.org/pipermail/python-list/2017-November/thread.html), 
> > or in Google Groups 
> > (https://groups.google.com/forum/#!topic/comp.lang.python/0ejrtZ6ET9g). 
> > It makes for odd reading via those channels.
> > 
> > I don't understand the motivation for limiting how words are 
> > distributed, but others on this list also do it. For example, Dennis Lee 
> > Bieber's messages are not in the Python-List archives either. If 
> > something is worth saying, why not let people find it later?
> 
> To which I would add:
> Setting headers is hardly a working method.
> Somebody quotes Stefan or Dennis and they are on the archives
> And some quote including emails some not
> etc

O and one more thing:
If Stefan or Dennis say something to the above dont expect a response from me
since I would not have seen theirs 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Rustom Mody
On Tuesday, November 21, 2017 at 5:27:42 PM UTC+5:30, Ned Batchelder wrote:
> On 11/20/17 9:50 AM, Stefan Ram wrote:
> > Ned Batchelder  writes:
> >> Also, why set headers that prevent the Python-List mailing list from
> >> archiving your messages?
> >I am posting to a Usenet newsgroup. I am not aware of any
> >"Python-List mailing list".
> >
> >I am posting specifically to the Usenet, because I am aware
> >of it's rules and I like it and wish to support it.
> >
> >I do not post to a "mailing list" because I do not know which
> >rules apply for mailing lists and whether mailing lists in
> >general or any specific mailing list is an environment that I
> >like or wish to support.
> >
> 
> The dual nature of this online community has long been confusing and 
> complicated.  It's both a newsgroup and a mailing list.  Add in Google 
> Groups, and you really have three different faces of the same content.
> 
> The fact is, posting to comp.lang.python means that your words are also 
> being distributed as a mailing list. Because of your messages' headers, 
> they are not in the archive of that list 
> (https://mail.python.org/pipermail/python-list/2017-November/thread.html), 
> or in Google Groups 
> (https://groups.google.com/forum/#!topic/comp.lang.python/0ejrtZ6ET9g). 
> It makes for odd reading via those channels.
> 
> I don't understand the motivation for limiting how words are 
> distributed, but others on this list also do it. For example, Dennis Lee 
> Bieber's messages are not in the Python-List archives either. If 
> something is worth saying, why not let people find it later?

To which I would add:
Setting headers is hardly a working method.
Somebody quotes Stefan or Dennis and they are on the archives
And some quote including emails some not
etc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Read Firefox sqlite files with Python

2017-11-06 Thread Rustom Mody
On Monday, November 6, 2017 at 8:42:29 AM UTC+5:30, Steve D'Aprano wrote:
> On Mon, 6 Nov 2017 12:39 am, Paul Moore wrote:
> 
> > On 5 November 2017 at 01:22, Steve D'Aprano wrote:
> >> On Sun, 5 Nov 2017 04:32 am, Steve D'Aprano wrote:
> >>
> >>> I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5.
> >>>
> >>>
> >>> import sqlite3
> >>> con = sqlite3.connect('foo.sqlite')
> >>> with open('dump.sql', 'w') as f:
> >>> for line in con.iterdump():
> >>> f.write(line + '\n')
> >>
> >>
> >> Never mind. I dumped the file using the sqlite3 command line tool. Thank
> >> you to all those who answered.
> >>
> >> The file contains three INSERT statements, the first two don't have
> >> anything of interest, and the third (which presumably contains all the data
> >> I'm trying to recover) is an opaque 600+ KB blob.
> >>
> >> Naturally. Why would you use a database as a database, when instead you
> >> could just dump a big ball of mud into it?
> > 
> > Hmm, *.sql files normally contain SQL source code (as this one does).
> 
> The .sql file is the result of running .dump from the sqlite command line
> tool. The original source database is 'foo.sqlite'. To be precise, it is the
> database used by the Firefox Add-On "One Tab".
> 
> /home/steve/.mozilla/firefox/2z5po7dx.default/storage/permanent/indexeddb+++extension-at-one-tab-dot-com/idb/1832832054obnaet.sqlite
> 
> One Tab provides an alternative bookmark-like function, allowing you to record
> URLs in groups for later use -- a bit like bookmarks. So I've been using this
> for some months, until the add-on stopped working. (Yet again an automatic
> update has screwed me and broken functionality.) So now I'm trying to
> retrieve the bookmarks.

[Not python-related and likely not an answer… Just what I would try]

1. Get hold of an old live ubuntu (say 12.4) ISO/flash/CD and boot
2. Mount /home
3. Make livecd~/.mozilla symlink to home/~steven/.mozilla

Do you see your bookmarks?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Thread safety issue (I think) with defaultdict

2017-11-02 Thread Rustom Mody
On Friday, November 3, 2017 at 6:28:28 AM UTC+5:30, Steve D'Aprano wrote:
> On Fri, 3 Nov 2017 07:24 am, Chris Angelico wrote:
> 
> > On Fri, Nov 3, 2017 at 3:27 AM, Israel Brewster wrote:
> >>
> >> Actually, that saying is about regular expressions, not threads :-) . In
> >> the end, threads are as good a way as handling concurrency as any other,
> >> and simpler than many. They have their drawbacks, of course, mainly in the
> >> area of overhead, and of course only multiprocessing can *really* take
> >> advantage of multiple cores/CPU's on a machine, but unlike regular
> >> expressions, threads aren't ugly or complicated. Only the details of
> >> dealing with concurrency make things complicated, and you'll have to deal
> >> with that in *any* concurrency model.
> >>
> > 
> > Thank you. I've had this argument with many people, smart people (like
> > Steven), people who haven't grokked that all concurrency has costs -
> 
> Of course I grok that all concurrency has costs. Apart from comparatively rare
> cases of "embarrassingly parallel" algorithms, any form of concurrent or
> parallel processing is significantly harder than sequential code.
> 
> 
> > that threads aren't magically more dangerous than other options.
> 
> There's nothing magical about it.
> 
> Threads are very much UNMAGICALLY more dangerous than other options because
> they combine:
> 
> - shared data; and
> 
> - non-deterministic task switching.

… which is to say «bad mix of imperative programming and concurrency»



«The world is concurrent» [Joe Armstrong creator of Erlang]

If you get up from your computer just now for a coffee, it does not mean I have
to at the same time. More pertinently, it would be rather wasteful if the
billion+ transistors of an i7 waited for each other rather than switching 
independently.

The problem is that von Neumann preferred to simplify the programming task 
along 
the lines nowadays called "imperative programming"… after whom we get the
terms "von Neumann model", "von Neumann machine" etc

IOW threads are a particularly extreme example of the deleterious effects
of stuffing the world into the mold of someone's (von Neumann's) brain.

ie shared data + task switching = combinatorially explosive results

Take your own statement «any form of concurrent or parallel processing is
significantly harder than sequential code» 

and apply it to the abc of imperative programming:

Problem: Interchange values of variables x and y

Layman answer:
x = y
y = x

[Ignore for a moment that python has an answer that is almost identical to the 
above and is correct: x,y = y,x]

"Correct" answer:
temp = x
x = y
y = temp

Correct? Really???
Or is that being trained to "think like a programmer" means learning to 
convolute our brains into an arbitrary and unnecessary sequentiality?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Invoking return through a function?

2017-11-02 Thread Rustom Mody
On Tuesday, October 31, 2017 at 11:05:30 AM UTC+5:30, Steve D'Aprano wrote:
> On Tue, 31 Oct 2017 02:26 pm, Rustom Mody wrote:
> 
> > My own feeling about lisp-macros is conflicted:
> > - They are likely the most unique feature of lisp, putting it at the top of
> > the blub-language tower
> > - They are the single reason Lisp can never succeed like mainstream
> > languages: Any significant Lisp sub-ecosystem will inevitably develop a
> > macro set which succinctly and precisely expresses its needs but is arcane
> > and incomprehensible to someone from another sub-ecosystem.
> 
> Well said. That's one of the disadvantages of Forth as well: since Forth
> allows you to define your own control-structures, even the structure of the
> code can be unfamiliar.
> 
> Another way to put it might be that any sufficiently complex Lisp program
> doesn't look like Lisp any more.

It seems we agree on the facts but not the accounting

Facts: A fixed syntax language (C, Java, Python etc) is likely to have
similar looking programs across a wide spectrum of applications as compared to
a syntax-definable-at-runtime language like Lisp

Accounting: You seem to count this as advantage to fixed-syntax?

Note that if you carry this principle all the way, any application whatever 
running on an x86 will be running x86 instructions; which look more uniform 
than 
the diverse hl-languages  that produced them.



> 
> Except perhaps for the myriad parentheses *wink* 

Not so: reader-macros can change lisp all the way to the lexical level
And used to do things like html-templating, sql-embedding etc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Invoking return through a function?

2017-10-30 Thread Rustom Mody
On Tuesday, October 31, 2017 at 7:45:18 AM UTC+5:30, Alberto Riva wrote:
> On 10/30/2017 12:23 AM, Rustom Mody wrote:
> > On Sunday, October 29, 2017 at 9:52:01 PM UTC+5:30, Rick Johnson wrote:
> >> On Sunday, October 29, 2017 at 9:19:03 AM UTC-5, Alberto Riva wrote:
> > 
> >>> In a language like Lisp
> >>
> >> Python is nothing like Lisp, and for good reason! Sure, we
> >> have a few lispers and functional fanboys who hang around
> >> here, and sometimes Rustom can get a little preachy about
> >> FP, but mostly, we tolerate the fanboyism -- so long as it's
> >> not rabid fanboyism.
> > 
> > Rick's personal comments are one of the standard entertainments of this 
> > list. Enjoy!
> > 
> > The comments on FP are more problematic:
> > 
> > - These misconceptions are more widespread than just Rick
> > - They are right enough to be hard to refute
> > - And wrong enough to cause confusion and misdirection
> > - And irrelevant to (threads like) this one
> > 
> > My super-short rejoiner to the FP-irrelevancy is:
> > «If there is one key takeaway from functional programming maybe it should 
> > be: "Truth is a function of time" »
> > 
> > In more detail:
> > - Lisp (1960)  was the second functional language; its predecessor was 
> > something called Formula Translator — usually shortened to Fortran (c. 1957)
> > - By the late 80s, many FPers had begun regard Lisp as a setback for 
> > functional programming. [Dont get me wrong: Ive enjoyed Scheme more than 
> > any other
> > programming language. Its just that conflating Lisp and FP is an error (in 
> > 2017)]
> > 
> > More historical details at 
> > http://blog.languager.org/2015/04/cs-history-1.html and sequel
> > 
> > At a more conceptual level, people dont get that there are two dimensions
> > - the apply-lambda axis — usually called functional programming
> > - the eval-quote axis — which has precious little to do with FP (and is 
> > more relevant to your question)
> > 
> > These two dimensions of power uniquely coincide in Lisp (Scheme).
> > 
> > As you correctly (almost) point out
> > - Python is very much a lisp… its semantic under-belly
> > - However, syntactically its more like C/Java etc in the sense of having a 
> > rigid
> > fixed-at-language-design-time syntax
> > 
> > More at http://blog.languager.org/2013/08/applying-si-on-sicp.html
> > 
> > For a question like macros (syntax-extensions) that sits between the two 
> > your
> > question is interesting and I am not sure I know how to do it…
> > I remember seeing something about this recently but my google-foo is 
> > failing me
> > at the moment
> > 
> > However I would look at
> > - PEP 263 https://www.python.org/dev/peps/pep-0263/ — Source Code Encodings…
> > - Hooking into the codec module 
> > https://docs.python.org/3/library/codecs.html
> > - hooking into ast module https://docs.python.org/3/library/ast.html
> > 
> > An old attempt in this direction: 
> > http://code.activestate.com/recipes/546539/
> > 
> > You've already got the moral-hi-horse guys giving you the dope of why this 
> > is evil. Swallow if you like. My own lightweight
> > suggestion would be that the natural pythonic way of unstructured exit is 
> > exceptions. Not as succinct as a tailormade syntax extension. But good 
> > enough IMHO
> > 
> > PS I personally would be interested if you get this (syntax extension) 
> > running
> 
> Thanks for the interesting reply! But once again: I was not proposing to 
> add lisp-style macros to Python; I have no interest in doing that since 
> I believe it's pretty much impossible :)

https://github.com/pythonql/pythonql

is the example that shows how lisp-style extended-syntax (macros) can be done 
via file-encodings in a modern python.  Or if you prefer modern lingo: “How to
embed an internal DSL into python”

Note: I am not recommending you take this line; just that its not impossible
as you seem to imagine.

My own feeling about lisp-macros is conflicted:
- They are likely the most unique feature of lisp, putting it at the top of the
blub-language tower
- They are the single reason Lisp can never succeed like mainstream languages:
Any significant Lisp sub-ecosystem will inevitably develop a macro set which
succinctly and precisely expresses its needs but is arcane and incomprehensible
to someone from another sub-ecosystem.

This is Turing-completeness Lisp-specific style: 
The basic Turing-result is that programs can be arbitrarily complex to the point
of being unanalysable.
For mainstream languages that complexity sits squarely in the application
For lisp there is a choice of simplifying the application by concentrating
the complexity in a macro/DSL layer between implementation and application
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pythonw.exe error

2017-10-30 Thread Rustom Mody
On Monday, October 30, 2017 at 10:11:49 PM UTC+5:30, Igor Korot wrote:
> Hi,
> 
> 
> 
> On Oct 30, 2017 11:27 AM, "George Kalamaras via Python-list" wrote:
> 
> When I am running IDLE return to me Missing python36.dll error
> 
> Στάλθηκε από την Αλληλογραφία για Windows 10
> 
> 
> Could you please translate this from Greek?

Google translate tells me this is "Sent from mail for Windows 10"

IOW its probably a mail auto-footer of the OP, not the error message
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Invoking return through a function?

2017-10-29 Thread Rustom Mody
On Sunday, October 29, 2017 at 9:52:01 PM UTC+5:30, Rick Johnson wrote:
> On Sunday, October 29, 2017 at 9:19:03 AM UTC-5, Alberto Riva wrote:

> > In a language like Lisp
> 
> Python is nothing like Lisp, and for good reason! Sure, we
> have a few lispers and functional fanboys who hang around
> here, and sometimes Rustom can get a little preachy about
> FP, but mostly, we tolerate the fanboyism -- so long as it's
> not rabid fanboyism.

Rick's personal comments are one of the standard entertainments of this list. 
Enjoy!

The comments on FP are more problematic:

- These misconceptions are more widespread than just Rick
- They are right enough to be hard to refute
- And wrong enough to cause confusion and misdirection
- And irrelevant to (threads like) this one

My super-short rejoiner to the FP-irrelevancy is:
«If there is one key takeaway from functional programming maybe it should be: 
"Truth is a function of time" »

In more detail:
- Lisp (1960)  was the second functional language; its predecessor was 
something called Formula Translator — usually shortened to Fortran (c. 1957)
- By the late 80s, many FPers had begun regard Lisp as a setback for functional 
programming. [Dont get me wrong: Ive enjoyed Scheme more than any other 
programming language. Its just that conflating Lisp and FP is an error (in 
2017)]

More historical details at http://blog.languager.org/2015/04/cs-history-1.html 
and sequel

At a more conceptual level, people dont get that there are two dimensions
- the apply-lambda axis — usually called functional programming
- the eval-quote axis — which has precious little to do with FP (and is more 
relevant to your question)

These two dimensions of power uniquely coincide in Lisp (Scheme).

As you correctly (almost) point out
- Python is very much a lisp… its semantic under-belly
- However, syntactically its more like C/Java etc in the sense of having a 
rigid 
fixed-at-language-design-time syntax

More at http://blog.languager.org/2013/08/applying-si-on-sicp.html

For a question like macros (syntax-extensions) that sits between the two your
question is interesting and I am not sure I know how to do it…
I remember seeing something about this recently but my google-foo is failing me 
at the moment

However I would look at
- PEP 263 https://www.python.org/dev/peps/pep-0263/ — Source Code Encodings…
- Hooking into the codec module https://docs.python.org/3/library/codecs.html
- hooking into ast module https://docs.python.org/3/library/ast.html

An old attempt in this direction: http://code.activestate.com/recipes/546539/

You've already got the moral-hi-horse guys giving you the dope of why this is 
evil. Swallow if you like. My own lightweight
suggestion would be that the natural pythonic way of unstructured exit is 
exceptions. Not as succinct as a tailormade syntax extension. But good enough 
IMHO

PS I personally would be interested if you get this (syntax extension) running
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ide vs ide

2017-10-28 Thread Rustom Mody
On Saturday, October 28, 2017 at 4:46:03 PM UTC+5:30, Christian Gollwitzer 
wrote:
> Am 28.10.17 um 09:04 schrieb Rustom Mody:
> > [The other day I was writing a program to split alternate lines of a file;
> > Apart from file-handling it was these two lines:
> > 
> >  for x in lines[0::2]:   print(x.strip())
> >  for x in lines[1::2]:   print(x.strip())
> > ]
> 
> ...and using the best(TM) tool for it, it is a one-liner:
> 
> gawk '{ print > "split" NR%2}' input.txt

Ooo!¡!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ide vs ide

2017-10-28 Thread Rustom Mody
On Saturday, October 28, 2017 at 11:59:14 AM UTC+5:30, Andrew Z wrote:
> Yeah, lets start the war!
> // joking!
> 
> But if i think about it... there are tons articles and flame wars about "a
> vs b".
> And yet, what if the question should be different:
> 
> If you were to create the "ide" for yourself (think lego) , what are the
> functions that you _use_ and like a lot?

[Not really an answer to your question…]
But in a related direction:

I think we need to talk more systematically about 
- programming-in-the-small:  [< 70 lines — one or so screenfuls; only 1 file]
- -in-the-medium : all files in one directory
- -in-the-large : multiple directories/languages/OSes etc
- -huge : millions of lines; thousands of man-years

I think one of the main attractions (to me but also generally to teachers)
is that languages like python make programming-in-the-tiny a realistic 
possibility
ie a couple of lines worked out possibly file-less, at the interpreter prompt.

[The other day I was writing a program to split alternate lines of a file;
Apart from file-handling it was these two lines:

for x in lines[0::2]:   print(x.strip())
for x in lines[1::2]:   print(x.strip())
]

So coming to your question: IDEs are good for medium and (diminishingly) for 
large programs.

Useful python programs are often small; even tiny
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Let's talk about debuggers!

2017-10-25 Thread Rustom Mody
On Wednesday, October 25, 2017 at 6:37:47 PM UTC+5:30, Thomas Jollans wrote:
> Hi,
> 
> I just wanted to know what tools everyone used for debugging Python
> applications - scripts / backend / desktop apps / notebooks / whatever.
> Apart from the usual dance with log files and strategically inserted
> print() calls, that is.
> 
> Of course we all know and mildly dislike pdb.
> 
> Personally, in practice, I'm most likely to need a debugger when
> prototyping a function in a Jupyter notebook. There, ipdb, summoned with
> the %%debug magic incantation, does the trick.
> 
> Sometimes, though, I miss having a visual debugger. You know, the kind
> that Visual Basic has had for decades. There's one in Chrome dev tools
> if you ever have the misfortune of writing JavaScript.
> 
> What options are there for Python (that work)? What text editors (and
> IDEs) have a decent integrated debugger or debugging plugin? (Is there
> anything for Sublime?) Does anyone use them? (How do YOU debug?)
> 
> I vaguely remember WinPDB, but that hasn't seen a release in more than
> seven years...

pdb inside emacs works (to a fashion)
And it shows the arrow for current line so its at least quasi-gui

I believe idle too is much more usable than a few years earlier
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: grapheme cluster library

2017-10-23 Thread Rustom Mody
On Monday, October 23, 2017 at 1:15:35 PM UTC+5:30, Steve D'Aprano wrote:
> On Mon, 23 Oct 2017 05:47 pm, Rustom Mody wrote:
> 
> > On Monday, October 23, 2017 at 8:06:03 AM UTC+5:30, Lawrence D’Oliveiro
> > wrote:
> [...]
> >> Bear in mind that the logical representation of the text is as code points,
> >> graphemes would have more to do with rendering.
> > 
> > Heh! Speak of Euro/Anglo-centrism!
> 
> I think that Lawrence may be thinking of glyphs. Glyphs are the display form
> that are rendered. Graphemes are the smallest unit of written language.
> 
> 
> > In a sane world graphemes would be called letters
> 
> Graphemes *aren't* letters.
> 
> For starters, not all written languages have an alphabet. No alphabet, no
> letters. Even in languages with an alphabet, not all graphemes are letters.
> 
> Graphemes include:
> 
> - logograms (symbols which represent a morpheme, an entire word, or 
>   a phrase), e.g. Chinese characters, ampersand &, the ™ trademark 
>   or ® registered trademark symbols;
> 
> - syllabic characters such as Japanese kana or Cherokee;
> 
> - letters of alphabets;
> 
> - letters with added diacritics;
> 
> - punctuation marks;
> 
> - mathematical symbols;
> 
> - typographical symbols;
> 
> - word separators;
> 
> and more. Many linguists also include digraphs (pairs of letters) like the
> English "th", "sh", "qu", or "gh" as graphemes.
> 
> 
> https://www.thoughtco.com/what-is-a-grapheme-1690916
> 
> https://en.wikipedia.org/wiki/Grapheme

Um… Ok So I am using the wrong word? Your first link says:
| For example, the word 'ghost' contains five letters and four graphemes 
| ('gh,' 'o,' 's,' and 't')

Whereas new regex findall does:

>>> findall(r'\X', "ghost")
['g', 'h', 'o', 's', 't']
>>> findall(r'\X', "church")
['c', 'h', 'u', 'r', 'c', 'h']
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: grapheme cluster library (Posting On Python-List Prohibited)

2017-10-23 Thread Rustom Mody
On Monday, October 23, 2017 at 8:06:03 AM UTC+5:30, Lawrence D’Oliveiro wrote:
> On Saturday, October 21, 2017 at 5:11:13 PM UTC+13, Rustom Mody wrote:
> > Is there a recommended library for manipulating grapheme clusters?
> 
> Is this <http://anoopkunchukuttan.github.io/indic_nlp_library/> any good?

Thanks looks promising.
Dunno how much it lives up to the claims 
[For now the one liner from regex's findall has sufficed:
findall(r'\X', «text»)  

[Thanks MRAB for the library]
 
> Bear in mind that the logical representation of the text is as code points, 
> graphemes would have more to do with rendering.

Heh! Speak of Euro/Anglo-centrism!

In a sane world graphemes would be called letters
And unicode codepoints would be called something else — letterlets??
To be fair to the Unicode consortium, they strive hard to call them codepoints
But in an anglo-centric world, the conflation of codepoint to letter is 
inevitable I guess.
To hear how a non Roman-centric view of the world would sound:
A 'w' is a poorly double-struck 'u'
A 't' is a crossed 'l'
Reasonable?

The lead of https://en.wikipedia.org/wiki/%C3%9C has

| Ü, or ü, is a character…classified as a separate letter in several extended 
Latin alphabets 
| (including Azeri, Estonian, Hungarian and Turkish), but as the letter U with 
an 
| umlaut/diaeresis in others such as Catalan, French, Galician, German, Occitan 
and Spanish.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: grapheme cluster library

2017-10-21 Thread Rustom Mody
On Saturday, October 21, 2017 at 9:22:24 PM UTC+5:30, MRAB wrote:
> On 2017-10-21 05:11, Rustom Mody wrote:
> > Is there a recommended library for manipulating grapheme clusters?
> > 
> > In particular, in devanagari
> > क् + ि = कि
> > in (pseudo)unicode names
> > KA-letter + I-sign = KI-composite-letter
> > 
> > I would like to be able to handle KI as a letter rather than two 
> > code-points.
> > Can of course write an automaton to group but guessing that its already
> > available some place…
> > 
> You can use the regex module to split a string into graphemes:
> 
> regex.findall(r'\X', string)

Thanks MRAB
Yes as I said I discovered r'\X'
Ultimately my code was (effectively) one line!

print("".join(map[x] for x in findall(r'\X', l)))

with map being a few 100 elements of a dictionary such as
map = {
 ...
 'ॐ': "OM",
...
}

$ cat purnam-deva 
ॐ पूर्णमदः पूर्णमिदं पूर्णात्पुर्णमुदच्यते
पूर्णस्य पूर्णमादाय पूर्णमेवावशिष्यते ॥

$ ./devanagari2roman.py purnam-deva 
OM pUraNamadaH pUraNamidaM pUraNAtpuraNamudachyate
pUraNasya pUraNamAdAya pUraNamavAvashiShyate ..
OM shAntiH shAntiH shAntiH ..

Basically, an inversion of the itrans input method
https://en.wikipedia.org/wiki/ITRANS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: grapheme cluster library

2017-10-21 Thread Rustom Mody
On Saturday, October 21, 2017 at 11:51:57 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Oct 21, 2017 at 3:25 PM, Stefan Ram wrote:
> > Rustom Mody  writes:
> >>Is there a recommended library for manipulating grapheme clusters?
> >
> >   The Python Library has a module "unicodedata", with functions like:
> >
> > |unicodedata.normalize( form, unistr )
> > |
> > |Returns the normal form »form« for the Unicode string »unistr«.
> > |Valid values for »form« are »NFC«, »NFKC«, »NFD«, and »NFKD«.
> >
> >   . I don't know whether the transformation you are looking for
> >   is one of those.
> 
> No, that's at a lower level than grapheme clusters.
> 
> Rustom, have you looked on PyPI? There are a couple of hits, including
> one simply called "grapheme".

There is this one line solution using regex (or 2 char solution!)
Not perfect but a good start

>>> from regex import findall
>>> veda="""ॐ पूर्णमदः पूर्णमिदं पूर्णात्पुर्णमुदच्यते
पूर्णस्य पूर्णमादाय पूर्णमेवावशिष्यते ॥
ॐ शान्तिः शान्तिः शान्तिः ॥"""

>>> findall(r'\X', veda)
['ॐ', ' ', 'पू', 'र्', 'ण', 'म', 'दः', ' ', 'पू', 'र्', 'ण', 'मि', 'दं', ' ', 
'पू', 'र्', 'णा', 'त्', 'पु', 'र्', 'ण', 'मु', 'द', 'च्', 'य', 'ते', '\n', 
'पू', 'र्', 'ण', 'स्', 'य', ' ', 'पू', 'र्', 'ण', 'मा', 'दा', 'य', ' ', 'पू', 
'र्', 'ण', 'मे', 'वा', 'व', 'शि', 'ष्', 'य', 'ते', ' ', '॥', '\n', 'ॐ', ' ', 
'शा', 'न्', 'तिः', ' ', 'शा', 'न्', 'तिः', ' ', 'शा', 'न्', 'तिः', ' ', '॥']
>>> 

Compare

>>> [x for x in veda]
['ॐ', ' ', 'प', 'ू', 'र', '्', 'ण', 'म', 'द', 'ः', ' ', 'प', 'ू', 'र', '्', 
'ण', 'म', 'ि', 'द', 'ं', ' ', 'प', 'ू', 'र', '्', 'ण', 'ा', 'त', '्', 'प', 'ु', 
'र', '्', 'ण', 'म', 'ु', 'द', 'च', '्', 'य', 'त', 'े', '\n', 'प', 'ू', 'र', 
'्', 'ण', 'स', '्', 'य', ' ', 'प', 'ू', 'र', '्', 'ण', 'म', 'ा', 'द', 'ा', 'य', 
' ', 'प', 'ू', 'र', '्', 'ण', 'म', 'े', 'व', 'ा', 'व', 'श', 'ि', 'ष', '्', 'य', 
'त', 'े', ' ', '॥', '\n', 'ॐ', ' ', 'श', 'ा', 'न', '्', 'त', 'ि', 'ः', ' ', 
'श', 'ा', 'न', '्', 'त', 'ि', 'ः', ' ', 'श', 'ा', 'न', '्', 'त', 'ि', 'ः', ' ', 
'॥']

What is not working are the vowel-less consonant-joins: 
ie ... 'र्', 'ण' ... 
[3,4 element of the findall]
should be one 'र्ण'

But its good enough for me for now I think

PS Stefan I dont see your responses unless someone quotes them. Thanks anyway 
for the inputs
-- 
https://mail.python.org/mailman/listinfo/python-list


grapheme cluster library

2017-10-20 Thread Rustom Mody
Is there a recommended library for manipulating grapheme clusters?

In particular, in devanagari
क् + ि = कि 
in (pseudo)unicode names
KA-letter + I-sign = KI-composite-letter

I would like to be able to handle KI as a letter rather than two code-points.
Can of course write an automaton to group but guessing that its already
available some place…
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] beginning to code

2017-09-19 Thread Rustom Mody
On Tuesday, September 19, 2017 at 4:41:01 PM UTC+5:30, Antoon Pardon wrote:
> Op 19-09-17 om 11:22 schreef Steven D'Aprano:
> > Except for bools, where people freak out and are convinced the world will 
> > end if you just ask an object "are you true or false?". 
> >
> > Perhaps just a *tiny* exaggeration *wink*
> 
> On the other hand, python is very eager to convert objects to a bool. For
> strings and iterators you are expected to write a dunder method. If you
> think it makes no sense to see specific instances as true or false, you
> have to explicitly write a __bool__ that raises an exception. I think
> it would have been a better choice that a TypeError would have been
> raised if __bool__ wasn't defined.

How exceptional is python's choice to NOT raise exceptions can be seen by 
examples:

>>> [] + 2
Traceback (most recent call last):
  File "", line 1, in 
TypeError: can only concatenate list (not "int") to list
>>> [] < 0
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: list() < int()
>>> 1[2]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not subscriptable
>>> 2 < []
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: int() < list()
>>> len(2)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: object of type 'int' has no len()
>>> [x for x in 1]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not iterable
>>> -[]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: bad operand type for unary -: 'list'


>>> [] or []
[]
# Ah well... Same category as...

>>> ("empty" if [] else "nonempty")
'nonempty'
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] beginning to code

2017-09-18 Thread Rustom Mody
On Monday, September 18, 2017 at 6:25:09 PM UTC+5:30, Rustom Mody wrote:
> On Monday, September 18, 2017 at 5:23:49 PM UTC+5:30, Rick Johnson wrote:
> > On Sunday, September 17, 2017 at 8:51:38 PM UTC-5, INADA Naoki wrote:
> > > >
> > > > >
> > > > > I would agree that testing any of those for '== True' or
> > > > > the like is pointless redundancy,
> > > >
> > > > But what's wrong with syntactical redundancy when it brings
> > > > _clarity_ to the source code? And why can't Python be smart?
> > > > Consider the collowing code:
> > > >
> > > > if bool(someObject) == True:
> > > > # Do something
> > > >
> > > > Yes, from a "byte-code perspective", this source code is
> > > > superfluous, but, from a source code perspective, this code
> > > > is perfectly balanced between explicit and implicit.
> > > 
> > > I can't agree with you.  It's too redundant.  It doesn't
> > > provide any information about what coder think. 
> > 
> > It's not about what the "coder thinks", many times what the
> > coder thinks is wrong, it's about writing code that is
> > intuitive to as wide an audience as possible.
> > 
> > > While PEP 8 recommends `if x:`, I accept `if x > 0` or `if
> > > len(x) > 0` when I review code in my company.
> > 
> > So when `x` is an iterable, as in:
> > 
> > if len(x) > 0:
> > # blah
> > 
> > You're okay with the explicit test. Or when `x` is a
> > numeric, as in:
> > 
> > if x > 0:
> > # blah
> > 
> > You're okay with the explicit test. So, from a standpoint of
> > consistency, you /should/ be okay with this:
> > 
> > if bool(x) == True:
> > # blah
> > 
> > But you're not! :-). 
> 
> I have a feeling Rick that you are mixing up two unrelated things:
> - the bool(x) part
> - the ... == True part
> 
> The operation 
> x == True
> for true(!)/proper booleans x is a no-op
> because True == True is True
> and False == True is False
> And there are no other (proper) booleans
> 
> However because anything else can be bool-ish even though not boolean
> you need the bool(x) to effect the mapping:
> 
> {None, 0, "" {}, []} → False
> Everything_else → True
> 
> This mapping is neither obvious nor trivial

Sufficiently non-obvious that I missed the key element:
{None, 0, "" {}, [], False} → False
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] beginning to code

2017-09-18 Thread Rustom Mody
On Monday, September 18, 2017 at 5:23:49 PM UTC+5:30, Rick Johnson wrote:
> On Sunday, September 17, 2017 at 8:51:38 PM UTC-5, INADA Naoki wrote:
> > >
> > > >
> > > > I would agree that testing any of those for '== True' or
> > > > the like is pointless redundancy,
> > >
> > > But what's wrong with syntactical redundancy when it brings
> > > _clarity_ to the source code? And why can't Python be smart?
> > > Consider the collowing code:
> > >
> > > if bool(someObject) == True:
> > > # Do something
> > >
> > > Yes, from a "byte-code perspective", this source code is
> > > superfluous, but, from a source code perspective, this code
> > > is perfectly balanced between explicit and implicit.
> > 
> > I can't agree with you.  It's too redundant.  It doesn't
> > provide any information about what coder think. 
> 
> It's not about what the "coder thinks", many times what the
> coder thinks is wrong, it's about writing code that is
> intuitive to as wide an audience as possible.
> 
> > While PEP 8 recommends `if x:`, I accept `if x > 0` or `if
> > len(x) > 0` when I review code in my company.
> 
> So when `x` is an iterable, as in:
> 
> if len(x) > 0:
> # blah
> 
> You're okay with the explicit test. Or when `x` is a
> numeric, as in:
> 
> if x > 0:
> # blah
> 
> You're okay with the explicit test. So, from a standpoint of
> consistency, you /should/ be okay with this:
> 
> if bool(x) == True:
> # blah
> 
> But you're not! :-). 

I have a feeling Rick that you are mixing up two unrelated things:
- the bool(x) part
- the ... == True part

The operation 
x == True
for true(!)/proper booleans x is a no-op
because True == True is True
and False == True is False
And there are no other (proper) booleans

However because anything else can be bool-ish even though not boolean
you need the bool(x) to effect the mapping:

{None, 0, "" {}, []} → False
Everything_else → True

This mapping is neither obvious nor trivial

And one could argue that leaving python to implicitly make [] (say) into False
should be documented

So if you drop the hangup with the red-herring ...==True 
you have a point in asking for the bool(...)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: String to Dictionary conversion in python

2017-09-15 Thread Rustom Mody
On Saturday, September 16, 2017 at 2:04:39 AM UTC+5:30, jlad...@itu.edu wrote:
> On Thursday, September 14, 2017 at 11:33:56 PM UTC-7, Ian wrote:
> > On Fri, Sep 15, 2017 at 12:01 AM,   wrote:
> > > Hi,
> > >
> > > Can anyone help me in the below issue.
> > >
> > > I need to convert string to dictionary
> > >
> > > string = " 'msisdn': '7382432382', 'action': 'select', 'sessionId': 
> > > '123', 'recipient': '7382432382', 'language': 'english'"
> > >
> > > Can anyone help me with the code
> > 
> > It looks like this might do what you need:
> > 
> > py> import ast
> > py> string = " 'msisdn': '7382432382', 'action': 'select',
> > 'sessionId': '123', 'recipient': '7382432382', 'language': 'english'"
> > py> ast.literal_eval('{%s}' % string)
> > {'sessionId': '123', 'recipient': '7382432382', 'msisdn':
> > '7382432382', 'action': 'select', 'language': 'english'}
> 
> Very clever!  
Yeah… I used to think thus
But literal_eval has excessive crud in its error messages:

>>> from ast import literal_eval

>>> literal_eval("{'x':1}")
{'x': 1}

Ok…

>>> literal_eval("{x:1}")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.7/ast.py", line 80, in literal_eval
return _convert(node_or_string)
  File "/usr/lib/python2.7/ast.py", line 63, in _convert
in zip(node.keys, node.values))
  File "/usr/lib/python2.7/ast.py", line 62, in 
return dict((_convert(k), _convert(v)) for k, v
  File "/usr/lib/python2.7/ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string


>>> literal_eval("'x':1")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.7/ast.py", line 49, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
  File "/usr/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
  File "", line 1
'x':1
   ^
SyntaxError: invalid syntax




> And definitely not an answer that would be acceptable for a homework 
> assignment.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-11 Thread Rustom Mody
On Monday, September 11, 2017 at 1:28:24 PM UTC+5:30, Marko Rauhamaa wrote:
> Gregory Ewing:
> 
> > Chris Angelico wrote:
> >> Async functions in
> >> JS are an alternative to callback hell; most people consider async
> >> functions in Python to be an alternative to synchronous functions.
> >
> > What do you base that on? Seems to me async is an alternative
> > to callback-based frameworks such as Twisted.
> >
> > Calling async functions an alternative to sync functions
> > doesn't make sense, because if sync functions will do what
> > you want, there's no need to use async ones.
> 
> Asyncio makes it possible to write a single-threaded program in
> multithreading style.
> 
> The multithreading style means entwining the state of a finite state
> machine in the form of the source code. While a callback-based program
> will use one or more variables (object attributes) to store the state --
> or leave it implicit -- an asyncio program marks each state with the
> "await" keyword.
> 
> The multithreading style is convenient in cases where each state is
> blocked on a single possible event. Trouble is, most state machines I
> run into (and that's my bread and butter), each state is blocked on
> several or even numerous alternative events.

Do you have some reading material suggestions for grokking the a-world?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-09 Thread Rustom Mody
On Sunday, September 10, 2017 at 7:12:10 AM UTC+5:30, Gregory Ewing wrote:
> Pavol Lisy wrote:
> > Interesting reading:
> > https://stackoverflow.blog/2017/09/06/incredible-growth-python/?cb=1
> 
> So, Python's rate of expansion is accelerating, like
> the universe. Does that mean there's some kind of dark
> energy fuelling its growth?

Something to do with the small Hamming-distance between "God" and "Guido" ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A question on modification of a list via a function invocation

2017-09-07 Thread Rustom Mody
On Friday, September 8, 2017 at 7:39:38 AM UTC+5:30, Steve D'Aprano wrote:
> On Fri, 8 Sep 2017 04:24 am, Rustom Mody wrote:
> 
> > On Thursday, September 7, 2017 at 6:52:04 PM UTC+5:30, Gregory Ewing wrote:
> >> Rustom Mody wrote:
> >> 
> >> > I said: In that case please restate the definition of 'is' from the 
> >> > manual
> >> > which invokes the notion of 'memory' without bringing in memory.
> >> 
> >> I don't know whether it's in the manual, but at least for
> >> mutable objects, there is a way to define the notion of
> >> "same object" that doesn't require talking about "memory":
> >> 
> >> Two names refer to the same object if and only if mutations
> >> made through one are visible through the other.
> > 
> > Seems a sensible comment!
> 
> 
> Except that it is wrong, or at least over-generalised. It is trivially easy to
> show false positives:
> 
> py> class K: # defines an object
> ... def __init__(self, x):
> ... self.x = x
> ... def append(self, value):
> ... self.x.append(value)
> ...
> py> a = []
> py> b = K(a)
> py> a is b  # these are not the same object (they're different types)
> False
> py> b.append(99)  # but modifying b modifies a
> py> a
> [99]
> 
> 
> Rustom, I've already given you the definitive answer to your question about 
> how
> to define `is` without talking about memory. You haven't replied or
> acknowledged it, so here is it again:
> 
> `is` compares the two operands for identity. 

Preamble… so far so good

> If the two operands are the same
> object, `is` returns True, if they are distinct objects, `is` returns False.

restated
a is b iff a is b

A more than usually egregious demo of the circularity of defining 
isness/sameness

Models are needed
Math is one possible model
Machines are another
Paper and pen — which Chris keeps referring to — is another

Remove all models and you have frank hopeless circularity

> 
> 
> This does require that we agree on "same object", which as you point out is 
> (in
> its full generality) a difficult thing to define. 

More than difficult, impossible in the fully abstract philosophical case
When concretized to specific models not necessarily
the fundamental circularity then pushed out to the model
1 + 2 = 3
Are these '3's on your and my screen same? Same font? Same time?


E.g. in the past I've raised
> the paradox of My Grandfather's Axe.

Dont see the relevance (here)

> 
> But the intuitive, common-sense notion of "same object" is, I think, 
> sufficient
> here. If you want to argue that it is *not* sufficient, I think it's up to you
> to demonstrate a problem with the definition.
> 

Its not that you cant raise philosophical problems if you want
But when concretized to (basic) math, there are no disputes
so the argument becomes obtuseness to no point

In the case of python data model every single interminable thread like this one,
obviously started by a noob asking something genuinely and indicating
a real confusion disproves your claim to obvious intuition and common sense

Just to reiterate: Someone asked a question
Its not clear what (s)he understood from what we have going on and on about for
100s of posts



> Can you show an actual false positive (two distinct objects for which `is`
> returns True) or false negative (the same object given as both operands for
> `is` nevertheless returns False)? In the absence of any actual bugs in the
> definition, I maintain that it is sufficient.

You are not paying attention — the example above I gave in which
python arbitrarily hi-handedly, inconsistently manifests different behavior
between integer 1 and tuple (1,2)

I am now dropping off this thread [more important things to do]
with this observation:

There are these strange wondrous things in the world called 'mothers'
They take bawling shiing peeing pieces of fleshy exasperation called 'babies'
And convert them into intelligent human beings

Dunno how they do it…

More easily: if I, knowing English, read a German-English dictionary its ok,
a well-founded action — learning unknown-German via known-English

But reading a 'normal' English-English dictionary like Webster, Oxford etc
is borderline infinite recursion…
And occasionally fails — ambiguities, grey areas
Still it mostly works… with enough good faith

However bootstrapping the whole process from absolute zero — the mothers' task 
— 
is frankly beyond my ken

Bare (pure-philosophical, model-less) identity/sameness is analogous

So… what you think is obvious and trivially intuitive — the bald fact of 
semantics and comprehension — is to me quite miraculous
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >