Re: Python 2.7 range Function provokes a Memory Error

2023-03-06 Thread Stephen Tucker
Hi again,

I tried xrange, but I got an error telling me that my integer was too big
for a C long.

Clearly, xrange in Py2 is not capable of dealing with Python (that is,
possibly very long) integers.

I am raising this because,

(a) IF xrange in Py3 is a simple "port" from Py2, then it won't handle
Python integers either.

AND

(b) IF xrange in Py3 is intended to be equivalent to range (which, even in
Py2, does handle Python integers)

THEN

It could be argued that xrange in Py3 needs some attention from the
developer(s).

Stephen Tucker.


On Thu, Mar 2, 2023 at 6:24 PM Jon Ribbens via Python-list <
python-list@python.org> wrote:

> On 2023-03-02, Stephen Tucker  wrote:
> > The range function in Python 2.7 (and yes, I know that it is now
> > superseded), provokes a Memory Error when asked to deiliver a very long
> > list of values.
> >
> > I assume that this is because the function produces a list which it then
> > iterates through.
> >
> > 1. Does the  range  function in Python 3.x behave the same way?
>
> No, in Python 3 it is an iterator which produces the next number in the
> sequence each time.
>
> > 2. Is there any equivalent way that behaves more like a  for loop (that
> is,
> > without producing a list)?
>
> Yes, 'xrange' in Python 2 behaves like 'range' in Python 3.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread Stephen Tucker
Hi,

The range function in Python 2.7 (and yes, I know that it is now
superseded), provokes a Memory Error when asked to deiliver a very long
list of values.

I assume that this is because the function produces a list which it then
iterates through.

1. Does the  range  function in Python 3.x behave the same way?

2. Is there any equivalent way that behaves more like a  for loop (that is,
without producing a list)?

To get round the problem I have written my own software that is used in a
for  loop.

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


Re: Precision Tail-off?

2023-02-17 Thread Stephen Tucker
As a follow-up to my previous message, I have just produced the following
log on IDLE, for your information:
--
>>> math.e ** (math.log
(12345678900) / 3)
4.979338592181741e+16
>>> 10 ** (math.log10 (12345678900)
/ 3)
4.979338592181736e+16
>>> 12345678900 ** (1.0 / 3.0)
4.979338592181734e+16
>>> 123456789e42 ** (1.0 / 3.0)
4.979338592181734e+16
------

Stephen Tucker.


On Fri, Feb 17, 2023 at 10:27 AM Stephen Tucker 
wrote:

> Thanks, one and all, for your reponses.
>
> This is a hugely controversial claim, I know, but I would consider this
> behaviour to be a serious deficiency in the IEEE standard.
>
> Consider an integer N consisting of a finitely-long string of digits in
> base 10.
>
> Consider the infinitely-precise cube root of N (yes I know that it could
> never be computed unless N is the cube of an integer, but this is a
> mathematical argument, not a computational one), also in base 10. Let's
> call it RootN.
>
> Now consider appending three zeroes to the right-hand end of N (let's call
> it NZZZ) and NZZZ's infinitely-precise cube root (RootNZZZ).
>
> The *only *difference between RootN and RootNZZZ is that the decimal
> point in RootNZZZ is one place further to the right than the decimal point
> in RootN.
>
> None of the digits in RootNZZZ's string should be different from the
> corresponding digits in RootN.
>
> I rest my case.
>
> Perhaps this observation should be brought to the attention of the IEEE. I
> would like to know their response to it.
>
> Stephen Tucker.
>
>
> On Thu, Feb 16, 2023 at 6:49 PM Peter Pearson 
> wrote:
>
>> On Tue, 14 Feb 2023 11:17:20 +, Oscar Benjamin wrote:
>> > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker 
>> wrote:
>> [snip]
>> >> I have just produced the following log in IDLE (admittedly, in Python
>> >> 2.7.10 and, yes I know that it has been superseded).
>> >>
>> >> It appears to show a precision tail-off as the supplied float gets
>> bigger.
>> [snip]
>> >>
>> >> For your information, the first 20 significant figures of the cube
>> root in
>> >> question are:
>> >>49793385921817447440
>> >>
>> >> Stephen Tucker.
>> >> --
>> >> >>> 123.456789 ** (1.0 / 3.0)
>> >> 4.979338592181744
>> >> >>> 1234567890. ** (1.0 / 3.0)
>> >> 49793385921817.36
>> >
>> > You need to be aware that 1.0/3.0 is a float that is not exactly equal
>> > to 1/3 ...
>> [snip]
>> > SymPy again:
>> >
>> > In [37]: a, x = symbols('a, x')
>> >
>> > In [38]: print(series(a**x, x, Rational(1, 3), 2))
>> > a**(1/3) + a**(1/3)*(x - 1/3)*log(a) + O((x - 1/3)**2, (x, 1/3))
>> >
>> > You can see that the leading relative error term from x being not
>> > quite equal to 1/3 is proportional to the log of the base. You should
>> > expect this difference to grow approximately linearly as you keep
>> > adding more zeros in the base.
>>
>> Marvelous.  Thank you.
>>
>>
>> --
>> To email me, substitute nowhere->runbox, invalid->com.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Precision Tail-off?

2023-02-17 Thread Stephen Tucker
Thanks, one and all, for your reponses.

This is a hugely controversial claim, I know, but I would consider this
behaviour to be a serious deficiency in the IEEE standard.

Consider an integer N consisting of a finitely-long string of digits in
base 10.

Consider the infinitely-precise cube root of N (yes I know that it could
never be computed unless N is the cube of an integer, but this is a
mathematical argument, not a computational one), also in base 10. Let's
call it RootN.

Now consider appending three zeroes to the right-hand end of N (let's call
it NZZZ) and NZZZ's infinitely-precise cube root (RootNZZZ).

The *only *difference between RootN and RootNZZZ is that the decimal point
in RootNZZZ is one place further to the right than the decimal point in
RootN.

None of the digits in RootNZZZ's string should be different from the
corresponding digits in RootN.

I rest my case.

Perhaps this observation should be brought to the attention of the IEEE. I
would like to know their response to it.

Stephen Tucker.


On Thu, Feb 16, 2023 at 6:49 PM Peter Pearson 
wrote:

> On Tue, 14 Feb 2023 11:17:20 +, Oscar Benjamin wrote:
> > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker 
> wrote:
> [snip]
> >> I have just produced the following log in IDLE (admittedly, in Python
> >> 2.7.10 and, yes I know that it has been superseded).
> >>
> >> It appears to show a precision tail-off as the supplied float gets
> bigger.
> [snip]
> >>
> >> For your information, the first 20 significant figures of the cube root
> in
> >> question are:
> >>49793385921817447440
> >>
> >> Stephen Tucker.
> >> --
> >> >>> 123.456789 ** (1.0 / 3.0)
> >> 4.979338592181744
> >> >>> 1234567890. ** (1.0 / 3.0)
> >> 49793385921817.36
> >
> > You need to be aware that 1.0/3.0 is a float that is not exactly equal
> > to 1/3 ...
> [snip]
> > SymPy again:
> >
> > In [37]: a, x = symbols('a, x')
> >
> > In [38]: print(series(a**x, x, Rational(1, 3), 2))
> > a**(1/3) + a**(1/3)*(x - 1/3)*log(a) + O((x - 1/3)**2, (x, 1/3))
> >
> > You can see that the leading relative error term from x being not
> > quite equal to 1/3 is proportional to the log of the base. You should
> > expect this difference to grow approximately linearly as you keep
> > adding more zeros in the base.
>
> Marvelous.  Thank you.
>
>
> --
> To email me, substitute nowhere->runbox, invalid->com.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Precision Tail-off?

2023-02-13 Thread Stephen Tucker
Hi,

I have just produced the following log in IDLE (admittedly, in Python
2.7.10 and, yes I know that it has been superseded).

It appears to show a precision tail-off as the supplied float gets bigger.

I have two questions:
1. Is there a straightforward explanation for this or is it a bug?
2. Is the same behaviour exhibited in Python 3.x?

For your information, the first 20 significant figures of the cube root in
question are:
   49793385921817447440

Stephen Tucker.
--
>>> 123.456789 ** (1.0 / 3.0)
4.979338592181744
>>> 123456.789 ** (1.0 / 3.0)
49.79338592181744
>>> 123456789. ** (1.0 / 3.0)
497.9338592181743
>>> 123456789000. ** (1.0 / 3.0)
4979.338592181743
>>> 12345678900. ** (1.0 / 3.0)
49793.38592181742
>>> 1234567890. ** (1.0 / 3.0)
497933.8592181741
>>> 123456789. ** (1.0 / 3.0)
4979338.59218174
>>> 123456789000. ** (1.0 / 3.0)
49793385.9218174
>>> 12345678900. ** (1.0 / 3.0)
497933859.2181739
>>> 1234567890. ** (1.0 / 3.0)
4979338592.181739
>>> 123456789. ** (1.0 / 3.0)
49793385921.81738
>>> 123456789000. ** (1.0 / 3.0)
497933859218.1737
>>> 12345678900. ** (1.0 / 3.0)
4979338592181.736
>>> 1234567890. ** (1.0 / 3.0)
49793385921817.36
>>> 123456789. ** (1.0 / 3.0)
497933859218173.56
>>> 123456789000. ** (1.0 / 3.0)
4979338592181735.0
>>> 12345678900. ** (1.0 / 3.0)
4.979338592181734e+16
>>> 1234567890. ** (1.0 / 3.0)
4.979338592181734e+17
>>> 123456789. ** (1.0 /
3.0)
4.979338592181733e+18
>>> 123456789000. ** (1.0 /
3.0)
4.979338592181732e+19
>>> 12345678900. **
(1.0 / 3.0)
4.9793385921817313e+20
--
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: IDLE "Codepage" Switching?

2023-01-18 Thread Stephen Tucker
Thanks for these responses.

I was encouraged to read that I'm not the only one to find this all
confusing.

I have investigated a little further.

1. I produced the following IDLE log:

>>> mylongstr = ""
>>> for thisCP in range (1, 256):
mylongstr += chr (thisCP) + " " + str (ord (chr (thisCP))) + ", "


>>> print mylongstr
1, 2, 3, 4, 5, 6, 7, 8, 9,
 10, 11, 12,
 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31,   32, ! 33, " 34, # 35, $ 36, % 37, & 38, ' 39, ( 40, ) 41, * 42, + 43,
, 44, - 45, . 46, / 47, 0 48, 1 49, 2 50, 3 51, 4 52, 5 53, 6 54, 7 55, 8
56, 9 57, : 58, ; 59, < 60, = 61, > 62, ? 63, @ 64, A 65, B 66, C 67, D 68,
E 69, F 70, G 71, H 72, I 73, J 74, K 75, L 76, M 77, N 78, O 79, P 80, Q
81, R 82, S 83, T 84, U 85, V 86, W 87, X 88, Y 89, Z 90, [ 91, \ 92, ] 93,
^ 94, _ 95, ` 96, a 97, b 98, c 99, d 100, e 101, f 102, g 103, h 104, i
105, j 106, k 107, l 108, m 109, n 110, o 111, p 112, q 113, r 114, s 115,
t 116, u 117, v 118, w 119, x 120, y 121, z 122, { 123, | 124, } 125, ~
126, 127, タ 128, チ 129, ツ 130, テ 131, ト 132, ナ 133, ニ 134, ヌ 135, ネ 136, ノ
137, ハ 138, ヒ 139, フ 140, ヘ 141, ホ 142, マ 143, ミ 144, ム 145, メ 146, モ 147,
ヤ 148, ユ 149, ヨ 150, ラ 151, リ 152, ル 153, レ 154, ロ 155, ワ 156, ン 157, ゙
158, ゚ 159, ᅠ 160, ᄀ 161, ᄁ 162, ᆪ 163, ᄂ 164, ᆬ 165, ᆭ 166, ᄃ 167, ᄄ 168,
ᄅ 169, ᆰ 170, ᆱ 171, ᆲ 172, ᆳ 173, ᆴ 174, ᆵ 175, ᄚ 176, ᄆ 177, ᄇ 178, ᄈ
179, ᄡ 180, ᄉ 181, ᄊ 182, ᄋ 183, ᄌ 184, ᄍ 185, ᄎ 186, ᄏ 187, ᄐ 188, ᄑ 189,
ᄒ 190, ﾿ 191, À 192, Á 193, Â 194, Ã 195, Ä 196, Å 197, Æ 198, Ç 199, È
200, É 201, Ê 202, Ë 203, Ì 204, Í 205, Î 206, Ï 207, Ð 208, Ñ 209, Ò 210,
Ó 211, Ô 212, Õ 213, Ö 214, × 215, Ø 216, Ù 217, Ú 218, Û 219, Ü 220, Ý
221, Þ 222, ß 223, à 224, á 225, â 226, ã 227, ä 228, å 229, æ 230, ç 231,
è 232, é 233, ê 234, ë 235, ì 236, í 237, î 238, ï 239, ð 240, ñ 241, ò
242, ó 243, ô 244, õ 245, ö 246, ÷ 247, ø 248, ù 249, ú 250, û 251, ü 252,
ý 253, þ 254, ÿ 255,
>>>

2. I copied and pasted the IDLE log into a text file and ran a program on
it that told me about every byte in the log.

3. I discovered the following:

Bytes 001 to 127 (01 to 7F hex) inclusive were printed as-is;

Bytes 128 to 191 (80 to BF) inclusive were output as UTF-8-encoded
characters whose codepoints were FF00 hex more than the byte values (hence
the strange glyphs);

Bytes 192 to 255 (C0 to FF) inclusive were output as UTF-8-encoded
characters - without any offset being added to their codepoints in the
meantime!

I thought you might just be interested in this - there does seem to be some
method in IDLE's mind, at least.

Stephen Tucker.








On Wed, Jan 18, 2023 at 9:41 AM Peter J. Holzer  wrote:

> On 2023-01-17 22:58:53 -0500, Thomas Passin wrote:
> > On 1/17/2023 8:46 PM, rbowman wrote:
> > > On Tue, 17 Jan 2023 12:47:29 +, Stephen Tucker wrote:
> > > > 2. Does the IDLE in Python 3.x behave the same way?
> > >
> > > fwiw
> > >
> > > Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
> > > Type "help", "copyright", "credits" or "license()" for more
> information.
> > > str = ""
> > > for c in range(140, 169):
> > >  str += chr(c) + " "
> > >
> > > print(str)
> > > Œ   Ž ‘ ’ “ ” • – — ˜ ™ š › œ   ž Ÿ   ¡ ¢ £ ¤ ¥
> > > ¦ § ¨
> > >
> > >
> > > I don't know how this will appear since Pan is showing the icon for a
> > > character not in its set.  However, even with more undefined characters
> > > the printable one do not change. I get the same output running Python3
> > > from the terminal so it's not an IDLE thing.
> >
> > I'm not sure what explanation is being asked for here.  Let's take
> Python3,
> > so we can be sure that the strings are in unicode.  The font being used
> by
> > the console isn't mentioned, but there's no reason it should have glyphs
> for
> > any random unicode character.
>
> Also note that the characters between 128 (U+0080) and 159 (U+009F)
> inclusive aren't printable characters. They are control characters.
>
> hp
>
> --
>_  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


IDLE "Codepage" Switching?

2023-01-17 Thread Stephen Tucker
I have four questions.

1. Can anybody explain the behaviour in IDLE (Python version 2.7.10)
reported below? (It seems that the way it renders a given sequence of bytes
depends on the sequence.)

2. Does the IDLE in Python 3.x behave the same way?

3. If it does, is this as it should behave?

4. If it is, then why is it as it should behave?
==
>>> mylongstr = ""
>>> for thisCP in range (157, 169):
mylongstr += chr (thisCP) + " "


>>> print mylongstr
ン ゙ ゚ ᅠ ᄀ ᄁ ᆪ ᄂ ᆬ ᆭ ᄃ ᄄ
>>> mylongstr = ""
>>> for thisCP in range (158, 169):
mylongstr += chr (thisCP) + " "


>>> print mylongstr
ž Ÿ   ¡ ¢ £ ¤ ¥ ¦ § ¨
>>> mylongstr = ""
>>> for thisCP in range (157, 169):
    mylongstr += chr (thisCP) + " "


>>> print mylongstr
ン ゙ ゚ ᅠ ᄀ ᄁ ᆪ ᄂ ᆬ ᆭ ᄃ ᄄ
==

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


Re: file.read Method Documentation (Python 2.7.10)

2023-01-12 Thread Stephen Tucker
Chris,

Thanks for this clarification.

I have not found documentation that disagrees with you. I simply observe
that the documentation that I have alluded to earlier in this chain
(section 5.9 File Objects) could have been made clearer by the addition of
a note along the lines that the behaviour of a file's read method (in
particular, what the unit of information is that it reads (that is, "byte",
"UTF-8 encoded character", or whatever)) depends on the way in which the
file has been opened.

Thank you, Chris (and others) for your attention to my request. I consider
this enquiry closed.

Stephen.




On Wed, Jan 11, 2023 at 5:36 PM Chris Angelico  wrote:

> On Thu, 12 Jan 2023 at 04:31, Stephen Tucker 
> wrote:
> > 1. Create BOM.txt
> > 2. Input three bytes at once from BOM.txt and print them
> > 3. Input three bytes one at a time from BOM.txt and print them
>
> All of these correctly show that a file, in binary mode, reads and writes
> bytes.
>
> > 4. Input three bytes at once from BOM.txt and print them
> > >>> import codecs
> > >>> myfil = codecs.open ("BOM.txt", mode="rb", encoding="UTF-8")
>
> This is now a codecs file, NOT a vanilla file object. See its docs here:
>
> https://docs.python.org/2.7/library/codecs.html#codecs.open
>
> The output is "codec-dependent" but I would assume that UTF-8 will
> yield Unicode text strings.
>
> > 5. Attempt to input three bytes one at a time from BOM.txt and print them
> > -
> >
> > >>> myfil = codecs.open ("BOM.txt", mode="rb", encoding="UTF-8")
> > >>> myBOM_4 = myfil.read (1)
> > >>> myBOM_4
> > u'\ufeff'
>
> > A. The attempt at Part 5 actually inputs all three bytes when we ask it
> to input just the first one!
>
> On the contrary; you asked it for one *character* and it read one
> character.
>
> Where were you seeing documentation that disagreed with this?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: file.read Method Documentation (Python 2.7.10)

2023-01-11 Thread Stephen Tucker
Chris,

Thanks for your reply.

I hope the evidence below (taken from IDLE) clarifies my issue:

Stephen.

==


1. Create BOM.txt
-

>>> myfil = open ("BOM.txt", "wb")
>>> myfil.write ("\xef" + "\xbb" + "\xbf")
>>> myfil.close()

2. Input three bytes at once from BOM.txt and print them


>>> myfil = open ("BOM.txt", "rb")
>>> myBOM = myfil.read (3)
>>> myBOM
'\xef\xbb\xbf'
>>> myfil.close()

3. Input three bytes one at a time from BOM.txt and print them
--

>>> myfil = open ("BOM.txt", "rb")
>>> myBOM_1 = myfil.read (1)
>>> myBOM_2 = myfil.read (1)
>>> myBOM_3 = myfil.read (1)
>>> myBOM_1
'\xef'
>>> myBOM_2
'\xbb'
>>> myBOM_3
'\xbf'
>>> myfil.close()

4. Input three bytes at once from BOM.txt and print them


>>> import codecs
>>> myfil = codecs.open ("BOM.txt", mode="rb", encoding="UTF-8")
>>> myBOM = unicode (myfil.read (3))
>>> myBOM
u'\ufeff'
>>> myfil.close ()

5. Attempt to input three bytes one at a time from BOM.txt and print them
-

>>> myfil = codecs.open ("BOM.txt", mode="rb", encoding="UTF-8")
>>> myBOM_4 = myfil.read (1)
>>> myBOM_5 = myfil.read (1)
>>> myBOM_6 = myfil.read (1)
>>> myBOM_4
u'\ufeff'
>>> myBOM_5
u''
>>> myBOM_6
u''
>>> myfil.close()

Notes

A. The attempt at Part 5 actually inputs all three bytes when we ask it to
input just the first one!

B. The outcome from Part 5 shows that, actually, the request to input text
in Part 4 brought about a response from the program something like this:

   Input the UTF-8-encoded character as the first "byte";
   As expected, after reaching the end of the file, continue supplying an
empty string for each of the requested extra bytes.

==


On Wed, Jan 11, 2023 at 11:00 AM Chris Angelico  wrote:

> On Wed, 11 Jan 2023 at 21:31, Stephen Tucker 
> wrote:
> >
> > Chris -
> >
> > In the Python 2.7.10 documentation, I am referring to section 5.
> Built-in Types, subsection 5.9 File Objects.
> >
> > In that subsection, I have the following paragraph:
> >
> > file.read([size])
> >
> > Read at most size bytes from the file (less if the read hits EOF before
> obtaining size bytes). If the size argument is negative or omitted, read
> all data until EOF is reached. The bytes are returned as a string object.
> An empty string is returned when EOF is encountered immediately. (For
> certain files, like ttys, it makes sense to continue reading after an EOF
> is hit.) Note that this method may call the underlying C function fread()
> more than once in an effort to acquire as close to size bytes as possible.
> Also note that when in non-blocking mode, less data than was requested may
> be returned, even if no size parameter was given.
> >
>
> Yes, so it should be that number of bytes, which is what it does, isn't it?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: file.read Method Documentation (Python 2.7.10)

2023-01-11 Thread Stephen Tucker
Chris -

In the Python 2.7.10 documentation, I am referring to section 5. Built-in
Types, subsection 5.9 File Objects.

In that subsection, I have the following paragraph:

file.read([*size*])

Read at most *size* bytes from the file (less if the read hits EOF before
obtaining *size* bytes). If the *size* argument is negative or omitted,
read all data until EOF is reached. The bytes are returned as a string
object. An empty string is returned when EOF is encountered immediately.
(For certain files, like ttys, it makes sense to continue reading after an
EOF is hit.) Note that this method may call the underlying C function
fread() more than once in an effort to acquire as close to *size* bytes as
possible. Also note that when in non-blocking mode, less data than was
requested may be returned, even if no *size* parameter was given.

Note

This function is simply a wrapper for the underlying fread() C function,
and will behave the same in corner cases, such as whether the EOF value is
cached.
Stephen.

On Mon, Jan 9, 2023 at 6:25 PM Chris Angelico  wrote:

> On Tue, 10 Jan 2023 at 01:36, Stephen Tucker 
> wrote:
> >
> > Dear Python-list,
> >
> > Yes, I know that Python 2.x is no longer supported.
> >
> > I have found that the documentation for this method is misleading when
> the
> > file being read is UTF-8-encoded:
> >
> >Instead of reading *size* bytes, the method reads *size *UTF-8 byte
> > *sequences*.
> >
> > Has this error been corrected in the Python 3.x documentation?
> >
>
> What documentation is this? The builtin 'file' type doesn't know
> anything about encodings, and only ever returns bytes.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


file.read Method Documentation (Python 2.7.10)

2023-01-09 Thread Stephen Tucker
Dear Python-list,

Yes, I know that Python 2.x is no longer supported.

I have found that the documentation for this method is misleading when the
file being read is UTF-8-encoded:

   Instead of reading *size* bytes, the method reads *size *UTF-8 byte
*sequences*.

Has this error been corrected in the Python 3.x documentation?

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


Are these good ideas?

2022-11-14 Thread Stephen Tucker
Hi,

I have two related issues I'd like comments on.

Issue 1 - Global Values

Some years ago, I had a situation where
(a) I could supply low-level functions that carry out tasks,
(b) I needed those functions to communicate with each other, but
(c) I had no access to the module that invoked my functions.

In order to achieve this, I hit on the idea that I also supply a module
that I describe as a "global values" module. This module …
(i) … defines the values that the functions use to communicate with each
other;
(ii) … is the subject of an import statement in each of my functions;
(iii) … initialises its values at the start of each run (since the import
only carries out an actual import once per session);
(iv) … acts as a repository for the values thereafter.

This solution works well.

Given that I am not particularly concerned about efficiency,
(1) Is this a reasonable way to achieve this goal?
(2) Do you know of any better ways?

Issue 2 - Passed Parameters

I am now facing another situation where I am wanting to pass 6 or 7
parameters down through several layers of logic (function A calling
function B calling ... ) and for results to be passed back.

Having had the idea described above, I am considering using it again to
save all the parameter-and-results passing.

I see nothing wrong with doing that, but I may well be missing something!

Comments, please!

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


Re: on GNU EMACS's python-mode, loading entire buffer

2022-09-29 Thread Stephen Berman
On Sun, 04 Sep 2022 16:47:07 -0300 Meredith Montgomery  
wrote:

> Meredith Montgomery  writes:
>
>> Meredith Montgomery  writes:
>>
>> [...]
>>
>>> I would also be interested in a command that restarts the REPL afresh
>>> and reloads my buffer --- sort of like keyboard's [F5] of the IDLE.
>>
>> A partial solution for this is the following procedure.
>>
>> (defun python-revert-and-send-buffer-to-repl ()
>>   "Revert current buffer and sends it to the Python REPL."
>>   (interactive)
>>   (revert-buffer "ignore-auto-no" "no-confirm")
>>   (python-shell-send-buffer))
>>
>> We can map this to the F5-key and that improves things.  But a restart
>> of the REPL would be the ideal.  (Sometimes we really want to start
>> afresh.  Sometimes.  Most often we don't want that.)
>
> It's not easy to restart the REPL.  You can send "quit()" to it and
> invoke run-python again interactively by typing out one command after
> another, but if you write a procedure such as this one below, it doesn't
> work: it gives me the impression that there's a timing issue, that is,
> perhaps the procedure is too fast and something happens before it
> should.
>
> (defun python-save-send-buffer-to-repl ()
>   (interactive)
>   (save-buffer)
>   (python-shell-send-string "quit()")
>   (run-python)
>   (python-shell-send-buffer)
>   (python-shell-switch-to-shell))

It does seem like a timing issue.  This works for me:

(defun python-save-send-buffer-to-repl ()
  (interactive)
  (save-buffer)
  (python-shell-send-string "quit()")
  (sit-for 0.1)
  (run-python)
  (python-shell-send-buffer)
  (python-shell-switch-to-shell))

But if I decrease the wait to 0.05 it doesn't work.

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


Discerning "Run Environment"

2022-05-18 Thread Stephen Tucker
Hi,

I am a Windows 10 user still using Python 2.x (for good reasons, I assure
you.)

I have a Python 2.x module that I would like to be able to use in a variety
of Python 2.x programs. The module outputs characters to the user that are
only available in the Unicode character set.

I have found that the selection of characters in that set that are
available to my software depends on whether, for example, the program is
being run during an IDLE session or at a Command Prompt.

I am therefore needing to include logic in this module that (a) enables it
to output appropriate characters depending on whether it is being run
during an IDLE session or at a command prompt, and (b) enables it to
discern which of these two "run environments" it is running in.

Goal (a) is achieved easily by using string.replace to replace unavailable
characters with available ones where necessary.

The best way I have found so far to achieve goal (b) is to use sys.modules
and ascertain whether any modules contain the string "idlelib". If they do,
that I assume that the software is being run in an IDLE session.

I suspect that there is a more Pythonic (and reliable?) way of achieving
goal (b).

Can anyone please tell me if there is, and, if there is, what it is?

Thanks.

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


Re: Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
To Cameron Simpson,

Thanks for your in-depth and helpful reply. I have noted it and will be
giving it close attention when I can.

The main reason why I am still using Python 2.x is that my colleagues are
still using a GIS system that has a Python programmer's interface - and
that interface uses Python 2.x.

The team are moving to an updated version of the system whose Python
interface is Python 3.x.

However, I am expecting to retire over the next 8 months or so, so I do not
need to be concerned with Python 3.x - my successor will be doing that.

Stephen.


On Thu, Apr 28, 2022 at 2:07 PM Cameron Simpson  wrote:

> On 28Apr2022 12:32, Stephen Tucker  wrote:
> >Consider the following log from a run of IDLE:
> >==
> >
> >Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
> >on win32
> >Type "copyright", "credits" or "license()" for more information.
> >>>> print (u"\u2551")
> >║
> >>>> print ([u"\u2551"])
> >[u'\u2551']
> >>>>
> >==
> >
> >Yes, I am still using Python 2.x - I have good reasons for doing so and
> >will be moving to Python 3.x in due course.
>
> Love to hear those reasons. Not suggesting that they are invalid.
>
> >I have the following questions arising from the log:
> >1. Why does the second print statement not produce [ ║]  or ["║"] ?
>
> Because print() prints the str() or each of its arguments, and str() of
> a list if the same as its repr(), which is a list of the repr()s of
> every item in the list. Repr of a Unicode string looks like what you
> have in Python 2.
>
> >2. Should the second print statement produce [ ║]  or ["║"] ?
>
> Well, to me its behaviour is correct. Do you _want_ to get your Unicode
> glyph? in quotes? That is up to you. But consider: what would be sane
> output if the list contained the string "], [3," ?
>
> >3. Given that I want to print a list of Unicode strings so that their
> >characters are displayed (instead of their Unicode codepoint definitions),
> >is there a more Pythonic way of doing it than concatenating them into a
> >single string and printing that?
>
> You could print them with empty separators:
>
> print(s1, s2, .., sep='')
>
> To do that in Python 2 you need to:
>
> from __future__ import print_function
>
> at the top of your Python file. Then you've have a Python 3 string print
> function. In Python 2, pint is normally a statement and you don't need
> the brackets:
>
> print u"\u2551"
>
> but print() is genuinely better as a function anyway.
>
> >4. Does Python 3.x exhibit the same behaviour as Python 2.x in this
> respect?
>
> Broadly yes, except that all strings are Unicode strings and we don't
> bothing with the leading "u" prefix.
>
> Cheers,
> Cameron Simpson 
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
Hi PythonList Members,

Consider the following log from a run of IDLE:

==

Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
>>> print (u"\u2551")
║
>>> print ([u"\u2551"])
[u'\u2551']
>>>

==

Yes, I am still using Python 2.x - I have good reasons for doing so and
will be moving to Python 3.x in due course.

I have the following questions arising from the log:

1. Why does the second print statement not produce [ ║]  or ["║"] ?

2. Should the second print statement produce [ ║]  or ["║"] ?

3. Given that I want to print a list of Unicode strings so that their
characters are displayed (instead of their Unicode codepoint definitions),
is there a more Pythonic way of doing it than concatenating them into a
single string and printing that?

4. Does Python 3.x exhibit the same behaviour as Python 2.x in this respect?

Thanks in anticipation.

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


[issue28080] Allow reading member names with bogus encodings in zipfile

2022-03-23 Thread Stephen J. Turnbull


Stephen J. Turnbull  added the comment:

I'm not going to have time to look at the PR for a couple days.

I don't understand what the use case is for writing or appending with filenames 
in a non-UTF-8 encoding.  At least in my experience, reading such files is 
rare, but I have never been asked to write one.  The correspondents who send me 
zipfiles with the directory encoded in shift_jisx0213 are perfectly happy to 
read zipfiles with the directory encoded in UTF-8.

If that is true for other users, then unzipping the file to a temporary 
directory with the appropriate --metadata-encoding, adding the required paths 
there, and zipping a new archive seems perfectly workable.  In that case making 
this feature read-only makes the most sense to me.

--

___
Python tracker 
<https://bugs.python.org/issue28080>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46734] Add Maildir.get_flags() to access message flags without opening the file

2022-02-12 Thread Stephen Gildea


Change by Stephen Gildea :


--
keywords: +patch
pull_requests: +29463
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31302

___
Python tracker 
<https://bugs.python.org/issue46734>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46734] Add Maildir.get_flags() to access message flags without opening the file

2022-02-12 Thread Stephen Gildea


New submission from Stephen Gildea :

A message's flags are stored in its filename by Maildir, so the flags
are available without reading the message file itself.  The structured
message file name makes it efficient to scan a large mailbox to select
only messages that are, for example, not Trashed.

The mailbox.Maildir interface does not expose these flags, however.  The
only way to access the flags through the mailbox library is to create a
mailbox.MaildirMessage object, which has a get_flags() method.  But
creating a MaildirMessage requires opening the message file, which is slow.

I propose adding a parallel get_flags(key) method to mailbox.Maildir,
so that the flags are available without having to create a
MaildirMessage object.

In iterating through a mailbox with thousands of messages, I find that
this proposed Maildir.get_flags() method is 50 times faster than
MaildirMessage.get_flags().

--
components: Library (Lib)
messages: 413145
nosy: gildea
priority: normal
severity: normal
status: open
title: Add Maildir.get_flags() to access message flags without opening the file
type: enhancement
versions: Python 3.11

___
Python tracker 
<https://bugs.python.org/issue46734>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Problem Installing Pipenv

2021-12-17 Thread Stephen P. Molnar
I have Python 3.9 installed in Windows 10 on my Laptop and have installed
pipenv v-2021.11.5. When I invoke the python shell command, it fails with
thee following errors:

 

 

C:\Users\SPM\Apps\Spyder-5.2.1>pipenv shell

Traceback (most recent call last):

  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main

return _run_code(code, main_globals, None,

  File "C:\Python39\lib\runpy.py", line 87, in _run_code

exec(code, run_globals)

  File "C:\Python39\Scripts\pipenv.exe\__main__.py", line 7, in 

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1137, in __call__

return self.main(*args, **kwargs)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1062, in main

rv = self.invoke(ctx)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1668, in invoke

return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1404, in invoke

return ctx.invoke(self.callback, **ctx.params)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
763, in invoke

return __callback(*args, **kwargs)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\decorators.py",
line 84, in new_func

return ctx.invoke(f, obj, *args, **kwargs)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
763, in invoke

return __callback(*args, **kwargs)

 File "C:\Python39\lib\site-packages\pipenv\cli\command.py", line 419, in
shell

do_shell(

  File "C:\Python39\lib\site-packages\pipenv\core.py", line 2309, in
do_shell

shell = choose_shell()

TypeError: choose_shell() missing 1 required positional argument: 'project'

 

Stephen P. Molnar, Ph.D.

(614)312-7528

Skype: smolnar1

 

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


[issue45356] Calling `help` executes @classmethod @property decorated methods

2021-12-01 Thread Stephen Rosen


Stephen Rosen  added the comment:

Probably >90% of the use-cases for chaining classmethod are a read-only class 
property.
It's important enough that some tools (e.g. sphinx) even have special-cased 
support for classmethod(property(...)).

Perhaps the general case of classmethod(descriptor(...)) should be treated 
separately from the common case?

> I propose deprecating classmethod chaining.  It has become clear that it 
> doesn't really do what people wanted and can't easily be made to work.

If classmethod(property(f)) is going to be removed, can an implementation of 
classproperty be considered as a replacement?

Or perhaps support via the other ordering, property(classmethod(f))?

--
nosy: +sirosen2

___
Python tracker 
<https://bugs.python.org/issue45356>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35228] Index search in CHM help crashes viewer

2021-10-13 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy: +Zero

___
Python tracker 
<https://bugs.python.org/issue35228>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Is there a better way to create a list of None objects?

2021-08-12 Thread Stephen Tucker
Thanks for this feedback, Chris, Matthieu. Both are spot on - and thanks
for the timing comparison, Matthieu. I suppose I didn't think to try the
solution you suggest because I didn't think that I would end up with a
single list, but 8 of them.

OK, I'll stop wriggling.

Stephen.

On Thu, Aug 12, 2021 at 10:22 AM Matthieu Dartiailh 
wrote:

> You can achieve the same result by writing:
> [None] * 8
>
> Comparing both cases in IPython I get:
>
> In [1]: %timeit list((None,)*8)
> 110 ns ± 0.785 ns per loop (mean ± std. dev. of 7 runs, 1000 loops
> each)
>
> In [2]: %timeit [None] * 8
> 88.2 ns ± 0.432 ns per loop (mean ± std. dev. of 7 runs, 1000 loops
> each)
>
> So the list multiplication appears a bit faster.
>
> Best
>
> Matthieu
>
> Le 8/12/2021 à 10:57 AM, Stephen Tucker a écrit :
> > Hi,
> >
> > I thought I'd share the following piece of code that I have recently
> written
> > (a) to check that what I have done is reasonable - even optimum,
> > (b) to inform others who might be wanting to do similar things, and
> > (c) to invite comment from the community.
> >
> > ---
> >
> > #
> >
> > # Yes: Create an empty list of Band Limits for this language
> >
> > #
> >
> > # Note. The rather complicated logic on the right-hand side of the
> >
> > #   assignment below is used here because none of the following
> >
> > #   alternatives had the desired effect:
> >
> > #
> >
> > # Logic Effect
> >
> > #
> >
> > # [None * 8]TypeError: unsupported operand type(s) for *: ...
> >
> > # [(None) * 8]  TypeError: unsupported operand type(s) for *: ...
> >
> > # [((None)) * 8]TypeError: unsupported operand type(s) for *: ...
> >
> > # [(None,) * 8] [(None, None, None, None, None, None, None, None)]
> >
> > # list ((None) * 8) TypeError: unsupported operand type(s) for *: ...
> >
> > #
> >
> > diclll_BLim [thisISO_] = list ((None,) * 8)
> >
> >
> > ---
> >
> > Thanks in anticipation.
> >
> > Stephen Tucker.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Is there a better way to create a list of None objects?

2021-08-12 Thread Stephen Tucker
Hi,

I thought I'd share the following piece of code that I have recently written
(a) to check that what I have done is reasonable - even optimum,
(b) to inform others who might be wanting to do similar things, and
(c) to invite comment from the community.

---

#

# Yes: Create an empty list of Band Limits for this language

#

# Note. The rather complicated logic on the right-hand side of the

#   assignment below is used here because none of the following

#   alternatives had the desired effect:

#

# Logic Effect

#

# [None * 8]TypeError: unsupported operand type(s) for *: ...

# [(None) * 8]  TypeError: unsupported operand type(s) for *: ...

# [((None)) * 8]TypeError: unsupported operand type(s) for *: ...

# [(None,) * 8] [(None, None, None, None, None, None, None, None)]

# list ((None) * 8) TypeError: unsupported operand type(s) for *: ...

#

diclll_BLim [thisISO_] = list ((None,) * 8)


---

Thanks in anticipation.

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


[issue30256] Adding a SyncManager Queue proxy to a SyncManager dict or Namespace proxy raises an exception

2021-08-03 Thread Stephen Carboni


Stephen Carboni  added the comment:

Just chiming in to say that this is still broken for me on Python 3.9.6, 
Win10/64: https://pastebin.com/64F2iKaj

But, works for 3.10.0b4.

--
nosy: +stephen.entropy

___
Python tracker 
<https://bugs.python.org/issue30256>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Trying to read from a text file to generate a graph

2021-07-29 Thread Stephen Berman
[Resending to the list only, since I couldn't post it without subscribing.]

On Wed, 28 Jul 2021 11:58:21 -0400 "Steve"  wrote:

> I forgot about the no-file rule...
>
>> On 28Jul2021 02:55, Steve  wrote:
>> I am going though a struggle with this and just don't see where it
>> fails.  I am using the Dual Bar Graph.py program from
>> https://matplotlib.org/stable/gallery/index.html website.  The file
>> from the web site works so that shows that all my installations are
>> complete.
>>
>> My program, LibreGraphics 05.py program runs but the graph is all
>> smutched up.  I am pulling data from the EXCEL-FILE.txt into the
>> program, selecting three values for each line and creating three
>> variables formatted as is shown in the original demo file.
>>
>> When you run the program, choose 112 when prompted. You will see the
>> values of the variables I want to pass to the graph section of the
>> code.  If the values are hardcoded, the graphs look good.  When the
>> variables generated by my section of the code, it does not.

The problem is due to the values of Sensors, TestStrips and SampleNumber
being strings; what you want is for them to be lists, as in the
assignments you commented out.  And since the data from the file is read
in as strings, you have to cast the elements of the Sensors and
TestStrips lists to integers, since you want the numerical values.  The
following code does the job:

Sensors = []
TestStrips = []
SampleNumber = []

x = 1
SensorNumber = input("Enter senaor number: ")
with open("_EXCEL-FILE.txt", 'r') as infile:
for lineEQN in infile:
if (lineEQN[0:1]== "."):
SN = lineEQN[44:48].strip()
if (SensorNumber == SN):
SN = x
SampleNumber.append(SN)

sv = lineEQN[25:29].strip()
Sensors.append(int(sv))

tv = lineEQN[32:37].strip()
TestStrips.append(int(tv))

x += 1

labels = SampleNumber

Add the rest of your code from the second half to make the desired bar
chart.

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


[issue43972] Simple HTTP Request Handler in http.server does not set a content-length and does not close connections on 301s

2021-05-06 Thread Stephen Rosen

Stephen Rosen  added the comment:

Thanks for working with me to reproduce and understand the issue. I'm a little 
surprised that with the sample which sets the protocol version you're still not 
seeing the issue.

If I create a directory tree, e.g.

repro
├── foo/
└── server.py

where `server.py` is the sample I gave, and run `server.py`, I find that `curl 
localhost:8000/foo` hangs. `curl -v` includes a message as part of its output 
which states that it's waiting for the connection to close.

Full verbose output:
```
$ curl localhost:8000/foo -v
*   Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /foo HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Server: SimpleHTTP/0.6 Python/3.8.5
< Date: Thu, 06 May 2021 15:53:13 GMT
< Location: /foo/
* no chunk, no close, no size. Assume close to signal end
<
^C
```


This holds over a few python versions: 3.6.12, 3.8.5, and 3.9.1 . That's 
probably a good enough sample since the relevant code hasn't changed in the 
stdlib.

It's doubtful that the exact version of curl matters for this. I can also see 
the issue with Firefox opening `localhost:8000/foo`. It hangs without 
processing the redirect.


Running the sample I gave, you're seeing curl exit cleanly? I wonder, with 
verbose output, maybe there's some useful message that will tell us why it's 
exiting. Does it not print the message, "no chunk, no close, no size. Assume 
close to signal end" ?


> Note: the existing behavior is 10+ year old and don't want to introduce 
> changes if it is not a bug.

I completely understand this stance. I believe it is a bug, but that it's rare 
enough that hasn't been filed or resolved, in spite of its age.

Some browsers (e.g. Chrome) process redirects without waiting for a payload, so 
they would mask the issue. Plus, it only shows up when the protocol_version is 
set.

I had a script at work with this issue for over a year without anyone running 
into the hangs. A coworker who prefers Firefox noticed the issue only recently, 
and I traced that back to this behavior.
So even in my case, I didn't stumble across this issue until we'd been using 
the same test script with the bug in it for a long time.

--

___
Python tracker 
<https://bugs.python.org/issue43972>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43972] Simple HTTP Request Handler in http.server does not set a content-length and does not close connections on 301s

2021-05-01 Thread Stephen Rosen


Stephen Rosen  added the comment:

Ach! Sorry! I didn't even realize this but the issue only arises when you are 
modifying the handler to set the protocol to HTTP/1.1 .

In HTTP/1.0 , there's no notion of persistent connections, so the issue does 
not arise.

But when the protocol version changes to 1.1 , persistent connections are the 
norm, and curl will wait indefinitely.

The following short script is sufficient to reproduce:
```
import http.server


class CustomRequestHandler(http.server.SimpleHTTPRequestHandler):
protocol_version = "HTTP/1.1"


with http.server.HTTPServer(("", 8000), CustomRequestHandler) as httpd:
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("\nKeyboard interrupt received, exiting.")
```

After double-checking the docs, the current doc for `protocol_version` [1] is 
quite clear about this:
"your server must then include an accurate Content-Length header (using 
send_header()) in all of its responses to clients"

I still think the fix I proposed is an improvement. Setting a Content-Length 
isn't forbidden in HTTP/1.0 , and it guarantees good behavior when HTTP/1.1 is 
used.

[1] 
https://docs.python.org/3/library/http.server.html#http.server.BaseHTTPRequestHandler.protocol_version

--

___
Python tracker 
<https://bugs.python.org/issue43972>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43972] Simple HTTP Request Handler in http.server does not set a content-length and does not close connections on 301s

2021-04-28 Thread Stephen Rosen


Change by Stephen Rosen :


--
keywords: +patch
pull_requests: +24395
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25705

___
Python tracker 
<https://bugs.python.org/issue43972>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43972] Simple HTTP Request Handler in http.server does not set a content-length and does not close connections on 301s

2021-04-28 Thread Stephen Rosen


New submission from Stephen Rosen :

If you use the `http.server` simple server and handler to serve a directory, 
navigating to a directory name without a trailing slash will trigger a 301 to 
add the trailing slash.

For example, if "foo/" is a directory under the file server, a GET for "/foo" 
will receive a 301 Moved Permanently response with a Location header pointing 
at "/foo/".

However, the response is sent without a "Content-Length: 0" and the connection 
is not closed. Unfortunately, certain clients will hang indefinitely and wait 
under these conditions, without processing the redirect. In my testing, curl 
7.68 and Firefox 87 both exhibted this behavior.

If a Content-Length header is set, these clients behave correctly.
For example, subclass the handler and add

def send_response(self, code):
super().send_response(code)
if code == HTTPStatus.MOVED_PERMANENTLY:
self.send_header("Content-Length", "0")

--
components: Library (Lib)
messages: 392272
nosy: sirosen
priority: normal
severity: normal
status: open
title: Simple HTTP Request Handler in http.server does not set a content-length 
and does not close connections on 301s
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue43972>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Are there Python modules that allow a program to write to the screen?

2021-04-26 Thread Stephen Tucker
Hi,

I have old software written in GWBASIC that I use to plot diagrams on the
screen.

In Windows 10, I have to resort to using the DOSBox emulator to run it.

I would dearly like to re-write it in Python - ideally Python 2.7.

What, if anything, is available?

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


[issue17519] unittest should not try to run abstract classes

2021-04-01 Thread Stephen Thorne


Stephen Thorne  added the comment:

I have done some experimentation here and thought through this feature request.

The concept we are trying to deliver is: "I would like to share functionality 
between test classes, by having an abstract parent, with concrete leaves"

The metaclass abc.ABCMeta provides functionality that means two things:

 - any class with this metaclass (so the class and all its subclasses, 
typically) that have @abc.abstractmethod or @abc.abstractproperty decorated 
methods will be treated as abstract
 - any class that is treated as abstract will raise an exception immediately, 
to make it clear to the programmer (and unit tests) that a programming error 
has occured.

Following this through, we end up with two ways in which this can go  wrong in 
unit testing if we ask our unit testing framework to not test abstract classes.

This is a complete example, with both failure modes illustrated:

Consider:

class AbstractTestCase(unittest.TestCase, metaclass=abc.ABCMeta):
  ...

class FooTest(AbstractTestCase):
  def foo(self):
return 1

In this case, AbstractTestCase will not be skipped: this is because without any 
abstract methods inside it: it's not actually considered 'abstract', and is a 
concrete class.

In the second case:

class AbstractTestCase(unittest.TestCase, metaclass=abc.ABCMeta):
  @abc.abstractmethod
  def foo(self):
...

  @abc.abstractmethod
   def bar(self):
...

class FooTest(AbstractTestCase):
  def foo(self):
return 1

In this case, because AbstractTestCase has 2 abstract methods, it will be 
skipped. No tests run. But also FooTest will be skipped because it has 1 
abstract method, and is therefore also abstract.

If this were a 'normal' program, we would see an exception raised when FooTest 
is instanciated, but because we're skipping tests in abstract classes, we skip 
all the tests and exit with success.

My gut feeling on this is that what we really want is a decorator that says: 
Skip this class, and only this class, explicitly. All subclasses are concrete, 
only this one is abstract.

--
nosy: +sthorne

___
Python tracker 
<https://bugs.python.org/issue17519>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42844] Turtle Module -- "onclick" arguments enchancement

2021-01-06 Thread Stephen


Change by Stephen :


--
keywords: +patch
pull_requests: +22972
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24143

___
Python tracker 
<https://bugs.python.org/issue42844>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42844] Turtle Module -- "onclick" arguments enchancement

2021-01-06 Thread Stephen

New submission from Stephen :

I have created an enhancement in the Turtle module. When a programmer wants to 
have an action performed after clicking on a Turtle object, the programmer is 
currently unable to supply any arguments into the method that is run when 
"on_clicked" which is extremely limiting, especially to beginners who are 
looking to modify multiple objects on the screen at one time, such as in a 
game. I have modified the implementation of the “on_clicked” method to be able 
to provide keyword arguments into the method through a dictionary that is later 
unpacked into the target method. Attached is an example of the benefits of this 
enhancement to the turtle module.

--
components: Library (Lib)
files: on_click_arguments_example.py
messages: 384513
nosy: sc1341
priority: normal
severity: normal
status: open
title: Turtle Module -- "onclick" arguments enchancement
type: enhancement
versions: Python 3.10
Added file: https://bugs.python.org/file49723/on_click_arguments_example.py

___
Python tracker 
<https://bugs.python.org/issue42844>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Simple question - end a raw string with a single backslash ?

2020-10-19 Thread Stephen Tucker
For a neatish way to get a string to end with a single backslash, how about
   mystr = r"abc\ "[:-1]
(Note the space at the end of the rough-quoted string.)



Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Oct 19, 2020 at 9:26 AM Antoon Pardon  wrote:

>
>
> Op 13/10/20 om 15:14 schreef Serhiy Storchaka:
> > 13.10.20 11:52, Tony Flury via Python-list пише:
> >> I am trying to write a simple expression to build a raw string that ends
> >> in a single backslash. My understanding is that a raw string should
> >> ignore attempts at escaping characters but I get this :
> >>
> >>  >>> a = r'end\'
> >>File "", line 1
> >>  a = r'end\'
> >>^
> >> SyntaxError: EOL while scanning string literal
> >>
> >> I interpret this as meaning that the \' is actually being interpreted as
> >> a literal quote - is that a bug ?
> >
> > r'You can\'t end raw string literal with a single "\"'
> >
> > If backslash be true inner in a raw string, the above literal would end
> > after \'. It would be very hard to write a raw string containing both \'
> > and \", and even \''' and \""" (there are such strings in the stdlib).
> >
> > So you have problem either with trailing backslash, or with inner
> > backslash followed by quotes. Both problems cannot be solved at the same
> > time. Python parser works as it works because initially it was easier to
> > implement, and now this cannot be changed because it would break some
> > amount of correct code.
>
> IMO the way python does this is broken.
>
>  >>> st=r'You can\'t end raw string literal with a single "\"'
>  >>> print(st)
>
> Now either the \ is special or it is not.
>
> 1) If it is special, it should change how the ' is treated but not
> appear itself.
>
> 2) If it is not special, it should just appear and not change how the '
> is treated.
>
> What python does here is a combination of both. The \ appears and it
> changes how the ' is treated. That is IMO broken.
>
> --
> Antoon Pardon.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue19500] ftplib: Add client-side SSL session resumption

2020-09-23 Thread Stephen Ash


Change by Stephen Ash :


--
nosy:  -Stephen Ash

___
Python tracker 
<https://bugs.python.org/issue19500>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Bulletproof json.dump?

2020-07-07 Thread Stephen Rosen
On Mon, Jul 6, 2020 at 6:37 AM Adam Funk  wrote:

> Is there a "bulletproof" version of json.dump somewhere that will
> convert bytes to str, any other iterables to list, etc., so you can
> just get your data into a file & keep working?
>

Is the data only being read by python programs? If so, consider using
pickle: https://docs.python.org/3/library/pickle.html
Unlike json dumping, the goal of pickle is to represent objects as exactly
as possible and *not* to be interoperable with other languages.


If you're using json to pass data between python and some other language,
you don't want to silently convert bytes to strings.
If you have a bytestring of utf-8 data, you want to utf-8 decode it before
passing it to json.dumps.
Likewise, if you have latin-1 data, you want to latin-1 decode it.
There is no universal and correct bytes-to-string conversion.

On Mon, Jul 6, 2020 at 9:45 AM Chris Angelico  wrote:

> Maybe what we need is to fork out the default JSON encoder into two,
> or have a "strict=True" or "strict=False" flag. In non-strict mode,
> round-tripping is not guaranteed, and various types will be folded to
> each other - mainly, many built-in and stdlib types will be
> represented in strings. In strict mode, compliance with the RFC is
> ensured (so ValueError will be raised on inf/nan), and everything
> should round-trip safely.
>

Wouldn't it be reasonable to represent this as an encoder which is provided
by `json`? i.e.

from json import dumps, UnsafeJSONEncoder
...
json.dumps(foo, cls=UnsafeJSONEncoder)

Emphasizing the "Unsafe" part of this and introducing people to the idea of
setting an encoder also seems nice.


On Mon, Jul 6, 2020 at 9:12 AM Chris Angelico  wrote:

> On Mon, Jul 6, 2020 at 11:06 PM Jon Ribbens via Python-list
>  wrote:
> >

> The 'json' module already fails to provide round-trip functionality:
> >
> > >>> for data in ({True: 1}, {1: 2}, (1, 2)):
> > ... if json.loads(json.dumps(data)) != data:
> > ... print('oops', data, json.loads(json.dumps(data)))
> > ...
> > oops {True: 1} {'true': 1}
> > oops {1: 2} {'1': 2}
> > oops (1, 2) [1, 2]
>
> There's a fundamental limitation of JSON in that it requires string
> keys, so this is an obvious transformation. I suppose you could call
> that one a bug too, but it's very useful and not too dangerous. (And
> then there's the tuple-to-list transformation, which I think probably
> shouldn't happen, although I don't think that's likely to cause issues
> either.)


Ideally, all of these bits of support for non-JSON types should be opt-in,
not opt-out.
But it's not worth making a breaking change to the stdlib over this.

Especially for new programmers, the notion that
deserialize(serialize(x)) != x
just seems like a recipe for subtle bugs.

You're never guaranteed that the deserialized object will match the
original, but shouldn't one of the goals of a de/serialization library be
to get it as close as is reasonable?


I've seen people do things which boil down to

json.loads(x)["some_id"] == UUID(...)

plenty of times. It's obviously wrong and the fix is easy, but isn't making
the default json encoder less strict just encouraging this type of bug?

Comparing JSON data against non-JSON types is part of the same category of
errors: conflating JSON with dictionaries.
It's very easy for people to make this mistake, especially since JSON
syntax is a subset of python dict syntax, so I don't think `json.dumps`
should be encouraging it.

On Tue, Jul 7, 2020 at 6:52 AM Adam Funk  wrote:

> Here's another "I'd expect to have to deal with this sort of thing in
> Java" example I just ran into:
>
> >>> r = requests.head(url, allow_redirects=True)
> >>> print(json.dumps(r.headers, indent=2))
> ...
> TypeError: Object of type CaseInsensitiveDict is not JSON serializable
> >>> print(json.dumps(dict(r.headers), indent=2))
> {
>   "Content-Type": "text/html; charset=utf-8",
>   "Server": "openresty",
> ...
> }
>

Why should the JSON encoder know about an arbitrary dict-like type?
It might implement Mapping, but there's no way for json.dumps to know that
in the general case (because not everything which implements Mapping
actually inherits from the Mapping ABC).
Converting it to a type which json.dumps understands is a reasonable
constraint.

Also, wouldn't it be fair, if your object is "case insensitive" to
serialize it as
  { "CONTENT-TYPE": ... } or { "content-type": ... } or ...
?

`r.headers["content-type"]` presumably gets a hit.
`json.loads(json.dumps(dict(r.headers)))["content-type"]` will get a
KeyError.

This seems very much out of scope for the json package because it's not
clear what it's supposed to do with this type.
Libraries should ask users to specify what they mean and not make
potentially harmful assumptions.

Best,
-Stephen
-- 
https://mail.python.org/mailman/listinfo/python-list


PEP 622

2020-07-02 Thread Stephen Carboni
Why are OR patterns going to use the bitwise operator instead of
logical or operator?

https://www.python.org/dev/peps/pep-0622/#combining-multiple-patterns-or-patterns

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


How to handle async and inheritance?

2020-06-30 Thread Stephen Rosen
Hi all,

I'm looking at a conflict between code sharing via inheritance and async
usage. I would greatly appreciate any guidance, ideas, or best practices
which might help.

I'll speak here in terms of a toy example, but, if anyone wants to look at
the real code, I'm working on webargs. [1] Specifically, we have a `Parser`
class and an `AsyncParser` subclass, and the two have a lot of code
duplication to handle async/await. [2]


I've got an inheritance structure like this:

class MyAbstractType: ...
class ConcreteType(MyAbstractType): ...
class AsyncConcreteType(MyAbstractType): ...

One of my goals, of course, is to share code between ConcreteType and
AsyncConcreteType via their parent.
But the trouble is that there are functions defined like this:

class MyAbstractType:
def foo(self):
x = self.bar()
y = self.baz(x)
... # some code here, let's say 20 lines

class AsyncConcreteType(MyAbstractType):
async def foo(self):
x = await self.bar()
y = self.baz(x)
... # the same 20 lines as above, but with an `await` added
every-other line


I'm aware that I'm looking at "function color" and that my scenario is
pitting two language features -- inheritance and async -- against one
another. But I don't see a clean way out if we want to support an
"async-aware" version of a class with synchronous methods.

What I tried already, which I couldn't get to work, was to either fiddle
with things like `inspect` to see if the current function is async or to
use a class variable to indicate that the current class is the async
version. The idea was to write something like

class MyAbstractType:
_use_async_calls = False
def foo(self):
x = self._await_if_i_am_async(self.bar)
y = self.baz(x)
...

and that way, the async subclass just needs to change signatures to be
async with little stubs and set the flag,

class AsyncConcreteType(MyAbstractType):
_use_async_calls = True
async def foo(self):
return super().foo()
async def bar(self):
return super().bar()

but this (some of you are ahead of me on this, I'm sure!) did not work at
all. I couldn't find any way to write `_await_if_i_am_async`, other than
possibly doing some weird things with `exec`.
Once I concluded that the python wouldn't let me decide whether or not to
use await at runtime, at least with tools of which I'm aware, I basically
gave up on that route.


However, it seems like there should be some clever technique for defining
`MyAbstractType.foo` such that it awaits on certain calls *if* there's some
indication that it should do so. It's obviously possible with `exec`, but I
don't want to convert all of the core codepaths into giant `exec` blocks.
Perhaps there's a way which is safer and more maintainable though?


If anyone has experience in this space and can offer up a good solution, I
would love to hear about it.
And if someone wants to go above-and-beyond and look at webargs, and
suggest a better way for us to support aiohttp, I'd obviously welcome that
kind of help as well!

Thanks in advance, and best regards,
-Stephen


[1] https://github.com/marshmallow-code/webargs
[2]
https://github.com/marshmallow-code/webargs/blob/6668d267fa4135cf3f653e422bd168298f2213a8/src/webargs/asyncparser.py#L24
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41092] Report actual size from 'os.path.getsize'

2020-06-23 Thread Stephen Finucane


Change by Stephen Finucane :


--
keywords: +patch
pull_requests: +20254
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21088

___
Python tracker 
<https://bugs.python.org/issue41092>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41092] Report actual size from 'os.path.getsize'

2020-06-23 Thread Stephen Finucane


New submission from Stephen Finucane :

The 'os.path.getsize' API returns the apparent size of the file at *path*, that 
is, the number of bytes the file reports itself as consuming. However, it's 
often useful to get the actual size of the file, or the size of file on disk. 
It would be helpful if one could get this same information from 
'os.path.getsize'.

--
components: Library (Lib)
messages: 372183
nosy: stephenfin
priority: normal
severity: normal
status: open
title: Report actual size from 'os.path.getsize'
type: enhancement
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue41092>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How to test?

2020-06-20 Thread Stephen Rosen
Worth noting: by assertTrue he probably meant assertEqual.
But I'd recommend using assertIn [1] if you're using unittest to check
output written to stdout/stderr.
That way, your tests are slightly more robust to changes in the exact
output.


pytest may also be helpful for this (or any!) type of testing.
Disclaimer/warning: pytest can be confusing even for experienced python
programmers because it does some fancy things.
But if you put in the time to learn it, it's very popular because of the
way it structures testsuites and code reuse (i.e. fixtures).

It can do a lot to help you, and provides output capturing out of the box
[2] as well as some handy tools for building temporary testing directories
[3].


[1]
https://docs.python.org/3.6/library/unittest.html#unittest.TestCase.assertIn
[2] https://docs.pytest.org/en/stable/capture.html
[3] https://docs.pytest.org/en/stable/tmpdir.html

On Fri, Jun 19, 2020 at 2:18 PM Terry Reedy  wrote:

> On 6/17/2020 12:34 PM, Tony Flury via Python-list wrote:
>
> > In a recent application that I wrote (where output to the console was
> > important), I tested it using the 'unittest' framework, and by patching
> > sys.stderr to be a StringIO - that way my test case could inspect what
> > was being output.
>
> Tony's code with hard returns added so that code lines remain separated
> instead of wrapping.
>
> with patch('sys.stderr', StringIO()) as stderr:
>application.do_stuff()  self.assertTrue(stderr.getvalue(),
>'Woops - that didn\'t work')
> This doc, worth reading more than once, is
> https://docs.python.org/3/library/unittest.mock.html#the-patchers
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue40932] subprocess docs don't qualify the instruction to use shlex.quote by OS

2020-06-09 Thread Stephen Farris


New submission from Stephen Farris :

The subprocess docs state: "When using shell=True, the shlex.quote() function 
can be used to properly escape whitespace and shell metacharacters in strings 
that are going to be used to construct shell commands." While this is true on 
Unix, it is not true on Windows. On Windows it is easy to create scenarios 
where shell injection still exists despite using shlex.quote properly (e.g. 
subprocess.run(shlex.quote("' '"), shell=True) launches the Windows 
calculator, which it wouldn't do if shlex.quote was able to prevent shell 
injection on Windows). While the shlex docs state that shlex is for Unix, the 
subprocess docs imply that shlex.quote will work on Windows too, possibly 
leading some developers to erroneously use shlex.quote on Windows to try to 
prevent shell injection. Recommend: 1) qualifying the above section in the 
subprocess docs to make it clear that this only works on Unix, and 2) updating 
the shlex docs with warnings that shlex.quote in particular is not for use on 
Window
 s.

--
assignee: docs@python
components: Documentation
messages: 371140
nosy: Stephen Farris, docs@python
priority: normal
severity: normal
status: open
title: subprocess docs don't qualify the instruction to use shlex.quote by OS
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue40932>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40932] subprocess docs don't qualify the instruction to use shlex.quote by OS

2020-06-09 Thread Stephen Farris


Change by Stephen Farris :


--
type:  -> security

___
Python tracker 
<https://bugs.python.org/issue40932>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39673] Map errno==ETIME to TimeoutError

2020-05-25 Thread Stephen J. Turnbull


Stephen J. Turnbull  added the comment:

First, let me say I like Giampaolo's TimeoutExpired *much* better as the name 
for this kind of exception!  But that ship has sailed.

I don't understand Giampaolo's comment.  If I understand the claim correctly, 
the problem is that people who should be catching some application-specific 
exception may be misled into catching TimeoutError instead, or into trying to 
get application-specific attributes from TimeoutError.  But that ship sailed 
with the creation of TimeoutError.  (We have a whole fleet sailing with this 
exception.)  Unless Giampaolo is proposing to deprecate TimeoutError?  I'm 
sympathetic ;-), but deprecation is a PITA and takes forever.

If we're not going to deprecate, it seems to me that it's much more 
developer-friendly to catch ETIME with TimeoutError, as that seems very likely 
to be the expected behavior.  It's true that even if Giampaolo changes 
TimeoutExpired to subclass TimeoutError, generic TimeoutError won't have 
.seconds.  But if you catch a TimeoutExpired with TimeoutError, that instance 
*will* have .seconds, and if you try to get .seconds on generic TimeoutError, 
you'll get a different uncaught exception (AttributeError vs. TimeoutError), 
but that TimeoutError wouldn't have been handled by catching TimeoutExpired.

I agree with Eric that people who were distinguishing OSError with .errno=ETIME 
from TimeoutError might be at risk, but I wouldn't do that: if I were going to 
be distinguishing particular OSErrors on the basis of errno (other than in 
"Unexpected OSError (errno = %d)" reporting style), I'd just catch OSError and 
do that.  On the other hand, I might expect TimeoutError to catch ETIME.  And 
Giampaolo says he's never seen either.  I suppose the author of psutil would be 
as likely as anyone to have seen it!

On net (unless we go the deprecation route) it seems that the convenience and 
"intuition" of adding ETIME to TimeoutError outweighs that risk.

I wish there were somebody who was there at the creation of ETIME!

--
nosy: +sjt

___
Python tracker 
<https://bugs.python.org/issue39673>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40219] ttk LabeledScale: label covered by hidden element

2020-04-07 Thread Stephen Bell


Change by Stephen Bell :


--
type:  -> behavior

___
Python tracker 
<https://bugs.python.org/issue40219>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40219] ttk LabeledScale: label covered by hidden element

2020-04-07 Thread Stephen Bell


New submission from Stephen Bell :

The LabeledScale in tkinter.ttk seems to have some kind of hidden element that 
covers the LabeledScale's label when the value is set to mid-scale. Tested on 
Windows 10, Python 3.6

See below code to reproduce:

import tkinter
from tkinter import ttk

master = tkinter.Tk()
_out1Value = tkinter.IntVar(master)
out1Slider = ttk.LabeledScale(master, from_=-100, to=100, variable=_out1Value, 
compound="bottom")
_out1Value.set(0)

# uncomment to "fix"
# out1Slider.label.lift()

out1Slider.pack()

master.mainloop()

--
components: Tkinter
messages: 365940
nosy: Stephen Bell
priority: normal
severity: normal
status: open
title: ttk LabeledScale: label covered by hidden element
versions: Python 3.6

___
Python tracker 
<https://bugs.python.org/issue40219>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Exceptions versus Windows ERRORLEVEL

2020-04-06 Thread Stephen Tucker
Thanks, Eryk - this is very helpful.

Stephen.

On Mon, Apr 6, 2020 at 6:43 AM Eryk Sun  wrote:

> On 4/3/20, Stephen Tucker  wrote:
> >
> > Does an exception raised by a Python 3.x program on a Windows machine set
> > ERRORLEVEL?
>
> ERRORLEVEL is an internal state of the CMD shell. It has nothing to do
> with Python. If Python exits due to an unhandled exception, the
> process exit code will be 1. If CMD waits on the process, it will set
> the ERRORLEVEL based on the exit code. But CMD doesn't always wait. By
> default its START command doesn't wait. Also, at the interactive
> command prompt it doesn't wait for non-console applications such as
> "pythonw.exe"; it only waits for console applications such as
> "python.exe".
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Exceptions versus Windows ERRORLEVEL

2020-04-03 Thread Stephen Tucker
Hi,

I have found that raising an exception in a Python 2.7.10 program running
under Windows does not set ERRORLEVEL.

I realise that Python 2.x is no longer supported.

Does an exception raised by a Python 3.x program on a Windows machine set
ERRORLEVEL?

If not, are there plans for it to do so?

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


Re: Multiple comparisons in a single statement

2020-03-16 Thread Stephen Tucker
OK. You are right. I was misleading.

I am sorry for wasting your time.

Thanks you for helping me to express myself.

Stephen.



<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 13, 2020 at 7:05 PM Dennis Lee Bieber 
wrote:

> On Fri, 13 Mar 2020 09:34:35 +, Stephen Tucker  >
> declaimed the following:
>
> >
> >*All:  *For the record, I meant that the tuples are all the same. The
>
>
> "all the same" is still ambiguous...
>
> >>> str1 = "A String"
> >>> str2 = "Another String"
> >>> str3 = "A" + " " + "String"
> >>> id(str1), id(str2), id(str3)
> (105461360, 105461296, 105461232)
> >>> tpl1 = (str1, str2)
> >>> tpl2 = (str1, str2)
> >>> tpl3 = (str3, str2)
> >>> id(tpl1), id(tpl2), id(tpl3)
> (90094216, 90094152, 90093576)
> >>> tpl1 == tpl2
> True
> >>> tpl1 == tpl3
> True
> >>> tpl4 = tpl3
> >>> tpl4 == tpl3
> True
> >>> tpl1 is tpl2
> False
> >>> tpl1 is tpl3
> False
> >>> tpl1 is tpl4
> False
> >>> tpl3 is tpl4
> True
> >>>
>
> tpl3 IS THE SAME as tpl4
> tpl1 is NOT THE SAME as tpl2, tpl3, or tpl4
>
> However, the CONTENTS of tpl4 compare as equivalent to tpl1, tpl2, and tpl3
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.com
> http://wlfraed.microdiversity.freeddns.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple comparisons in a single statement

2020-03-13 Thread Stephen Tucker
*Chris:*   Thank you for your confirmation.

*All:  *For the record, I meant that the tuples are all the same. The
tuples I have in mind contain strings, so the issue regarding the
"equality" (or otherwise) of 0 and 0.0 does not arise in my case.

Stephen.




To answer the question

On Thu, Mar 12, 2020 at 11:26 PM John Pote 
wrote:

>
> On 12/03/2020 18:08, Chris Angelico wrote:
> > On Fri, Mar 13, 2020 at 4:55 AM Stephen Tucker 
> wrote:
> >> A quickie (I hope!).
> >>
> >> I am running Python 2.7.10 (and, yes, I know, support for it has been
> >> withdrawn.)
> > This is the same in Python 3.
> >
> >> I have three tuples that have been generated separately and I want to
> check
> >> that they are identical. all I want to do is to terminate the program
> and
> >> report an error if all three are not identical.
> >>
> >> My initial attempt to do this is to use logic of the form
> >>
> >> if not (mytup1 == mytup2 == mytup3):
> >> raise Exception ("Tuples are not identical")
> >>
> >> I have tried this logic form in IDLE, and it seems to do what I want.
> >>
> >> Is this a reasonable way to do this, or is there a better way?
> >>
> > Yes absolutely! (Although, as a minor quibble, I would say "equal"
> > rather than "identical" here - when you talk about identity, you're
> > usually using the 'is' operator.) The meaning of chained comparisons
> > is broadly equivalent to comparing the middle one against the others
> > ("a==b==c" is "a==b and b==c"), which does the right thing here.
> >
> > It's slightly unusual to negate a query rather than using "!=", but it
> > makes good sense here.
>
> In case anyone thinks the original expr
>   not (mytup1 == mytup2 == mytup3)
> could be changed to
>   (mytup1 != mytup2!= mytup3)
> remember that applying De Morgan's theorem to the original expression
> would require the 'and' operation used in chained comparisons to change
> to an 'or' operation (Python always does the 'and' operation in chained
> comparisions). EG for simple integers instead of tuples,
>
>  >>> not (1==1==1)
> False
>  >>> not (2==1==1)
> True
>  >>> (1!=1!=1)
> False  correct as before
>  >>> (2!=1!=1)
> False  oops!
>
> John
>
> >
> > ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Multiple comparisons in a single statement

2020-03-12 Thread Stephen Tucker
A quickie (I hope!).

I am running Python 2.7.10 (and, yes, I know, support for it has been
withdrawn.)

I have three tuples that have been generated separately and I want to check
that they are identical. all I want to do is to terminate the program and
report an error if all three are not identical.

My initial attempt to do this is to use logic of the form

if not (mytup1 == mytup2 == mytup3):
   raise Exception ("Tuples are not identical")

I have tried this logic form in IDLE, and it seems to do what I want.

Is this a reasonable way to do this, or is there a better way?

Thanks in anticipation.

Stephen Tucker.


<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39548] Request fails when 'WWW-Authenticate' header for Digest Authentication does not contain 'qop'

2020-02-06 Thread Stephen Balousek


Change by Stephen Balousek :


--
versions: +Python 3.7

___
Python tracker 
<https://bugs.python.org/issue39548>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38686] WWW-Authenticate qop="auth,auth-int" rejected by urllib

2020-02-06 Thread Stephen Balousek


Change by Stephen Balousek :


--
pull_requests: +17752
pull_request: https://github.com/python/cpython/pull/18338

___
Python tracker 
<https://bugs.python.org/issue38686>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39548] Request fails when 'WWW-Authenticate' header for Digest Authentication does not contain 'qop'

2020-02-03 Thread Stephen Balousek


Change by Stephen Balousek :


--
keywords: +patch
pull_requests: +17711
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18338

___
Python tracker 
<https://bugs.python.org/issue39548>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39548] Request fails when 'WWW-Authenticate' header for Digest Authentication does not contain 'qop'

2020-02-03 Thread Stephen Balousek


New submission from Stephen Balousek :

When making an HTTP request using an opener with an attached 
HTTPDigestAuthHandler, the request causes a crash when the returned 
'WWW-Authenticate' header for the 'Digest' domain does not return the optional 
'qop' value.

Response headers:
=
Content-Type: application/json
Content-Security-Policy: default-src 'self' 'unsafe-eval' 
'unsafe-inline';img-src 'self' data:
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 600
WWW-Authenticate: Digest realm="ServiceManager", nonce="1580815098100956"
WWW-Authenticate: Basic realm="ServiceManager", charset="UTF-8"
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Expires: 0
Pragma: no-cache

Crash:
==
Error:   Exception: 'NoneType' object has no attribute 'split'
Traceback (most recent call last):
...
  File "/home/sbalousek/bin/restap.py", line 1317, in RunTest
status, payload, contentType = ExecuteRequest(baseUrl, test, tap);
  File "/home/sbalousek/bin/restap.py", line 1398, in ExecuteRequest
response= opener.open(request, payload, timeout);
  File "/usr/lib/python3.8/urllib/request.py", line 523, in open
response = meth(req, response)
  File "/home/sbalousek/bin/restap.py", line 1065, in http_response
return self.process_response(request, response, 
HTTPErrorProcessor.http_response);
  File "/home/sbalousek/bin/restap.py", line 1056, in process_response
return handler(self, request, response);
  File "/usr/lib/python3.8/urllib/request.py", line 632, in http_response
response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 555, in error
result = self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 494, in _call_chain
result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1203, in http_error_401
retry = self.http_error_auth_reqed('www-authenticate',
  File "/usr/lib/python3.8/urllib/request.py", line 1082, in 
http_error_auth_reqed
return self.retry_http_digest_auth(req, authreq)
  File "/usr/lib/python3.8/urllib/request.py", line 1090, in 
retry_http_digest_auth
auth = self.get_authorization(req, chal)
  File "/usr/lib/python3.8/urllib/request.py", line 1143, in get_authorization
if 'auth' in qop.split(','):
AttributeError: 'NoneType' object has no attribute 'split'

Diagnosis:
==
The crash is a result of an optional 'qop' value missing from the 
'WWW-Authenticate' header.

This bug was introduced in changes for issue 38686.

--
components: Library (Lib)
messages: 361330
nosy: Stephen Balousek
priority: normal
severity: normal
status: open
title: Request fails when 'WWW-Authenticate' header for Digest Authentication 
does not contain 'qop'
type: crash
versions: Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue39548>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Clarification on Immutability please

2020-01-21 Thread Stephen Tucker
Oh dear, I am sorry. I have created quite a storm.

Moreover, I am sorry because I misremembered what I had typed into Idle. My
original tuple only had two elements, not three, so the slicing [:2] didn't
affect the tuple at all - and so the second id() gave the same address as
the first one.

So, yes, I am stupid - or just having senior moments (I am 65, after all).

Stephen.




On Wed, Jan 22, 2020 at 4:30 AM Michael Torrie  wrote:

> On 1/21/20 6:52 PM, Ethan Furman wrote:
> > On 01/21/2020 10:55 AM, Michael Torrie wrote:
> >
> >> Slicing
> >> returns a new object whether one is slicing a tuple, list, or a string,
> >> the latter two are mutable objects.
> >
> > Strings are not mutable.
>
> Yup I got my items in the wrong order. I meant to say list, tuple, or a
> string, the latter two are immutable objects.  Thanks for correcting me.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Clarification on Immutability please

2020-01-21 Thread Stephen Tucker
Hi Python-list folk,

I am sure this has been answered many times before, but I need to ask it
again.

Given that the following is valid Python 2.7.10 (when keyboarded into Idle):

mytup = ("q", "w", "e")
id(mytup)
mytup = mytup [:2]
id(mytup)

and even that the first id(mytup) returns the same address as the second
one, I am left wondering exactly what immutability is.

I am left concluding that mytup is not actually a tuple (even though type
(mytup) tells me that it is).

My only explanation is that mytup is, actually, a pointer to a tuple; the
pointer can't change, but the contents of that pointer (or the data to
which the pointer points) can change.

That said, if I then type

mytup = mytup + ("r", "t")
id(mytup)

I find that this third id call returns a different address from the one
returned by the first two.

Somehow, it seems, tuples can be reduced in length (from the far end)
(which is not what I was expecting), but they cannot be extended (which I
can understand).

I am probably confused, ignorant, stupid, or any combination of the above.

Can you please help me become less so?

Many thanks.

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


Re: The file method read does not "see" CR

2019-12-10 Thread Stephen Tucker
Chris,

Many thanks. The first part of your answer was spot on. I have modified the
program, opening its input file in "rb" mode, and now the program is
working as I intend it to.

I am puzzled by the second part, where you say that the read call will
return one character, if the file is in text mode.

I was expecting this statement to read

   The read call will return one byte if the file is in binary mode.

Given that I *was *opening the file in "r" mode (which, I am assuming, is
"text" mode), then, if your statement is true, I have two more questions:

   1. If CR is a character and I open the file in text mode, then why does
the program not "see" the CR characters?

   2. Does the program not see CR characters under these circumstances
because they do not "count" as characters or for some other reason?

(You have probably spotted that this question 1 is virtually the same as my
original question.)

Stephen.














On Tue, Dec 10, 2019 at 10:39 AM Chris Angelico  wrote:

> On Tue, Dec 10, 2019 at 9:17 PM Stephen Tucker 
> wrote:
> >
> > I am running Python 2.7.10 on a Windows 10 machine. I have written a
> Python
> > program that counts occurrences of bytes in a text file and have run it
> on
> > a small test file. This file has CR-LF sequences at the ends of its
> lines.
> > The Python program counted the LF bytes, but didn't count any CR bytes.
> > Given that the documentation for the read method claims that exactly size
> > bytes are read by each call to the method (in this case, size is 1) does
> > this behaviour constitute a bug?
> >
>
> Are you trying to treat the file as text, or bytes? Are you looking
> for occurrences of bytes, or characters? Make a decision on that, then
> code accordingly. If you want to look for bytes, then open the file in
> binary mode and read it as bytes. If you want to look for characters,
> then you probably shouldn't care about which sort of line ending it
> is, but if you really do, then disable newline processing and examine
> the end of each logical line.
>
> The read call will return one character, if the file is in text mode.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


The file method read does not "see" CR

2019-12-10 Thread Stephen Tucker
I am running Python 2.7.10 on a Windows 10 machine. I have written a Python
program that counts occurrences of bytes in a text file and have run it on
a small test file. This file has CR-LF sequences at the ends of its lines.
The Python program counted the LF bytes, but didn't count any CR bytes.
Given that the documentation for the read method claims that exactly size
bytes are read by each call to the method (in this case, size is 1) does
this behaviour constitute a bug?

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


Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-08 Thread Stephen Waldron
Ok firstly, this idea was inspired specifically by a project I'm working on for 
school concerning linked lists, in which I was trying to create a method that 
performed a function on elements iteratively without having to navigate the 
list from the head each time (of course taking the function as a parameter). 
This project is intended to be a personal module for future use. 

In the process of this discourse here, however, I think I've found an 
alternative for this specific issue, (so thanks guys) but generally speaking, 
there were other times I've wanted to use functions as parameters, typically 
while making personal modules, like a purely Js button module I had made a few 
years back, and it was apparent that the only way to do so in Python was to 
define first, then pass, which I simply didn't like the idea of in the context 
of a module, short of defining each function before the module instances with 
`def temp(*args):` or some other generic name I won't use past the module 
function instance.

Now yes, as many of you have pointed out, there may exist other workarounds for 
various instances in which one may think to use a function as an argument. 
Multi-line lambdas are a very intriguing method for the broad topic, (thanks, 
they will be useful in the future ^ ^b ++), but as @Chris Angelico mentioned, 
they can't really be used as replacements for def, and from what I've 
experienced trying them out, it wasn't always clear what could be done for some 
of the lines one would want to write.

Finally, some clarification for @David Raymond
> Isn't this basically just defining a function... but without an argument 
> list? How would that know what "str" is?

In my original post, I said:
> If they are not, they won't be assigned to, which would cause an error unless 
> a default value is given. These parameters could be available for passing in 
> the annexed function if mentioned when the parameter is called.

Nyeh, it's written poorly, but I guess I should clarify by saying that, per the 
proposal, arguments are inherent from the parent function to the annexed 
function if and only if that argument is assigned to when the annexed function 
is called as the parameter it fills in the parent function's definition. Of 
course it can also use all other variables within it's scope.

In the example you're referring to, this is done on line 3:
foo (str = str1)
making foo inherit "str" from myFoo, which was given the default value " ".

(I would suppose another viable alternative would be using nonlocal as I'll 
example below)

Also you ask if it's just defining a function. In all of my examples, I use 
only one instance of the parent function (which is actually pretty useless), 
but the power in doing this actually lies in calling it in various locations 
and passing different arguments and annexing different functions (kinda what 
functions are for, haha). I might be hard-pressed to think of an example short 
of writing out a more complex program, but here is.. something?.. I guess 
simply assume runOpt(prompt, foo) is a previously defined function, and 
variables used in the annex are within the annexed function's scope, but prompt 
is not inherited:


runOpt ("Play Game"):
getUserData()
chr[0].id = 0
time = 0
score = 0

scene = 1


runOpt ("How To Play"):
nonlocal prompt

loadBg()
display(prompt)

scene = 2


runOpt ("Settings"):
checkDefaults()
chr[0].id = 5

scene = 3





N.B. on everything (also some TLs you could skip): 
This is just a suggestion, I think it would be nice for previously stated 
reasons (ease, aesthetics, function, yadda-yadda). I would still love to hear 
ways I could currently achieve things similar, as that is one of the things I 
look for from suggestions since "I don't know how to do x right now and have 
not previously found a solution" is implied, but one trigger I do have is a 
reply of "that is not the way it is" to a "this is how I think it should be" 
statement; doesn't give me any hint as to the merits or demerits of my thought, 
as flawed as it may indeed be, in logistics, implementation, practice etc. 
Can't really say anyone has done that quite yet, but just making it known, so 
"What you can try" and "The suggestion is impractical because..." responses are 
welcome. 

Also, one of the reasons for my suggestions is ease. The structure used is 
fairly common in Python, and thus fairly intuitive (I hypothesize at least). I 
know from experience that once you learn something, it becomes fairly easy and 
intuitive for you, but not necessarily for others and you sometimes forget the 
struggle you endured to get there. Of course I'm not saying others shouldn't 
have to learn to, but if there's a way to make it easier for others, I'd push 
it. Now I am still going to learn all about async, await, yield (which I think 
deserves more cred from what I can see so far), and lambda (cuz I wanna) but if 
I think learning and 

Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Thanks Antoon. I do suppose that it is kind of wrong to say the only way is to 
"reference its [the function's] name" as an argument, however the point I was 
trying to make was that it isn't possible to pass a function that is either not 
in some way previously defined or a reference to something previously defined.

In your example, you still make reference to the existing function `truediv` 
from the `operator` library, even though the `partial` function does create a 
new function.

What I'm aiming for is the ability to, within a function call, pass a suite 
that would be there automatically defined by the compiler/interpreter. Another 
comment did mention lambda functions, which does to some degree provide that 
capability, but is restricted to well, lambda functions (only expressions, not 
statements).

Your example does however suggest the possibilities of a function or expression 
that creates functions. For example, the `function` expression in JavaScript.

```
//Definition
function myFoo (str1, str2, foo){
console.log( foo(str1), foo(str2) );
}


//Call
myFoo ("hello", "world!", function(str){

str[0] = str[0].toUpper();
return str;

});


Output:
Hello World!
```

However it does not seem that there would be any such expression in Python as 
is. In python, this code would be written:


```
#Definition
def myFoo (str1, str2, foo):
print( foo(str1), foo(str2) )


#Call
def other_foo(str):
str = list(str)[0].upper() + str[1:]
return str

myFoo ("hello", "world!", other_foo)

```


Here is it rewritten using the proposal:
```
#Definition
def myFoo (str1, str2, foo, str = " "):
print( foo(str = str1), foo(str = str2) )


#Call
myFoo ("hello", "world!"):
str = list(str)[0].upper() + str[1:]
return str

```

Of course this example presents only a minor, though you can see the difference 
in the call, in which no new function needs be referenced.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Thanks Antoon. I do suppose that it is kind of wrong to say the only way is to 
"reference its [the function's] name" as an argument, however the point I was 
trying to make was that you cannot pass a function that is either not in some 
way previously defined or a reference to something previously defined.

In your example, you still make reference to the existing function `truediv` 
from the `operator` library, even though the `partial` function does create a 
new function.

What I'm aiming for is the ability to, within a function call, pass a suite 
that would be there automatically defined by the compiler/interpreter. Another 
comment did mention lambda functions, which does to some degree provide that 
capability, but is restricted to well, lambda functions (only expressions, not 
statements).

Your example does however suggest the possibilities of a function or expression 
that creates functions. For example, the `function` expression in JavaScript.

```
//Definition
function myFoo (str1, str2, foo){
console.log( foo(str1), foo(str2) );
}


//Call
myFoo ("hello", "world!", function(str){

str[0] = str[0].toUpper();
return str;

});


Output:
Hello World!
```

However it does not seem that there would be any such expression in Python as 
is. In python, this code would be written:


```
#Definition
def myFoo (str1, str2, foo):
print( foo(str1), foo(str2) )


#Call
def other_foo(str):
str = list(str)[0].upper() + str[1:]
return str

myFoo ("hello", "world!", other_foo)

```


Here is it rewritten using the proposal:
```
#Definition
def myFoo (str1, str2, foo, str = " "):
print( foo(str = str1), foo(str = str2) )


#Call
myFoo ("hello", "world!"):
str = list(str)[0].upper() + str[1:]
return str

```

Of course this example presents only a minor, though you can see the difference 
in the call, in which no new function needs be referenced.
-- 
https://mail.python.org/mailman/listinfo/python-list


Syntax Suggestion: Pass Function Definition as Argument

2019-11-07 Thread Stephen Waldron
Hi, I'm new to the group and to Python, so forgive me if I make any faux-pas 
here. As I can tell, the only way to pass a function as an argument is to 
reference its name as follows:

def foo1(message):
print(message)

def foo2(foo, message):
print("Your function says:")
foo(message)


>>foo2(foo1, "Hello World!")
Your function says:
Hello World!


This is how it is at the moment, however it may be more agreeable, especially 
if that is the only purpose of the function, for python users to be able to 
define new functions inside of function calls. The way I propose this may occur 
is using similar syntax as control structures, as exampled below:

def foo2(foo):
print("Message to print:", end = " ")
foo()


>>foo2():
print("Hello World!")

Message to print: Hello World!


In this proposal, it should be noted, that unlike control structures, the 
brackets are required for the function call. The "suite" or "annex" is defined 
as a function object by the compiler and passed inside the call. Here are some 
other examples of the proposal.



*Non-Function Arguments with Annexed Functions*
Non-Function Arguments should be placed in the brackets before annexed 
functions, and this should be reflected in the parameter order. If they are 
not, they won't be assigned to, which would cause an error unless a default 
value is given. These parameters could be available for passing in the annexed 
function if mentioned when the paramaeter is called.

def myFoo (num1, num2, foo):
return foo (num1, num2)


>>myFoo(20, 30):
return num1 + num2

50


*Annexing Multiple Functions or Out of Order Annex*
To specify the order in which functions are annexed, or annex multiple 
functions, one could use the parameter name before the specific suite.

class Book:
def __init__(self, name, author):
self.name = name
self.author = author


def doToBooks (bookList, first, then, book = None):

for book in bookList
first(book = book)
then(book = book)

myBooks = [
Book("The Way of the World", "Lucy Cole"),
Book("To Live or To Love", "Georgio Dunham"),
Book("Twelve Days of Success", "Anita Duvette")
]

doToBooks (myBooks):
print(book.name)
then:
print(" - " + book.author + "\n")



>
The Way of The World
 - Lucy Cole

To Live or To Die
 - Georgio Dunham

Twelve Days of Success
 - Anita Duvette



This proposal does not detract from the core appearance and appeal of Python 
while creating an option for users and module makers who want themselves or the 
users of their modules not to have to previously define functions in order to 
use the code. This would make such code more aesthetic and compact, and take 
away the need for defining a new function, name and all, specifically for such 
which ultimately would be used only once as an argument. 
   
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37903] IDLE Shell sidebar.

2019-11-02 Thread Stephen Paul Chappell


Stephen Paul Chappell  added the comment:

@rhettinger: The turtle demo is easily accessible through the menus via Help > 
Turtle Demo.

It is nice to see there are others interested in IDLE's improvement. :-)

--

___
Python tracker 
<https://bugs.python.org/issue37903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37903] IDLE Shell sidebar.

2019-11-01 Thread Stephen Paul Chappell


Stephen Paul Chappell  added the comment:

Zero: "not to have them added as text as is usual in a terminal window"
taleinat: "removing prompts from the shell window's text widget"

Zero: "print the values of ps1 and ps2 in the proposed ShellIO subclass"
taleinat: "separate sidebar showing where prompts and user input were"

We appear to be in agreement.

terry.reedy: "Labels, such as '>>>', 'Out', 'Inp', and 'Err' would be used"
Zero:"Having IDLE react to sys.ps1 and sys.ps2"

My suggestion is to take those labels terry.reedy talks about from the values 
of ps1 and ps2 since they are already documented and standard for "the 
interpreter ... in interactive mode." If psX needs to introduced for other 
prompts that may be needed ("Maybe use 'Con', maybe use Dbg and Wrn."), it 
would provide a sensible way to customize those labels as well.

--

___
Python tracker 
<https://bugs.python.org/issue37903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37903] IDLE Shell sidebar.

2019-10-31 Thread Stephen Paul Chappell


Stephen Paul Chappell  added the comment:

Maybe my impression has been false this whole time, but the Python interactive 
interpreter seems to be very similar to the IDLE shell window. My question is, 
"Why not make them even more so?" Having IDLE react to sys.ps1 and sys.ps2 
opens up the shell to similar use cases as having them defined in the 
interactive interpreter. My suggestion is not to have them added as text as is 
usual in a terminal window but to print the values of ps1 and ps2 in the 
proposed ShellIO subclass. That would make label customization possible in a 
way that is already documented and standard.

--

___
Python tracker 
<https://bugs.python.org/issue37903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6188] Error Evaluating float(x) ** float(y)

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue6188>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21957] ASCII Formfeed (FF) & ASCII Vertical Tab (VT) Have Hexadecimal Representation

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue21957>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24185] Add Function for Sending File to Trash (or Recycling Bin)

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue24185>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21402] tkinter.ttk._val_or_dict assumes tkinter._default_root exists

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue21402>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18601] Example "command-line interface to difflib" has typographical error

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue18601>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21537] functools.lru_cache does not cache exceptions

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue21537>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18558] Iterable glossary entry needs clarification

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue18558>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31848] "aifc" module does not always initialize "Aifc_read._ssnd_chunk"

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue31848>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31476] Stdlib source files not installed

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue31476>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7676] IDLE shell shouldn't use TABs

2019-10-31 Thread Stephen Paul Chappell


Change by Stephen Paul Chappell :


--
nosy:  -Zero

___
Python tracker 
<https://bugs.python.org/issue7676>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37903] IDLE Shell sidebar.

2019-10-31 Thread Stephen Paul Chappell


Stephen Paul Chappell  added the comment:

The documentation for sys.ps1 and sys.ps2 states that they "are only defined if 
the interpreter is in interactive mode." Since the IDLE shell is meant to be 
interactive (and to reduce the differences between the shell and running Python 
directly), would it be helpful if ps1 and ps2 were defined when running IDLE? 
The shell could then honor their values.

If such a direction was explored, one issue may be that the sidebar could not 
simply be 3 char wide. The documentation also states that non-strings are 
evaluated each time they are needed by the interpreter. This allows for such 
interesting possibilities as shown with the code below but may not be desired 
functionality for the IDLE shell window.

import sys
from datetime import datetime

class TimePrompt:
def __init__(self, prefix, suffix):
self.prefix, self.suffix = prefix, suffix
def __str__(self):
return f'{self.prefix}{datetime.now()}{self.suffix}'

sys.ps1, sys.ps2 = TimePrompt('', ' >>> '), TimePrompt('', ' ... ')

--
nosy: +Zero

___
Python tracker 
<https://bugs.python.org/issue37903>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38636] IDLE regression: toggle tabs and change indent width functions

2019-10-30 Thread Stephen Paul Chappell


Stephen Paul Chappell  added the comment:

When I start IDLE and the shell window appears, my first task is to press "Alt 
+ T" to change from using tabs to spaces and then "Alt + U" to change from 
using 8 spaces to 4. This allows code pasted from the shell into an editor 
window or other IDE to not require reformatting since those settings seem to be 
common for Python code. If the defaults for these settings were to be exposed 
in IDLE's settings under the General tab (maybe near the new "Show line numbers 
in new windows" checkbox), would it be best to make that request here or to 
open a new bug with an enhancement suggestion?

--

___
Python tracker 
<https://bugs.python.org/issue38636>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38636] "Alt + T" and "Alt + U" Broken in IDLE on Windows

2019-10-29 Thread Stephen Paul Chappell


New submission from Stephen Paul Chappell :

In the latest Python 3.8.0 installation when running IDLE on Windows, pressing 
"Alt + T" generates the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\Python38\Lib\tkinter\__init__.py", line 1883, in 
__call__
return self.func(*args)
  File "C:\Program Files\Python38\Lib\idlelib\multicall.py", line 176, in 
handler
r = l[i](event)
TypeError: toggle_tabs_event() missing 1 required positional argument: 
'event'

Similarly, pressing "Alt + U" will generate a very similar error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\Python38\Lib\tkinter\__init__.py", line 1883, in 
__call__
return self.func(*args)
  File "C:\Program Files\Python38\Lib\idlelib\multicall.py", line 176, in 
handler
r = l[i](event)
TypeError: change_indentwidth_event() missing 1 required positional 
argument: 'event'

--
assignee: terry.reedy
components: IDLE, Windows
messages: 355678
nosy: Zero, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: "Alt + T" and "Alt + U" Broken in IDLE on Windows
type: behavior
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue38636>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38365] Issue 38363 - False Alarm - Sorry!

2019-10-03 Thread Stephen Tucker


New submission from Stephen Tucker :

Hi,

Issue 38363 is a false alarm - I am sorry to have wasted your time.

My mistake was that the file that had the BOM in it also had a space at the
end of the filename. I removed the space and the module was found OK.

Sorry again.

Stephen Tucker.

--
messages: 353854
nosy: Stephen_Tucker
priority: normal
severity: normal
status: open
title: Issue 38363 - False Alarm - Sorry!

___
Python tracker 
<https://bugs.python.org/issue38365>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38363] No Module named ..." and UTF-8 Byte Order Marks

2019-10-03 Thread Stephen Tucker


New submission from Stephen Tucker :

Hi,

I am running Python 2.7.10 on Windows 10.

I have discovered that if a .py source text file (that is, a Module text
file) starts with a UTF-8 Byte Order Mark, the module does not get "found"
by the  import  statement.

I have just spent an inordinate amount of time reaching this conclusion.

I realise that 2.7.10 is probably not being supported any more, however,
please let me ask the questions anyway:

Could ...
   Either:   ... the error message please be more helpful? (Like, for
example,  "Module begins with a Byte Order Mark")
   Or:... the BOM be allowed at the start of a Module?

Thanks.

Stephen Tucker.

--
messages: 353841
nosy: Stephen_Tucker
priority: normal
severity: normal
status: open
title: No Module named ..." and UTF-8 Byte Order Marks

___
Python tracker 
<https://bugs.python.org/issue38363>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread Stephen Tucker
Markos,

I can explain the difference from a non-numpy point of view - I hope you
will be able to see how this difference affects what you are trying to do
in numpy.

vector_1 is an np.array consisting of a three-element list, with the three
elements being 1, 0 and 1.

vector_2 is an np.array consisting (at the top level) of a one-element
list, with that element (at this top level) being a three-element list,
with these three elements (at the lower level) being 1, 0 and 1.

Stephen.




On Fri, Jun 21, 2019 at 7:29 AM Markos  wrote:

>
> Hi,
>
> I'm studying Numpy and I don't understand the difference between
>
> >>> vector_1 = np.array( [ 1,0,1 ] )
>
> with 1 bracket and
>
> >>> vector_2 = np.array( [ [ 1,0,1 ] ] )
>
> with 2 brackets
>
> The shape of vector_1 is:
>
> >>> vector_1.shape
> (3,)
>
> But the shape of vector_2 is:
>
> >>> vector_2.shape
> (1, 3)
>
> The transpose on vector_1 don't work:
>
> >>> vector_1.T
> array([1, 0, 1])
>
> But the transpose method in vector_2 works fine:
>
> >>> vector_2.T
> array([[1],
> [0],
> [1]])
>
>
> I thought that both vectors would be treated as an matrix of 1 row and 3
> columns.
>
> Why this difference?
>
> Any tip?
>
> Thank you,
> Markos
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28609] argparse claims '*' positional argument is required in error output

2019-05-27 Thread Stephen McDowell


Stephen McDowell  added the comment:

> For optionals, `required` is set by the programmer.  But for positionals it 
> is set with: ...
> So for '?' argument, required is False.  But for '*', it must also have a 
> 'default' parameter (not just the default None).
> So the proposed patch is overriding the 'required' value that was set during 
> 'add_argument'.  And issuing this error message is the main purpose of the 
> 'required' attribute.

nargs='*' being marked as `required` is incorrect though, isn't it?

I was also very confused by this behavior, the only reason I found this bug was 
to search before opening new, and had a patch prepared that is nearly identical 
to the one here.

1. It's really helpful to know about explicitly setting `default=None|[]` 
depending on use case.  Would a docs PR briefly explaining at the bottom of the 
nargs [a] docs explaining how to change the error message via `default` be 
welcome?  This is a slightly challenging problem to search for.

2. My understanding is the ultimate rejection of the patch is because it's 
bypassing the `required` attribute.  So to fix this adequately, changing ? and 
* to not show up as required (when no `default` provided) should be done?


[a] https://docs.python.org/3/library/argparse.html#nargs

--
nosy: +svenevs

___
Python tracker 
<https://bugs.python.org/issue28609>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Question about floating point

2018-08-28 Thread Stephen Tucker
Hi Frank,

One difference is that, in order to carry out the instructions embodied in
the first example, the computer has to perform arithmetic. And it adds the
binary approximation of 1.1 (which is very slightly wrong) to the binary
approximation of 2.2 (which, again, is very slightly wrong). It then prints
the denary equivalent to the sum of those two which happens to be very
slightly more than 3.3.

When you type 3.3, it stores that as the binary approximation of 3.3 (which
is y at that stage, to answer your question, and is, again, no surprise,
also very slightly wrong) and then prints the denary equivalent of that
binary approximation which happens to end up sufficiently close to 3.3 so
as to cause it to print 3.3.

I hope that helps.

The experts around here (of which I am not one) may well point you to the
decimal  package which allows better handling of such arithmetic, if you
are want the computer to behave more like you would want it to behave.

Regards,

Stephen Tucker.








On Tue, Aug 28, 2018 at 3:11 PM, Frank Millman  wrote:

> Hi all
>
> I know about this gotcha -
>
> x = 1.1 + 2.2
>>>> x
>>>>
>>> 3.3003
>
> According to the docs, the reason is that "numbers like 1.1 and 2.2 do not
> have exact representations in binary floating point."
>
> So when I do this -
>
> y = 3.3
>>>> y
>>>>
>>> 3.3
>
> what exactly is happening? What is 'y' at this point?
>
> Or if I do this -
>
> z = (1.1 + 2.2) * 10 / 10
>>>> z
>>>>
>>> 3.3
>
> What makes it different from the first example?
>
> Thanks
>
> Frank Millman
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34442] zlib module not built on windows

2018-08-20 Thread Stephen Kelly


New submission from Stephen Kelly :

I tried to build python 3.7.0 from source.

I ran the PCBuild/build.bat script. That downloaded zlib to the external/ 
directory.

However, it does not seem to be built. When running I get:

python\3.7.0\lib\zipfile.py", line 646, in _check_compression   

"Compression requires the (missing) zlib module")   

 
RuntimeError: Compression requires the (missing) zlib module  

I examined PCBuild/pcbuild.proj. It makes no mention of zlib, though it 
mentions other externals.

I notice that Python 3.6.1 contained zlib in Modules/zlib instead of coming 
from external/.

Presumably that source was moved, but the Windows-related scripts were not 
updated.

--
components: Extension Modules
messages: 323791
nosy: steveire
priority: normal
severity: normal
status: open
title: zlib module not built on windows
type: compile error
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue34442>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Learning Python

2018-06-05 Thread Stephen Tucker
I have found Learning Python by Mark Lutz helpful. I have the 4th edition
(2009). Its ISBN is 978-0-596-15806-4.

A lot will depend on your learning style. This book reads more like a set
of course notes than a reference book, but it does contain tables and
summaries, too.

On Tue, Jun 5, 2018 at 5:51 PM, T Berger  wrote:

> Can someone learn Python through a book such as Head Start Python? Would
> an online course from MIT or google be better?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29595] Expose max_queue_size in ThreadPoolExecutor

2018-03-30 Thread Stephen ONeal

Stephen ONeal <stephen.oneal...@gmail.com> added the comment:

My project we're going into the underlying _work_queue and blocking adding more 
elements based on unfinished_tasks to accomplish this, bubbling this up to the 
API would be a welcome addition.

--
nosy: +stephen.oneal...@gmail.com

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue29595>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Stephen Hansen
On Mon, Mar 26, 2018, at 2:19 PM, Rick Johnson wrote:
>Sure, the behavior that Steven
> uncovered is odd, but it could be that Maz harbors a strong
> disliking for undisciplined pupils, and thus, he designed
> and placed this little trap in the hopes the pain it induced
> might encourage the petulant little meat-heads to follow
> some sensible styling rules.

My god, I've been away from this list for quite awhile, but we're still 
entertaining this fool? 

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33035] Some examples in documentation section 4.7.2 are incorrect

2018-03-09 Thread Stephen Wille Padnos

New submission from Stephen Wille Padnos <st...@thothsystems.com>:

Section 4.7.2 of the documentation, "Keyword Arguments", has several examples 
of valid calls to the sample function parrot.

The function definition is:
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):

The last two calls in the valid samples are actually not valid, since they are 
missing the required "voltage" parameter.
parrot('a million', 'bereft of life', 'jump') # 3 positional arguments
parrot('a thousand', state='pushing up the daisies')  # 1 positional, 1 keyword

They should be changed to include a value for voltage, along with a change to 
the comment:
parrot(1000, 'a million', 'bereft of life', 'jump') # 4 positional 
arguments
parrot(1000, 'a thousand', state='pushing up the daisies')  # 2 positional, 1 
keyword

This issue is present in all currently available versions of the documentation: 
2.7; 3.5; 3.6.4; pre (3.7); and dev (3.8).

--
assignee: docs@python
components: Documentation
messages: 313485
nosy: docs@python, stephenwp
priority: normal
severity: normal
status: open
title: Some examples in documentation section 4.7.2 are incorrect
type: enhancement
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33035>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32325] C API should use 'const char *' instead of 'char *'

2017-12-14 Thread Stephen Kelly

New submission from Stephen Kelly <steve...@gmail.com>:

When using C++ to extend python, one may use PyGetSetDef for example:


static PyGetSetDef Noddy_getseters[] = {
{"first",
 (getter)Noddy_getfirst, (setter)Noddy_setfirst,
 "first name",
 NULL},
{"last",
 (getter)Noddy_getlast, (setter)Noddy_setlast,
 "last name",
 NULL},
{NULL}  /* Sentinel */
};

However, in C++ implicit conversion from const char* to char* is deprecated 
since C++98, and is a removed conversion in C++11.

 https://godbolt.org/g/sswUKM

GCC/Clang warn about this, and MSVC in conformance mode (/permissive-) errors 
on it.

PyGetSetDef and similar APIs should use const char* instead of char* for 
members such as `name`.

--
components: Library (Lib)
messages: 308316
nosy: steveire
priority: normal
severity: normal
status: open
title: C API should use 'const char *' instead of 'char *'
type: enhancement
versions: Python 3.8

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32325>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24132] Direct sub-classing of pathlib.Path

2017-11-08 Thread Stephen M. Gava

Stephen M. Gava <elgua...@python.net> added the comment:

@paul.moore is the original contributor mia? i seem to remember pathlib as once 
being marked 'provisional', i think it should have stayed that way until this 
problem was resolved. easy to say i know ;) when i don't have a patch.

@projetmbc yes i found various work-arounds on the web and decided to not use 
any of them. really i feel this should be fixed as it's a jarring inconsistency 
with naturally expected behaviour for a class in python.

so i added my report to this as a topic bump because i don't think this should 
be forgotten about and in case anyone might come up with an idea how to fix it.

--
versions: +Python 3.6 -Python 3.5

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue24132>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24132] Direct sub-classing of pathlib.Path

2017-11-07 Thread Stephen M. Gava

Stephen M. Gava <elgua...@python.net> added the comment:

Using a set of paths with special properties and formats in a project, thought 
"the cleanest oop way to do this is try out python's oop paths in pathlib". 
Subclassed Path to implement my extra (non platfor specific) properties and 
fell at the first hurdle because of this issue... 

for me pathlib does not provide oop paths if i can't subclass Path, for 
whatever reason.

reverted to treating paths as strings and writing functions to handle my 
special path properties and formats.

i was also surprised when i found another bug report on this issue that said it 
was closed for 3.7, great i thought this has been solved, but no, the other 
report was closed because it was about the same issue as this ancient report.

--
nosy: +elguavas

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue24132>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31848] "aifc" module does not always initialize "Aifc_read._ssnd_chunk"

2017-10-23 Thread Stephen Paul Chappell

New submission from Stephen Paul Chappell <noctis.skyto...@gmail.com>:

When Aifc_read runs initfp, it conditionally sets self._ssnd_chunk and is not 
guaranteed to do so. At the bottom of the method, a check is made to see if the 
attribute has a false value; and if so, an error is supposed to be raised. If a 
SSND chunk is never found, checking self._ssnd_chunk causes an attribute error 
to be raised similar to this:

AttributeError: 'Aifc_read' object has no attribute '_ssnd_chunk'

The error was found on the following distribution:

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit 
(AMD64)] on win32

--
components: Library (Lib), Tests
messages: 304804
nosy: Zero
priority: normal
severity: normal
status: open
title: "aifc" module does not always initialize "Aifc_read._ssnd_chunk"
type: crash
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31848>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: integer copy

2017-10-20 Thread Stephen Tucker
ast,

For what it's worth,

After

a = 5
b = 5
afloat = float(a)
bfloat = float(b)

afloat is bfloat

returns False.

Stephen Tucker.


On Fri, Oct 20, 2017 at 9:58 AM, ast <nomail@com.invalid> wrote:

>
> "ast" <nomail@com.invalid> a écrit dans le message de
> news:59e9b419$0$3602$426a7...@news.free.fr...
>
> Neither works for large integers which is
> even more disturbing
>
> a = 6555443
>
> b = copy.copy(a)
> a is b
>
> True
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31660] sys.executable different in os.execv'd python3.6 virtualenv session in python2 vs python3

2017-10-02 Thread Stephen Moore

Stephen Moore <delfick...@gmail.com> added the comment:

I just realised python3 sets it's own __PYVENV_LAUNCHER__ and if you unset it 
before calling to os.execv, then the virtualenv has the correct sys.executable.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31660>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31660] sys.executable different in os.execv'd python3.6 virtualenv session in python2 vs python3

2017-10-02 Thread Stephen Moore

Stephen Moore <delfick...@gmail.com> added the comment:

It appears the problem doesn't appear when using python3 -m venv.

Also it seems __PYVENV_LAUNCHER__ is set to the virtualenv's python except when 
it's a python3.6 virtualenv and we os.execv from python3.6, where it's set the 
system python.

Should I be making an issue with the virtualenv project?

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31660>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31660] sys.executable different in os.execv'd python3.6 virtualenv session in python2 vs python3

2017-10-01 Thread Stephen Moore

New submission from Stephen Moore <delfick...@gmail.com>:

Hi,

I've come across a problem whereby if you do an os.execv to a python3.6 
virtualenv python inside python2.7 vs python3.6 then the resulting python 
session has a different sys.executable.

Where if you os.execv from python2.7 the sys.executable is equal to the 
virtualenv python

Whereas from python3.6 the resulting python session has a sys.executable of the 
system python.

An example of this in play can be found at 
https://gist.github.com/delfick/d750dc83e3b28e90cef8e2bfbd5b175a

Note that I don't see the problem if the virtualenv is based on python2.7 
(https://gist.github.com/delfick/f1ad6872e2614189a7d98f2583ffc564)

--
components: macOS
messages: 303507
nosy: Stephen Moore, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: sys.executable different in os.execv'd python3.6 virtualenv session in 
python2 vs python3
versions: Python 2.7, Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31660>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31476] Stdlib source files not installed

2017-09-15 Thread Stephen Paul Chappell

Stephen Paul Chappell added the comment:

The URL for the installer that was used last is:

https://www.python.org/ftp/python/3.6.2/python-3.6.2-amd64-webinstall.exe

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31476>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31476] "Open Module..." Not Working in IDLE for Standard Library

2017-09-14 Thread Stephen Paul Chappell

New submission from Stephen Paul Chappell:

Ever since Python 3.6.1, trying to open a Python-source library module in IDLE 
on Windows (10) has not worked properly since the installer has only been 
providing *.pyc files. Learning how to use Python has always been easy since it 
(1) has a great help document, (2) makes it easy to get help() on objects, and 
(3) allows the source to easily be explored and/or patched. Is there something 
special that needs to be done to get both the standard library's *.py files and 
precompile them to *.pyc during installation?

I would be glad to run further tests if the Windows installer can be run 
headless with specific command-line arguments.

--
assignee: terry.reedy
components: IDLE, Library (Lib), Windows
messages: 302201
nosy: Zero, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: "Open Module..." Not Working in IDLE for Standard Library
type: behavior
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31476>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   4   5   6   7   8   9   10   >