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

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

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

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

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

Problem Installing Pipenv

2021-12-17 Thread Stephen P. Molnar
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

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.

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

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

2021-07-28 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 th

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: Bulletproof json.dump?

2020-07-07 Thread Stephen Rosen
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
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/web

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 te

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
? 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&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free. www.avast.com <http

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 O

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

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

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

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

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)

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

2019-06-21 Thread Stephen Tucker
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

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: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Stephen Hansen
t 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

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: Python programming language vulnerabilities

2017-09-11 Thread Stephen Michell
CORRECTION. My sincere apologies to anyone that tried the link that I posted. The actual link is www.open-std.org/jtc1/sc22/wg23 follow the link to documents, or go directly there via www.open-std.org/jtc1/sc22/wg23/docs/documents.html I was informed that there are some broken links to documen

Re: Python programming language vulnerabilities

2017-09-10 Thread Stephen Michell
My apologies. I maintain that website. There should have been no broken links. I will fix that. The previous version of TR 24772 had annexes for language-specific material. We have split those out, so the main document (Tr 24772-1) only has language independent material. The last Python documen

Python programming language vulnerabilities

2017-09-09 Thread Stephen Michell
in Python (for technical level, persons that provide technical supervision to implementers, or that write and maintain organizational Python coding standards. If you are interested in helping, please reply to this posting. Thank you Stephen Michell Convenor, ISO/IEC/JTC 1/SC 22/WG 23

Re: How to write raw strings to Python

2017-07-05 Thread Stephen Tucker
you try this, you get an error message. Stephen. <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=si

Re: How to write raw strings to Python

2017-07-05 Thread Stephen Tucker
tworld\' you get an error message. Stephen. <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=si

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

2017-06-30 Thread Stephen Tucker
. The following code does not provoke an error message: groupkey = {(0,0): []} groupkey = {tuple([0,3]): []} groupkey[tuple([0,3])] = groupkey[tuple([0,3])] + [[0,1]] I hope this helps you. Stephen. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaig

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
mn of line counts; Import these lines into an Excel Spreadsheet and calculate whatever you like with them. Stephen. On Sun, Oct 23, 2016 at 9:51 PM, Tomasz Rola wrote: > On Wed, Oct 05, 2016 at 01:56:59PM -0400, Malcolm Greene wrote: > > Looking for a quick way to calculate lines of c

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: for / while else doesn't make sense

2016-05-19 Thread Stephen Hansen
it. They aren't. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-10 Thread Stephen Hansen
implementation, it is guaranteed that: >>> a = "a" "a" >>> b = "aa" Are the same. Two+ string literals are implicitly combined into one at compile time. > 'master craftswoman' my ass... Yes, you're being that. Please stop. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: What should a decorator do if an attribute already exists?

2016-05-10 Thread Stephen Hansen
. Your decorator should, IMHO, treat the attribute as private data, and if something else is using the same thing, something has clearly gone wrong and raising the error early and clearly is right. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-08 Thread Stephen Hansen
On Sun, May 8, 2016, at 02:46 PM, DFS wrote: > On 5/8/2016 5:38 PM, Stephen Hansen wrote: > > On Sun, May 8, 2016, at 02:16 PM, DFS wrote: > >> I was surprised to see the PEP8 guide approve of: > >> > >> "Yes: if x == 4: print x, y; x, y = y, x" >

Re: pylint woes

2016-05-08 Thread Stephen Hansen
its speaking *only* about *whitespace*. ALL its saying is, "don't put spaces before commas, colons or semicolons". You can infer nothing else about it. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-08 Thread Stephen Hansen
an error happens. You rollback. Or correct the data. Since the data didn't go in, there should (in theory) be nothing TO commit if an error happens. Or, there should be partial data in that needs a rollback before you decide to do something else. -- Stephen Hansen m e @ i x o k a i . i o -- h

Re: pylint woes

2016-05-08 Thread Stephen Hansen
s): may be sorta vaguely long, but its not that long. Just do it and move on. Get over whatever makes you not like it. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-07 Thread Stephen Hansen
examples to comment > > > if ("Please choose a state" in str(matches)): > if (var == "val" or var2 == "val2"): Gah, don't do that. You're adding meaningless noise. Especially in the first case. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-07 Thread Stephen Hansen
> Aside: I haven't tried, but is 'names' a bad idea or illegal for the > name of a python list or variable? Nothing wrong with names. Or 'name', for that matter. Try to avoid abbreviations. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-07 Thread Stephen Hansen
ist1)) and list1[j] are all indirection, when item1 is clearly (if given a better name then 'item1') something distinct you're working on. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Stephen Hansen
On Sat, May 7, 2016, at 12:17 PM, Christopher Reimer wrote: > On 5/5/2016 6:37 PM, Stephen Hansen wrote: > > On Thu, May 5, 2016, at 06:26 PM, Christopher Reimer wrote: > >> Which is one is correct (Pythonic)? Or does it matter? > > First, pylint is somewhat opinionated,

Re: pylint woes

2016-05-07 Thread Stephen Hansen
on on what is "good" or "bad" programming habits. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-07 Thread Stephen Hansen
"Consider using enumerate instead of iterating with range > and len" > > the offending code is: > for j in range(len(list1)): >do something with list1[j], list2[j], list3[j], etc. > > enumeration would be: > for j,item in enumerate(list1): >do something with

Re: Python is an Equal Opportunity Programming Language

2016-05-07 Thread Stephen Hansen
them in a disenfranchised position. Recognizing those faults and taking corrective action is fundamentally an act in the name of equality. Correcting for inequalities can not, itself, be a purely "equal" task done in pure blindness of the contextual reality of what is going on in the world. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Why do these statements evaluate the way they do?

2016-05-07 Thread Stephen Hansen
the only things you should use 'is' for is when comparing to singletons like None, True or False (And consider strongly not comparing against False/True with is, but instead just 'if thing' and if its True, it passes). Otherwise, 'is' should only be used when you&#

Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread Stephen Hansen
ep track of the references in your head to make sure things will get closed at proper times. The 'with' statement clearly defines when resources should be closed, so its preferred (As I see you've adopted from other responses). But its also needed in other Python implementations whic

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 07:46 PM, Dan Sommers wrote: > On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote: > > > ''.join(x for x in string if x.isupper()) > > > The difference is, both filter and your list comprehension *build a > > list* which i

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Stephen Hansen
list comprehension *build a list* which is not needed, and wasteful. The above skips building a list, instead returning a generator, and join pulls items out of it one at a time as it uses them. No needlessly creating a list only to use it and discard it. -- Stephen Hansen m e @ i x o k a i . i o

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
input. Um, no one said that. I was arguing that the *regular expression* doesn't need to be responsible for validation. > - Even if you do somehow end up with junk, there couldn't possibly be any > real consequences to that. No one said that either... > - It doesn't matte

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 05:31 AM, DFS wrote: > You are out of your mind. Whoa, now. I might disagree with Steven D'Aprano about how to approach this problem, but there's no need to be rude. Everyone's trying to help you, after all. -- Stephen Hansen m e @ i x o k a

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 10:43 AM, Steven D'Aprano wrote: > On Thu, 5 May 2016 11:32 pm, Stephen Hansen wrote: > > > On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: > >> Oh, a further thought... > >> > >> On Thursday 05 May 2016 16:46, Ste

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: > Oh, a further thought... > > On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > > I don't even care about faster: Its overly complicated. Sometimes a > > regular expression really is the clearest way t

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 12:04 AM, Steven D'Aprano wrote: > On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > > > On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: > >> Start by writing a function or a regex that will distinguish strings that > >&g

Re: Whittle it on down

2016-05-04 Thread Stephen Hansen
#x27;m all for the idea that one shouldn't go to regex when Python's powerful string type can answer the problem more clearly, but this seems to go out of its way to do otherwise. I don't even care about faster: Its overly complicated. Sometimes a regular expression really is the clearest

Re: Whittle it on down

2016-05-04 Thread Stephen Hansen
URTS PRIVATE', 'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & >>> FITNESS CLUBS', 'www.lafitness.com', 'HEALTH & FITNESS CLUBS', >>> 'www.lafitness.com', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & >>> GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', >>> 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS >>> TRAINERS', '5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact >>> Us', 'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', >>> 'Add/Update Listing', 'Business Profile Login', 'F.A.Q.'] Then: >>> pattern = re.compile(r"^[A-Z\s&]+$") >>> output = [x for x in list if pattern.match(x)] >>> output ['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS'] -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access

2016-05-04 Thread Stephen Hansen
hp?group=gmane.comp.db.sqlite.general > Any ideas? Sorry, I don't use Access. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Conditionals And Control Flows

2016-05-04 Thread Stephen Hansen
, "x and y" is false. If x is true, though, it'll return y. In this case, "x and y" will be a true thing if y is a true thing, and a false thing if y is a false thing. As you can see, all of this logic happens without ever using True or False. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: You gotta love a 2-line python solution

2016-05-03 Thread Stephen Hansen
On Mon, May 2, 2016, at 08:57 PM, jf...@ms4.hinet.net wrote: > Stephen Hansen at 2016/5/3 11:49:22AM wrote: > > On Mon, May 2, 2016, at 08:27 PM, jf...@ms4.hinet.net wrote: > > > But when I try to get this forum page, it does get a html file but can't > > > be vie

Re: Saving Consol outputs in a python script

2016-05-03 Thread Stephen Hansen
() Output will be a string, string has a splitlines method, etc. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: You gotta love a 2-line python solution

2016-05-02 Thread Stephen Hansen
On Mon, May 2, 2016, at 08:27 PM, jf...@ms4.hinet.net wrote: > But when I try to get this forum page, it does get a html file but can't > be viewed normally. What does that mean? -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to clean up list items?

2016-05-02 Thread Stephen Hansen
On Mon, May 2, 2016, at 11:09 AM, DFS wrote: > I'd prefer to get clean data in the first place, but I don't know a > better way to extract it from the HTML. Ah, right. I didn't know you were scraping HTML. Scraping HTML is rarely clean so you have to do a lot of cleanup. -

Re: Python3 html scraper that supports javascript

2016-05-02 Thread Stephen Hansen
rodu_dokumentarni_film/playlist.m3u8?foo=bar";> > > > but I can't come to that point. Why? As important as it is to show code, you need to show what actually happens and what error message is produced. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to clean up list items?

2016-05-02 Thread Stephen Hansen
2'] That said: list1 = [t.strip() for t in list1 if t and not t.isspace()] -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to retrieve and write html contents to file

2016-05-02 Thread Stephen Hansen
On Mon, May 2, 2016, at 12:37 AM, DFS wrote: > On 5/2/2016 2:27 AM, Stephen Hansen wrote: > > I'm again going back to the point of: its fast enough. When comparing > > two small numbers, "twice as slow" is meaningless. > > Speed is always meaningful. >

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Stephen Hansen
ame constant factor, at which point the difference is irrelevant. If you believe otherwise, demonstrate it. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: You gotta love a 2-line python solution

2016-05-01 Thread Stephen Hansen
ib.urlretrieve(webpage,webfile) WORKS > > webfile = "rD:\econpy001.html" The r is *outside* the string. Its: r"D:\econpy001.html" -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Code Opinion - Enumerate

2016-05-01 Thread Stephen Hansen
27;s too much noise to it, but in general: Using enumerate increases readability, and I use it whenever the idiom: for index, item in enumerate(thing): ... is used. Enumerate is your friend. Hug it. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: You gotta love a 2-line python solution

2016-05-01 Thread Stephen Hansen
On Sun, May 1, 2016, at 10:08 PM, DFS wrote: > On 5/2/2016 1:02 AM, Stephen Hansen wrote: > >> I actually use "D:\\file.html" in my code. > > > > Or you can do that. But the whole point of raw strings is not having to > > escape slashes :) > > >

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Stephen Hansen
. You haven't shown that. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Stephen Hansen
rt urllib2; r = urllib2.urlopen(webpage); f = open(filename, 'w'); f.write(r.read()); f.close();" 10 loops, best of 3: 175 msec per loop That's a whole lot less the 0.88secs. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Stephen Hansen
On Sun, May 1, 2016, at 09:50 PM, DFS wrote: > On 5/2/2016 12:40 AM, Chris Angelico wrote: > > On Mon, May 2, 2016 at 2:34 PM, Stephen Hansen wrote: > >> On Sun, May 1, 2016, at 09:06 PM, DFS wrote: > >>> Then I tested them in loops - the VBScript is MUCH faster: 0.

Re: You gotta love a 2-line python solution

2016-05-01 Thread Stephen Hansen
On Sun, May 1, 2016, at 09:51 PM, DFS wrote: > On 5/2/2016 12:31 AM, Stephen Hansen wrote: > > On Sun, May 1, 2016, at 08:39 PM, DFS wrote: > >> To save a webpage to a file: > >> - > >> 1. import url

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Stephen Hansen
s not fast enough for you? That's less then a second. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >