Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2018 06:49:57 +1100, Chris Angelico wrote:

> On Sun, Feb 4, 2018 at 6:34 AM, Mark Lawrence 
> wrote:
>> On 03/02/18 17:56, Peter J. Holzer wrote:
>>> You seem to confuse the mailing-list and the newsgroup. The
>>> mailing-list doesn't have a spam problem, and it is already (lightly)
>>> moderated.
>>>
>>> The newsgroup does have a spam problem (as well as a few other
>>> problems, like gmane mangling message-ids and breaking threads).
>>> Google groups is an interface to the newsgroup.
>>>
>>> There is a bi-directional gateway between them, but they aren't the
>>> same thing.
>>>
>>>  hp
>>>
>>>
>> No, they are one and the same thing, except that this is automatically
>> blocked by the numpty moderators, whereas some things that I state on
>> gg are passed, other things aren't.  It is quite clear that the
>> moderators are biased against people such as myself who are autistic
> 
> No, the moderators are biased against people who are constantly rude.
> Did you know that, autistic or not, you have the power to choose the
> tone of the words you type?

How about people with Tourette's Syndrome and a hair-trigger "Send" 
command?

:-)

Seriously though, Mark, the newsgroup and the mailing list aren't the 
same thing. They use different technology, they're run by different 
organisations, and they have different moderators (actual people 
moderating the mailing list, nobody moderating the newsgroup). You can 
see from the detailed message headers which messages reach you directly 
via the newsgroup and which have come through the mailing list, or vice 
versa.

With a little care, you can even ensure that a message goes to the 
newgroup but not the mailing list, although I'm not sure if you can do it 
the other way.


-- 
Steve

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


Why not have a recvall method?

2018-02-04 Thread 陶青云
Hello, allThe socket object has a `sendall` method that can send all bytes you 
specified. Oppositely, socket only has
a recv method. I wonder why there is not a `recvall` method?
To workaround this, I use `f = socket.makefile('rb')`, then `call f.read(n)`
Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 2.6.7: Does socket.gethostbyaddr truncate?

2018-02-04 Thread Emil Natan
On Sat, Feb 3, 2018 at 1:11 PM, Peter J. Holzer  wrote:

> On 2018-01-30 08:56:16 -0800, Dan Stromberg wrote:
> > dig -x should return a single PTR in all cases, shouldn't it?
>
> No. dig -x should return *all* PTR records. There is usually at most one
> of them, but there may be several. (46 seems a bit much, but there
> really isn't any limit).
>
> > What IP are you using?
>
> Yup. I want to see an address with 46 PTR records, too ;-).
>
> > On Tue, Jan 30, 2018 at 4:05 AM, Antoon Pardon 
> wrote:
> > > I am using python 2.6.7 to do a little network programming, but it
> seems I don't
> > > get all the results.
> > >
> > > When I call socket.gethostbyaddr(IP) entry [1] of the result is a list
> of 34 addresses.
>
> gethostbyaddr just calls the underlying C library function. It is
> possibly that this has a limit (either on the number of names or more
> likely on the packet size).
>
> hp
>
> --
>_  | 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 
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
I would guess it's the packet size limitation. Using EDNS0 you can have
packet size of up 4096 bytes, but it's the underlying IP protocol which
limits further the amount of data in a single packet. Given the 20 bytes
IPv4 header and 8 bytes DNS header, that leaves 1472 bytes for data. Bigger
payload leads to IP fragmentation which in many cases is blocked by
firewalls or other network devices on the way.

In your case dig -x runs on the same machine where the Python code runs? If
yes, then it's not network issue.

What's the size of the response containing 34 addresses? What's the size of
the response from dig when all 46 addresses are returned?

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


Why not have a recvall method?

2018-02-04 Thread 陶青云
Hello, all  
The socket object has a `sendall` method that can send all bytes you specified. 
 
Oppositely, socket only has a recv method. I wonder why there is not a 
`recvall` method?  
To workaround this, I use `f = socket.makefile('rb')`, then all `f.read(n)` 
Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not have a recvall method?

2018-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2018 19:26:36 +0800, 陶青云 wrote:

> Hello, allThe socket object has a `sendall` method that can send all
> bytes you specified. Oppositely, socket only has a recv method. I wonder
> why there is not a `recvall` method? To workaround this, I use `f =
> socket.makefile('rb')`, then `call f.read(n)` Thanks.

I am not an expert on sockets, but since f.read(n) will read a maximum of 
n bytes, isn't that the same as socket_obj.recv(n)?



-- 
Steve

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


Re: Why not have a recvall method?

2018-02-04 Thread 陶青云
makefile('rb') return a  io.BufferedReader and the 
doc(https://docs.python.org/3/library/io.html#io.BufferedIOBase.read) says:
If the argument is positive, and the underlying raw stream is not 
interactive, multiple raw reads may be issued to satisfy the byte count (unless 
EOF is reached first).

 
-- Original --
From:  "Steven D'Aprano";
Date:  Sun, Feb 4, 2018 09:31 PM
To:  "python-list";
Subject:  Re: Why not have a recvall method?
 
On Sun, 04 Feb 2018 19:26:36 +0800, 陶青云 wrote:

> Hello, allThe socket object has a `sendall` method that can send all
> bytes you specified. Oppositely, socket only has a recv method. I wonder
> why there is not a `recvall` method? To workaround this, I use `f =
> socket.makefile('rb')`, then `call f.read(n)` Thanks.

I am not an expert on sockets, but since f.read(n) will read a maximum of 
n bytes, isn't that the same as socket_obj.recv(n)?



-- 
Steve

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


Re: 2.6.7: Does socket.gethostbyaddr truncate?

2018-02-04 Thread Chris Angelico
On Tue, Jan 30, 2018 at 11:05 PM, Antoon Pardon  wrote:
> I am using python 2.6.7 to do a little network programming, but it seems I 
> don't
> get all the results.
>
> When I call socket.gethostbyaddr(IP) entry [1] of the result is a list of 34 
> addresses.
>
> However when I use: dig -x IP I get a list of 46 addresses.
>
> Am I using the wrong function? Is this a bug? If the latter, is there a work 
> around?
>

Can you post the full output of dig? Maybe it's switched to TCP.

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


Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Jason Qian via Python-list
Hi,

   This is the case of calling python from c and the python function  will
return a string.

   It seems python been called correctly, but got error when convert the
python string to c string.

-- c --

   PyObject* pValue = PyObject_CallObject(pFunc, pArgs);


-- python --

import string, random
def StringGen(argv):
out_string_size=int(argv);
output_data=''.join(random.choice(string.ascii_lowercase) for x in
range(out_string_size))
return output_data


I try:

 PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
const char* sp = 0;
if (!PyArg_ParseTuple(pValue, "s", &sp)) {
}

and got

"SystemError: new style getargs format but argument is not a tuple"



Thanks for the help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Chris Angelico
On Mon, Feb 5, 2018 at 3:52 AM, Jason Qian via Python-list
 wrote:
> Hi,
>
>This is the case of calling python from c and the python function  will
> return a string.
>
>It seems python been called correctly, but got error when convert the
> python string to c string.
>
> -- c --
>
>PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
>
>
> -- python --
>
> import string, random
> def StringGen(argv):
> out_string_size=int(argv);
> output_data=''.join(random.choice(string.ascii_lowercase) for x in
> range(out_string_size))
> return output_data
>
>
> I try:
>
>  PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
> const char* sp = 0;
> if (!PyArg_ParseTuple(pValue, "s", &sp)) {
> }
>
> and got
>
> "SystemError: new style getargs format but argument is not a tuple"
>

You're using something that is specifically for parsing *arguments*
(as indicated by the "PyArg" prefix). If you want to get a 'const char
*' from a Python string, you probably want to encode it UTF-8. There's
a convenience function for that:

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUTF8AndSize

And if you know for sure that there won't be any \0 in the string, you
can use the next function in the docs, which doesn't bother returning
the size. (It'll always be null-terminated.)

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


Re: Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Jason Qian via Python-list
Hi Chris,

   Thanks a lot ! Using PyUnicode_DecodeUTF8 fix the problem.



On Sun, Feb 4, 2018 at 12:02 PM, Chris Angelico  wrote:

> On Mon, Feb 5, 2018 at 3:52 AM, Jason Qian via Python-list
>  wrote:
> > Hi,
> >
> >This is the case of calling python from c and the python function
> will
> > return a string.
> >
> >It seems python been called correctly, but got error when convert the
> > python string to c string.
> >
> > -- c --
> >
> >PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
> >
> >
> > -- python --
> >
> > import string, random
> > def StringGen(argv):
> > out_string_size=int(argv);
> > output_data=''.join(random.choice(string.ascii_lowercase) for x in
> > range(out_string_size))
> > return output_data
> >
> >
> > I try:
> >
> >  PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
> > const char* sp = 0;
> > if (!PyArg_ParseTuple(pValue, "s", &sp)) {
> > }
> >
> > and got
> >
> > "SystemError: new style getargs format but argument is not a tuple"
> >
>
> You're using something that is specifically for parsing *arguments*
> (as indicated by the "PyArg" prefix). If you want to get a 'const char
> *' from a Python string, you probably want to encode it UTF-8. There's
> a convenience function for that:
>
> https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUTF8AndSize
>
> And if you know for sure that there won't be any \0 in the string, you
> can use the next function in the docs, which doesn't bother returning
> the size. (It'll always be null-terminated.)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Help on PyImport_Import(pNAme)

2018-02-04 Thread Jason Qian via Python-list
Hi,

  This only works when loading  modules from the current directory.
  Is there a way I can load from somewhere else ?

Thanks for help,
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not have a recvall method?

2018-02-04 Thread Dan Stromberg
On Sun, Feb 4, 2018 at 5:26 AM, 陶青云  wrote:
> Hello, all
> The socket object has a `sendall` method that can send all bytes you 
> specified.
> Oppositely, socket only has a recv method. I wonder why there is not a 
> `recvall` method?
> To workaround this, I use `f = socket.makefile('rb')`, then all `f.read(n)`
> Thanks.

You're probably good with socket.makefile('rb').

An alternative that allows things like reading null-terminated input:
http://stromberg.dnsalias.org/~strombrg/bufsock.html

I wrote it and have been using it in production for years.
-- 
https://mail.python.org/mailman/listinfo/python-list


Parsing Nested List

2018-02-04 Thread Stanley Denman
I am trying to parse a Python nested list that is the result of the 
getOutlines() function of module PyPFD2 using pyparsing module. This is the 
result I get. what in the world are 'expandtabs' and why is that making a 
difference to my parse attempt?

Python Code
7
import PPDF2,pyparsing
from pyparsing import Word, alphas, nums
pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
List=pdfReader.getOutlines()
myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
myparser.parseString(List)

This is the error I get:

Traceback (most recent call last):
  File "", line 1, in 
myparser.parseString(List)
  File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
instring = instring.expandtabs()
AttributeError: 'list' object has no attribute 'expandtabs'

Thanks so much, not getting any helpful responses from https://python-forum.io.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Nested List

2018-02-04 Thread Chris Angelico
On Mon, Feb 5, 2018 at 9:26 AM, Stanley Denman
 wrote:
> I am trying to parse a Python nested list that is the result of the 
> getOutlines() function of module PyPFD2 using pyparsing module. This is the 
> result I get. what in the world are 'expandtabs' and why is that making a 
> difference to my parse attempt?
>
> Python Code
> 7
> import PPDF2,pyparsing
> from pyparsing import Word, alphas, nums
> pdfFileObj=open('x.pdf','rb')
> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> List=pdfReader.getOutlines()
> myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
> myparser.parseString(List)
>
> This is the error I get:
>
> Traceback (most recent call last):
>   File "", line 1, in 
> myparser.parseString(List)
>   File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
> instring = instring.expandtabs()
> AttributeError: 'list' object has no attribute 'expandtabs'
>
> Thanks so much, not getting any helpful responses from 
> https://python-forum.io.

By the look of this code, it's expecting a string. (The variable name
"instring" is suggestive of this, and strings DO have an expandtabs
method.) You're calling a method named "parseString", and presumably
giving it a list. I don't know what you mean by "nested" though.

Maybe you want to iterate over the list and parse each of the strings in it?

More info about what you're trying to do here would help.

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


3.6.4 IDLE

2018-02-04 Thread Rob Alspach
Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
former versions). I have never used python but have some IS background. The
videos I am seeing online all show the IDE / IDLE; however, it does not
install for me. I am installing from the download
python-3.6.4-embed-amd64.zip. I am running windows 10. I also have Oracle
on this laptop.

The file does not have an installer and also does not write to the file
path. I have already uninstalled and reinstalled the problem remains. I can
update the path no problem but where can I get the IDLE / IDE to follow
along with the videos on youtube? I am using notepad currently but have no
way to execute any files I write. If I save a file in notepad and open
through python the python window terminates when the operation is complete
(much to fast for these old eyes).
-- 
https://mail.python.org/mailman/listinfo/python-list


Can't load Python program on my HP ENVY computer

2018-02-04 Thread Bernard via Python-list



I have an HP ENVY TouchSmart 17 Notebook PC.
Windows 8.1.
Intel(R) Core(TM) i7-4700 mQ cpu @ 2.40 ghz 2.40ghz
64-bit operation system x64 based processor
Full Windows touch support with 10 touch points

Can you send me the link to the correct Python version that will run on this 
computer.  I have tried to install Python several times and it just keeps 
hanging up in the initialization phase.

Thanks,
B

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


Re: Parsing Nested List

2018-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2018 14:26:10 -0800, Stanley Denman wrote:

> I am trying to parse a Python nested list that is the result of the
> getOutlines() function of module PyPFD2 using pyparsing module.

pyparsing parses strings, not lists.

I fear that you have completely misunderstood what pyparsing does: it 
isn't a general-purpose parser of arbitrary Python objects like lists. 
Like most parsers (actually, all parsers that I know of...) it takes text 
as input and produces some sort of machine representation:

https://en.wikipedia.org/wiki/Parsing#Computer_languages


So your code is not working because you are calling parseString() with a 
list argument:

myparser.parseString(List)


The name of the function, parseString(), should have been a hint that it 
requires a *string* as argument.

You have generated an outline:

List = pdfReader.getOutlines()

but do you know what the format of that list is? I'm going to assume that 
it looks something like this:

['ABCD 01 of 99', 'EFGH 02 of 99', 'IJKL 03 of 99', ...]

since that matches the template you gave to pyparsing. Notice that:

- words are separated by spaces;

- the first word is any arbitrary word, made up of just letters;

- followed by EXACTLY two digits;

- followed by the word "of";

- followed by EXACTLY two digits.

Furthermore, I'm assuming it is a simple, non-nested list. If that is not 
the case, you will need to explain precisely what the format of the 
outline actually is.

To parse this list is simple and pyparsing is not required:

for item in List:
words = item.split()
if len(words) != 4:
raise ValueError('bad input data: %r' % item)
first, number, x, total = words
number = int(number)
assert x == 'of'
total = int(total)
print(first, number, total)




Hope this helps.

(Please keep any replies on the list.)



-- 
Steve

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


Re: 3.6.4 IDLE

2018-02-04 Thread Chris Angelico
On Mon, Feb 5, 2018 at 8:09 AM, Rob Alspach  wrote:
> Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
> former versions). I have never used python but have some IS background. The
> videos I am seeing online all show the IDE / IDLE; however, it does not
> install for me. I am installing from the download
> python-3.6.4-embed-amd64.zip. I am running windows 10. I also have Oracle
> on this laptop.
>
> The file does not have an installer and also does not write to the file
> path. I have already uninstalled and reinstalled the problem remains. I can
> update the path no problem but where can I get the IDLE / IDE to follow
> along with the videos on youtube? I am using notepad currently but have no
> way to execute any files I write. If I save a file in notepad and open
> through python the python window terminates when the operation is complete
> (much to fast for these old eyes).

What you'll normally want to do is get the regular installer. Go to
python.org and look at the download links right there on the front
page; that'll give you a much more normal way of getting hold of the
full Python suite.

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


Re: Parsing Nested List

2018-02-04 Thread Stanley Denman
On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote:
> I am trying to parse a Python nested list that is the result of the 
> getOutlines() function of module PyPFD2 using pyparsing module. This is the 
> result I get. what in the world are 'expandtabs' and why is that making a 
> difference to my parse attempt?
> 
> Python Code
> 7
> import PPDF2,pyparsing
> from pyparsing import Word, alphas, nums
> pdfFileObj=open('x.pdf','rb')
> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> List=pdfReader.getOutlines()
> myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
> myparser.parseString(List)
> 
> This is the error I get:
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> myparser.parseString(List)
>   File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
> instring = instring.expandtabs()
> AttributeError: 'list' object has no attribute 'expandtabs'
> 
> Thanks so much, not getting any helpful responses from 
> https://python-forum.io.

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


Re: Parsing Nested List

2018-02-04 Thread Stanley Denman
On Sunday, February 4, 2018 at 5:06:26 PM UTC-6, Steven D'Aprano wrote:
> On Sun, 04 Feb 2018 14:26:10 -0800, Stanley Denman wrote:
> 
> > I am trying to parse a Python nested list that is the result of the
> > getOutlines() function of module PyPFD2 using pyparsing module.
> 
> pyparsing parses strings, not lists.
> 
> I fear that you have completely misunderstood what pyparsing does: it 
> isn't a general-purpose parser of arbitrary Python objects like lists. 
> Like most parsers (actually, all parsers that I know of...) it takes text 
> as input and produces some sort of machine representation:
> 
> https://en.wikipedia.org/wiki/Parsing#Computer_languages
> 
> 
> So your code is not working because you are calling parseString() with a 
> list argument:
> 
> myparser.parseString(List)
> 
> 
> The name of the function, parseString(), should have been a hint that it 
> requires a *string* as argument.
> 
> You have generated an outline:
> 
> List = pdfReader.getOutlines()
> 
> but do you know what the format of that list is? I'm going to assume that 
> it looks something like this:
> 
> ['ABCD 01 of 99', 'EFGH 02 of 99', 'IJKL 03 of 99', ...]
> 
> since that matches the template you gave to pyparsing. Notice that:
> 
> - words are separated by spaces;
> 
> - the first word is any arbitrary word, made up of just letters;
> 
> - followed by EXACTLY two digits;
> 
> - followed by the word "of";
> 
> - followed by EXACTLY two digits.
> 
> Furthermore, I'm assuming it is a simple, non-nested list. If that is not 
> the case, you will need to explain precisely what the format of the 
> outline actually is.
> 
> To parse this list is simple and pyparsing is not required:
> 
> for item in List:
> words = item.split()
> if len(words) != 4:
> raise ValueError('bad input data: %r' % item)
> first, number, x, total = words
> number = int(number)
> assert x == 'of'
> total = int(total)
> print(first, number, total)
> 
> 
> 
> 
> Hope this helps.
> 
> (Please keep any replies on the list.)
> 
> 
> 
> -- 
> Steve

Thank you so much Steve.  I do seem to be barking up the wrong tree.  The 
result of running getOutlines() is indeed a nested list: it is the pdfs 
bookmarks.  There are 3 levels: level 1 is the section from A-F. When a section 
there are exhibits, so in Section A we have exhibits 1A to nA. Finally there 
are bookmarks for individual pages in an exhibit.   So we have this for Section 
A:

[{'/Title': 'Section A.  Payment Documents/Decisions', '/Page': 
IndirectObject(1, 0), '/Type': '/FitB'}, [{'/Title': '1A:  Disability 
Determination Transmittal (831) Dec. Dt.:  05/27/2016 (1 page)', '/Page': 
IndirectObject(1, 0), '/Type': '/FitB'}, [{'/Title': '1A (Page 1 of 1)', 
'/Page': IndirectObject(1, 0), '/Type': '/FitB'}], {'/Title': '2A:  Disability 
Determination Explanation (DDE) Dec. Dt.:  05/27/2016 (10 pages)', '/Page': 
IndirectObject(6, 0), '/Type': '/FitB'}, [{'/Title': '2A (Page 1 of 10)', 
'/Page': IndirectObject(6, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 2 of 
10)', '/Page': IndirectObject(10, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 3 
of 10)', '/Page': IndirectObject(14, 0), '/Type': '/FitB'}, {'/Title': '2A 
(Page 4 of 10)', '/Page': IndirectObject(18, 0), '/Type': '/FitB'}, {'/Title': 
'2A (Page 5 of 10)', '/Page': IndirectObject(22, 0), '/Type': '/FitB'}, 
{'/Title': '2A (Page 6 of 10)', '/Page': IndirectObject(26, 0), '/Type': 
'/FitB'}, {'/Title': '2A (Page 7 
 of 10)', '/Page': IndirectObject(30, 0), '/Type': '/FitB'}, {'/Title': '2A 
(Page 8 of 10)', '/Page': IndirectObject(34, 0), '/Type': '/FitB'}, {'/Title': 
'2A (Page 9 of 10)', '/Page': IndirectObject(38, 0), '/Type': '/FitB'}, 
{'/Title': '2A (Page 10 of 10)', '/Page': IndirectObject(42, 0), '/Type': 
'/FitB'}], {'/Title': '3A:  ALJ Hearing Decision (ALJDEC) Dec. Dt.:  12/17/2012 
(22 pages)', '/Page': IndirectObject(47, 0), '/Type': '/FitB'}, [{'/Title': '3A 
(Page 1 of 22)', '/Page': IndirectObject(47, 0), '/Type': '/FitB'}, {'/Title': 
'3A (Page 2 of 22)', '/Page': IndirectObject(51, 0), '/Type': '/FitB'}, 
{'/Title': '3A (Page 3 of 22)', '/Page': IndirectObject(55, 0), '/Type': 
'/FitB'}, {'/Title': '3A (Page 4 of 22)', '/Page': IndirectObject(59, 0), 
'/Type': '/FitB'}, {'/Title': '3A (Page 5 of 22)', '/Page': IndirectObject(63, 
0), '/Type': '/FitB'}, {'/Title': '3A (Page 6 of 22)', '/Page': 
IndirectObject(67, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 7 of 22)', 
'/Page': IndirectObjec
 t(71, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 8 of 22)', '/Page': 
IndirectObject(75, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 9 of 22)', 
'/Page': IndirectObject(79, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 10 of 
22)', '/Page': IndirectObject(83, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 
11 of 22)', '/Page': IndirectObject(88, 0), '/Type': '/FitB'}, {'/Title': '3A 
(Page 12 of 22)', '/Page': IndirectObject(92, 0), '/Type': '/FitB'}, {'/Title': 
'3A (Page 13 of 22)', '/Page': Indirect

[RELEASED] Python 3.4.8 and Python 3.5.5 are now available

2018-02-04 Thread Larry Hastings


On behalf of the Python development community, I'm happy to announce the 
availability of Python 3.4.8 and Python 3.5.5.


Both Python 3.4 and 3.5 are in "security fixes only" mode.  Both 
versions only accept security fixes, not conventional bug fixes, and 
both releases are source-only.



You can find Python 3.4.8 here:

   https://www.python.org/downloads/release/python-348/


And you can find Python 3.5.5 here:

   https://www.python.org/downloads/release/python-355/



Happy Pythoning,


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


Re: Why not have a recvall method?

2018-02-04 Thread 陶青云
Thank you, it's very helpful.
I think the recvall should builtin to the _socket module like sendall.
 
 
-- Original --
From:  "Dan Stromberg";
Date:  Mon, Feb 5, 2018 06:01 AM
To:  "陶青云";
Cc:  "python-list";
Subject:  Re: Why not have a recvall method?
 
On Sun, Feb 4, 2018 at 5:26 AM, 陶青云  wrote:
> Hello, all
> The socket object has a `sendall` method that can send all bytes you 
> specified.
> Oppositely, socket only has a recv method. I wonder why there is not a 
> `recvall` method?
> To workaround this, I use `f = socket.makefile('rb')`, then all `f.read(n)`
> Thanks.

You're probably good with socket.makefile('rb').

An alternative that allows things like reading null-terminated input:
http://stromberg.dnsalias.org/~strombrg/bufsock.html

I wrote it and have been using it in production for years.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 3.6.4 IDLE

2018-02-04 Thread Terry Reedy

On 2/4/2018 4:09 PM, Rob Alspach wrote:

Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
former versions). I have never used python but have some IS background. The
videos I am seeing online all show the IDE / IDLE; however, it does not
install for me. I am installing from the download
python-3.6.4-embed-amd64.zip.


This is for people who want to embed Python in a C program, or something 
like that.  Go back to

https://www.python.org/downloads/release/python-364/
and get either a 32-bit x86 or 64-bit x86-64 installer.
I suggest the 64-bit if your Win10 is 64-bit, as is likely.
I suggest the 'executable' versus the 'web-based' installer, as one can 
read something else while downloading (less than a minute), and one will 
have the installer to repair or revise, but that is up to you.


--
Terry Jan Reedy

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


Re: 3.6.4 IDLE

2018-02-04 Thread MRAB

On 2018-02-04 21:09, Rob Alspach wrote:

Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
former versions). I have never used python but have some IS background. The
videos I am seeing online all show the IDE / IDLE; however, it does not
install for me. I am installing from the download
python-3.6.4-embed-amd64.zip. I am running windows 10. I also have Oracle
on this laptop.

The file does not have an installer and also does not write to the file
path. I have already uninstalled and reinstalled the problem remains. I can
update the path no problem but where can I get the IDLE / IDE to follow
along with the videos on youtube? I am using notepad currently but have no
way to execute any files I write. If I save a file in notepad and open
through python the python window terminates when the operation is complete
(much to fast for these old eyes).

python-3.6.4-embed-amd64.zip is for "embedded, small or minimal hardware 
devices". I think you probably don't want that one!


I always use the "executable installer".
--
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Nested List

2018-02-04 Thread Stanley Denman
On Sunday, February 4, 2018 at 5:32:51 PM UTC-6, Stanley Denman wrote:
> On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote:
> > I am trying to parse a Python nested list that is the result of the 
> > getOutlines() function of module PyPFD2 using pyparsing module. This is the 
> > result I get. what in the world are 'expandtabs' and why is that making a 
> > difference to my parse attempt?
> > 
> > Python Code
> > 7
> > import PPDF2,pyparsing
> > from pyparsing import Word, alphas, nums
> > pdfFileObj=open('x.pdf','rb')
> > pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> > List=pdfReader.getOutlines()
> > myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
> > myparser.parseString(List)
> > 
> > This is the error I get:
> > 
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > myparser.parseString(List)
> >   File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
> > instring = instring.expandtabs()
> > AttributeError: 'list' object has no attribute 'expandtabs'
> > 
> > Thanks so much, not getting any helpful responses from 
> > https://python-forum.io.

I have found that I can use the index values in the list to print out the 
section I need.  So print(MyList[7]) get me to section f taht I want.  
print(MyList[9][1]) for example give me a string that is the bookmark entry for 
Exhibit 1F.  But this index value would presumeably be different for each pdf 
file - that is there may not always be Section A-E, but there will always be a 
Section F. In ther words, the index values that get me to the right section 
would be different in each pdf file.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: auto-correct a speech-to-text output and relate to of the words based on syllables

2018-02-04 Thread dieter
"Peter J. Holzer"  writes:
> On 2018-02-03 09:34:57 +0100, dieter wrote:
> ...
> The difficulty is to *recognise* it correctly. Was that tangle of sound
> waves an "l" or an "r"? This not as unambiguous as you seem to think.
> So a speech-to-text program may hear "right" when the speaker was really
> saying "light". If you have only the output from that program you must
> determine whether "right" is correct or must be corrected to "light".

The primary recommendation from my first response has been:
determine the step in the process chain that made the error.
If already the first step ("speech-to-text") has wrongly interpreted
"light" as "right", then obviously context is necessary to determine
that this was wrong.

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


Why no '|' operator for dict?

2018-02-04 Thread Frank Millman

Hi all

I recently learned that you can create a set 'on-the-fly' from two existing 
sets using the '|' operator -


Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit 
(AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.


set_1 = set(('a', 'b', 'c'))
set_2 = set(('d',))
set_1 | set_2

{'d', 'a', 'c', 'b'}




I was hoping that I could do the same with a dictionary, but it does not 
work -



dict_1 = {1: 'one', 2: 'two'}
dict_2 = {3: 'three'}
dict_1 | dict_2

Traceback (most recent call last):
 File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'dict' and 'dict'




The best that I can come up with is -

dict([(k, v) for k, v in dict_1.items()] + [(k, v) for k, v in 
dict_2.items()])

{1: 'one', 2: 'two', 3: 'three'}




So I have 2 questions -

1. Is there any particular reason why '|' is not supported?

2. Is there a better way to do what I want?

Thanks

Frank Millman


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


Re: Help on PyImport_Import(pNAme)

2018-02-04 Thread dieter
Jason Qian via Python-list  writes:

>   This only works when loading  modules from the current directory.
>   Is there a way I can load from somewhere else ?

Have a look at the module `importlib` and especially its function
`import_module`.

Python knows about two forms of "import": "absolute import"
and "relative import".
An "absolute import" tries (in the usual case) to import from a list
of directories, maintained in "sys.path"; a "relative import"
(recognized via the module name starting with a .") relative to
a package.

Section 31.5.6.3 of
"https://docs.python.org/3/library/importlib.html#module-importlib.util";
tells you how to import a source file directly (independent from
any context).

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