Re: super().__init__() and bytes

2024-12-03 Thread Greg Ewing via Python-list
On 4/12/24 3:24 am, Roel Schroeven wrote: It's not entirely clear to me though how bytes.__new__ *can* set an object's value. Isn't __new__ also a regular function? Yes, but the __new__ methods of the builtin immutable objects (int, str, bytes, etc.) are implemented in C, and so are able to do

Re: FileNotFoundError thrown due to file name in file, rather than file itself

2024-11-12 Thread Greg Ewing via Python-list
On 13/11/24 8:10 am, Left Right wrote: since logs are designed to grow indefinitely, the natural response to this design property is log rotation. I don't see how writing logs to stderr solves that problem in any way. Whatever stderr is sent to still has a potentially unlimited amount of data t

Re: Two aces up Python's sleeve

2024-11-07 Thread Greg Ewing via Python-list
On 8/11/24 3:04 am, Mild Shock wrote: This only works for small integers. I guess this is because tagged pointers are used nowadays ? No, it's because integers in a certain small range are cached. Not sure what the actual range is nowadays, it used to be something like -5 to 256 I think. BT

Re: Specifying local dependency with Poetry

2024-11-05 Thread Greg Ewing via Python-list
On 6/11/24 4:13 am, Loris Bennett wrote: [tool.poetry.dependencies] python = "^3.6" first-package = "^1.6.0" Could not find a version that satisfies the requirement first-package<2.0.0,>=1.6.0 (from second-package==0.5.0) (from versions: ) No matching distribution found for first-package<2.0

doRe: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-03 Thread Greg Ewing via Python-list
On 3/10/24 11:48 am, Left Right wrote: So, streaming parsers (eg. SAX) are written for a regular language that approximates XML. SAX doesn't parse a whole XML document, it parses small pieces of it independently and passes them on. It's more like a lexical analyser than a parser in that respect

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-01 Thread Greg Ewing via Python-list
On 2/10/24 12:26 pm, avi.e.gr...@gmail.com wrote: The real problem is how the JSON is set up. If you take umpteen data structures and wrap them all in something like a list, then it may be a tad hard to stream as you may not necessarily be examining the contents till the list finishes gigabytes l

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-01 Thread Greg Ewing via Python-list
On 2/10/24 10:03 am, Left Right wrote: Consider also an interesting consequence of SCSI not being able to have infinite words: this means, besides other things that fsync() is nonsense! :) If you aren't familiar with the concept: UNIX filesystem API suggests that it's possible to destage arbitrar

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-01 Thread Greg Ewing via Python-list
On 1/10/24 8:34 am, Left Right wrote: You probably forgot that it has to be _streaming_. Suppose you parse the first digit: can you hand this information over to an external function to process the parsed data? -- No! because you don't know the magnitude yet. By that definition of "streaming",

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Greg Ewing via Python-list
On 9/09/24 2:13 am, Karsten Hilbert wrote: For what it's worth here's the current state of code: That code doesn't inspire much confidence in me. It's far too convoluted with too much micro-management of exceptions. I would much prefer to have just *one* place where exceptions are caught and l

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Greg Ewing via Python-list
On 8/09/24 11:03 pm, Jon Ribbens wrote: On 2024-09-08, Greg Ewing wrote: try: do something .commit() except: log something .rollback() What if there's an exception in your exception handler? I'd put the rollback in the 'finally' handler, so it's always called.

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Greg Ewing via Python-list
On 8/09/24 9:20 am, Karsten Hilbert wrote: try: do something except: log something finally: .commit() cadence is fairly Pythonic and elegant in that it ensures the the .commit() will always be reached regardless of exception

Re: Crash when launching python

2024-09-04 Thread Greg Ewing via Python-list
On 5/09/24 7:48 am, Barry Scott wrote: Beware that you cannot use print to stdout for a .app as its stdin/stdout do not go anywhere useful. You can invoke the executable inside the package from the Terminal. Normally it's in the .app/Contents/MacOS subdirectory. The name varies, but there's u

Re: Couldn't install numpy on Python 2.7

2024-06-12 Thread Greg Ewing via Python-list
On 13/06/24 4:31 am, avi.e.gr...@gmail.com wrote: It seems Microsoft is having a problem where something lik 2/3 of Windows users have not upgraded from Windows 10 after many years At least Python 3 is a clear improvement over Python 2 in many ways. Whereas the only thing Microsoft seems to hav

Re: Use of statement 'global' in scripts.

2024-05-08 Thread Greg Ewing via Python-list
On 8/05/24 1:32 pm, Popov, Dmitry Yu wrote: The statement 'global', indicating variables living in the global scope, is very suitable to be used in modules. I'm wondering whether in scripts, running at the top-level invocation of the interpreter, statement 'global' is used exactly the same way

Re: xkcd.com/353 ( Flying with Python )

2024-03-30 Thread Greg Ewing via Python-list
On 30/03/24 7:21 pm, HenHanna wrote: https://xkcd.com/1306/ what does  SIGIL   mean? I think its' a Perl term, referring to the $/@/# symbols in front of identifiers. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: GIL-Removal Project Takes Another Step (Posting On Python-List Prohibited)

2024-03-20 Thread Greg Ewing via Python-list
On 20/03/24 4:14 pm, Lawrence D'Oliveiro wrote: not to mention the latency when there isn’t quite enough memory for an allocation and you have to wait until the next GC run to proceed. Run the GC a thousand times a second, and the latency is still 1 millisecond. That's not the way it usually wo

Re: (Mastermind) puzzle (with 3 digits) -- Elegant (readable) code Sought

2024-02-27 Thread Greg Ewing via Python-list
On 26/02/24 12:45 pm, Lawrence D'Oliveiro wrote: def score(candidate, answer) : return \ ( sum(a == b for a, b in zip(candidate, answer)), sum ( i != j and a == b for i, a in enumerate(candidate)

Re: Await expressions (Posting On Python-List Prohibited)

2024-01-26 Thread Greg Ewing via Python-list
On 27/01/24 10:46 am, Stefan Ram wrote: But your explanation seems to have no mention of the "something" / "the awaitable object" part following the preposition "on". Shouldn't this awaitable object play a rôle in the explanation of what happens? If it helps at all, you can think of an

Re: Question about garbage collection

2024-01-16 Thread Greg Ewing via Python-list
On 17/01/24 1:01 am, Frank Millman wrote: I sometimes need to keep a reference from a transient object to a more permanent structure in my app. To save myself the extra step of removing all these references when the transient object is deleted, I make them weak references. I don't see how wea

Re: Question about garbage collection

2024-01-16 Thread Greg Ewing via Python-list
On 17/01/24 4:00 am, Chris Angelico wrote: class Form: def __init__(self): self.elements = [] class Element: def __init__(self, form): self.form = form form.elements.append(self) If you make the reference from Element to Form a weak reference, it won't keep

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-15 Thread Greg Ewing via Python-list
On 16/01/24 11:55 am, Mats Wichmann wrote: Windows natively has something called python.exe and python3.exe which is interfering here I'm wondering whether py.exe should be taught to recognise these stubs and ignore them. This sounds like something that could trip a lot of people up. -- Greg

Re: Extract lines from file, add to new files

2024-01-15 Thread Greg Ewing via Python-list
On 15/01/24 9:07 pm, Chris Angelico wrote: The grammar *can't* specify everything. If it did, it would have to have rules for combining individual letters into a NAME and individual characters into a string literal. The lexical level of a grammar can be, and often is, described formally using r

Re: Extract lines from file, add to new files

2024-01-15 Thread Greg Ewing via Python-list
On 15/01/24 1:54 pm, dn wrote: Soon after, Wirth simplified rather than expanded, and developed Pascal. Before Pascal there was Algol-W, which Wirth invented as a rebellion against how complicated Algol 68 was becoming. When I first saw this I was stunned, then attracted to its simplicity, bu

Re: Extract lines from file, add to new files

2024-01-14 Thread Greg Ewing via Python-list
On 15/01/24 1:28 am, Left Right wrote: Python isn't a context-free language, so the grammar that is used to describe it doesn't actually describe the language Very few languages have a formal grammar that *fully* describes the set of strings that constitute valid programs, including all the rul

Re: Extract lines from file, add to new files

2024-01-14 Thread Greg Ewing via Python-list
On 13/01/24 11:34 pm, Left Right wrote: To make this shorter, Python allows: for in ... : ... Um, no, it doesn't. An assignment target is not, on its own, a statement. It's hard to make sense of what you're saying. You seem to be surprised by the fact that Python doesn't require variables t

Re: Extract lines from file, add to new files

2024-01-13 Thread Greg Ewing via Python-list
On 13/01/24 3:14 pm, Chris Angelico wrote: On Sat, 13 Jan 2024 at 13:11, Left Right via Python-list wrote: Very few languages allow arbitrary complex expressions in the same place they allow variable introduction. What do you mean by this? Most languages I've worked with allow variables to

Re: Extract lines from file, add to new files

2024-01-13 Thread Greg Ewing via Python-list
On 13/01/24 1:45 pm, Left Right wrote: I use the term "destructuring" in the same way Hyperspec uses it. It's not a Python term. I don't know what you call the same thing in Python. I'm not sure what you understand from it. I thought you meant what is usually called "unpacking" in Python. I

Re: Extract lines from file, add to new files

2024-01-12 Thread Greg Ewing via Python-list
On 13/01/24 12:11 am, Left Right wrote: x = [...] for x[i] in x: print(i) I suspect you've misremembered something, because this doesn't do anything surprising for me: >>> x = [1, 2, 3] >>> for x[i] in x: print(i) ... Traceback (most recent call last): File "", line 1, in NameErro

Re: mypy question

2023-12-30 Thread Greg Ewing via Python-list
On 31/12/23 10:06 am, Thomas Passin wrote: my suggestion above does work, *except* that you cannot mix-and-match different DictTypex types Have you tried declaring the argument as a Mapping instead of a dict? Seeing as Thomas Passin's Sequence experiment worked, it seems like this should work t

Re: Aw: Re: mypy question

2023-12-30 Thread Greg Ewing via Python-list
On 31/12/23 8:05 am, Chris Angelico wrote: Ah, I think you've hit on the problem there. Consider this: def add_item(stuff: dict[str: str | int]): stuff["spam"] = "ham" stuff["vooom"] = 1_000_000 Yep, that's it exactly. It's not the union itself that's the problem, but the fact that t

Re: mypy question

2023-12-29 Thread Greg Ewing via Python-list
On 30/12/23 4:02 am, Karsten Hilbert wrote: def run_rw_queries ( link_obj:_TLnkObj=None, queries:list[dict[str, str | list | dict[str, Any]]]=None, Given that I would have thought that passing in list[dict[str, str]] for "queries" ought to be type safe.

Re: Context without manager

2023-11-26 Thread Greg Ewing via Python-list
On 27/11/23 5:03 pm, Grant Edwards wrote: I should probably have written "how to fool that into working when he's not using a 'with' statement" It should be possible to run the context protocol yourself. Something like (warning, untested): class MyDeviceWrapper: def __init__(self

Re: Context without manager

2023-11-26 Thread Greg Ewing via Python-list
On 27/11/23 9:03 am, Stefan Ram wrote: Above, "have" is followed by another verb in "have been", so it should be eligible for a contraction there! Yes, "been" is the past participle of 'to be", so "I've been" is fine. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: on a tail-recursive square-and-multiply

2023-11-07 Thread Greg Ewing via Python-list
On 8/11/23 2:26 pm, Julieta Shem wrote: For the first time I'm trying to write a tail-recursive square-and-multiply and, even though it /seems/ to work, I'm not happy with what I wrote and I don't seem to understand it so well. Stepping back a bit, why do you feel the need to write this tail-re

Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Greg Ewing via Python-list
On 8/11/23 8:10 am, MRAB wrote: Something to do with how scoping is implemented in comprehensions? Yes, together with the way class scopes work during class construction. Behind the scenes, the body of a listcomp happens to be implemented as a nested function. Usually you don't notice this, b

Re: Checking if email is valid

2023-11-06 Thread Greg Ewing via Python-list
On 6/11/23 6:34 pm, rbowman wrote: We've found even if you directly ask the user often the answer is 'I dunno' or some mythology they have constructed to explain the problem. This seems to apply to hardware issues as well. Louis Rossmann has a philosophy of "Never believe what the customer tell

Re: Checking if email is valid

2023-11-06 Thread Greg Ewing via Python-list
On 7/11/23 7:45 am, Mats Wichmann wrote: Continuing with the example, if you have a single phone number field, or let a mobile number be entered in a field marked for landline, you will probably assume you can text to that number. But if the site can detect that you've entered a mobile number

Re: Question(s)

2023-10-27 Thread Greg Ewing via Python-list
On 25/10/23 2:32 pm, Chris Angelico wrote: Error correcting memory, redundant systems, and human monitoring, plus the ability to rewrite the guidance software on the fly if they needed to. Although the latter couldn't actually be done with the AGC, as the software was in ROM. They could poke va

Re: type annotation vs working code

2023-10-03 Thread Greg Ewing via Python-list
On 4/10/23 5:25 pm, dn wrote: The first question when dealing with the Singleton Pattern is what to do when more than one instantiation is attempted My preferred way of handling singletons is not to expose the class itself, but a function that creates an instance the first time it's called, and

Re: Dynamically modifying "__setattr__"

2023-09-29 Thread Greg Ewing via Python-list
On 28/09/23 10:44 pm, Stefan Ram wrote: class A: def __init__( self ): self.__setattr__ = self.setattr def setattr( self, key, value ): print( 'setattr called.' ) Any idea how to achieve something like this? class A: def __init__(self): self.x = 17

Re: error of opening Python

2023-09-26 Thread Greg Ewing via Python-list
On 27/09/23 3:30 pm, Chris Roy-Smith wrote: surely running a 64 bit version of python in a 23mbit version of windows will cause significant problems! 23 millibits? I don't think you'd be able to run much at all with that few bits! :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-

Re: []=[]

2023-09-22 Thread Greg Ewing via Python-list
On 23/09/23 4:51 am, Stefan Ram wrote: []=[] (Executes with no error.) # []=[] ( 1 ) #\_/# (Executes with no error.) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Getty fully qualified class name from class object

2023-08-22 Thread Greg Ewing via Python-list
On 23/08/23 2:45 am, Ian Pilcher wrote: How can I programmatically get 'logging.Handler' from the class object? Classes have a __module__ attribute: >>> logging.Handler.__module__ 'logging' -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Greg Ewing via Python-list
On 17/08/23 7:10 pm, c.bu...@posteo.jp wrote: def foobar(translate):     if not translate:     # I try to mask the global _() builtins-function     def _(txt):     return txt     return _('Hello') This causes _ to become a local that is left undefined on one branch of the

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Greg Ewing via Python-list
On 5/07/23 10:33 am, Alan Gauld wrote: (*) C++ is the odd one out because it doesn't have GC, but then neither does it have an Object superclass so very often MI in C++ does not involve creating diamonds! And especially if the MI style is mixin based. Even if all your mixins have empty construc

Re: Should NoneType be iterable?

2023-06-20 Thread Greg Ewing via Python-list
On 20/06/23 7:36 pm, Barry wrote: I have some APIs that do return None or a list. The None says that a list is not available and that the caller is responsible with dealing in a application-domain specific with with that situation. In that case, the caller should probably be checking for None r

Re: Should NoneType be iterable?

2023-06-19 Thread Greg Ewing via Python-list
I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Match statement with literal strings

2023-06-07 Thread Greg Ewing via Python-list
On 8/06/23 10:18 am, Jason Friedman wrote: SyntaxError: name capture 'RANGE' makes remaining patterns unreachable The bytecode compiler doesn't know that you intend RANGE to be a constant -- it thinks it's a variable to bind a value to. To make this work you need to find a way to refer to the

Re: Why does IDLE use a subprocess?

2023-05-30 Thread Greg Ewing via Python-list
On 29/05/23 8:10 am, James Schaffler wrote: However, some minimal testing of InteractiveInterpreter leads me to believe that the Interpreter object has its own view of local/global variables and therefore shouldn't be able to affect the calling interpreter Globals you create by executing code

Re: What to use instead of nntplib?

2023-05-30 Thread Greg Ewing via Python-list
On 31/05/23 8:44 am, aapost wrote: Even if I did partake in the modern github style of code distribution, how many packages have issues where the "maintainers" inherited the package and really haven't dug deep enough in to the code to see how it really works. They have issues that sit around fo

Re: Does os.path relpath produce an incorrect relative path?

2023-05-25 Thread Greg Ewing via Python-list
On 25/05/23 7:49 pm, BlindAnagram wrote: The first of these three results produces an incorrect relative path because relpath does not strip off any non-directory tails before comparing paths. It has no way of knowing whether a pathname component is a directory or not. It's purely an operation

Re: Addition of a .= operator

2023-05-20 Thread Greg Ewing via Python-list
On 21/05/23 9:18 am, Richard Damon wrote: This just can't happen (as far as I can figure) for .= unless the object is defining something weird for the inplace version of the operation, Indeed. There are clear use cases for overriding +=, but it's hard to think of one for this. So it would just

Re: Addition of a .= operator

2023-05-20 Thread Greg Ewing via Python-list
On 21/05/23 5:54 am, Alex Jando wrote: hash.=hexdigest() That would be a very strange and unprecedented syntax that munges together an attribute lookup and a call. Keep in mind that a method call in Python is actually two separate things: y = x.m() is equivalent to f = x.m y = f() But it

Re: An "adapter", superset of an iterator

2023-05-03 Thread Greg Ewing via Python-list
On 4/05/23 9:29 am, Chris Angelico wrote: So you're asking for map to be able to return an iterator if given an iterator, or an adapter if given an adapter. That makes it quite complicated to use and reason about. Also a bit slower, since it would need to inspect its argument and decide what to

Re: How to 'ignore' an error in Python?

2023-04-29 Thread Greg Ewing via Python-list
On 30/04/23 2:43 am, jak wrote: Maybe I expressed myself badly but I didn't mean to propose alternatives to the EAFP way but just to evaluate the possibility that it is not a folder. If it's not a folder, you'll find out when the next thing you try to do to it fails. You could check for it ear

Re: Incomplete sys.path with embeddable python (Windows)!?

2023-04-22 Thread Greg Ewing via Python-list
On 23/04/23 10:04 am, Ralf M. wrote: I thought about that, but for that to work all local modules across all script locations must have unique names, otherwise import might get hold of a module from the wrong directory. You could put all the local modules belonging to a particular script into

Re: Incomplete sys.path with embeddable python (Windows)!?

2023-04-21 Thread Greg Ewing via Python-list
How are you invoking your script? Presumably you have some code in your embedding application that takes a script path and runs it. Instead of putting the code to update sys.path into every script, the embedding application could do it before running the script. -- Greg -- https://mail.python.org

Re: Weak Type Ability for Python

2023-04-13 Thread Greg Ewing via Python-list
On 14/04/23 4:55 am, avi.e.gr...@gmail.com wrote: While we are at it, why stop with imaginary numbers when you can imagine extensions thereof? Unfortunately, it has been proven there are and can only be two additional such constructs. You can go beyond that if you broaden your horizons enough.

Re: [Python-Dev] Small lament...

2023-04-04 Thread Greg Ewing via Python-list
On 4/04/23 2:09 pm, avi.e.gr...@gmail.com wrote: Sadly, between Daylight Savings time and a newer irrational PI π Day, I am afraid some April Foolers got thrown off albeit some may shower us with nonsense in May I. Pi day isn't responsible, but it is because of changes to daylight saving. T

Re: How to add clickable url links to 3D Matplotlib chart ?

2023-03-29 Thread Greg Ewing via Python-list
On 30/03/23 8:39 am, a a wrote: How to add clickable url links to the following 3D Matplotlib chart to make it knowledge representation 3D chart, make of 1,000+ open Tabs in Firefox ? It seems that matplotlib can be made to generate SVG images with hyperlinks in them: https://matplotlib.org/s

Re: What kind of "thread safe" are deque's actually?

2023-03-29 Thread Greg Ewing via Python-list
On 30/03/23 6:13 am, Chris Angelico wrote: I'm not sure what would happen in a GIL-free world but most likely the lock on the input object would still ensure thread safety. In a GIL-free world, I would not expect deque to hold a lock the entire time that something was iterating over it. That wo

Re: What kind of "thread safe" are deque's actually?

2023-03-28 Thread Greg Ewing via Python-list
On 28/03/23 2:25 pm, Travis Griggs wrote: Interestingly the error also only started showing up when I switched from running a statistics.mean() on one of these, instead of what I had been using, a statistics.median(). Apparently the kind of iteration done in a mean, is more conflict prone than

Re: How to get get_body() to work? (about email)

2023-03-19 Thread Greg Ewing via Python-list
On 20/03/23 7:07 am, Jon Ribbens wrote: Ah, apparently it got removed in Python 3, which is a bit odd as the last I heard it was added in Python 2.2 in order to achieve consistency with other types. As far as I remember, the file type came into existence with type/class unification, and "open"

Re: We can call methods of parenet class without initliaze it?

2023-03-15 Thread Greg Ewing via Python-list
On 15/03/23 10:57 pm, scruel tao wrote: How can I understand this? Will it be a problem? I can't remember any details offhand, but I know I've occasionally made use of the ability to do this. It's fine as long as the method you're calling doesn't rely on anything you haven't initialised yet. -

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 4:00 pm, 2qdxy4rzwzuui...@potatochowder.com wrote: My ~/.pythonrc contains the following: import readline import rlcompleter readline.parse_and_bind( 'tab: complete' ) I don't have a ~/.pythonrc, so that's not what's doing it for me. -- Greg -- https://mail.python.o

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 2:57 pm, Chris Angelico wrote: import sys; "readline" in sys.modules Is it? Yes, it is -- but only when using the repl! If I put that in a script, I get False. My current theory is that it gets pre-imported when using Python interactively because the repl itself uses it. -- Greg

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 1:46 pm, Grant Edwards wrote: That's not how it acts for me. I have to "import readline" to get command line recall and editing. Maybe this has changed? Or is platform dependent? With Python 3.8 on MacOSX I can use up arrow with input() to recall stuff I've typed before, without ha

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 12:43 pm, Grant Edwards wrote: When a computer dies, I generally just cp -a (or rsync -a) $HOME to a new one. Same here, more or less. My current machine has multiple archaeological layers going back about 5 generations of technology... -- Greg -- https://mail.python.org/mailman/li

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 11:43 am, Chris Angelico wrote: import readline print("Pseudo-prompt: ", end="") msg1 = input() msg2 = input("Actual prompt: ") print(repr(msg1)) print(repr(msg2)) At each of the prompts, type a bit of text, then backspace it all the way. The actual prompt will remain, but the pseudo

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 10:59 am, Cameron Simpson wrote: I think this might be the common case of a module which wraps another library It's not quite the same thing, though -- the library it wraps is already hooked into things behind the scenes in ways that may not be obvious. (Unless you're Dutch?) -- Gr

Re: Baffled by readline module

2023-03-09 Thread Greg Ewing via Python-list
On 10/03/23 10:08 am, Grant Edwards wrote: It finally dawned on me after seeing an example I found elsewhere that you don't call some module method to fetch the next user-entered line. You call the input() built-in. Having a module modify the behavior of a built-in makes me cringe. Importing

Re: Feature migration

2023-03-08 Thread Greg Ewing via Python-list
On 9/03/23 8:29 am, avi.e.gr...@gmail.com wrote: They seem to be partially copying from python a feature that now appears everywhere but yet strive for some backwards compatibility. They simplified the heck out of all kinds of expressions by using INDENTATION. It's possible this was at least pa

Re: Fast full-text searching in Python (job for Whoosh?)

2023-03-06 Thread Greg Ewing via Python-list
On 7/03/23 6:49 am, avi.e.gr...@gmail.com wrote: But the example given wanted to match something like "V6" in middle of the text and I do not see how that would work as you would now need to search 26 dictionaries completely. It might even make things worse, as there is likely to be a lot of

Re: Fast full-text searching in Python (job for Whoosh?)

2023-03-06 Thread Greg Ewing via Python-list
On 7/03/23 4:35 am, Weatherby,Gerard wrote: If mailing space is a consideration, we could all help by keeping our replies short and to the point. Indeed. A thread or two of untrimmed quoted messages is probably more data than Dino posted! -- Greg -- https://mail.python.org/mailman/listinfo/p

Re: Cutting slices

2023-03-05 Thread Greg Ewing via Python-list
On 6/03/23 11:43 am, Stefan Ram wrote: A user tries to chop of sections from a string, but does not use "split" because the separator might become more complicated so that a regular expression will be required to find it. What's wrong with re.split() in that case? -- Greg -- https:

Re: Bug 3.11.x behavioral, open file buffers not flushed til file closed.

2023-03-05 Thread Greg Ewing via Python-list
On 6/03/23 1:02 pm, Cameron Simpson wrote: Also, fsync() need not expedite the data getting to disc. It is equally valid that it just blocks your programme _until_ the data have gone to disc. Or until it *thinks* the data has gone to the disk. Some drives do buffering of their own, which may i

Re: Fast full-text searching in Python (job for Whoosh?)

2023-03-04 Thread Greg Ewing via Python-list
On 5/03/23 5:12 pm, Dino wrote: I can do a substring search in a list of 30k elements in less than 2ms with Python. Is my reasoning sound? I just did a similar test with your actual data and got about the same result. If that's fast enough for you, then you don't need to do anything fancy. --

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Greg Ewing via Python-list
On 4/03/23 7:51 am, avi.e.gr...@gmail.com wrote: I leave you with the question of the day. Was Voldemort pythonic? Well, he was fluent in Parseltongue, which is not a good sign. I hope not, otherwise we'll have to rename Python to "The Language That Shall Not Be Named" and watch out for horcr

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Greg Ewing via Python-list
On 3/03/23 9:54 am, Ian Pilcher wrote: I haven't found anything that talks about which form is considered to be more Pythonic in those situations where there's no functional difference. In such cases I'd probably go for type(x), because it looks less ugly. x.__class__ *might* be slightly more

Re: Python 3.10 Fizzbuzz

2023-03-01 Thread Greg Ewing via Python-list
On 2/03/23 10:59 am, gene heskett wrote: Human skin always has the same color Um... no? -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-27 Thread Greg Ewing via Python-list
On 28/02/23 4:24 pm, Hen Hanna wrote: is it poss. to peek at the Python-list's messages without joining ? It's mirrored to the comp.lang.python usenet group, or you can read it through gmane with a news client. -- Greg -- https://mail.python.org/mailman/listinfo/py

Re: Python 3.10 Fizzbuzz

2023-02-27 Thread Greg Ewing via Python-list
On 28/02/23 5:08 am, Thomas Passin wrote: On 2/27/2023 11:01 AM, Mats Wichmann wrote: If you intend to run Black on your code to ensure consistent formatting, you may as well learn to prefer double quotes, because it's going to convert single to double I prefer single quotes because they are

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Greg Ewing via Python-list
On 28/02/23 7:40 am, avi.e.gr...@gmail.com wrote: inhahe made the point that this may not have been the original intent for python and may be a sort of bug that it is too late to fix. Guido has publically stated that it was a deliberate design choice. The merits of that design choice can be d

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Greg Ewing via Python-list
On 27/02/23 10:07 pm, Roel Schroeven wrote: I'm guessing you're thinking about variables leaking out of list comprehensions. I seem to remember (but I could be wrong) it was a design mistake rather than a bug in the code, but in any case it's been fixed now (in the 2 to 3 transition, I think).

Re: TypeError: can only concatenate str (not "int") to str

2023-02-25 Thread Greg Ewing via Python-list
On 26/02/23 10:53 am, Paul Rubin wrote: I'm not on either list but the purpose of the tutor list is to shunt beginner questions away from the main list. There's a fundamental problem with tutor lists. They rely on experienced people, the ones capable of answering the questions, to go out of the

Re: semi colonic

2023-02-23 Thread Greg Ewing via Python-list
On 24/02/23 9:26 am, avi.e.gr...@gmail.com wrote: Python One-Liners: Write Concise, Eloquent Python Like a Professional Illustrated Edition by Christian Mayer (Author) I didn't know there were any Professional Illustrated Editions writing Pythom. You learn something every day! :-) -- Greg --

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 9:37 am, Hen Hanna wrote: for the first several weeks... whenever i used Python... all i could think ofwas this is really Lisp (inside) with a thin veil of Java/Pascal syntax.. - that everything is first converted

Re: semi colonic

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 1:58 pm, avi.e.gr...@gmail.com wrote: Would anything serious break if it was deprecated for use as a statement terminator? Well, it would break all the code of people who like to write code that way. They might get a bit miffed if we decide that their code is not serious. :-) On t

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 9:12 am, Hen Hanna wrote: On Wednesday, February 22, 2023 at 2:32:57 AM UTC-8, Anton Shepelev wrote: def f(a): print(black_magic(a))# or black_magic('a') f(v1)# prints: v1 f(v2)# prints: v2 the ter

Re: Precision Tail-off?

2023-02-17 Thread Greg Ewing via Python-list
On 18/02/23 7:42 am, Richard Damon wrote: On 2/17/23 5:27 AM, Stephen Tucker wrote: None of the digits in RootNZZZ's string should be different from the corresponding digits in RootN. Only if the storage format was DECIMAL. Note that using decimal wouldn't eliminate this particular problem,

Re: ChatGPT Generated news poster code

2023-02-10 Thread Greg Ewing via Python-list
For a moment I thought this was going to be a script that uses ChatGPT to generate a random news post and post it to Usenet... Which would also have been kind of cool, as long as it wasn't overused. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Organizing modules and their code

2023-02-05 Thread Greg Ewing via Python-list
On 6/02/23 4:23 am, Weatherby,Gerard wrote: Well, first of all, while there is no doubt as to Dijkstra’s contribution to computer science, I don’t think his description of scientific thought is correct. The acceptance of Einstein’s theory of relativity has nothing to do with internal consisten

Re: Organizing modules and their code

2023-02-04 Thread Greg Ewing via Python-list
On 5/02/23 11:18 am, transreductionist wrote: This analogy came to me the other day. For me, I would rather walk into a grocery store where the bananas, apples, and oranges are separated in to their own bins, instead of one common crate. On the other hand, if the store has an entire aisle dev

Re: Is it possible to inheret a metaclass.

2020-04-10 Thread Greg Ewing via Python-list
On 11/04/20 12:19 am, Pieter van Oostrum wrote: Your Pardon is not a class, it is a function. To elaborate on that a bit, the way inheritance of metaclasses works is that when you define a class, if you don't explicity specify a metaclass, it uses the class of the base class as the metaclass.