Re: Python 2.7 range Function provokes a Memory Error

2023-03-06 Thread Stephen Tucker
n 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

Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread Stephen Tucker
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
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

Re: Precision Tail-off?

2023-02-17 Thread Stephen Tucker
otN. 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

Precision Tail-off?

2023-02-13 Thread Stephen Tucker
. 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

Re: IDLE "Codepage" Switching?

2023-01-18 Thread Stephen Tucker
ce 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.

IDLE "Codepage" Switching?

2023-01-17 Thread Stephen Tucker
quot; >>> for thisCP in range (158, 169): mylongstr += chr (thisCP) + " " >>> print mylongstr ž Ÿ ¡ ¢ £ ¤ ¥ ¦ § ¨ >>> mylongstr = "" >>> for thisCP in range (157, 169): mylongstr += chr (thisCP) + " " >>>

Re: file.read Method Documentation (Python 2.7.10)

2023-01-12 Thread Stephen Tucker
sider 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

Re: file.read Method Documentation (Python 2.7.10)

2023-01-11 Thread Stephen Tucker
d (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 th

Re: file.read Method Documentation (Python 2.7.10)

2023-01-11 Thread Stephen Tucker
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

file.read Method Documentation (Python 2.7.10)

2023-01-09 Thread Stephen Tucker
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
ng 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

Discerning "Run Environment"

2022-05-18 Thread Stephen Tucker
oal (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
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 &q

Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
ythonic 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

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

2021-08-12 Thread Stephen Tucker
t; 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, >

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

2021-08-12 Thread Stephen Tucker
) * 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

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

2021-04-25 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

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

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 sta

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?

Re: Multiple comparisons in a single statement

2020-03-16 Thread Stephen Tucker
s://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_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 > > declaime

Re: Multiple comparisons in a single statement

2020-03-13 Thread Stephen Tucker
n 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

Multiple comparisons in a single statement

2020-03-12 Thread Stephen Tucker
Thanks in anticipation. Stephen Tucker. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm

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, y

Clarification on Immutability please

2020-01-21 Thread Stephen Tucker
eems, 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
d 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 writt

The file method read does not "see" CR

2019-12-10 Thread Stephen Tucker
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: 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 consi

Re: Question about floating point

2018-08-28 Thread Stephen Tucker
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.30

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

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 wrote: > > "ast" a écrit dans le message de > news:59e9b419$0$3602$426a7...@news.free.fr... >

Re: How to write raw strings to Python

2017-07-05 Thread Stephen Tucker
Sam, You use f.write(r'hello\tworld') The r in front of the string stands for raw and is intended to switch off the escape function of the backslash in the string. It works fine so long as the string doesn't end with a backslash, as in f.write('hello\tworld\') If you try this, you get an error

Re: How to write raw strings to Python

2017-07-05 Thread Stephen Tucker
Sam, You use r'hello\tworld' The r in front of the string stands for raw and it is intended to switch off the normal escape function of a backslash. It works fine so long as the string doesn't end with a backslash. If you end the string with a backslash, as in r'hello\tworld\' you get an error

Re: how to add new tuple as key in dictionary?

2017-06-30 Thread Stephen Tucker
Hello there, Ho Yeung Lee, The use of groupkey[tuple([0,3])] to the right of the = is attempting to access an entry in your dictionary that you have not already created. That is why you are getting the error message. You need to create an entry whose key is tuple([0,3]) before you can access it. T

Unhelpful error message

2017-06-06 Thread Stephen Tucker
g to a floating point number. Now, in the example I have given here, it is obvious that the string is null, but in the example that threw me into a loop, it was not obvious. It would be more helpful is the system replied: ValueError: could not convert null string to float Any chance of that bec

Re: Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-03 Thread Stephen Tucker
(MyFunction()) becomes print (MyFunction(parameters-separated-with-commas)) ]; (3) and rerun the new code - which should then do what you are wanting it to do. I hope this helps. Stephen Tucker. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaig

Re: calling a program from Python batch file

2016-12-07 Thread Stephen Tucker
This might be totally irrelevant, but, if (a) the data to be read by the program during a given run is known when the program is run/launched, (b) that data is purely textual and (c) that data can be read by the program from the stdin channel, then my idea is (1) before the launch, put that data in

Re: Quick way to calculate lines of code/comments in a collection of Python scripts?

2016-10-24 Thread Stephen Tucker
Tomasz, How about using the command prompt command FIND /C on each of your source files as follows: FIND/C "#" >NumbersOfLinesContainingPythonComments.dat FIND/C /V "#" >NumbersOfLinesNotContainingPythonComments.dat You would end up with two files each with a column of line counts; Import thes

Re: Doubled backslashes in Windows paths

2016-10-07 Thread Stephen Tucker
nted to the Windows Command interpreter, the spaces are accepted as part of it without the need then of enclosing quotes. Hope this helps. Yours, Stephen Tucker. On Fri, Oct 7, 2016 at 6:30 AM, Oz-in-DFW wrote: > I'm using Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC >

Re: degrees and radians.

2016-08-24 Thread Stephen Tucker
For what it's worth, mathematicians naturally work with angles in radians. The mathematics of the trignonmetric functions works naturally when the angle is expressed in radians. For the older among us, logarithms also have a "natural" base, and that is the number e. Back in those days, however, e

Re: Self Learning Fortran Programming

2016-06-01 Thread Stephen Tucker
book. Stephen Tucker. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=w

Re: find all multiplicands and multipliers for a number

2015-04-10 Thread Stephen Tucker
Dario Alpern has written a program that uses the Elliptic Curve Method (ECM) for factorising a number. ECM is one of the _very_ fast methods for finding the prime factors of a number. He has even offered the code for his program. You could have a go at using or converting his code to do what you ar

Re: Challenge: optimizing isqrt

2014-11-26 Thread Stephen Tucker
Another _possible_ performance improvement that is staring us in the face is that 2*b could be replaced with b<<1. Given that b+b (an earlier suggestion of mine) involves two table look-ups for b, whereas b<<1 only involves one, it seems that the scope here for improvement is significant. By the w

Re: Challenge: optimizing isqrt

2014-11-23 Thread Stephen Tucker
t be used in those situations. Stephen Tucker. On Thu, Nov 20, 2014 at 6:00 PM, Serhiy Storchaka wrote: > On 01.11.14 03:29, Steven D'Aprano wrote: > >> There is an algorithm for calculating the integer square root of any >> positive integer using only integer oper

Re: Unicode Objects in Tuples

2013-10-11 Thread Stephen Tucker
e "non-geekiness" of a string is, itself, far too geeky for my liking. The distinction seems to be an utterly spurious - even artificial or arbitrary one to me. (Sorry about the rant.) On Fri, Oct 11, 2013 at 10:22 AM, Ned Batchelder wrote: > On 10/11/13 4:16 AM, Stephen Tucker wro

Unicode Objects in Tuples

2013-10-11 Thread Stephen Tucker
objects in tuples get their characters sent to the file as escape sequences. Why is this the case? 4. As for question 1 above, I ask here also: What is the neatest way to get round this? Stephen Tucker. -- https://mail.python.org/mailman/listinfo/python-list

getting rpy2 from repository

2010-02-28 Thread Stephen Tucker
Hi all, I have Enthought Python 4.3 installed on my OS X 10.5. When I do $ easy_install rpy2 Searching for rpy2 No matching release version found. Searching for latest development version. Reading http://www.enthought.com/repo/epd/eggs/MacOSX/10.4_x86/ Please enter credentials to access this repo