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: Line continuation and comments

2023-02-27 Thread Robert Latest via Python-list
Edmondo Giovannozzi wrote: > Il giorno mercoledì 22 febbraio 2023 alle 09:50:14 UTC+1 Robert Latest ha > scritto: >> I found myself building a complicated logical condition with many ands and >> ors which I made more manageable by putting the various terms on individual >> lines and breaking them w

Re: Line continuation and comments

2023-02-27 Thread Robert Latest via Python-list
Paul Bryan wrote: > Adding to this, there should be no reason now in recent versions of > Python to ever use line continuation. Black goes so far as to state > "backslashes are bad and should never be used": > > https://black.readthedocs.io/en/stable/the_black_code_style/ future_style.html#using-

Re: Line continuation and comments

2023-02-27 Thread Robert Latest via Python-list
Robert Latest wrote: > Paul Bryan wrote: >> Adding to this, there should be no reason now in recent versions of >> Python to ever use line continuation. Black goes so far as to state >> "backslashes are bad and should never be used": >> >> https://black.readthedocs.io/en/stable/the_black_code_style

How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
When matching a string against a longer string, where both strings have spaces in them, we need to escape the spaces.  This works (no spaces): import re example = 'abcdefabcdefabcdefg' find_string = "abc" for match in re.finditer(find_string, example):     print(match.start(), match.end()) Tha

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, [email protected] 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: 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: Python 3.10 Fizzbuzz

2023-02-27 Thread Rob Cliffe via Python-list
On 27/02/2023 21:04, Ethan Furman wrote: On 2/27/23 12:20, rbowman wrote: > "By using Black, you agree to cede control over minutiae of hand- > formatting. In return, Black gives you speed, determinism, and freedom > from pycodestyle nagging about formatting. You will save time and mental >

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
Yes, that's it.  I don't know how long it would have taken to find that detail with research through the voluminous re documentation.  Thanks very much.  Feb 27, 2023, 15:47 by [email protected]: > On 2023-02-27 23:11, Jen Kris via Python-list wrote: > >>

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
I went to the re module because the specified string may appear more than once in the string (in the code I'm writing).  For example:  a = "X - abc_degree + 1 + qq + abc_degree + 1"  b = "abc_degree + 1"  q = a.find(b) print(q) 4 So it correctly finds the start of the first instance, but not

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
string.count() only tells me there are N instances of the string; it does not say where they begin and end, as does re.finditer.  Feb 27, 2023, 16:20 by [email protected]: > Would string.count() work for you then? > > On Mon, Feb 27, 2023 at 5:16 PM Jen Kris via Python-list <

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
I haven't tested it either but it looks like it would work.  But for this case I prefer the relative simplicity of: example = 'X - abc_degree + 1 + qq + abc_degree + 1' find_string = re.escape('abc_degree + 1') for match in re.finditer(find_string, example):     print(match.start(), match.end())

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: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
hings that are far from the same such as matching two > repeated words of any kind in any case including "and and" and "so so" or > finding words that have multiple doubled letter as in the stereotypical > bookkeeper. In those cases, you may want even more than offset

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
Using str.startswith is a cool idea in this case.  But is it better than regex for performance or reliability?  Regex syntax is not a model of simplicity, but in my simple case it's not too difficult.  Feb 27, 2023, 18:52 by [email protected]: > On 2/27/2023 9:16 PM, [email protected]

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
I wrote my previous message before reading this.  Thank you for the test you ran -- it answers the question of performance.  You show that re.finditer is 30x faster, so that certainly recommends that over a simple loop, which introduces looping overhead.  Feb 28, 2023, 05:44 by li...@tompass

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jon Ribbens via Python-list
On 2023-02-28, Thomas Passin wrote: > On 2/28/2023 10:05 AM, Roel Schroeven wrote: >> Op 28/02/2023 om 14:35 schreef Thomas Passin: >>> On 2/28/2023 4:33 AM, Roel Schroeven wrote: [...] (2) Searching for a string in another string, in a performant way, is not as simple as it first

Re: Python 3.10 Fizzbuzz

2023-03-01 Thread Jon Ribbens via Python-list
On 2023-03-01, Simon Ward wrote: > On Tue, Feb 28, 2023 at 04:05:19PM -0500, [email protected] wrote: >>Is it rude to name something "black" to make it hard for some of us to >>remind them of the rules or claim that our personal style is so often >>the opposite that it should be called "whit

Re: How to fix this issue

2023-03-01 Thread Rob Cliffe via Python-list
On 01/03/2023 18:46, Thomas Passin wrote: If this is what actually happened, this particular behavior occurs because Python on Windows in a console terminates with a instead of the usual . I think you mean . -- https://mail.python.org/mailman/listinfo/python-list

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: Look free ID genertion (was: Is there a more efficient threading lock?)

2023-03-01 Thread Jon Ribbens via Python-list
On 2023-03-02, Chris Angelico wrote: > On Thu, 2 Mar 2023 at 08:01, <[email protected]> wrote: >> On 2023-03-01 at 14:35:35 -0500, >> [email protected] wrote: >> > What would have happened if all processors had been required to have >> > some low level instruction that effecti

Re: Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread Jon Ribbens via Python-list
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

Packing Problem

2023-03-02 Thread Rob Cliffe via Python-list
I found Hen Hanna's "packing" problem to be an intriguing one: Given a list of words:     ['APPLE', 'PIE', 'APRICOT', 'BANANA', 'CANDY'] find a string (in general non-unique) as short as possible which contains the letters of each of these words, in order, as a subsequence. It struck me as being

Re: Packing Problem

2023-03-02 Thread Rob Cliffe via Python-list
Slightly improved version (deals with multiple characters together instead of one at a time): # Pack.py def Pack(Words):     if not Words:     return ''     # The method is to build up the result by adding letters at the beginning     # and working forward, and by adding letters at the end,

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: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Greg Ewing via Python-list
On 4/03/23 7:51 am, [email protected] 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: 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: Cryptic software announcements (was: ANN: DIPY 1.6.0)

2023-03-05 Thread Rob Cliffe via Python-list
On 01/03/2023 00:13, Peter J. Holzer wrote: [This isn't specifically about DIPY, I've noticed the same thing in other announcements] On 2023-02-28 13:48:56 -0500, Eleftherios Garyfallidis wrote: Hello all, We are excited to announce a new release of DIPY: DIPY 1.6.0 is out from the oven!

Re: Cutting slices

2023-03-05 Thread Rob Cliffe via Python-list
On 05/03/2023 22:59, aapost wrote: On 3/5/23 17:43, Stefan Ram wrote:    The following behaviour of Python strikes me as being a bit    "irregular". 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 regu

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: 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: 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: 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, [email protected] 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: Feature migration

2023-03-08 Thread Greg Ewing via Python-list
On 9/03/23 8:29 am, [email protected] 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: 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: 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 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 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 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 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 4:00 pm, [email protected] 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: =- and -= snag

2023-03-14 Thread Jon Ribbens via Python-list
On 2023-03-13, Morten W. Petersen wrote: > I was working in Python today, and sat there scratching my head as the > numbers for calculations didn't add up. It went into negative numbers, > when that shouldn't have been possible. > > Turns out I had a very small typo, I had =- instead of -=. > > I

Re: =- and -= snag

2023-03-14 Thread Rob Cliffe via Python-list
On 14/03/2023 21:28, [email protected] wrote: TThere are people now trying to in some ways ruin the usability by putting in type hints that are ignored and although potentially helpful as in a linter evaluating it, instead often make it harder to read and write code if required to use it

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

Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list
I accidentally used 'argparse' like this in my Python 3.9 program: parser.add_argument ("-c, --clean", dest="clean", action="store_true") parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true") instead of: parser.add_argument ("-c", "--clean", dest="clean", action="store_

Re: Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list
Thomas Passin wrote: Are you trying to troll here? You just showed how you got an error with this construction, so why are you asking how to get an error with this construction? I meant (obviously), another error-message besides: error: unrecognized arguments: -cn Perhaps from 'parser.

Re: Packing Problem

2023-03-18 Thread Rob Cliffe via Python-list
f Rob Cliffe via Python-list Date: Thursday, March 2, 2023 at 2:12 PM To: [email protected] Subject: Re: Packing Problem *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Slightly improved version (deals with multiple charac

Re: Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list
Thomas Passin wrote: So please, try to think out how your questions will seem to the reader, and be clear about what you are asking.  You may not know the terminology that some other people use, but don't let that stop you from being clear about what you really need to find out.  Including more

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: How to get get_body() to work? (about email)

2023-03-20 Thread Jon Ribbens via Python-list
On 2023-03-19, Stefan Ram wrote: > Peng Yu writes: >>But when I try the following code, get_body() is not found. How to get >>get_body() to work? > > Did you know that this post of mine here was posted to > Usenet with a Python script I wrote? > > That Python script has a function to show t

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

2023-03-20 Thread Jon Ribbens via Python-list
On 2023-03-19, Stefan Ram wrote: > Jon Ribbens writes: >>(Also, I too find it annoying to have to avoid, but calling a local >>variable 'file' is somewhat suspect since it shadows the builtin.) > > Thanks for your remarks, but I'm not aware > of such a predefined name "file"! Ah, apparently

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

2023-03-20 Thread Jon Ribbens via Python-list
On 2023-03-19, Greg Ewing wrote: > 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 exist

How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
The base class: class Constraint(object): def __init__(self, strength):     super(Constraint, self).__init__()     self.strength = strength def satisfy(self, mark):     global planner     self.choose_method(mark) The subclass: class UrnaryConstraint(Constraint): def __init__

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
Thanks to Richard Damon and Peter Holzer for your replies.  I'm working through the call chain to understand better so I can post a followup question if needed.  Thanks again. Jen Mar 26, 2023, 19:21 by [email protected]: > On 3/26/23 1:43 PM, Jen Kris via Python-li

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
the choose_method in the UrnaryConstraint class because of "super(BinaryConstraint, self).__init__(strength)" in step 2 above?  Thanks for helping me clarify that.  Jen Mar 26, 2023, 18:55 by [email protected]: > On 2023-03-26 19:43:44 +0200, Jen Kris via Python-list wrote: &g

Re: How does a method of a subclass become a method of the base class?

2023-03-26 Thread Jen Kris via Python-list
Cameron, Thanks for your reply.  You are correct about the class definition lines – e.g. class EqualityConstraint(BinaryConstraint).  I didn’t post all of the code because this program is over 600 lines long.  It's DeltaBlue in the Python benchmark suite.  I’ve done some more work since thi

Re: How does a method of a subclass become a method of the base class?

2023-03-27 Thread Jen Kris via Python-list
Thanks to everyone who answered this question.  Your answers have helped a lot.  Jen Mar 27, 2023, 14:12 by [email protected]: > On 3/26/23 17:53, Jen Kris via Python-list wrote: > >> I’m asking all these question because I have worked in a procedural style >> for many

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: 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: 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: [Python-Dev] Small lament...

2023-04-04 Thread Greg Ewing via Python-list
On 4/04/23 2:09 pm, [email protected] 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: Weak Type Ability for Python

2023-04-13 Thread Greg Ewing via Python-list
On 14/04/23 4:55 am, [email protected] 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: 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: 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: Is npyscreen still alive?

2023-04-24 Thread Tim Daneliuk via Python-list
On 4/24/23 09:14, Stefan Ram wrote: Grant Edwards writes: The other big advantage of an ncurses program is that since curses support is in the std library, a curses app is simpler to distribute. IIRC curses is not in the standard library /on Windows/. I miss a platform independent (well

Re: Is npyscreen still alive?

2023-04-24 Thread Tim Daneliuk via Python-list
On 4/24/23 11:32, Grant Edwards wrote: On 2023-04-24, Grant Edwards wrote: The other big advantage of an ncurses program is that since curses support is in the std library, a curses app is simpler to distribute. Right now, the application is a single .py file you just copy to the destination

Re: Question regarding unexpected behavior in using __enter__ method

2023-04-25 Thread Rob Cliffe via Python-list
This puzzled me at first, but I think others have nailed it.  It is not to do with the 'with' statement, but with the way functions are defined. When a class is instantiated, as in x=X():     the instance object gets (at least in effect), as attributes, copies of functions defined *in the class*

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: 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: Python-pickle error

2023-05-09 Thread Tony Flury via Python-list
Charles, by your own admission, you deleted your pkl file, And your code doesn't write that pkl file (pickle.dumps(...) doesn't write a file it creates a new string and at no point will it write to the file : What you need is this : import pickle number=2 my_pickled_

Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Hi, Need some help, in the Python, I have a array of string var_array=["Opt1=DG","Opt1=DG2"] I need to call c library and pass var_array as parameter In the argtypes, how do I set up ctypes.POINTER(???) for var_array? func.argtypes=[ctypes.c_void_p,ctypes.c_int, ctypes.POINTER()] I

Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Awesome, thanks! On Thu, May 11, 2023 at 1:47 PM Eryk Sun wrote: > On 5/11/23, Jason Qian via Python-list wrote: > > > > in the Python, I have a array of string > > var_array=["Opt1=DG","Opt1=DG2"] > > I need to call c library and pass var_arra

PythonPath / sys.path

2023-05-14 Thread Grizzy Adams via Python-list
Hi All My first post (repeated) I am having a problem with PythonPath / sys.path I have a dir where I keep all my current work, but I can't seem to add it to PythonPath / sys.path When I try to import one of my modules I see >>>import My_Working_File Traceback (most recent call last): File

Re: PythonPath / sys.path

2023-05-14 Thread Grizzy Adams via Python-list
Sunday, May 14, 2023 at 11:11, Mats Wichmann wrote: Re: PythonPath / sys.path (at least in part) >On 5/14/23 10:43, Barry wrote: >> I take it you have business reasons to use an obsolete version python. >> Where did you get your version of python from? >In fact, a *nine* year old version of Pyt

Re: What to use instead of nntplib?

2023-05-16 Thread Grizzy Adams via Python-list
Tuesday, May 16, 2023 at 9:26, Alan Gauld wrote: Re: What to use instead of nntplib? (at least in part) >On 15/05/2023 22:11, Grant Edwards wrote: >> I got a nice warning today from the inews utility I use daily: >> >> DeprecationWarning: 'nntplib' is deprecated and slated for removal in >>

Help on ImportError('Error: Reinit is forbidden')

2023-05-17 Thread Jason Qian via Python-list
Hi, I Need some of your help. I have the following C code to import *Import python.* It works 99% of the time, but sometimes receives "*ImportError('Error: Reinit is forbidden')*". error. **We run multiple instances of the app parallelly. *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Ju

Learning tkinter

2023-05-18 Thread Rob Cliffe via Python-list
I am trying to learn tkinter. Several examples on the internet refer to a messagebox class (tkinter.messagebox). But: Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> impor

Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Jason Qian via Python-list
On Thu, May 18, 2023 at 3:53 AM Barry wrote: > > > > On 17 May 2023, at 20:35, Jason Qian via Python-list < > [email protected]> wrote: > > > >  Hi, > > > > I Need some of your help. > > > > I have the following C code to impor

Silly (maybe) question re imported module(s)

2023-05-18 Thread Grizzy Adams via Python-list
Morning All I'm working through the tutorial and running / saving work that I wish to keep and build on, most times I can save and (re)import later with no difference to when typed in console or editor and run with F5 (which saves before it can run) But sometimes saved work (albeit small) whe

Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Grizzy Adams via Python-list
Friday, May 19, 2023 at 12:25, Barry Scott wrote: Re: Silly (maybe) question re impor (at least in part) > > >> On 19 May 2023, at 07:44, Grizzy Adams via Python-list >> wrote: >> >> Morning All >> >> I'm working through the tutorial and runnin

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: 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: What to use instead of nntplib?

2023-05-22 Thread Jon Ribbens via Python-list
On 2023-05-22, Skip Montanaro wrote: >> My understanding is that nntplib isn't being erased from reality, >> it's merely being removed from the set of modules that are provided >> by default. >> >> I presume that once it's removed from the core, it will still be >> possible to install it via pip o

Re: Addition of a .= operator

2023-05-23 Thread Rob Cliffe via Python-list
On 20/05/2023 18:54, Alex Jando wrote: I have many times had situations where I had a variable of a certain type, all I cared about it was one of it's methods. For example: import hashlib hash = hashlib.sha256(b'word') hash = hash.

Re: Addition of a .= operator

2023-05-23 Thread Rob Cliffe via Python-list
This sort of code might be better as a single expression. For example: user = ( request.GET["user"] .decode("utf-8") .strip() .lower() ) user = orm.user.get(name=user) LOL.  And I thought I was the one with a (self-confessed) tendency to write too slick, dense, smart-alec

Re: Addition of a .= operator

2023-05-23 Thread Rob Cliffe via Python-list
On 23/05/2023 22:03, Peter J. Holzer wrote: On 2023-05-21 20:30:45 +0100, Rob Cliffe via Python-list wrote: On 20/05/2023 18:54, Alex Jando wrote: So what I'm suggesting is something like this: hash = hashlib.sha256(b'w

Tkinter docs?

2023-05-23 Thread Rob Cliffe via Python-list
I have recently started converting a large project to tkinter, starting with zero knowledge of tkinter.  (You are free to think: BAD IDEA. 😁) I am well aware that adopting a new tool always involves a learning curve, and that one is prone to think that things are more difficult than they are/sho

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: Tkinter docs?

2023-05-30 Thread Rob Cliffe via Python-list
Thanks to everyone who replied.  All replies were constructive, none were telling me to stop belly-aching. I forgot/omitted to state that it was I who wrote the original project (in a completely different language), making the task of re-writing it much less formidable.  And meaning that I am fa

Why does IDLE use a subprocess?

2023-05-30 Thread James Schaffler via Python-list
Originally posted to idle-dev, but thought this might be a better place. Let me know if it isn't. Hi, I was curious about the internals of IDLE, and noticed that IDLE uses executes user code in a "subprocess" that's separate from the Python interpreter that is running IDLE itself (which does t

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: 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: Why does IDLE use a subprocess?

2023-05-30 Thread James Schaffler via Python-list
On Tuesday, May 30th, 2023 at 9:14 PM, Greg Ewing wrote: > Globals you create by executing code in the REPL have their own > namespace. But everything else is shared -- builtins, imported > Python modules, imported C extension modules, etc. etc. Thanks for the explanation. Could you elaborate on p

Re: Why does IDLE use a subprocess?

2023-05-31 Thread James Schaffler via Python-list
On Tuesday, May 30th, 2023 at 10:18 PM, Chris Angelico wrote: > Yep, what you're seeing there is the namespace and nothing else. But > if you mess with an actual builtin object, it'll be changed for the > other interpreter too. > > > > > import ctypes > > > > ctypes.cast(id(42), ctypes.POINTER(cty

Re: f-string syntax deficiency?

2023-06-06 Thread Chris Angelico via Python-list
On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote: > (Recently there has been an effort to provide clearer and more useful > error messages; this seems to be a case where there is still room for > improvement: "SyntaxError: invalid syntax" doesn't immediately remind me > of that fact that 'return'

Re: f-string syntax deficiency?

2023-06-06 Thread Roel Schroeven via Python-list
Op 6/06/2023 om 16:48 schreef Chris Angelico via Python-list: On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote: > (Recently there has been an effort to provide clearer and more useful > error messages; this seems to be a case where there is still room for > improvement: "Syntax

Re: f-string syntax deficiency?

2023-06-06 Thread Mark Bourne via Python-list
Roel Schroeven wrote: Op 6/06/2023 om 16:08 schreef Chris Angelico: On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: > > The following f-string does not parse and gives syntax error on 3.11.3: > > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' > > However this expression, which is

[RELEASE] Python 3.11.4, 3.10.12, 3.9.17, 3.8.17, 3.7.17, and 3.12.0 beta 2 are now available

2023-06-07 Thread Łukasz Langa via Python-list
Greetings! Time for another combined release of six separate versions of Python! Before you scroll away to the download links Please

Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation

2023-06-07 Thread Florian Guilbault via Python-list
Dear Python Technical Team, I hope this email finds you well. I am reaching out to you today to seek assistance with an issue I am facing regarding the installation of 'pip' despite my numerous attempts to resolve the problem. Recently, I performed installation, uninstallation, and even repair op

Re: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation

2023-06-07 Thread Mats Wichmann via Python-list
On 6/7/23 10:08, MRAB via Python-list wrote: On 2023-06-07 15:54, Florian Guilbault via Python-list wrote: Dear Python Technical Team, I hope this email finds you well. I am reaching out to you today to seek assistance with an issue I am facing regarding the installation of 'pip'

<    14   15   16   17   18   19   20   21   22   23   >