Re: IoT automation

2018-01-28 Thread Dale Marvin via Python-list

On 1/28/18 7:39 AM, Prahallad Achar wrote:

Hello team,
Could you please help me out in automation of IoT product end to end

Regards
Prahallad



 ?

--Dale

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


Re: Welcome to the "Python-list" mailing list (Digest mode)

2018-01-28 Thread nelson jon kane
When I enter the word python in the search box on my Chrome Windows 10, this is 
what comes up. Can you tell me what each of these "types" of Python mean? Thank 
you.

[cid:aa3fd74d-d71d-42c0-b063-4f20c463987b]


From: Python-list  on 
behalf of python-list-requ...@python.org 
Sent: Sunday, January 28, 2018 1:28:19 PM
To: nelsonjonka...@live.com
Subject: Welcome to the "Python-list" mailing list (Digest mode)

Welcome to the Python-list@python.org mailing list! The purpose of
this mailing list is to support general discussions about the Python
programming language.  Please remember that this list is mirrored to
the Usenet newsgroup comp.lang.python.

For more information on the Python programming language see


To post to this list, send your message to:

  python-list@python.org

General information about the mailing list is at:

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

If you ever want to unsubscribe or change your options (eg, switch to
or from digest mode, change your password, etc.), visit your
subscription page at:

  https://mail.python.org/mailman/options/python-list/nelsonjonkane6%40live.com


You can also make such adjustments via email by sending a message to:

  python-list-requ...@python.org

with the word `help' in the subject or body (don't include the
quotes), and you will get back a message with instructions.

You must know your password to change your options (including changing
the password, itself) or to unsubscribe without confirmation.  It is:

  Parkhill40

Normally, Mailman will remind you of your python.org mailing list
passwords once every month, although you can disable this if you
prefer.  This reminder will also include instructions on how to
unsubscribe or change your account options.  There is also a button on
your options page that will email your current password to you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Welcome to the "Python-list" mailing list (Digest mode)

2018-01-28 Thread nelson jon kane
Where did this guy in the video below get the version of Python that he's 
using? I don't have it in my computer.His version has this across the top:  
 
*for.py - C:/Users/Madhur/Desktop/for.py*



  https://www.youtube.com/watch?v=I5_UxvF_svw

[https://www.bing.com/th?id=OVP.24cLPPXEaXtBRV4AsjxkNwEsCo&pid=Api]

Python Programming Tutorial - 18: The FOR 
Loop
www.youtube.com
In this tutorial we'll check out the FOR Loop in python and see how it is 
different from the WHILE Loop.





From: nelson jon kane 
Sent: Sunday, January 28, 2018 6:05:04 PM
To: python-list@python.org
Subject: Re: Welcome to the "Python-list" mailing list (Digest mode)


When I enter the word python in the search box on my Chrome Windows 10, this is 
what comes up. Can you tell me what each of these "types" of Python mean? Thank 
you.

[cid:aa3fd74d-d71d-42c0-b063-4f20c463987b]


From: Python-list  on 
behalf of python-list-requ...@python.org 
Sent: Sunday, January 28, 2018 1:28:19 PM
To: nelsonjonka...@live.com
Subject: Welcome to the "Python-list" mailing list (Digest mode)

Welcome to the Python-list@python.org mailing list! The purpose of
this mailing list is to support general discussions about the Python
programming language.  Please remember that this list is mirrored to
the Usenet newsgroup comp.lang.python.

For more information on the Python programming language see


To post to this list, send your message to:

  python-list@python.org

General information about the mailing list is at:

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

If you ever want to unsubscribe or change your options (eg, switch to
or from digest mode, change your password, etc.), visit your
subscription page at:

  https://mail.python.org/mailman/options/python-list/nelsonjonkane6%40live.com


You can also make such adjustments via email by sending a message to:

  python-list-requ...@python.org

with the word `help' in the subject or body (don't include the
quotes), and you will get back a message with instructions.

You must know your password to change your options (including changing
the password, itself) or to unsubscribe without confirmation.  It is:

  Parkhill40

Normally, Mailman will remind you of your python.org mailing list
passwords once every month, although you can disable this if you
prefer.  This reminder will also include instructions on how to
unsubscribe or change your account options.  There is also a button on
your options page that will email your current password to you.
-- 
https://mail.python.org/mailman/listinfo/python-list


IoT automation

2018-01-28 Thread Prahallad Achar
Hello team,
Could you please help me out in automation of IoT product end to end

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


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

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 8:24 PM, Dan Stromberg  wrote:
> If an NN can ... play go on a level that can beat the best human in the
> world

Correcting myself: I think Google's AlphaGo used more than one NN,
plus perhaps a little traditional reading algorithm.  So I probably
should have said "If NN's can ...".
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 5:46 PM, Steven D'Aprano
 wrote:
> On Sun, 28 Jan 2018 17:13:05 -0800, Dan Stromberg wrote:
>> It feel like it'd be possible to train a neural network to translate
>> text in a screenshot to plain text though.
>
> That would be OCR, which has been around long before neural networks.
> Neither OCR nor neural networks can magically enhance low-res pixellated
> images and *accurately* turn them into text.

Yes, I'm familiar with OCR, but last I heard, it was still requiring
tuning with a specific font.

Is it really true that OCR appeared long before Neural Networks
(NN's)?  I first heard of NN's in the 80's, but OCR more like the
90's.  NN's have been around a long time, but it's only recently that
they've become highly useful because of the increase in computer
power, an explosion of digital data availability, and algorithm
improvements.

If an NN can translate from English to German well, and can tell a cat
from a dog, or play go on a level that can beat the best human in the
world, an NN might be able to do the job OCR was intended for given
adequate training data.  And we could probably write a little gobject
introspection app to generate copious training data.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
The message type is bytes,  this may make different ?

 print(type(message))



On Sun, Jan 28, 2018 at 8:41 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Sun, 28 Jan 2018 20:31:39 -0500, Jason Qian via Python-list wrote:
>
> > Thanks a lot :)
> >
> > os.write(1, message)  works !
>
> I still do not believe that print(message) doesn't work. I can see no
> reason why you need to use os.write().
>
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Larry Martell
On Sun, Jan 28, 2018 at 10:04 AM, 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:
>
> - for the sender, instead of a simple copy and paste, they have to take a
> screen shot, possibly trim the image to remove any bits of the screen
> they don't want to show, attach it to their email or upload it to an
> image hosting site;
>
> - for the receiver, you are reliant on a forum which doesn't strip
> attachments, or displays externally hosted images; the visually impaired
> are excluded from using a screen reader; and nobody can copy or edit the
> given text.
>
> It is as if people are deliberately inconveniencing themselves in order
> to inconvenience the people they are asking to help them.
>
> With the exception of one *exceedingly* overrated advantage, namely the
> ability to annotate the image with coloured lines and circles and
> squiggles or other graphics (which most people don't bother to do), this
> seems to me to be 100% counter-productive for everyone involved. Why has
> it spread and why do people keep doing it?
>
> I don't want to be the old man yelling "Get Of My Lawn!" to the cool
> kids, but is this just another sign of the downward spiral of programming
> talent? Convince me that there is *some* justification for this practice.
> Even a tiny one.
>
> (The day a programmer posts a WAV file of themselves reading their code
> out aloud, is the day I turn my modem off and leave the internet forever.)

I work remotely and have for over 20 years. At first I communicated
with my colleagues via phone and email. Then it was skype for a while
but then it went back to email. Then IRC had a moment, then it was
slack for a while, then back to email. Now everyone seems to be
switching to google hangouts, both chat and video. Recently I have
seen that some people are sending screen shots of their code and/or
error messages instead of copy/pasting.  It's mostly with the younger
ones, and I do not care for it at all, but I did not want to be the
old fogy, so I did not say anything.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 6:04 PM, Steven D'Aprano
 wrote:
> On Sun, 28 Jan 2018 17:49:44 -0800, Dan Stromberg wrote:
> So what was the clue that it was bytes that you saw that (nearly)
> everyone else missed? Especially me.

Can I get away with saying "it was just a good guess"?

I've been using byte strings a bunch in one of my projects. That didn't hurt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 17:49:44 -0800, Dan Stromberg wrote:

> On Sun, Jan 28, 2018 at 5:35 PM, Steven D'Aprano
>  wrote:
>> On Sun, 28 Jan 2018 17:04:56 -0800, Dan Stromberg wrote:
>>> How about:
>> os.write(1, message)
>>
>> What do you think that will do that print() doesn't do?
> 
 message = b'*does not exist\r\n\tat com.*' 
 os.write(1, message)
> *does not exist
> at com.*26

 print(message)
> b'*does not exist\r\n\tat com.*'


What was the clue that made you think that Jason was using bytes? In his 
posts, he always said it was a string, and when he printed the repr() of 
the message, it was a string, not bytes. If it were bytes, we would have 
seen this:

py> message = b'*does not exist\r\n\tat com.*'
py> print(repr(message))
b'*does not exist\r\n\tat com.*'


That is NOT the output that Jason showed. His output was:

py> string_message = '*does not exist\r\n\tat com.*'
py> print(repr(string_message))
'*does not exist\r\n\tat com.*'


Ah wait no it wasn't even that. The output he showed had no quotation 
marks. I didn't pick up on that: what he sent us as supposed output was 
actually impossible. He has been editing the output.

So what was the clue that it was bytes that you saw that (nearly) 
everyone else missed? Especially me.


-- 
Steve

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 19:51:06 -0500, Jason Qian via Python-list wrote:

> print(repr(message))  out :
> 
> *does not exist\r\n\tat com.*

For the record, I'd just like to say that this is not the output of 
Jason's call to print(). It has been edited to remove the 

b' '

delimiters which would have solved the problem: he isn't printing a 
string at all, he is printing bytes.

Jason, you have wasted our time by editing your output to hide what it 
actually shows. Don't do that again. When we ask to see the output of 
something, we need to see the ACTUAL output, not an edited version.


-- 
Steve

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


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

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 17:13:05 -0800, Dan Stromberg wrote:

> I'm afraid the perspective may be:
> Text == primitive
> GUI == modern
> 
> It feel like it'd be possible to train a neural network to translate
> text in a screenshot to plain text though.

That would be OCR, which has been around long before neural networks. 
Neither OCR nor neural networks can magically enhance low-res pixellated 
images and *accurately* turn them into text.

https://en.wikipedia.org/wiki/Optical_character_recognition


-- 
Steve

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 5:35 PM, Steven D'Aprano
 wrote:
> On Sun, 28 Jan 2018 17:04:56 -0800, Dan Stromberg wrote:
>> How about:
> os.write(1, message)
>
> What do you think that will do that print() doesn't do?

>>> message = b'*does not exist\r\n\tat com.*'
>>> os.write(1, message)
*does not exist
at com.*26
>>> print(message)
b'*does not exist\r\n\tat com.*'
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 20:31:39 -0500, Jason Qian via Python-list wrote:

> Thanks a lot :)
> 
> os.write(1, message)  works !

I still do not believe that print(message) doesn't work. I can see no 
reason why you need to use os.write().




-- 
Steve

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 17:04:56 -0800, Dan Stromberg wrote:

> How about:
 os.write(1, message)


What do you think that will do that print() doesn't do?



-- 
Steve

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Steven D'Aprano
Jason, your Python output and the C output are not the same.

Also, it looks like your email client is adding formatting codes to the 
email, or something. Please look at your post here:

https://mail.python.org/pipermail/python-list/2018-January/730384.html

Do you notice the extra asterisks added? I think they are added by your 
email program. Please do not use any formatting, they make the output 
confusing and make it difficult to understand what you are doing.

In Python, the output of print(repr(message)) looks like this:

does not exist\r\n\tat com.

(removing the asterisks at the start and end, which I believe are 
formatting added by to your email). That is, spelling it out character by 
character:

DE OH EE ES space EN OH TE space EE EX I ES TE backslash
AR backslash EN backslash TE AY TE space CE OH EM dot

That is what I expected. So if you print(message) without the repr, you 
should get exactly this:

does not exist
at com.



Here is the input and output of my Python session:

py> s = 'does not exist\r\n\tat com.'
py> print(s)
does not exist
at com.



That looks like exactly what you are expecting. If you are getting 
something different, please COPY AND PASTE as PLAIN TEXT (no formatting, 
no bold, no italics) the exact output from your Python session. And tell 
us what IDE you are using, or which interpreter. Are you using IDLE or 
PyCharm or Spyder or something else?

I repeat: do not add bold, or italics, do not use formatting of any kind. 
If you don't know how to turn the formatting off in your email program, 
you will need to find out.


You also print the individual characters of message from C:

for ch in message:
  printf("%d %c",ch, chr(ch))

and that outputs something completely different: the messages are not the 
same in your C code and your Python code.

Your Python code message is:

does not exist\r\n\tat com.


but your C code message appears to be:

not exist\r\n\tat com

(missing word "does" and final dot).

I do not understand why you are showing us C code. This is a Python 
forum, and you are having trouble printing from Python -- C is irrelevant.

I think you should just call print(message). If that doesn't do what you 
want, you need to show us what it actually does.



-- 
Steve

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
Thanks Peter,

  replace print with os.write  fixed the problem.



On Sun, Jan 28, 2018 at 3:57 AM, Peter Otten <__pete...@web.de> wrote:

> Jason Qian via Python-list wrote:
>
> > HI
> >
> >I have a string that contains \r\n\t
> >
> >[Ljava.lang.Object; does not exist*\r\n\t*at
> >[com.livecluster.core.tasklet
> >
> >
> >I would like to  print it as :
> >
> > [Ljava.lang.Object; does not exist
> >  tat com.livecluster.core.tasklet
> >
> >   How can I do this in python print ?
>
> Assuming the string contains the escape sequences rather than an actual
> TAB, CR or NL you can apply codecs.decode():
>
> >>> s = r"[Ljava.lang.Object; does not exist\r\n\tat
> com.livecluster.core.tasklet"
> >>> print(s)
> [Ljava.lang.Object; does not exist\r\n\tat com.livecluster.core.tasklet
> >>> import codecs
> >>> print(codecs.decode(s, "unicode-escape"))
> [Ljava.lang.Object; does not exist
> at com.livecluster.core.tasklet
>
> Note that this will decode all escape sequences that may occur in a string
> literal
> in Python, e. g.
>
> >>> codecs.decode(r"\x09 \u03c0 \N{soft ice cream}", "unicode-escape")
> '\t π 🍦'
>
> and will complain when the string is not a valid Python string literal:
>
> >>> codecs.decode(r"\x", "unicode-escape")
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position
> 0-1: truncated \xXX escape
>
> If you need more control you can build your own conversion routine:
>
> import re
>
> lookup = {
> "r": "\r",
> "n": "\n",
> "t": "\t",
> }
>
> def substitute(match):
> group = match.group(1)
> return lookup.get(group, group)
>
> def decode(s):
> return re.sub(r"\\(.)", substitute, s)
>
> s = decode("alpha\\n \\xomega")
> print(s)
> print(repr(s))
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
Thanks a lot :)

os.write(1, message)  works !

On Sun, Jan 28, 2018 at 8:04 PM, Dan Stromberg  wrote:

> How about:
> >>> os.write(1, message)
>
> On Sun, Jan 28, 2018 at 4:51 PM, Jason Qian via Python-list
>  wrote:
> > print(repr(message))  out :
> >
> > *does not exist\r\n\tat com.*
> >
> >
> > for ch in message:
> >   printf("%d %c",ch, chr(ch))
> >
> >
> > %d %c 110 n
> > %d %c 111 o
> > %d %c 116 t
> > %d %c 32
> > %d %c 101 e
> > %d %c 120 x
> > %d %c 105 i
> > %d %c 115 s
> > %d %c 116 t
> >
> > *%d %c 13%d %c 10*
> > *%d %c 9*
> > %d %c 97 a
> > %d %c 116 t
> > %d %c 32
> > %d %c 99 c
> > %d %c 111 o
> > %d %c 109 m
>
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Dan Sommers
On Mon, 29 Jan 2018 00:27:07 +, Steven D'Aprano wrote:

> On Mon, 29 Jan 2018 08:55:54 +1100, Tim Delaney wrote:
> 
>> I got back a Word document containing about 10 screenshots where they'd
>> apparently taken a screenshot, moved the horizontal scrollbar one
>> screen, taken another screenshot, etc.
> 
> You're lucky they didn't just take a single screen shot, thinking that 
> you can scroll past the edges to see what is off-screen.

No!  Not another pass by reference vs. pass by value thread!

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


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

2018-01-28 Thread Dan Stromberg
I'm afraid the perspective may be:
Text == primitive
GUI == modern

It feel like it'd be possible to train a neural network to translate
text in a screenshot to plain text though.

On Sun, Jan 28, 2018 at 7:04 AM, 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Tim Delaney
On 29 January 2018 at 11:27, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Mon, 29 Jan 2018 08:55:54 +1100, Tim Delaney wrote:
>
> > I got back a Word document containing about 10 screenshots where they'd
> > apparently taken a screenshot, moved the horizontal scrollbar one
> > screen, taken another screenshot, etc.
>
> You're lucky they didn't just take a single screen shot, thinking that
> you can scroll past the edges to see what is off-screen.


I suspect that was the case on the original screenshot in Word document ...

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
How about:
>>> os.write(1, message)

On Sun, Jan 28, 2018 at 4:51 PM, Jason Qian via Python-list
 wrote:
> print(repr(message))  out :
>
> *does not exist\r\n\tat com.*
>
>
> for ch in message:
>   printf("%d %c",ch, chr(ch))
>
>
> %d %c 110 n
> %d %c 111 o
> %d %c 116 t
> %d %c 32
> %d %c 101 e
> %d %c 120 x
> %d %c 105 i
> %d %c 115 s
> %d %c 116 t
>
> *%d %c 13%d %c 10*
> *%d %c 9*
> %d %c 97 a
> %d %c 116 t
> %d %c 32
> %d %c 99 c
> %d %c 111 o
> %d %c 109 m
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Jason Qian via Python-list
print(repr(message))  out :

*does not exist\r\n\tat com.*


for ch in message:
  printf("%d %c",ch, chr(ch))


%d %c 110 n
%d %c 111 o
%d %c 116 t
%d %c 32
%d %c 101 e
%d %c 120 x
%d %c 105 i
%d %c 115 s
%d %c 116 t

*%d %c 13%d %c 10*
*%d %c 9*
%d %c 97 a
%d %c 116 t
%d %c 32
%d %c 99 c
%d %c 111 o
%d %c 109 m





On Sun, Jan 28, 2018 at 9:50 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Sat, 27 Jan 2018 21:23:02 -0500, Jason Qian via Python-list wrote:
>
> > there are 0D 0A 09
>
> If your string actually contains CARRIAGE RETURN (OD) NEWLINE (OA), and
> TAB (09) characters, then you don't need to do anything. Just call print,
> and they will be printed correctly.
>
> If that doesn't work, then your input string doesn't contain what you
> think it contains. Please call this:
>
> print(repr(the_string))
>
> and COPY AND PASTE the output here so we can see it.
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Steven D'Aprano
On Mon, 29 Jan 2018 08:55:54 +1100, Tim Delaney wrote:

> I got back a Word document containing about 10 screenshots where they'd
> apparently taken a screenshot, moved the horizontal scrollbar one
> screen, taken another screenshot, etc.

You're lucky they didn't just take a single screen shot, thinking that 
you can scroll past the edges to see what is off-screen.


-- 
Steve

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


Re: Data-structure for multiway associativity in Python

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 14:48:02 -0800, qrious wrote:

> First list = { 1, 2, 3}
> Second list = { 4, 5, 6}
> Third list = { 7, 8, 9}
> 
> If I pass 9 as the argument, the return value of the function would be 
> {7, 8}.



subsets = [{1, 2, 3}, {4, 5, 6}, {7, 8, 9}]

data = {}
for subset in subsets:
for key in subset:
data[key] = subset

# At this point, your master data looks like this:
# 
# {1: {1, 2, 3},  2: {1, 2, 3},  3: {1, 2, 3},
#  4: {4, 5, 6},  5: {4, 5, 6},  6: {4, 5, 6}, 
#  7: {7, 8, 9},  8: {7, 8, 9},  9: {7, 8, 9}}
#
# but don't worry, that's not three COPIES of each set, just three
# references to the same one: each reference costs only a single
# pointer.

# Find a set associated with a key
subset = data[9]  # this is a lightning-fast lookup

# Get the items in the set, excluding the key itself
result = subset - {9}
assert result == {7, 8}

# Add a new data point to that set:
subset.add(10)
data[10] = subset

# Delete a data point:
del subset[9]
del data[9]



If you had started with a concrete example from the start, this would not 
have seemed like such a mysterious and difficult problem. Describing it 
as "multiway associativity" doesn't really help: as far as I can see, 
it's not multiway at all, it is just a straightforward case of one way 
associativity between each key and a set of values that contains that key.

Concrete examples are *really* useful for clarifying the requirements.



-- 
Steve

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


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

2018-01-28 Thread Gregory Ewing

Steven D'Aprano wrote:
(The day a programmer posts a WAV file of themselves reading their code 
out aloud, is the day I turn my modem off and leave the internet forever.)


Shh! Don't give them ideas!

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


Re: Data-structure for multiway associativity in Python

2018-01-28 Thread qrious
On Sunday, January 28, 2018 at 7:00:38 AM UTC-8, Steven D'Aprano wrote:

> 
> Since you specified that there are no lists with shared members, why 
> bother returning a list of lists? There will only ever be a single 
> matching list.
> 

That's correct. It will be a single list. My mistake in typing. 

> 
> To speed it up more, we'd need to know more information about how you are 
> using this. For example, if the values c1, ... d1, ... etc have some sort 
> of relationship, 

No relationship. 

> you might be able to generate some kind of multiway tree 
> that avoids having to search all of the thousands of lists before giving 
> up.

Which brings us to the Subject line of this thread. Without any relationship 
among the members, could we solve this using clever data structure? 
> 
> Are searches going to typically hit the same set c1... over and over 
> again? If so, then after matching, bring it to the front of the master 
> list. (You might want to use a deque for that.)
> 
> 
> 
> > Here a hash may be a way to go, but need help in figuring it out. Also,
> > can there be a faster and more memory efficient solution other than
> > hashes?
> 
> Probably not, not unless you have some sort of internal structure you can 
> take advantage of. For example, if all the strings in any group start 
> with the same letter, then you can dispatch directly to the right list:
> 
> data = {'c': {c1, c2, c3, ..., cn},
> 'd': {d1, ... } # and so on...
> }
> 
> def getAssocList(element):
> if element in data[element[0]]:
> return L
> raise ValueError('not found')
> 
> 
> But if there is no structure at all, and the elements in each list are 
> completely arbitrary, then there is nothing better than a linear search 
> through the entire collection of lists, looking at every single element 
> until you've matched what you're after.

The motivation of posting this thread is to explore if the above is true. 

> 
> But your description is pretty vague and for all I know what you actually 
> want is already a solved problem. Can you give more detail and cut-down 
> example of your data set? Say, two or three values per list, and two or 
> three lists.
> 
> 

First list = { 1, 2, 3} 
Second list = { 4, 5, 6} 
Third list = { 7, 8, 9} 

If I pass 9 as the argument, the return value of the function would be {7, 8}.


> -- 
> Steve

Thanks very much for your help and thoughts. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Tim Delaney
On 29 January 2018 at 02:04, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> 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.


I don't tend to see this from programmers I work with, but I'm constantly
having to deal with support tickets where the person raising the ticket put
a screenshot of something like a console or grid output of an SQL tool or
even a logfile opened in a text editor ... Even worse, usually they'll
paste the screenshot into a Word document first (which then causes
difficulties to view the screenshot due to page width, etc).

I had one case the other day where they'd taken a screenshot of some of the
columns of the output of an SQL query and pasted it into a Word document. I
specifically asked them not to do this, explained that the tool they were
using could export to CSV and that would be much more useful as I could
search it, etc. I offered to walk them through how to do the CSV export.
And I requested that they send me the entire output (all columns) of the
SQL output.

I got back a Word document containing about 10 screenshots where they'd
apparently taken a screenshot, moved the horizontal scrollbar one screen,
taken another screenshot, etc.

These are support people who are employed by the company I'm contracted to.
Doesn't matter how often I try to train them otherwise, this type of thing
keeps happening.

BTW: I have nothing to do with the final persistence format of the data,
but in practice I've had to learn the DB schema and stored procedures for
everything I support. Strangely the DB team don't have to learn my parts ...

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


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

2018-01-28 Thread Chris Angelico
On Mon, Jan 29, 2018 at 7:41 AM,   wrote:
> On Sunday, January 28, 2018 at 3:27:06 PM UTC-5, Chris Angelico wrote:
>> On Mon, Jan 29, 2018 at 7:13 AM, Chris Warrick  wrote:
>> > On 28 January 2018 at 20:19, Chris Angelico  wrote:
>> >> The vanilla Windows console (conhost.exe IIRC) is far from ideal for
>> >> copying and pasting from
>> >
>> > It’s been fixed in recent Windows 10 releases (select and Ctrl+C works 
>> > now).
>>
>> Haven't used it, but that's good news at least.
>>
>> >> Windows error popups are *impossible* to copy text from.
>> >
>> > Most standard error popups support pressing Ctrl+C to copy the text
>> > displayed in them.
>>
>> Really? Most? That would be a HUGE improvement. Historically, only a
>> handful have actually had selectable text. And really, it has to be
>> not just the core Windows error popups, but application ones as well;
>> so it has to be the underlying message-box API that supports it.
>>
>> ChrisA
>
> Most popups in applications using the standard Windows dialogs
> can still be copied from, even if the text doesn't look selectable:
>
>   - give the dialog a focus
>   - press Ctrl-A (this invisibly selects all text)
>   - press Ctrl-C to copy the text
>   - paste (Ctrl-V) into your favorite text editor.
>

Ah. Good that it's possible... but... a novice programmer is expected
to know this... how?

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


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

2018-01-28 Thread codewizard
On Sunday, January 28, 2018 at 3:27:06 PM UTC-5, Chris Angelico wrote:
> On Mon, Jan 29, 2018 at 7:13 AM, Chris Warrick  wrote:
> > On 28 January 2018 at 20:19, Chris Angelico  wrote:
> >> The vanilla Windows console (conhost.exe IIRC) is far from ideal for
> >> copying and pasting from
> >
> > It’s been fixed in recent Windows 10 releases (select and Ctrl+C works now).
> 
> Haven't used it, but that's good news at least.
> 
> >> Windows error popups are *impossible* to copy text from.
> >
> > Most standard error popups support pressing Ctrl+C to copy the text
> > displayed in them.
> 
> Really? Most? That would be a HUGE improvement. Historically, only a
> handful have actually had selectable text. And really, it has to be
> not just the core Windows error popups, but application ones as well;
> so it has to be the underlying message-box API that supports it.
> 
> ChrisA

Most popups in applications using the standard Windows dialogs 
can still be copied from, even if the text doesn't look selectable:

  - give the dialog a focus
  - press Ctrl-A (this invisibly selects all text)
  - press Ctrl-C to copy the text
  - paste (Ctrl-V) into your favorite text editor.

Regards,
Igor.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread eryk sun
On Sun, Jan 28, 2018 at 4:36 PM, Steven D'Aprano
 wrote:
> On Sun, 28 Jan 2018 15:54:31 +, Tim Golden wrote:
>
>> At least for Windows users, grabbing a partial screenshot (eg of text)
>> has been very easy since Windows 7 when the "Snipping Tool" was added to
>> the builtins.
>
> Thanks, I didn't know that.

It's a common feature in desktop environments. In Ubuntu Linux I can
hit Shift+PrintScreen to select and save part of the screen as a PNG
file, or copy it to the clipboard.

But it's no excuse for sending screen shots of source code.
Fortunately on Stack Overflow I usually see this for command prompt
screenshots of errors, not source code.

>> Certainly easier for the average user than trying to do a
>> slightly tricky rectangle selection within the Windows console.
>
> But I'm not seeing that it could possibly be easier than selecting text
> and hitting copy and paste. Not even in the Windows console, which I
> admit is a bit clunky, let alone a modern IDE. More *familiar*, maybe,
> but easier?

The new console in Windows 10 defaults to line-wrapping selection
instead of rectangle selection. Holding the ALT key temporarily
toggles the selection mode.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Chris Angelico
On Mon, Jan 29, 2018 at 7:13 AM, Chris Warrick  wrote:
> On 28 January 2018 at 20:19, Chris Angelico  wrote:
>> The vanilla Windows console (conhost.exe IIRC) is far from ideal for
>> copying and pasting from
>
> It’s been fixed in recent Windows 10 releases (select and Ctrl+C works now).

Haven't used it, but that's good news at least.

>> Windows error popups are *impossible* to copy text from.
>
> Most standard error popups support pressing Ctrl+C to copy the text
> displayed in them.

Really? Most? That would be a HUGE improvement. Historically, only a
handful have actually had selectable text. And really, it has to be
not just the core Windows error popups, but application ones as well;
so it has to be the underlying message-box API that supports it.

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


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

2018-01-28 Thread Chris Warrick
On 28 January 2018 at 20:19, Chris Angelico  wrote:
> The vanilla Windows console (conhost.exe IIRC) is far from ideal for
> copying and pasting from

It’s been fixed in recent Windows 10 releases (select and Ctrl+C works now).

> Windows error popups are *impossible* to copy text from.

Most standard error popups support pressing Ctrl+C to copy the text
displayed in them.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Terry Reedy

On 1/28/2018 10:54 AM, Tim Golden wrote:

On 28/01/2018 15:04, 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.


This happens on Stackoverflow too.  There, one can vote to close for 
lack of code or error message in the text.  I generally do not follow 
code image links and would encourage other to abstain also.


Hypothesis: as the number of beginning programming classes increases, 
the average quality, in some sense, of instructors and students go down. 
 On the other hand, I am sometimes impressed by what people attempt 
after too little preparation, in an attempt to improve their lives.



Where has this meme come from? It seems to be one which inconveniences
*everyone* involved:


At least for Windows users, grabbing a partial screenshot (eg of text) 
has been very easy since Windows 7 when the "Snipping Tool" was added to 
the builtins. Certainly easier for the average user than trying to do a 
slightly tricky rectangle selection within the Windows console.


I somehow missed the Snipping Tool.  Thanks for the information.  I 
won't use it for this list ;-), but an image of the MS Error box might 
be helpful occasionally on the tracker.


In Win10 Command Prompt, selection now works more of less normally, so 
that excuse is gone.


--
Terry Jan Reedy

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


Re: How to embed a native JIT compiler to a django app?

2018-01-28 Thread Etienne Robillard

Hi Stephane,

Thank you for your reply. As you suggested, I believe my approach was 
too complex. So I decided to replace Cython with PyPy in order to enable 
experimental support of JIT compilation for my Python/Django web 
applications.


Best regards,

Etienne


Le 2018-01-28 à 08:32, Stephane Wirtel via Python-list a écrit :

On 01/27, Etienne Robillard wrote:

Hi,

I want to compile a Django application into a C source file and embed 
a JIT compiler into the binary. Is there any way of doing this with 
llvm/clang?


Hi Etienne,

I think no, Django will use Python and this one is interpreted.
Answer, no...

Now, you could try to create a wheel file with your django project and
try that, but it is really complex.

Why do you want to package a Django app into a C file with a compiler?






--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

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


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

2018-01-28 Thread Grant Edwards
On 2018-01-28, Skip Montanaro  wrote:

> I've noticed it as well. I suspect it's from the Windows universe where
> it's common to snip a bit of the screen which isn't pure text when asking
> about some problematic GUI thing which is causing problems.

It's definitely a Windows thing.  Most Windows uses don't even
understand the concept of plain text vs. a bitmap picture of some text
being displayed by an app.

Just be glad that they're using a screen capture utilitly and not 
taking a picture of thier screen with their phone.  [Yes, I've dealt
with problem reports from customers where that's what they send.]

-- 
Grant





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


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

2018-01-28 Thread Chris Angelico
On Mon, Jan 29, 2018 at 3:36 AM, Steven D'Aprano
 wrote:
>> Certainly easier for the average user than trying to do a
>> slightly tricky rectangle selection within the Windows console.
>
> But I'm not seeing that it could possibly be easier than selecting text
> and hitting copy and paste. Not even in the Windows console, which I
> admit is a bit clunky, let alone a modern IDE. More *familiar*, maybe,
> but easier?

The vanilla Windows console (conhost.exe IIRC) is far from ideal for
copying and pasting from, and by and large, Windows error popups are
*impossible* to copy text from. So people get into the habit of either
transcribing by hand (tedious, error-prone, will inevitably
abbreviate) or taking a screenshot (100% reliable, nice and easy,
gives all the info). In a forum where attachments are acceptable,
which one are they going to be encouraged to use?

> Unless your sole programming language is Scratch or another "visual
> programming language", you're writing text and your question is about
> text. And the output is almost certainly text. Especially in the case of
> an exception, say.

I know that, and you know that, but not everyone does.

> I didn't even say *plain text*. I would completely understand it -- hate
> it, but understand it -- if people posted HTML and marked up their text
> with comments and colour. Hell, I'm even willing to consider that /maybe/
> programming source code should be some form of rich text. But at least
> rich text is text, not a bunch of pixels.

Yeah, I've occasionally seen HTML emails with full syntax
highlighting. It's rare though.

> I'm sorry to the OP of the other thread if he feels I'm picking on him,
> I'm not intending to single him out. I'm just seeing this habit more and
> more often in many different forums, and I had to ask where it was coming
> from. It's obviously *learned* behaviour: there's nothing natural about
> taking a screen shot to ask a question. I'm not surprised that yet again
> Microsoft has made the world a little bit worse by trying to make things
> easier for ordinary (l)users, and their bad habits are spreading into the
> programming community.

Agreed, this is not about any single person. There is a huge problem,
and most of it (IMO) derives from a general habit of the Windows (and
maybe Mac) GUIs of giving critical information in pop-up windows that
have *no way* to get a text dump from. The "culture of the screen
shot" has been around for way too long, and it's not going anywhere
any time soon, so all we can do is continue to tell people a better
way, and... well... hope for the text.

Okay, that pun was bad even in my own head. Sorry. Hope for the best.

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


Re: Compression of random binary data

2018-01-28 Thread Peter Pearson
On Sat, 27 Jan 2018 21:26:06 -0800 (PST), pendrysamm...@gmail.com wrote:
> If it is then show him this
>
> 387,420,489
>=
> 00110011 00111000 00110111 00101100 00110100 00110010 0011 0 ...

To save the casual reader a moment of disorientation, the
above binary string is just the ASCII representation of the
text string "387,420,489".

> 9^9 = ⬇️ (^ = to the power of)
>= 387,420,489
>
> But
>
> 9^9
>=
> 00111001 0100 00111001

Similarly, this is the ASCII representation of "9^9".  Our
self-confessedly intermittently sober correspondent appears to have
discovered the backside of the principle that a short text expression
can generate a large number.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Gene Heskett
On Sunday 28 January 2018 10:55:30 Peter J. Holzer wrote:

> On 2018-01-28 15:04:26 +, 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?
>
> Twitter? You can't send more than 140 characters[1], but you can send
> an image, so just put your text in an image to get around pesky size
> restrictions.
>
> But no, our users have done that for much longer than twitter exists.
> The typical mail to support doesn't contain an error message in plain
> text, not even a screenshot, it contains a word (or excel) file with a
> screenshot of the error message (typically scaled down so that the
> error message isn't readable any more).
>
> It reminds me about the old joke about the mathematician making
> coffee: He finds an empty cup in the sink, rinses it, puts some ground
> coffee and water into the coffee maker, waits for the water to run
> through and pours the coffee into the cup.
> The next day he wants some coffee again. But there is no cup in the
> sink. Instead there is a cup in the cupboard. So he takes the cup from
> the cupboard and puts it into the sink. Now he has reduced the problem
> to a previously solved problem and proceeds as before.
>
> Similarly the user sending a wort attachment instead of a plain text
> message knows how to take a screenshot, knows how to paste that into
> word and knows how to attach a word file to an email. So they combine
> those steps. They may or may not know how to copy some text into the
> email (to be fair, Windows error messages often cannot be copied), but
> it simply doesn't occur to them.
>
> I used to think that programmers (or techies in general) ought to be
> able to write emails in a fashion that makes it easy to extract the
> necessary information. I have since been disabused of the notion.
> Programmers are just as thoughtless and unable to put themselves into
> the recipient's shoes as the general population.
>
> Oh, and finally there is tools: I switched to Outlook for in-company
> mails a year ago (because my boss wants me to top-post and I simply
> can't do that if I have a decent editor, but with a crappy program
> like Outlook I can) and it is just amazing how time consuming it is to
> format a mail containing code examples to be readable. Taking a
> screenshot and pasting it into the mail is faster (even though
> Outlooks inline image handling is also atrocious).
>
> > (The day a programmer posts a WAV file of themselves reading their
> > code out aloud, is the day I turn my modem off and leave the
> > internet forever.)
>
> When the first MIME RFCs came out, a co-worker predicted that we would
> soon get audio-clips as signatures. Thank god he was wrong about that.
>
> hp
>
> [1] 280 now.

But by mentioning it, somebody will now do it. The problem will be what 
the hell do you play it with...

-- 
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Steven D'Aprano
On Sun, 28 Jan 2018 15:54:31 +, Tim Golden wrote:

> At least for Windows users, grabbing a partial screenshot (eg of text)
> has been very easy since Windows 7 when the "Snipping Tool" was added to
> the builtins. 

Thanks, I didn't know that.


> Certainly easier for the average user than trying to do a
> slightly tricky rectangle selection within the Windows console.

But I'm not seeing that it could possibly be easier than selecting text 
and hitting copy and paste. Not even in the Windows console, which I 
admit is a bit clunky, let alone a modern IDE. More *familiar*, maybe, 
but easier?


[...]
> FWIW I agree with you; and I even see this at work in different forms:
> someone sends a screenshot of a spreadsheet to illustrate a problem
> rather than the sheet itself. (When there's no especial sensitivity
> which might otherwise be a good reason).

Ah, this is the 21st century equivalent of somebody printing a document, 
scanning it, and emailing the scan. (Bonus points if they somehow manage 
to get the pages out of order or upside down when scanning.)


> But most people don't interact with text-only forums these days, so it's
> only natural that the don't consider that aspect of things.

No, sorry, I don't agree with that. I'm not talking about "most people", 
I'm talking about programmers, nor about "text-only" forums. Even if 
attachments came through, it would still be a bad idea to send 
screenshots to ask questions about your code.


Unless your sole programming language is Scratch or another "visual 
programming language", you're writing text and your question is about 
text. And the output is almost certainly text. Especially in the case of 
an exception, say.

(If your question is about, say, the layout of graphical elements in your 
GUI, then a screenshot is fine -- I'm not a troglodyte, I understand that 
sometimes a picture really is worth a thousand words.)

And writing an email requires writing text. And when people ask "fix my 
code for me", they are expecting to receive text they can copy and paste 
back. So text is the natural media for this sort of question, and there's 
nothing natural about thinking "I know, I'll take a virtual photo of this 
text and send that".

I didn't even say *plain text*. I would completely understand it -- hate 
it, but understand it -- if people posted HTML and marked up their text 
with comments and colour. Hell, I'm even willing to consider that /maybe/ 
programming source code should be some form of rich text. But at least 
rich text is text, not a bunch of pixels.

I'm sorry to the OP of the other thread if he feels I'm picking on him, 
I'm not intending to single him out. I'm just seeing this habit more and 
more often in many different forums, and I had to ask where it was coming 
from. It's obviously *learned* behaviour: there's nothing natural about 
taking a screen shot to ask a question. I'm not surprised that yet again 
Microsoft has made the world a little bit worse by trying to make things 
easier for ordinary (l)users, and their bad habits are spreading into the 
programming community.



-- 
Steve

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


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

2018-01-28 Thread Peter J. Holzer
On 2018-01-28 15:04:26 +, 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?

Twitter? You can't send more than 140 characters[1], but you can send an
image, so just put your text in an image to get around pesky size
restrictions.

But no, our users have done that for much longer than twitter exists.
The typical mail to support doesn't contain an error message in plain
text, not even a screenshot, it contains a word (or excel) file with a
screenshot of the error message (typically scaled down so that the error
message isn't readable any more).

It reminds me about the old joke about the mathematician making coffee:
He finds an empty cup in the sink, rinses it, puts some ground coffee
and water into the coffee maker, waits for the water to run through and
pours the coffee into the cup.
The next day he wants some coffee again. But there is no cup in the
sink. Instead there is a cup in the cupboard. So he takes the cup from
the cupboard and puts it into the sink. Now he has reduced the problem
to a previously solved problem and proceeds as before.

Similarly the user sending a wort attachment instead of a plain text
message knows how to take a screenshot, knows how to paste that into
word and knows how to attach a word file to an email. So they combine
those steps. They may or may not know how to copy some text into the
email (to be fair, Windows error messages often cannot be copied), but
it simply doesn't occur to them.

I used to think that programmers (or techies in general) ought to be
able to write emails in a fashion that makes it easy to extract the
necessary information. I have since been disabused of the notion.
Programmers are just as thoughtless and unable to put themselves into
the recipient's shoes as the general population.

Oh, and finally there is tools: I switched to Outlook for in-company
mails a year ago (because my boss wants me to top-post and I simply
can't do that if I have a decent editor, but with a crappy program like
Outlook I can) and it is just amazing how time consuming it is to format
a mail containing code examples to be readable. Taking a screenshot and
pasting it into the mail is faster (even though Outlooks inline image
handling is also atrocious).

> (The day a programmer posts a WAV file of themselves reading their code 
> out aloud, is the day I turn my modem off and leave the internet forever.)

When the first MIME RFCs came out, a co-worker predicted that we would
soon get audio-clips as signatures. Thank god he was wrong about that.

hp

[1] 280 now.

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-01-28 Thread Tim Golden

On 28/01/2018 15:04, 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:

- for the sender, instead of a simple copy and paste, they have to take a
screen shot, possibly trim the image to remove any bits of the screen
they don't want to show, attach it to their email or upload it to an
image hosting site;


At least for Windows users, grabbing a partial screenshot (eg of text) 
has been very easy since Windows 7 when the "Snipping Tool" was added to 
the builtins. Certainly easier for the average user than trying to do a 
slightly tricky rectangle selection within the Windows console.


Likewise, including it in an email isn't hard; there's a command to do 
it right there from within that tool.


And some at least of the disadvantages you cite for the receiver are 
rarely known or well understood by the senders. They regularly send and 
receive emails with embedded images; why should the mailing list they 
use be any different?


FWIW I agree with you; and I even see this at work in different forms: 
someone sends a screenshot of a spreadsheet to illustrate a problem 
rather than the sheet itself. (When there's no especial sensitivity 
which might otherwise be a good reason).


But most people don't interact with text-only forums these days, so it's 
only natural that the don't consider that aspect of things.


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


Re: Compression of random binary data (Posting On Python-List Prohibited)

2018-01-28 Thread Grant Edwards
On 2018-01-28, pendrysamm...@gmail.com  wrote:

> I have it in my head, just need someone to write the program for me,
> I know nothing about data compression or binary data other than 1s
> and 0s and that you can not take 2 number without a possible value
> more or less than them selves and compress them, I have been working
> for 1 1/2 years on a solution, just need help with programming. 
>
> If someone could get ahold of me when I am sober I could probably
> explain it a lot better, but I said fuck it I’ll show everyone a
> possibility instead of trying to do it on my own.

Wow...

Just... wow.

-- 
Grant





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


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

2018-01-28 Thread Skip Montanaro
I've noticed it as well. I suspect it's from the Windows universe where
it's common to snip a bit of the screen which isn't pure text when asking
about some problematic GUI thing which is causing problems.

I've never been a Windows user, but at my current job, Windows is core to
just about everything, so I am forced to use it for a lot of stuff
(Outlook, SQL Server, Excel, etc). I see lots of screen snips flow around,
and even use that technique at times when asking our help desk for some
mystifying Windows thing.

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


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

2018-01-28 Thread Karsten Hilbert
On Sun, Jan 28, 2018 at 03:04:26PM +, Steven D'Aprano wrote:

> (The day a programmer posts a WAV file of themselves reading their code 
> out aloud, is the day I turn my modem off and leave the internet forever.)

And the clever hack will be to send a WAV that tricks your
modem into surprising things by whistling just the right
way ...

:-)

Best,
Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sending Email using examples From Tutorials

2018-01-28 Thread Skip Montanaro
Your code is fine, ...


In addition to what Jason wrote, note that the way you need to authenticate
to most email servers has changed substantially since this tutorial example
was written. The OP has a yahoo.com email address. Even assuming you used
something like smtp.yahoo.com as the SMTP server, it's unlikely you could
just send mail through that host without some sort of authentication.

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


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

2018-01-28 Thread Wildman via Python-list
On Sun, 28 Jan 2018 15:04:26 +, 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:
> 
> - for the sender, instead of a simple copy and paste, they have to take a 
> screen shot, possibly trim the image to remove any bits of the screen 
> they don't want to show, attach it to their email or upload it to an 
> image hosting site;
> 
> - for the receiver, you are reliant on a forum which doesn't strip 
> attachments, or displays externally hosted images; the visually impaired 
> are excluded from using a screen reader; and nobody can copy or edit the 
> given text.
> 
> It is as if people are deliberately inconveniencing themselves in order 
> to inconvenience the people they are asking to help them.
> 
> With the exception of one *exceedingly* overrated advantage, namely the 
> ability to annotate the image with coloured lines and circles and 
> squiggles or other graphics (which most people don't bother to do), this 
> seems to me to be 100% counter-productive for everyone involved. Why has 
> it spread and why do people keep doing it?
> 
> I don't want to be the old man yelling "Get Of My Lawn!" to the cool 
> kids, but is this just another sign of the downward spiral of programming 
> talent? Convince me that there is *some* justification for this practice. 
> Even a tiny one.
> 
> (The day a programmer posts a WAV file of themselves reading their code 
> out aloud, is the day I turn my modem off and leave the internet forever.)

I can think of no justification for it.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compression of random binary data

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 21:50:24 -0800, pendrysammuel wrote:

> 387,420,489 is a number with only 2 repeating binary sequences

Okay. Now try these two numbers:

387420479
387420499



-- 
Steve

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


Re: Compression of random binary data

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 22:14:46 -0800, pendrysammuel wrote:

> I have it in my head, just need someone to write the program for me, 

Sure, my rate is $150 an hour.


> I
> know nothing about data compression or binary data other than 1s and 0s
> and that you can not take 2 number without a possible value more or less
> than them selves and compress them, I have been working for 1 1/2 years
> on a solution, just need help with programming.

Sounds like you should have spend two hours on learning a bit about data 
compression (start with Wikipedia) instead of wasting 1.5 years trying to 
guess a solution for something you know nothing about.


> If someone could get ahold of me when I am sober

O_o

Make that $550 an hour. Payable in advance.



-- 
Steve

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


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

2018-01-28 Thread Steven D'Aprano
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:

- for the sender, instead of a simple copy and paste, they have to take a 
screen shot, possibly trim the image to remove any bits of the screen 
they don't want to show, attach it to their email or upload it to an 
image hosting site;

- for the receiver, you are reliant on a forum which doesn't strip 
attachments, or displays externally hosted images; the visually impaired 
are excluded from using a screen reader; and nobody can copy or edit the 
given text.

It is as if people are deliberately inconveniencing themselves in order 
to inconvenience the people they are asking to help them.

With the exception of one *exceedingly* overrated advantage, namely the 
ability to annotate the image with coloured lines and circles and 
squiggles or other graphics (which most people don't bother to do), this 
seems to me to be 100% counter-productive for everyone involved. Why has 
it spread and why do people keep doing it?

I don't want to be the old man yelling "Get Of My Lawn!" to the cool 
kids, but is this just another sign of the downward spiral of programming 
talent? Convince me that there is *some* justification for this practice. 
Even a tiny one.

(The day a programmer posts a WAV file of themselves reading their code 
out aloud, is the day I turn my modem off and leave the internet forever.)



-- 
Steve

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


Re: Data-structure for multiway associativity in Python

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 10:01:47 -0800, qrious wrote:

> I need a data structure and a corresponding (hopefully fast) mechanism
> associated with it to do the following. While I am looking for the
> concept first, my preference for implementation of this will be in
> Python.
> 
> [c1, c2,..., cn] is a list of strings (for my own implementation, but
> could be any other type for the generic problem). There will be many
> hundreds, if not thousands, of such lists with no shared member.
> 
> The method getAssocList(e) will return lists of the lists for which e is
> an element.

Since you specified that there are no lists with shared members, why 
bother returning a list of lists? There will only ever be a single 
matching list.

data = [
[c1, c2, ..., cn],
[d1, d2, ..., dn], 
# hundreds more...
[z1, z2, ..., zn],
]

def getAssocList(element):
for L in data:
if element in L:
return L
raise ValueError('not found')


For faster results, use sets {c1, c2, ..., cn} rather than lists. The 
outer list still has to be a list though.

To speed it up more, we'd need to know more information about how you are 
using this. For example, if the values c1, ... d1, ... etc have some sort 
of relationship, you might be able to generate some kind of multiway tree 
that avoids having to search all of the thousands of lists before giving 
up.

Are searches going to typically hit the same set c1... over and over 
again? If so, then after matching, bring it to the front of the master 
list. (You might want to use a deque for that.)



> Here a hash may be a way to go, but need help in figuring it out. Also,
> can there be a faster and more memory efficient solution other than
> hashes?

Probably not, not unless you have some sort of internal structure you can 
take advantage of. For example, if all the strings in any group start 
with the same letter, then you can dispatch directly to the right list:

data = {'c': {c1, c2, c3, ..., cn},
'd': {d1, ... } # and so on...
}

def getAssocList(element):
if element in data[element[0]]:
return L
raise ValueError('not found')


But if there is no structure at all, and the elements in each list are 
completely arbitrary, then there is nothing better than a linear search 
through the entire collection of lists, looking at every single element 
until you've matched what you're after.

But your description is pretty vague and for all I know what you actually 
want is already a solved problem. Can you give more detail and cut-down 
example of your data set? Say, two or three values per list, and two or 
three lists.


-- 
Steve

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 21:23:02 -0500, Jason Qian via Python-list wrote:

> there are 0D 0A 09

If your string actually contains CARRIAGE RETURN (OD) NEWLINE (OA), and 
TAB (09) characters, then you don't need to do anything. Just call print, 
and they will be printed correctly.

If that doesn't work, then your input string doesn't contain what you 
think it contains. Please call this:

print(repr(the_string))

and COPY AND PASTE the output here so we can see it.



-- 
Steve

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


Re: Fwd: Text Strip() now working constantly.

2018-01-28 Thread Chris Angelico
On Mon, Jan 29, 2018 at 1:07 AM, Steven D'Aprano
 wrote:
> On Sat, 27 Jan 2018 11:25:35 -0600, George Shen wrote:
>
>> I have attached a JPG that clearly illustrate the issue.
> [...]
>> Please see the JPG.
>
> And what of us who are blind or visually impaired and use a screen reader
> to read text?
>
> Unless you use Photoshop to edit your source code, why are you using JPGs
> to show us code? Code is text. Copy and paste the text into your message.

... obligatory XKCD:

https://xkcd.com/1685/

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


Re: Fwd: Text Strip() now working constantly.

2018-01-28 Thread Steven D'Aprano
On Sat, 27 Jan 2018 11:25:35 -0600, George Shen wrote:

> I have attached a JPG that clearly illustrate the issue.
[...]
> Please see the JPG.

And what of us who are blind or visually impaired and use a screen reader 
to read text?

Unless you use Photoshop to edit your source code, why are you using JPGs 
to show us code? Code is text. Copy and paste the text into your message.


Thank you.


-- 
Steve

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


Re: How to embed a native JIT compiler to a django app?

2018-01-28 Thread Stephane Wirtel via Python-list

On 01/27, Etienne Robillard wrote:

Hi,

I want to compile a Django application into a C source file and embed 
a JIT compiler into the binary. Is there any way of doing this with 
llvm/clang?


Hi Etienne,

I think no, Django will use Python and this one is interpreted. 


Answer, no...

Now, you could try to create a wheel file with your django project and
try that, but it is really complex.

Why do you want to package a Django app into a C file with a compiler?




--
Stéphane Wirtel - http://wirtel.be - @matrixise
--
https://mail.python.org/mailman/listinfo/python-list


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Peter Otten
Jason Qian via Python-list wrote:

> HI
> 
>I have a string that contains \r\n\t
> 
>[Ljava.lang.Object; does not exist*\r\n\t*at
>[com.livecluster.core.tasklet
> 
> 
>I would like to  print it as :
> 
> [Ljava.lang.Object; does not exist
>  tat com.livecluster.core.tasklet
> 
>   How can I do this in python print ?

Assuming the string contains the escape sequences rather than an actual
TAB, CR or NL you can apply codecs.decode():

>>> s = r"[Ljava.lang.Object; does not exist\r\n\tat 
com.livecluster.core.tasklet"
>>> print(s)
[Ljava.lang.Object; does not exist\r\n\tat com.livecluster.core.tasklet
>>> import codecs
>>> print(codecs.decode(s, "unicode-escape"))
[Ljava.lang.Object; does not exist
at com.livecluster.core.tasklet

Note that this will decode all escape sequences that may occur in a string 
literal
in Python, e. g.

>>> codecs.decode(r"\x09 \u03c0 \N{soft ice cream}", "unicode-escape")
'\t π 🍦'

and will complain when the string is not a valid Python string literal:

>>> codecs.decode(r"\x", "unicode-escape")
Traceback (most recent call last):
  File "", line 1, in 
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 
0-1: truncated \xXX escape

If you need more control you can build your own conversion routine:

import re

lookup = {
"r": "\r",
"n": "\n",
"t": "\t",
}

def substitute(match):
group = match.group(1)
return lookup.get(group, group)

def decode(s):
return re.sub(r"\\(.)", substitute, s)

s = decode("alpha\\n \\xomega")
print(s)
print(repr(s))


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