Re: Find the path of a shell command

2022-10-13 Thread Jon Ribbens via Python-list
be symlinks to the same place). >>> >>>> A short idea is to just check /bin/rm and /usr/bin/rm, but I prefer >>>> searching thru PATH env. It only needs to do that once. >>> >>> I cannot think of any situation in which that will help you. But if for >>> some reason you really want to do that, you can use the shutil.which() >>> function from the standard library: >>> >>> >>> import shutil >>> >>> shutil.which('rm') >>> '/usr/bin/rm' >> >> Actually if I'm mentioning shutil I should probably mention >> shutil.rmtree() as well, which does the same as 'rm -r', without >> needing to find or run any other executables. > Except that you can't have parallel tasks, at least in an easy way. > Using Popen I just launch rm's and end the script. [threading.Thread(target=shutil.rmtree, args=(item,)).start() for item in items_to_delete] -- https://mail.python.org/mailman/listinfo/python-list

Re: for -- else: what was the motivation?

2022-10-14 Thread Rob Cliffe via Python-list
(f"server tag not found in {lfile}") I think there are other places I could be using it, but honestly I tend to forget it’s available. From: Python-list on behalf of Stefan Ram Date: Wednesday, October 12, 2022 at 2:22 PM To: python-list@python.org Subject: Re: for -- else: what was t

Re: for -- else: what was the motivation?

2022-10-17 Thread Robert Latest via Python-list
ade > sense, there is no such need now as Python has made a choice that meets the > need even if few may dare use it or even know about it! LOL! -- https://mail.python.org/mailman/listinfo/python-list

xml.etree and namespaces -- why?

2022-10-19 Thread Robert Latest via Python-list
xmlns:' attributes have been deleted by the parser xml = ''' http://www.inkscape.org/namespaces/inkscape"; xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"; xmlns="http://www.w3.org/2000/svg"; xmlns:svg="http://www.w3.org/2000/svg";> ''' if __name__ == '__main__': test_svg(xml) -- https://mail.python.org/mailman/listinfo/python-list

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Jon Ribbens via Python-list
espaces/inkscape'} element = root.find('inkspace:foo', namespaces) which will work for both of the above pieces of XML. But unfortunately as far as I can see nobody's thought about doing the same for attributes rather than tags. -- https://mail.python.org/mailman/listinfo/python-list

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Robert Latest via Python-list
x27;s generator to not change their prefixes. BTW, I only now thought to look at what actually is at Inkscape's namespace URI, and it turns out to be quite a nice explanation of what a namespace is and why it looks like a URL. -- https://mail.python.org/mailman/listinfo/python-list

Re: Need help with custom string formatter

2022-10-21 Thread Robert Latest via Python-list
it()? > return super().format_field( value, format_string ) Why do you prefer super().format_field() over plain format()? The doc says: "format_field() simply calls format()." So I figured I might do the same. Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Need help with custom string formatter

2022-10-21 Thread Robert Latest via Python-list
return obj, key def get_value(self, key, a, kw): '''I don't understand what this method is for, it never gets called''' raise NotImplementedError fmt = MagicString(format_spec) print('\nReal output:') print(fmt.format(o=o, z=z)) # Weirdly, somewhere on the way the standard formatting kicks in, too, as # the 'Pad me!' string does get padded (which must be some postprocessing, # as the string is still unpadded when passed into get_field()) -- https://mail.python.org/mailman/listinfo/python-list

Re: Need help with custom string formatter

2022-10-21 Thread Robert Latest via Python-list
n.org/mailman/listinfo/python-list

Re: Need help with custom string formatter

2022-10-22 Thread Robert Latest via Python-list
). > > So I'd take Stefan's statement above to imply that calling format() > directly should work. Yup, makes sense. -- https://mail.python.org/mailman/listinfo/python-list

Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Jon Ribbens via Python-list
into this: Minimal HTML file Minimal HTML file This is a minimal HTML file. Adding in the omitted , , , , and would make no difference and there's no particular reason to recommend doing so as far as I'm aware. -- https://mail.python.org/mailman/listinfo/python-list

Re: Beautiful Soup - close tags more promptly?

2022-10-24 Thread Jon Ribbens via Python-list
On 2022-10-24, Chris Angelico wrote: > On Tue, 25 Oct 2022 at 02:45, Jon Ribbens via Python-list > wrote: >> >> On 2022-10-24, Chris Angelico wrote: >> > On Mon, 24 Oct 2022 at 23:22, Peter J. Holzer wrote: >> >> Yes, I got that. What I wanted

Re: Persisting functions typed into the shell

2022-11-12 Thread Wayne Harris via Python-list
; So much for the topic of "In Python, /everything/ is an > object"! There seem to be first and second-class objects: > Shelveable and non-shelveable objects. Wow. Could the dis module help at all? Say by getting the bytes of the compiled function and then saving them to a file, then reading them off later and rebuilding the function with dis again? -- https://mail.python.org/mailman/listinfo/python-list

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Jon Ribbens via Python-list
nd print its length""" array = [1, 2, 3] array.clear print(len(array)) $ pylint -s n test.py * Module test test.py:4:0: W0104: Statement seems to have no effect (pointless-statement) -- https://mail.python.org/mailman/listinfo/python-list

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Jon Ribbens via Python-list
>"""Create an array and print its length""" >> >>array = [1, 2, 3] >>array.clear >>print(len(array)) >>$ pylint -s n test.py >>* Module test >>test.py:4:0: W0104: Statement seems to have no effect >> (pointless-statement) > > > Thanks, I should use linters more often. > > But why is it allowed in the first place? Because it's an expression, and you're allowed to execute expressions. -- https://mail.python.org/mailman/listinfo/python-list

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread Jon Ribbens via Python-list
more clearly, you're allowed to evaluate > an expression and ignore the result. ... because it may have side effects, and it's not possible to determine whether it will or not in advance. -- https://mail.python.org/mailman/listinfo/python-list

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-14 Thread Jon Ribbens via Python-list
> """Create an array and print its length""" > > . Apparently, linters know this and will not create > a warning for such string literals. Not only do they know this, pylint will complain if you *don't* include that line, which is why I included it ;-) -- https://mail.python.org/mailman/listinfo/python-list

Debugging Python C extensions with GDB

2022-11-14 Thread Jen Kris via Python-list
called from ctypes  -- that is not written using the C_API?  Thanks.  Jen -- https://mail.python.org/mailman/listinfo/python-list

Re: Debugging Python C extensions with GDB

2022-11-14 Thread Jen Kris via Python-list
Thanks for your reply.  Victor's article didn't mention ctypes extensions, so I wanted to post a question before I build from source.  Nov 14, 2022, 14:32 by ba...@barrys-emacs.org: > > >> On 14 Nov 2022, at 19:10, Jen Kris via Python-list >> wrote: >> >

Re: is mypy failing here

2022-11-24 Thread Kirill Ratkin via Python-list
osed to be a str and I expected mypy to indicate a type error > > should typing work for this case? > -- > Robin Becker > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list

Bug report - Python 3.10 from Microsoft Store - IDLE won't start

2022-11-29 Thread Johan Gunnarsson via Python-list
1 84 Lund<https://webmail.lu.se/owa/> Telefon: +46 46 222 18 23 www.medicin.lu.se<http://www.medicin.lu.se/> -- https://mail.python.org/mailman/listinfo/python-list

pip issue

2022-11-30 Thread Gisle Vanem via Python-list
ing. I assume this is an entry for an orphaned package "MarkupSafe" since a 'pip list | grep markup' will list 'MarkupSafe 2.1.1'. -- --gv -- https://mail.python.org/mailman/listinfo/python-list

Re: pip issue

2022-11-30 Thread Gisle Vanem via Python-list
es`). I had 2 folders named: site-packages\~arkupsafe\ site-packages\~arkupsafe-2.1.1.dist-info\ Removing those, the problem was gone. So perhaps this tilde '~' means something special for pip? -- --gv -- https://mail.python.org/mailman/listinfo/python-list

Re: FTP without username and password

2022-12-06 Thread Jon Ribbens via Python-list
rectory to be *writable* without a username and password? If so try the '-w' option. -- https://mail.python.org/mailman/listinfo/python-list

How to get the needed version of a dependency

2022-12-14 Thread Cecil Westerhof via Python-list
Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Re: How to get the needed version of a dependency

2022-12-14 Thread Cecil Westerhof via Python-list
cal/lib/python3.9/dist-packages/requests-2.28.1.dist-info/METADATA I see: Requires-Dist: charset-normalizer (<3,>=2) That already keeps charset-normalizer two months from being updated. Maybe I should contact Kenneth Reitz. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Re: Single line if statement with a continue

2022-12-15 Thread Cecil Westerhof via Python-list
ineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Re: Single line if statement with a continue

2022-12-17 Thread Rob Cliffe via Python-list
often done in my own code, albeit with a feeling of guilt that I was breaking a Python taboo.  Now I will do it with a clear conscience. 😁 Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Top level of a recursive function

2022-12-17 Thread Rob Cliffe via Python-list
ng it garbage-collected later). Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Why can't the pointer in a PyCapsule be NULL?

2022-12-30 Thread Robert Latest via Python-list
ent in the body. Makes sense. > . On a superficial level, the answer is: "Because > PyCapsule_GetPointer uses NULL to indicate failure." Makes sense, too. Thanks. -- https://mail.python.org/mailman/listinfo/python-list

Why can't the pointer in a PyCapsule be NULL?

2022-12-30 Thread Robert Latest via Python-list
Hi all, the question is in the subject. I'd like the pointer to be able to be NULL because that would make my code slightly cleaner. No big deal though. -- https://mail.python.org/mailman/listinfo/python-list

To clarify how Python handles two equal objects

2023-01-10 Thread Jen Kris via Python-list
remain equal, I can’t just do it in one operation because I can’t rely on the objects remaining equal.  Is my understanding of this correct?  Is there anything I’m missing?  Thanks very much.  Jen -- https://mail.python.org/mailman/listinfo/python-list

Re: To clarify how Python handles two equal objects

2023-01-10 Thread Jen Kris via Python-list
> On Wed, 11 Jan 2023 at 07:14, Jen Kris via Python-list > wrote: > >> >> I am writing a spot speedup in assembly language for a short but >> computation-intensive Python loop, and I discovered something about Python >> array handling that I would like to clarify.

Re: To clarify how Python handles two equal objects

2023-01-10 Thread Jen Kris via Python-list
matrix operations, you might use NumPy. Its > arrays and matrices are heavily optimized for fast processing and provide > many useful operations on them. No use calling out to C code yourself when > NumPy has been refining that for many years. > > On 1/10/2023 4:10 PM

Re: To clarify how Python handles two equal objects

2023-01-11 Thread Jen Kris via Python-list
= (int *)malloc(3 * sizeof(int)); > arr1[0] = 10; > arr1[1] = 11; > arr1[2] = 12; > > Does that help your understanding? > > -- > Greg > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: To clarify how Python handles two equal objects

2023-01-11 Thread Jen Kris via Python-list
023 om 16:33 schreef Jen Kris via Python-list: > >> Yes, I did understand that.  In your example, "a" and "b" are the same >> pointer, so an operation on one is an operation on the other (because >> they’re the same memory block). >> > > Sorry if

RE: To clarify how Python handles two equal objects

2023-01-13 Thread Jen Kris via Python-list
other data > structure. Of course, if anything else is accessing the result in the > original in between, it won't work. > > Just FYI, a similar analysis applies to uses of the numpy and pandas and > other modules if you get some kind of object holding indices to a series s

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Jen Kris via Python-list
34 >   >>> b=1234 >   >>> a is b >   False > > Not sure what happens if you manipulate the data referenced by 'b' in the > first example thinking you are changing something referred to by 'a' ... but > you might be smart to NOT th

RE: To clarify how Python handles two equal objects

2023-01-14 Thread Jen Kris via Python-list
a) > 3 > sys.getrefcount(b) > 3 > c = b > d = a > sys.getrefcount(a) > 5 > sys.getrefcount(d) > 5 > del(a) > sys.getrefcount(d) > 4 > b = "something else" > sys.getrefcount(d) > 3 > > So, in theory, you could carefully write your code to C

Re: To clarify how Python handles two equal objects

2023-01-14 Thread Jen Kris via Python-list
Yes, in fact I asked my original question – "I discovered something about Python array handling that I would like to clarify" -- because I saw that Python did it that way.  Jan 14, 2023, 15:51 by ros...@gmail.com: > On Sun, 15 Jan 2023 at 10:32, Jen Kris via Python-list >

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Jon Ribbens via Python-list
; > [ >{ "value": "some_key", 'a':1, 'b':2}, >{ "value": "some_other_key", 'a':3, 'b':4} > ] [{"value": key, **value} for d in input_data for key, value in d.items()] -- https://mail.python.org/mailman/listinfo/python-list

Re: ok, I feel stupid, but there must be a better way than this! (finding name of unique key in dict)

2023-01-20 Thread Rob Cliffe via Python-list
t with: listOfDescriptors = list() for cd in origListOfDescriptors:     cn = list(cd.keys())[0] # There must be a better way than this!     listOfDescriptors.append({     "value": cn,     "type": cd[cn]["a"],     "description": cd[cn]["b"]     }) and it works, but I look at this and think that there must be a better way. Am I missing something obvious? PS: Screw OpenAPI! Dino -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-24 Thread Mike Baskin via Python-list
getopt for the option stuff. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-24 Thread Mike Baskin via Python-list
o_stuff_with(sys.argv[1:]) > > What is argparse really doing for you? I second this.  "if '-h' in sys.argv:"  is usually what I do. Alternatively, you could use "--arg=" syntax and place your string "-4^2+5.3*abs(-2-1)/2" its right-hand side": infix2postfix [options] "--infix=-4^2+5.3*abs(-2-1)/2" This shouldn't be too hard for a user to work with.  You could scan the argument list for the presence of "--infix=" and display the help message if it isn't there. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list

Re: bool and int

2023-01-24 Thread Mike Baskin via Python-list
f integer. I never dug that deep into Python's guts but > I assume it goes back to boolean being an afterthought in C. Some people > fancy it up with #defines but I always use int. 0 is false, anything else > is true. > > C# is pickier, which I guess is a good thing. > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list

Re: Evaluation of variable as f-string

2023-01-27 Thread Rob Cliffe via Python-list
d/or locals dictionaries as needed for eval to use.  Something like this: def effify(non_f_str, glob=None, loc=None):     return eval(f'f"""{non_f_str}"""',     glob if glob is not None else globals(),     loc if loc is not None else locals()) Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: bool and int

2023-01-27 Thread Rob Cliffe via Python-list
isinstance(b,int) True >>> That immediately tells you that either     bool is a subclass of int     int is a subclass of bool     bool and int are both subclasses of some other class In fact the first one is true. This is not a logical necessity, but the way Python happens to be designe

Re: Evaluation of variable as f-string

2023-01-27 Thread Rob Cliffe via Python-list
rden - to support a relatively rare requirement". Perhaps someone will be inspired to write a function to do it. 😎 Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Evaluation of variable as f-string

2023-01-27 Thread Rob Cliffe via Python-list
Whoa! Whoa! Whoa! I appreciate the points you are making, Chris, but I am a bit taken aback by such forceful language. On 27/01/2023 19:18, Chris Angelico wrote: On Sat, 28 Jan 2023 at 05:31, Rob Cliffe via Python-list wrote: On 23/01/2023 18:02, Chris Angelico wrote: Maybe, rather than

Re: Usenet vs. Mailing-list (was: evaluation question)

2023-01-28 Thread Jon Ribbens via Python-list
appear in the list archive on the web. https://mail.python.org/pipermail/python-list/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Usenet vs. Mailing-list

2023-01-28 Thread Jon Ribbens via Python-list
. Although sometimes it does feel like it isn't, in that I reply to a post with an answer and then several other people reply significantly later with the same answer, as if my one had never existed... but whenever I check into it, my message has actually always made it to the list. -- https://mail.python.org/mailman/listinfo/python-list

Re: Usenet vs. Mailing-list

2023-01-29 Thread Jon Ribbens via Python-list
On 2023-01-29, Peter J. Holzer wrote: > On 2023-01-29 02:09:28 -, Jon Ribbens via Python-list wrote: >> I'm not aware of any significant period in the last twenty-one years >> that > [the gateway] >> hasn't been working. Although sometimes it does feel like

Re: evaluation question

2023-01-30 Thread Rob Cliffe via Python-list
n print was made a function. Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Evaluation of variable as f-string

2023-01-31 Thread Rob Cliffe via Python-list
On 27/01/2023 23:41, Chris Angelico wrote: On Sat, 28 Jan 2023 at 10:08, Rob Cliffe via Python-list wrote: Whoa! Whoa! Whoa! I appreciate the points you are making, Chris, but I am a bit taken aback by such forceful language. The exact same points have already been made, but not listened to

Re: Licensing?

2023-02-02 Thread Jon Ribbens via Python-list
anged? No. If you change someone else's code then you have created a derived work, which requires permission from both the original author and you to copy. (Unless you change it so much that nothing remains of the original author's code, of course.) -- https://mail.python.org/mailman/listinfo/python-list

Re: Licensing?

2023-02-02 Thread Jon Ribbens via Python-list
what remains, pretty much by definition, isn't going to be useful. You'd be better off simply starting from scratch and having an unimpeachable claim to own the entire copyright yourself. -- https://mail.python.org/mailman/listinfo/python-list

Re: Organizing modules and their code

2023-02-04 Thread Greg Ewing via Python-list
devoted to each fruit, but only ever one crate of fruit in each aisle, one would think they could make better use of their shelf space. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Organizing modules and their code

2023-02-05 Thread Greg Ewing via Python-list
part of it, and that was something he saw his colleagues failing to do. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: evaluation question

2023-02-06 Thread Rob Cliffe via Python-list
;t have it both ways. In any case, supporting two different syntaxes simultaneously would be messy and difficult to maintain. Better a clean break, with Python 2 support continuing for a long time (as it was). Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Evaluation of variable as f-string

2023-02-07 Thread Rob Cliffe via Python-list
f all available variables and their values?  If it were possible, it could be useful, and there would be no impact on Python run-time speed if it were only constructed on demand. Best wishes Rob -- https://mail.python.org/mailman/listinfo/python-list

Re: evaluation question

2023-02-07 Thread Rob Cliffe via Python-list
On 07/02/2023 08:15, Chris Angelico wrote: On Tue, 7 Feb 2023 at 18:49, Rob Cliffe via Python-list wrote: On 02/02/2023 09:31, mutt...@dastardlyhq.com wrote: On Wed, 1 Feb 2023 18:28:04 +0100 "Peter J. Holzer" wrote: --b2nljkb3mdefsdhx Content-Type: text/plain; charset=us-asc

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: ChatGPT Generated news poster code

2023-02-12 Thread Roland Müller via Python-list
Hello, On 2/11/23 03:31, Greg Ewing via Python-list wrote: 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. Actually, I like cynical humo

Python 3.8 pip installation on Windows 7

2023-02-14 Thread christoph sobotta via Python-list
s) (3C:F0) [13:32:29:617]: Unlocking Server MSI (s) (3C:F0) [13:32:29:914]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'. Action ended 13:32:29: InstallFinalize. Return value 1. Action ended 13:32:29: INSTALL. Return value 1. ... -- https://mail.python.org/mailman/listinfo/python-list

Re: Comparing caching strategies

2023-02-16 Thread Rob Cliffe via Python-list
future awaits [pun not intended] ... -- https://mail.python.org/mailman/listinfo/python-list

Re: Precision Tail-off?

2023-02-17 Thread Greg Ewing via Python-list
ar problem, since 1/3 isn't exactly representable in decimal either. To avoid it you would need to use an algorithm that computes nth roots directly rather than raising to the power 1/n. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: LRU cache

2023-02-18 Thread Rob Cliffe via Python-list
rt-Jan _cache.get(arg) should be a little faster and use slightly fewer resources than the try/except. Provided that you can provide a default value to get() which will never be a genuine "result". -- https://mail.python.org/mailman/listinfo/python-list

Line continuation and comments

2023-02-22 Thread Robert Latest via Python-list
org/mailman/listinfo/python-list

Re: semi colonic

2023-02-22 Thread Rob Cliffe via Python-list
tinfo/python-list

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Greg Ewing via Python-list
reg -- https://mail.python.org/mailman/listinfo/python-list

Re: semi colonic

2023-02-22 Thread Greg Ewing via Python-list
the other hand, if they really want to, they will still be able to abuse semicolons by doing this sort of thing: a = 5; pass b = 7; pass c = a * b; pass Then everyone will know it's some really serious code! -- Greg -- https://mail.python.org/mailman/listinfo/python-list

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
much better than an interpreter. There are some similarities between Python and Lisp-family languages, but really Python is its own thing. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: LRU cache

2023-02-22 Thread Rob Cliffe via Python-list
On 18/02/2023 17:19, Albert-Jan Roskam wrote: On Feb 18, 2023 17:28, Rob Cliffe via Python-list wrote: On 18/02/2023 15:29, Thomas Passin wrote: > On 2/18/2023 5:38 AM, Albert-Jan Roskam wrote: >>     I sometimes use this trick, which I learnt from a book by

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Rob Cliffe via Python-list
On 22/02/2023 20:05, Hen Hanna wrote: Python makes programming (debugging) so easy I agree with that! Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: semi colonic

2023-02-23 Thread Rob Cliffe via Python-list
alcPay(rate=1.5) if dow==6:     day="Sun"     calcPay(rate=2) Not so easy to spot the mistake now, is it? Not to mention the saving of vertical space. Best wishes Rob Cliffe PS If you really care, I can send you a more complicated example of real code from one of my programs which is HUGELY more readable when laid out in this way. -- https://mail.python.org/mailman/listinfo/python-list

Re: semi colonic

2023-02-23 Thread Rob Cliffe via Python-list
notwithstanding that IMO it is occasionally appropriate). Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Line continuation and comments

2023-02-23 Thread Rob Cliffe via Python-list
t line with the others (in a fixed font of course). Best wishes Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: semi colonic

2023-02-23 Thread Greg Ewing via Python-list
Greg -- https://mail.python.org/mailman/listinfo/python-list

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

2023-02-25 Thread Greg Ewing via Python-list
ewcomers at all. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a more efficient threading lock?

2023-02-25 Thread Jon Ribbens via Python-list
o having the > GIL. So I would have considered the multiprocessing module rather than > threading, for something like this. What does this mean? Are you saying the GIL has been removed? -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a more efficient threading lock?

2023-02-25 Thread Jon Ribbens via Python-list
omic, I believe. But, I think it is better to not have any shared > mutables regardless. I think it is the case that x += 1 is atomic but foo.x += 1 is not. Any replacement for the GIL would have to keep the former at least, plus the fact that you can do hundreds of things like list.append(foo) which are all effectively atomic. -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a more efficient threading lock?

2023-02-26 Thread Jon Ribbens via Python-list
On 2023-02-26, Barry Scott wrote: > On 25/02/2023 23:45, Jon Ribbens via Python-list wrote: >> I think it is the case that x += 1 is atomic but foo.x += 1 is not. > > No that is not true, and has never been true. > >:>>> def x(a): >:...    a += 1 >:... >

Re: Is there a more efficient threading lock?

2023-02-26 Thread Jon Ribbens via Python-list
On 2023-02-26, Chris Angelico wrote: > On Sun, 26 Feb 2023 at 16:16, Jon Ribbens via Python-list > wrote: >> On 2023-02-25, Paul Rubin wrote: >> > The GIL is an evil thing, but it has been around for so long that most >> > of us have gotten used to it, and some u

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
sition, I think). The semantics of list comprehensions was originally defined in terms of nested for loops. A consequence was that the loop variables ended up in the local scope just as with ordinary for loops. Later it was decided to change that. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Line continuation and comments

2023-02-27 Thread Robert Latest via Python-list
x > 100 > ) > You don't need the "\" to continue a line in this case I like that. Never thought of it. -- https://mail.python.org/mailman/listinfo/python-list

Re: Line continuation and comments

2023-02-27 Thread Robert Latest via Python-list
future_style.html#using-backslashes-for-with-statements Then I wonder how Mr. Black would go about these long "dot chaining" expressions that packages like pandas and sqlalchemy require. -- https://mail.python.org/mailman/listinfo/python-list

Re: Line continuation and comments

2023-02-27 Thread Robert Latest via Python-list
ses work there, too. -- https://mail.python.org/mailman/listinfo/python-list

How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
print(match.start(), match.end()) I’ve tried several other attempts based on my reseearch, but still no match.  I don’t have much experience with regex, so I hoped a reg-expert might help.  Thanks, Jen -- https://mail.python.org/mailman/listinfo/python-list

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
debated, but it wasn't a bug or an accident. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.10 Fizzbuzz

2023-02-27 Thread Greg Ewing via Python-list
python.org/mailman/listinfo/python-list

Re: Python 3.10 Fizzbuzz

2023-02-27 Thread Rob Cliffe via Python-list
posite of the choice I make. -- ~Ethan~ I've never tried Black or any other code formatter, but I'm sure we wouldn't get on. -- https://mail.python.org/mailman/listinfo/python-list

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 pyt...@mrabarnett.plus.com: > 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
_fixed_ string, not a > pattern/regexp. So why on earth are you using regexps to do your searching? > > The `str` type has a `find(substring)` function. Just use that! It'll be > faster and the code simpler! > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

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 bobmellow...@gmail.com: > 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
found + len(substring) > ... do whatever with start and end ... > pos = end > > Many people go straight to the `re` module whenever they're looking for > strings. It is often cryptic error prone overkill. Just something to keep in > mind. > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > -- 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
n/listinfo/python-list

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
gt; 26 40 > > If you may have variable numbers of spaces around the symbols, OTOH, the > whole situation changes and then regexes would almost certainly be the best > approach. But the regular expression strings would become harder to read. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
27;using_simple_loop(KEY, >> CORPUS)', globals=globals(), number=1000)) >>     print('using_re_finditer:', timeit.repeat(stmt='using_re_finditer(KEY, >> CORPUS)', globals=globals(), number=1000)) >> >> This does 5 runs of 1000 repetitions each, and reports the time in seconds >> for each of those runs. >> Result on my machine: >> >>     using_simple_loop: [0.1395295020792, 0.1306313000456, >> 0.1280345001249, 0.1318618002423, 0.1308461032626] >>     using_re_finditer: [0.00386140005233, 0.00406190124297, >> 0.00347899970256, 0.00341310216218, 0.003732001273] >> >> We find that in this test re.finditer() is more than 30 times faster >> (despite the overhead of regular expressions. >> >> While speed isn't everything in programming, with such a large difference in >> performance and (to me) no real disadvantages of using re.finditer(), I >> would prefer re.finditer() over writing my own. >> > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jon Ribbens via Python-list
er. It's easy enough to implement, though in Python you can't > take the additional step of tuning it to stay in cache. > > https://Robert.Muth.Org/Papers/1996-Approx-Multi.Pdf You've somehow title-cased that URL. The correct URL is: https://robert.muth.org/Papers/1996-approx-multi.pdf -- https://mail.python.org/mailman/listinfo/python-list

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