Re: Compression of random binary data

2017-10-29 Thread Ian Kelly
On Oct 28, 2017 5:53 PM, "Chris Angelico" wrote: > One bit. It might send the message, or it might NOT send the message. Not sending the message is equivalent to having a second possible message. -- https://mail.python.org/mailman/listinfo/python-list

Re: Compression of random binary data

2017-10-29 Thread Chris Angelico
On Sun, Oct 29, 2017 at 6:00 PM, Ian Kelly wrote: > On Oct 28, 2017 5:53 PM, "Chris Angelico" wrote: >> One bit. It might send the message, or it might NOT send the message. > > Not sending the message is equivalent to having a second possible message. Okay, now we're getting seriously existenti

Re: Problem with subprocess.Popen and EINTR

2017-10-29 Thread Piet van Oostrum
Cameron Simpson writes: [...] > What if you did this: > > os.signal(SIGINT, SIG_IGN) > ... code code code, including the Popen/wait ... > old_handler = os.signal(SIGINT, do_nothing_handler) > sleep(...) > os.signal(SIGINT, old_handler) > > SIG_IGN is different from a do-nothing handler; it

Re: Compression of random binary data

2017-10-29 Thread Gregory Ewing
Chris Angelico wrote: One bit. It might send the message, or it might NOT send the message. The entropy formula assumes that you are definitely going to send one of the possible messages. If not sending a message is a possibility, then you need to include an empty message in the set of messages

Re: Coding style in CPython implementation

2017-10-29 Thread Στέφανος Σωφρονίου
On Sunday, October 29, 2017 at 4:18:38 AM UTC+2, Dan Sommers wrote: > On Sat, 28 Oct 2017 16:20:54 -0700, Στέφανος Σωφρονίου wrote: > > > I do believe though that if (!d) is a lot clearer than if (d == NULL) > > as it is safer than falsely assigning NULL in d, by pure mistake. > > Having made my

Re: Compression of random binary data

2017-10-29 Thread Steve D'Aprano
On Sun, 29 Oct 2017 02:31 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> I don't think that's right. The entropy of a single message is a >> well-defined quantity, formally called the self-information. >> >> https://en.wikipedia.org/wiki/Self-information > > True, but it still depends on kn

Re: Compression of random binary data

2017-10-29 Thread Steve D'Aprano
On Sun, 29 Oct 2017 06:03 pm, Chris Angelico wrote: > On Sun, Oct 29, 2017 at 6:00 PM, Ian Kelly wrote: >> On Oct 28, 2017 5:53 PM, "Chris Angelico" wrote: >>> One bit. It might send the message, or it might NOT send the message. >> >> Not sending the message is equivalent to having a second pos

Re: Repairing Python installation?

2017-10-29 Thread Martin Schöön
Den 2017-10-28 skrev Karsten Hilbert : > On Sat, Oct 28, 2017 at 08:41:34PM +, Martin Schöön wrote: > >> It seems something is amiss with my Python 2.7 installation. Revisiting >> Nikola (static web site generator written in Python) for the first time >> in several years the other day I experie

Re: Repairing Python installation?

2017-10-29 Thread Martin Schöön
Den 2017-10-28 skrev Percival John Hackworth : > On 28-Oct-2017, Martin Schöön wrote > (in article ): > >> It seems something is amiss with my Python 2.7 installation. Revisiting >> Nikola (static web site generator written in Python) for the first time >> in several years the other day I experienc

Re: sys.path[] question

2017-10-29 Thread Thomas Jollans
On 28/10/17 19:24, ElChino wrote: > From the Python2.7 snippet in [1], Python2.7 reports that my > sys.path[] contains: > f:\ProgramFiler\Python27\lib\site-packages\pyreadline-2.0-py2.7-win32.egg > > (a .zip-file) > > But I have also a 'f:\ProgramFiler\Python27\lib\site-packages\pyreadline' > d

Re: Repairing Python installation?

2017-10-29 Thread Chris Warrick
On 28 October 2017 at 22:41, Martin Schöön wrote: > It seems something is amiss with my Python 2.7 installation. Revisiting > Nikola (static web site generator written in Python) for the first time > in several years the other day I experience some unexpected problems. I > got some help form the N

Re: sys.path[] question

2017-10-29 Thread ElChino
Thomas Jollans wrote: You can find out where a module is loaded from by checking its __file__ attribute. Run python (in interactive mode) and execute import pyreadline pyreadline.__file__ Thanks for that tip. Does that mean that only this .egg is where python imports all pyreadline files f

Re: Compression of random binary data

2017-10-29 Thread Steve D'Aprano
On Sun, 29 Oct 2017 01:56 pm, Stefan Ram wrote: > If the entropy of an individual message is not defined, > than it is still available to be defined. I define it > to be log2(1/p), where p is the probability of this > message. I also choose a unit for it, which I call "bit". That is exact

Invoking return through a function?

2017-10-29 Thread Alberto Riva
Hello, I'm wondering if there is a way of writing a function that causes a return from the function that called it. To explain with an example, let's say that I want to exit my function if a dict does not contain a given key. I could write: def testFun(): ... if key not in dict: retu

Re: Invoking return through a function?

2017-10-29 Thread Ned Batchelder
On 10/29/17 10:18 AM, Alberto Riva wrote: Hello, I'm wondering if there is a way of writing a function that causes a return from the function that called it. To explain with an example, let's say that I want to exit my function if a dict does not contain a given key. I could write: def test

Re: Invoking return through a function?

2017-10-29 Thread Steve D'Aprano
On Mon, 30 Oct 2017 01:18 am, Alberto Riva wrote: > Hello, > > I'm wondering if there is a way of writing a function that causes a > return from the function that called it. To explain with an example, > let's say that I want to exit my function if a dict does not contain a > given key. I could w

Re: Coding style in CPython implementation

2017-10-29 Thread Rick Johnson
On Sunday, October 29, 2017 at 4:00:59 AM UTC-5, Στέφανος Σωφρονίου wrote: [...] > I guess the following parts from "Zen of Python" apply to this case: > > - Beautiful is better than ugly. > - Explicit is better than implicit. > - Simple is better than complex. > - Readability counts. Now go

Re: Invoking return through a function?

2017-10-29 Thread bartc
On 29/10/2017 14:35, Steve D'Aprano wrote: On Mon, 30 Oct 2017 01:18 am, Alberto Riva wrote: I'm wondering if there is a way of writing a function that causes a return from the function that called it. You really should re-think your strategy. Your suggestion, if possible, would lead to dif

Re: Compression of random binary data

2017-10-29 Thread Ben Bacarisse
Gregory Ewing writes: > Ben Bacarisse wrote: >> But that has to be about the process that gives rise to the data, not >> the data themselves. > >> If I say: "here is some random data..." you can't tell if it is or is >> not from a random source. I can, as a parlour trick, compress and >> recover

Re: Invoking return through a function?

2017-10-29 Thread Rick Johnson
On Sunday, October 29, 2017 at 9:19:03 AM UTC-5, Alberto Riva wrote: > Hello, > > I'm wondering if there is a way of writing a function that > causes a return from the function that called it. To > explain with an example, let's say that I want to exit my > function if a dict does not contain a gi

Re: Invoking return through a function?

2017-10-29 Thread Alberto Riva
On 10/29/2017 10:35 AM, Steve D'Aprano wrote: On Mon, 30 Oct 2017 01:18 am, Alberto Riva wrote: Hello, I'm wondering if there is a way of writing a function that causes a return from the function that called it. To explain with an example, let's say that I want to exit my function if a dict do

Re: Invoking return through a function?

2017-10-29 Thread Alberto Riva
On 10/29/2017 11:13 AM, bartc wrote: (What the OP wants was also proposed a few weeks back in comp.lang.c. But that was only within nested functions, so if H is inside G, and G is inside F, then a 'returnall' from H would return directly directly from F. Apparently Lisp allows this...) Well

Re: Invoking return through a function?

2017-10-29 Thread Alberto Riva
On 10/29/2017 12:21 PM, Rick Johnson wrote: On Sunday, October 29, 2017 at 9:19:03 AM UTC-5, Alberto Riva wrote: Hello, I'm wondering if there is a way of writing a function that causes a return from the function that called it. To explain with an example, let's say that I want to exit my funct

Aw: Re: Invoking return through a function?

2017-10-29 Thread Karsten Hilbert
> In this specific case, I wanted to invoke a return if the key doesn't > exist (as I wrote in my post). But this is not strictly relevant, my > question was more general. To phrase it in yet another way: is there > *any other way* to invoke return on a function, except by explicitly > writing

Re: Repairing Python installation?

2017-10-29 Thread Martin Schöön
Den 2017-10-29 skrev Chris Warrick : > On 28 October 2017 at 22:41, Martin Schöön wrote: >> >> Could mixing pip installs with Debian distro installs of Python >> packages lead to conflicts or other problems? > > Yes, it does, you should avoid that at all cost. The best way to do it > is by using

Re: Repairing Python installation?

2017-10-29 Thread Chris Warrick
On 29 October 2017 at 18:11, Martin Schöön wrote: > I have installed Python 3 virtualenv and Nikola according to those > instructions. I now have a working Nikola but I sure don't know what > I am doing :-) How do I get back into that nikola python environment > next time? cd into your virtualenv

django celery delay function dont exetute

2017-10-29 Thread Xristos Xristoou
hello I want to use celery tasks in my Django project and I try to follow this very good tutorial from Mr.Vitor Freitas. but in my case and if try to run it that tutorial project i don't get results back the functions don't execute and in my case and in tutorial(i take message to wait and refre

Re: Invoking return through a function?

2017-10-29 Thread Rick Johnson
Alberto Riva wrote: > Rick Johnson wrote: > > Alberto Riva wrote: [...] > >> In a language like Lisp > > > > Python is nothing like Lisp, and for good reason! > > I would disagree with this. Actually, it's the most Lisp- > like language I've encountered in my 25 years of writing > software.

Re: Coding style in CPython implementation

2017-10-29 Thread Chris Angelico
On Mon, Oct 30, 2017 at 12:47 AM, Stefan Ram wrote: > =?UTF-8?B?zqPPhM6tz4bOsc69zr/PgiDOo8+Jz4bPgc6/zr3Or86/z4U=?= > writes: >>I guess the following parts from "Zen of Python" apply to this case: > > If we would agree to apply Python rules to C, > then we could also use this excerpt from PEP

Re: Invoking return through a function?

2017-10-29 Thread Alberto Riva
On 10/29/2017 02:13 PM, Rick Johnson wrote: Alberto Riva wrote: Rick Johnson wrote: Alberto Riva wrote: [...] In a language like Lisp Python is nothing like Lisp, and for good reason! I would disagree with this. Actually, it's the most Lisp- like language I've encountered in my 25

Re: Invoking return through a function?

2017-10-29 Thread Ned Batchelder
On 10/29/17 3:09 PM, Alberto Riva wrote: On 10/29/2017 02:13 PM, Rick Johnson wrote: Alberto Riva wrote: Rick Johnson wrote: Alberto Riva wrote: [...] In a language like Lisp Python is nothing like Lisp, and for good reason! I would disagree with this. Actually, it's the most Lisp- like

Re: Invoking return through a function?

2017-10-29 Thread bartc
On 29/10/2017 17:02, Alberto Riva wrote: On 10/29/2017 12:21 PM, Rick Johnson wrote: In this specific case, I wanted to invoke a return if the key doesn't exist (as I wrote in my post). But this is not strictly relevant, my question was more general. To phrase it in yet another way: is there

Re: Invoking return through a function?

2017-10-29 Thread Rick Johnson
Alberto Riva wrote: > Rick Johnson wrote: > > Alberto Riva wrote: > >> Rick Johnson wrote: > >>> Alberto Riva wrote: > > [...] > > > > > > > > > > In a language like Lisp > > > > > > > > Python is nothing like Lisp, and for good reason! > > > > > > I would disagree with this. Actually, it's th

Re: Python-list Digest, Vol 169, Issue 44

2017-10-29 Thread Deught Chilapondwa
Sir, You have been sending me alot of messages but hardly can I understand. Offcourse I registered with you, but I can't understand the messages reharding what I should do. Can you come back to me with clarification? Impatienly waiting to hear from you. Deught Chilapondwa. On 25 Oct 2017 6:01 pm,

Listing link urls

2017-10-29 Thread Kishore Kumar Alajangi
Hi, I am facing an issue with listing specific urls inside web page, https://economictimes.indiatimes.com/archive.cms Page contains link urls by year and month vise, Ex: /archive/year-2001,month-1.cms I am able to list all required urls using the below code, from bs4 import BeautifulSoup impor

Re: Listing link urls

2017-10-29 Thread Kishore Kumar Alajangi
+ tutor On Sun, Oct 29, 2017 at 6:57 AM, Kishore Kumar Alajangi < akishorec...@gmail.com> wrote: > Hi, > > I am facing an issue with listing specific urls inside web page, > > https://economictimes.indiatimes.com/archive.cms > > Page contains link urls by year and month vise, > Ex: /archive/year-

Re: Repairing Python installation?

2017-10-29 Thread Martin Schöön
Den 2017-10-29 skrev Chris Warrick : > On 29 October 2017 at 18:11, Martin Schöön wrote: >> I have installed Python 3 virtualenv and Nikola according to those >> instructions. I now have a working Nikola but I sure don't know what >> I am doing :-) How do I get back into that nikola python environ

Re: Sandsifter software finds hidden instructions inside processors.

2017-10-29 Thread skybuck2000
I am going to issue a warning about all of this software: SandSifter, Linux Mint 18.2 and install-apt and for windows: git For now I suspect running two instances of SandSifter at same time on Linux Mint 18.2 caused file system corruption as can be seen on these three screenshots also checkdisk

Re: Invoking return through a function?

2017-10-29 Thread Alberto Riva
As suggested by Ned I'm going to stop replying after pointing out just a couple of things. The most important one is the following: > But since your assertion of: "Python, like Lisp, has X,Y and > Z features in common" and furthermore that: "I cannot find > another language that has exactly thes

Re: Sandsifter software finds hidden instructions inside processors.

2017-10-29 Thread skybuck2000
I do remember a very rare and extreme Windows 7 system hang not so long ago. It was probably caused by having to many FireFox tabs open... and somehow a website/FireFox managed to "hang windows 7". Windows 7 might have been busy trying to write data to the harddisk and somehow during that proce

Re: Coding style in CPython implementation

2017-10-29 Thread ROGER GRAYDON CHRISTMAN
NOTE: The case in question was never comparing to True; it was comparing to NULL. There is no "No: if x == None" below, because None is not Boolean. Similarly comparing a pointer to NULL is not the same as comparing it to a Boolean. So I would favor the "Explicit is better than Implicit" in th

Re: Invoking return through a function?

2017-10-29 Thread Steve D'Aprano
On Mon, 30 Oct 2017 03:35 am, Alberto Riva wrote: > On 10/29/2017 10:35 AM, Steve D'Aprano wrote: [...] >> You mean *less* explicit. "checkKey" gives absolutely no hint that it >> causes the current function to return. > > That's just because I used a name that was too generic in my example. I >

Re: Invoking return through a function?

2017-10-29 Thread Steve D'Aprano
On Mon, 30 Oct 2017 02:35 am, Stefan Ram wrote: > So, I guess, we then must accept that sometimes - under > extraordinary circumstances - it should be tolerated to > write a function that is as long as six lines. An entire six lines... you cowboy! *wink* -- Steve “Cheer up,” they said,

Re: Invoking return through a function?

2017-10-29 Thread Steve D'Aprano
On Mon, 30 Oct 2017 06:09 am, Alberto Riva wrote: > But that's exactly why I would like to be able to use macros. I think > that being able to write "return if this happens" is much more explicit > than having to write the full if statement, every time. There have been proposals in the past for s

why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
def leftrotate(l, n): return l[n:] + l[:n] def rightrotate(l, n): return l[-n:] + l[:-n] def encode(s, k, kk): l = [ord(i) for i in s] return leftrotate(''.join([chr(i + k) for i in l]), kk) def decode(s, k, kk): l = [ord(i) for i in rightrotate(s, kk)] return ''.join([ch

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
if run these function to decode in python interactive console, it can decode correct, but when run with a big project, it append a letter Y On Monday, October 30, 2017 at 9:48:36 AM UTC+8, Ho Yeung Lee wrote: > def leftrotate(l, n): > return l[n:] + l[:n] > > def rightrotate(l, n): >

ValueError: Error 3 while encrypting in ECB mode

2017-10-29 Thread Ho Yeung Lee
>>> from Crypto.Cipher import AES >>> >>> key = 'mysecretpassword' >>> plaintext = 'Secret Message A' >>> encobj = AES.new(key, AES.MODE_ECB) >>> ciphertext = encobj.encrypt("hello") Traceback (most recent call last): File "", line 1, in File "C:\Python27\lib\site-packages\Crypto\Cipher\_mode_

Re: Coding style in CPython implementation

2017-10-29 Thread Στέφανος Σωφρονίου
On Monday, October 30, 2017 at 2:35:13 AM UTC+2, ROGER GRAYDON CHRISTMAN wrote: > NOTE: The case in question was never comparing to True; it was comparing to > NULL. > > There is no "No: if x == None" below, because None is not Boolean. > Similarly comparing a pointer to NULL is not the same as

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
i discover when it decode("\\",1,2) in interactive console is [ but decode in big project it see as decode(r"\\",1,2) [[ it double On Monday, October 30, 2017 at 9:51:01 AM UTC+8, Ho Yeung Lee wrote: > if run these function to decode in python interactive console, > it can decode correct, >

Re: why it append one more letter after decode?

2017-10-29 Thread Igor Korot
Hi, On Sun, Oct 29, 2017 at 8:50 PM, Ho Yeung Lee wrote: > > if run these function to decode in python interactive console, > it can decode correct, You probably changed the code somewhere... You just need to debug it and see what is happening... Thank you. > > but when run with a big project

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
it seems that it read csv file from "\\" to "" On Monday, October 30, 2017 at 11:03:57 AM UTC+8, Ho Yeung Lee wrote: > i discover when > it > decode("\\",1,2) > in interactive console > is [ > > but decode in big project > it see as > decode(r"\\",1,2) > [[ > > it double > > On Monday, Oc

Re: why it append one more letter after decode?

2017-10-29 Thread Igor Korot
Hi, On Sun, Oct 29, 2017 at 10:03 PM, Ho Yeung Lee wrote: > i discover when > it > decode("\\",1,2) > in interactive console > is [ > > but decode in big project > it see as > decode(r"\\",1,2) > [[ > > it double Those 2 lines are different. Thank you. > > On Monday, October 30, 2017 at 9:51:0

Re: why it append one more letter after decode?

2017-10-29 Thread Ho Yeung Lee
i fixed by replace("","\\") On Monday, October 30, 2017 at 11:16:02 AM UTC+8, Igor Korot wrote: > Hi, > > On Sun, Oct 29, 2017 at 10:03 PM, Ho Yeung Lee wrote: > > i discover when > > it > > decode("\\",1,2) > > in interactive console > > is [ > > > > but decode in big project > > it see a

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 > h

Re: ValueError: Error 3 while encrypting in ECB mode

2017-10-29 Thread Steve D'Aprano
On Mon, 30 Oct 2017 01:20 pm, Ho Yeung Lee wrote: from Crypto.Cipher import AES key = 'mysecretpassword' plaintext = 'Secret Message A' encobj = AES.new(key, AES.MODE_ECB) ciphertext = encobj.encrypt("hello") > Traceback (most recent call last): > File "", line 1, i

Re: Invoking return through a function?

2017-10-29 Thread Lele Gaifax
r...@zedat.fu-berlin.de (Stefan Ram) writes: > There are many macro processors available, like the C macro > preprocessor, gpp, M4, or funnelweb. You can always use them > for your Python source (which, in this case, isn't exactly Python > source anymore). Even more to the point, MacroPy!