Re: Python List is Not Dead

2024-12-29 Thread Cameron Simpson via Python-list
On 29Dec2024 07:16, Kevin M. Wilson wrote: Excuse please, my failure. As I have not been following this discussion, why is the subject "Python List Is NOT Dead" a subject for discussion? Has the list been moving towards closing? No, the list's still around. But there was a significant migrat

Re: Python List is Not Dead

2024-12-26 Thread Cameron Simpson via Python-list
On 25Dec2024 14:52, Abdur-Rahmaan Janhangeer wrote: I have been following discussions on Discourse (discuss.python.org) these last times. I think that it definitely lacks some of the joys of the mailing list: FYI, it has a very good "mailing list" mode. I use it that was >90% of the time, a

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

2024-11-11 Thread Cameron Simpson via Python-list
of code. So: config = configparser.ConfigParser() try: config.read(args.config_file) except FileNotFoundError as e: print(f"Error: configuration file {args.config_file} not found: {e}") This way you know that the config file was missing. Cheers, Cameron Simpson

Re: Printing UTF-8 mail to terminal

2024-11-05 Thread Cameron Simpson via Python-list
further encoded as quoted printable to avoid ambiguity about the meaning of bytes/octets which have their high bit set. BTW, doesn't this: for k in mail.keys(): print(f"{k}: {mail.get(k)}") print the quoted printable (i.e. not decoded) form of subject lines? Chee

Re: Two python issues

2024-11-05 Thread Cameron Simpson via Python-list
error should be given. There are many many circumstances where we replace a subsequence with a different subsequence of different length. Outlawing such a thing would remove and extremely useful feature. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: TkInter Scrolled Listbox class?

2024-11-04 Thread Cameron Simpson via Python-list
def config(self, *a, **kw): return self.Listbox.config(*a, **kw) and so forth for the various listbox methods you want to proxy to the listbox itself. You could pass scroll specific methods to the scrollbar as well. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/p

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 31Oct2024 21:53, alan.ga...@yahoo.co.uk wrote: On 31/10/2024 20:50, Cameron Simpson via Python-list wrote: If you're just dealing with this directly, use the `quopri` stdlib module: https://docs.python.org/3/library/quopri.html One of the things I love about this list are these l

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 01Nov2024 10:10, Loris Bennett wrote: as expected. The non-UTF-8 text occurs when I do mail = EmailMessage() mail.set_content(body, cte="quoted-printable") ... if args.verbose: print(mail) which is presumably also correct. The question is: What conversion is necessary in order t

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 01Nov2024 08:11, Loris Bennett wrote: Cameron Simpson writes: If you're using the Python email module to parse (or construct) the message as a `Message` object I'd expect that to happen automatically. I am using email.message.EmailMessage Noted. That seems like the correct a

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Cameron Simpson via Python-list
n.org/3/library/quopri.html Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Best Practice Virtual Environment

2024-10-05 Thread Cameron Simpson via Python-list
Just make a shared virtualenv, eg in /usr/local or /opt somewhere. Have the script commence with: #!/path/to/the/shred/venv/bin/python and make it readable and executable. Problem solved. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] How to stop a specific thread in Python 2.7?

2024-10-03 Thread Cameron Simpson via Python-list
reexisting Event may be supplied. Return a 2-tuple of `(T,E)`. ''' if E is None: E = Event() T = Thread(target=target, args=[E, *a], kwargs=kw) return T, E Something along those lines. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How to stop a specific thread in Python 2.7?

2024-09-25 Thread Cameron Simpson via Python-list
On 25Sep2024 22:56, marc nicole wrote: How to create a per-thread event in Python 2.7? Every time you make a Thread, make an Event. Pass it to the thread worker function and keep it to hand for your use outside the thread. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to stop a specific thread in Python 2.7?

2024-09-25 Thread Cameron Simpson via Python-list
if it becomes set. You just need a per-thred vent instead of a single Event for all the threads. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Bug in 3.12.5

2024-09-20 Thread Cameron Simpson via Python-list
On 20Sep2024 12:52, Martin Nilsson wrote: The attached program doesn’t work in 3.12.5, but in 3.9 it worked. This mailing list discards attachments. Please include your code inline in the message text. Thanks, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: python3 package import difference?

2024-08-08 Thread Cameron Simpson via Python-list
On 08Aug2024 21:55, Gilmeh Serda wrote: I guess in a sense Py2 was smarter figuring out what whent where and where it came from. Or it was a bad hack that has been removed. No, Python 2 offered less control. -- https://mail.python.org/mailman/listinfo/python-list

Re: python3 package import difference?

2024-08-07 Thread Cameron Simpson via Python-list
from dbi import * ModuleNotFoundError: No module named 'dbi' Python 3 imports are absolute (they start from the top of the package tree and you have no `dbi` at the top). You want a relative import i.e.: from .dbi import * Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Help needed - - running into issues with python and its tools

2024-08-03 Thread Cameron Simpson via Python-list
On 03Aug2024 16:34, o1bigtenor wrote: So please - - - how do I set up a venv so that I can install and run python 3.12 (and other needed programs related to 3.12) inside? Maybe this github comment will help with this: https://github.com/orgs/micropython/discussions/10255#discussioncomment-444

Re: Best use of "open" context manager

2024-07-07 Thread Cameron Simpson via Python-list
On 07Jul2024 22:22, Rob Cliffe wrote: it's legal, but doesn't work (trying to access the file after "with f" raises the same     ValueError: I/O operation on closed file. Just to this: of course. The with closes the file. But my version runs the with after the try/except. -- https://mail.py

Re: Best use of "open" context manager

2024-07-07 Thread Cameron Simpson via Python-list
On 07Jul2024 22:22, Rob Cliffe wrote: Remember, the `open()` call returns a file object _which can be used as a context manager_. It is separate from the `with` itself. Did you test this?     f = open(FileName) as f: is not legal syntax. No. You're right, remove the "as f:". it's legal, but

Re: Best use of "open" context manager

2024-07-06 Thread Cameron Simpson via Python-list
On 06Jul2024 11:49, Rob Cliffe wrote: try:     f = open(FileName) as f:     FileLines = f.readlines() except FileNotFoundError:     print(f"File {FileName} not found")     sys.exit() # I forgot to put "f.close()" here -:) for ln in File Lines:         print("I do a lot of processing here")      

Re: Suggested python feature: allowing except in context maneger

2024-06-14 Thread Cameron Simpson via Python-list
On 14Jun2024 09:07, Yair Eshel wrote: Cameron, I'm not really sure I got your point. I've used the "file not found" exception as an example for a behavior typical on context managers. This could be a failure to connect to DB, or threads. It also applies to any kind o

Re: Anonymous email users

2024-06-14 Thread Cameron Simpson via Python-list
On 14Jun2024 18:00, avi.e.gr...@gmail.com wrote: I notice that in some recent discussions, we have users who cannot be replied to directly as their email addresses are not valid ones, and I believe on purpose. Examples in the thread I was going to reply to are: henh

Re: Suggested python feature: allowing except in context maneger

2024-06-13 Thread Cameron Simpson via Python-list
pport, and doing stuff like merging an `except` with a `wtih` is bound to introduce some weird corner case, complicating its semantics. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Fwd: IDLE: clearing the screen

2024-06-04 Thread Cameron Simpson via Python-list
On 04Jun2024 22:43, Rob Cliffe wrote: import os def cls(): x=os.system("cls") Now whenever you type cls() it will clear the screen and show the prompt at the top of the screen. (The reason for the "x=" is: os.system returns a result, in this case 0.  When you evaluate an expression in the IDE

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Cameron Simpson via Python-list
On 29May2024 01:14, Thomas Passin wrote: Also, it's 2024 ... time to start using f-strings (because they are more readable than str.format()) By which Thomas means stuff like this: print(f'if block {name[index]} and index {index}') Notice the leading "f'". Personally I wouldn't even go t

Re: Terminal Emulator

2024-05-14 Thread Cameron Simpson via Python-list
On 14May2024 18:44, Gordinator wrote: I wish to write a terminal emulator in Python. I am a fairly competent Python user, and I wish to try a new project idea. What references can I use when writing my terminal emulator? I wish for it to be a true terminal emulator as well, not just a Tk text

Re: First two bytes of 'stdout' are lost

2024-04-11 Thread Cameron Simpson via Python-list
On 11Apr2024 14:42, Olivier B. wrote: I am trying to use StringIO to capture stdout, in code that looks like this: import sys from io import StringIO old_stdout = sys.stdout sys.stdout = mystdout = StringIO() print( "patate") mystdout.seek(0) sys.stdout = old_stdout print(mystdout.read()) Well

Re: How to Add ANSI Color to User Response

2024-04-11 Thread Cameron Simpson via Python-list
little module of my own, `cs.ansi_colour`, which you can get from PyPI using `pip`. The two most useful items in it for someone else are probably `colourise` and `colourise_patterns`. Link: https://github.com/cameron-simpson/css/blob/26504f1df55e1bbdef00c3ff7f0cb00b2babdc01/lib/python/cs/ansi

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-07 Thread Cameron Simpson via Python-list
On 06Mar2024 15:12, Jacob Kruger wrote: So, this does not make sense to me in terms of the following snippet from the official python docs page: https://docs.python.org/3/faq/programming.html "In Python, variables that are only referenced inside a function are implicitly global. If a variable

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-05 Thread Cameron Simpson via Python-list
;l1 =", l1) print("outside, x =", x, "l1 =", l1) f1() print("outside after f1, x =", x, "l1 =", l1) f2() print("outside after f2, x =", x, "l1 =", l1) Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Can one output something other than 'nan' for not a number values?

2024-02-16 Thread Cameron Simpson via Python-list
way with any sort of formatting string or other sort of cleverness? The simplest thing is probably just a function writing it how you want it: def float_s(f): if isnan(f): return "-" return str(f) and then use eg: print(f'value is {float_s(valu

Re: A question about import

2024-02-16 Thread Cameron Simpson via Python-list
rect use in the script you would import it there too: import datetime import A Note that the datetime module is only actually loaded once. The import binds the name into your local namespace like any other variable. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to implement the ** operator on a custom object

2024-02-09 Thread Cameron Simpson via Python-list
s dict, int, str and namedtuple. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to implement the ** operator on a custom object

2024-02-08 Thread Cameron Simpson via Python-list
On 08Feb2024 12:21, tony.fl...@btinternet.com wrote: I know that mappings by default support the ** operator, to unpack the mapping into key word arguments. Has it been considered implementing a dunder method for the ** operator so you could unpack an object into a key word argument, and the

Re: How would you name this dictionary?

2024-01-21 Thread Cameron Simpson via Python-list
On 21Jan2024 23:39, bagra...@live.com wrote: class NameMe(dict): def __missing__(self, key): return key I would need to know more about what it might be used for. What larger problem led you to writing a `dict` subclass with this particular `__missing__` implementation? -- https:/

Re: Type hints - am I doing it right?

2023-12-13 Thread Cameron Simpson via Python-list
ince I imagine config_database() would accept any kind of mapping (dicts, etc etc). Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Newline (NuBe Question)

2023-11-15 Thread Cameron Simpson via Python-list
grades.append(s.name) grades.append(s.finalGrade()) if s.finalGrade()>82: grades.append("Pass") else: grades.append("Fail") print(grades) Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Checking if email is valid

2023-11-01 Thread Cameron Simpson via Python-list
/rfc2821#section-4.1.1.6 I think a lot of mail receivers don't honour this one, for exactly the reasons above. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Checking if email is valid

2023-11-01 Thread Cameron Simpson via Python-list
special unique and opaue URL,please visit it to confirm receipt of this email (implying email is 'real"). You see this a lot when signing up for things. And for plenty of things I generate a random throw away address at mailinator.com (looking at you, every "catch up" free o

Re: return type same as class gives NameError.

2023-10-22 Thread Cameron Simpson via Python-list
This message: NameError: name 'Pnt' is not defined. Did you mean: 'PNT'? is unfortunate, because you have a very similar "PNT" name in scope. But it isn't what you want. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Where I do ask for a new feature

2023-10-19 Thread Cameron Simpson via Python-list
On 19Oct2023 20:16, Bongo Ferno wrote: A with statement makes clear that the alias is an alias and is local, and it automatically clears the variable after the block code is used. No it doesn't: >>> with open('/dev/null') as f: ... print(f) ... <_io.TextIOWrapper name='/dev/

Re: Why doc call `__init__` as a method rather than function?

2023-09-17 Thread Cameron Simpson via Python-list
ll it, the "bound method" knows that t is associated with `a` and puts that in as the first argument (usually named `self`). Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Imports and dot-notation

2023-08-09 Thread Cameron Simpson via Python-list
ble. But in a very long piece of code with many imports you might go for module1.funcname for clarity, particularly if funcname is generic or overlaps with another similar imported name. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Where is the error?

2023-08-07 Thread Cameron Simpson via Python-list
On 07Aug2023 08:02, Barry wrote: On 7 Aug 2023, at 05:28, Cameron Simpson via Python-list wrote: Used to use a Pascal compiler once which was uncannily good at suggesting where you'd missing a semicolon. Was that on DEC VMS? It was a goal at DEC for its compilers to do this well.

Re: Where is the error?

2023-08-06 Thread Cameron Simpson via Python-list
er the underlined code? Is this "clairvoyant" behaviour a side-effect of the new parser or was that a deliberate decision? I have the vague impression the new parser enabled the improved reporting. Used to use a Pascal compiler once which was uncannily good at suggestin

Re: isinstance()

2023-08-02 Thread Cameron Simpson via Python-list
e) There's similar language in this try/except documentation: file:///Users/cameron/var/doc/python/3.8.0/reference/compound_stmts.html#index-10 For an except clause with an expression, that expression is evaluated, and the clause matches the exception if the resulting object

Re: Should NoneType be iterable?

2023-06-20 Thread Cameron Simpson via Python-list
On 21Jun2023 10:09, Chris Angelico wrote: On Wed, 21 Jun 2023 at 09:59, Cameron Simpson via Python-list wrote: I wasted some time the other evening on an API which returned a string or None. My own API, and the pain it caused tells me that that API design choice isn't good (it's an

Re: Should NoneType be iterable?

2023-06-20 Thread Cameron Simpson via Python-list
And of course I'm very -1 on None acquiring iteration or other features. Fail early, fail often! Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Tkinter docs?

2023-05-24 Thread Cameron Simpson
On 24May2023 02:18, Rob Cliffe wrote:     There doesn't seem to be any decent documentation for it anywhere. Already mentioned in the replies, I use this: https://tkdocs.com/shipman/index.html quite a lot. -- https://mail.python.org/mailman/listinfo/python-list

Re: Tkinter (related)~

2023-05-18 Thread Cameron Simpson
it is part of the stdlib. On some platforms eg Ubuntu Linux the stdlib doesn't come in completely unless you ask - a lot of stdlib packages are apt things you need to ask for. On my Ubunut here tkinter comes from python3-tk. So: $ sudo apt-get install python3-tk Cheers, Cameron Si

Re: What to use instead of nntplib?

2023-05-16 Thread Cameron Simpson
On 16May2023 09:26, Alan Gauld wrote: 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 Python 3.13 What should I use in place of nntplib? I'm curious as to why

Re: What do these '=?utf-8?' sequences mean in python?

2023-05-09 Thread Cameron Simpson
8?B?" Aye. Specification: https://datatracker.ietf.org/doc/html/rfc2047 You should reach for jak's suggested email.header suggestion _before_ parsing the subject line. Details: https://docs.python.org/3/library/email.header.html#module-email.header Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: double bracket integer index in pandas; Is this a legal syntax

2023-05-03 Thread Cameron Simpson
column. versus: df[ [0] ] # spaces for clarity makes a new dataframe with only the first column. A dataframe can be thought of as an array of Series (one per column). Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: double bracket integer index in pandas; Is this a legal syntax

2023-05-03 Thread Cameron Simpson
lying this index: [1] which is a list of ints (with just one int). Have a look at this page: https://pandas.pydata.org/docs/user_guide/indexing.html If you suppply a list, it expects a list of labels. Is 1 a valid label for your particular dataframe? Cheers, Cameron Simpson --

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

2023-04-28 Thread Cameron Simpson
There are plenty of similar situations. Because of this I usually am prepared to make a missing final component with mkdir(), but not a potentially deep path with makedirs(). Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

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

2023-04-28 Thread Cameron Simpson
if not ok: ... not all directories made ... 2 notes on the above: - catching Exception, not a bare except (which catches a rather broader suit of things) - reporting the other exception Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Question regarding unexpected behavior in using __enter__ method

2023-04-20 Thread Cameron Simpson
j.y". The means that what happens to a name when you define the class depends on the typeof the value bound to the name. A plain function gets turned into an unbound instance method, but other things are left alone. When you went: __enter__ = int That's not a plain function and so "obj.__enter__" doesn't turn into a bound method - it it just `int`. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Fwd: pip is not installed

2023-04-16 Thread Cameron Simpson
install some package "foo". Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Weak Type Ability for Python

2023-04-12 Thread Cameron Simpson
On 13Apr2023 03:36, MRAB wrote: I thought that in Java you can, in fact, concatenate a string and an int, so I did a quick search online and it appears that you can. I stand corrected. I could have sworn it didn't, but it has been a long time. - Cameron Simpson -- https://mail.pytho

Re: Weak Type Ability for Python

2023-04-12 Thread Cameron Simpson
time with Java, being staticly typed). Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for package/library to extract MP4 metadata

2023-04-10 Thread Cameron Simpson
e knitty gritty you could try my `cs.iso14496` package, which has a full MP4/MOV parser and a hook for getting the metadata. Not as convenient as ffprobe, but if you care about the innards... Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Python file location

2023-03-29 Thread Cameron Simpson
cs/ for my modules, which are all named "cs.*" (avoids conflict). But that's just me. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Standard class for time *period*?

2023-03-29 Thread Cameron Simpson
n the whole. https://github.com/cameron-simpson/css/blob/0ade6d191833b87cab8826d7ecaee4d114992c45/lib/python/cs/timeseries.py#L2163 But it would be easy to give that class `__lt__` etc methods. You're welcome to use it, or anything from the module (it's on PyPI). Cheers, Cameron Simps

Re: Standard class for time *period*?

2023-03-29 Thread Cameron Simpson
On 30Mar2023 10:13, Cameron Simpson wrote: I do in fact have a `TimePartition` in my timeseries module; it presently doesn't do comparisons because I'm not comparing them - I'm just using them as slices into the timeseries data on the whole. https://github.com/cameron-s

Re: Standard class for time *period*?

2023-03-28 Thread Cameron Simpson
I'm not sure I understand Loris' other requirements though. It might be hard to write a general thing which was also still useful. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

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

2023-03-26 Thread Cameron Simpson
On 27Mar2023 12:03, Cameron Simpson wrote: On 27Mar2023 01:53, Jen Kris wrote: But that brings up a new question.  I can create a class instance with x = BinaryConstraint(), That makes an instance of EqualityConstraint. Copy/paste mistake on my part. This makes an instance of

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

2023-03-26 Thread Cameron Simpson
perclass inits get to run. This givens you full control to sompletely replace some superclass' init with a custom one. By calling super().__init__() we're saying we not replacing that stuff, we're running the old stuff and just doing something additional for our subclass. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

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

2023-03-26 Thread Cameron Simpson
that is stored as the ".__mro__" field on the new class (EqualityConstraint). You can look at it directly as "EqualityConstraint.__mro__". So looking up: self.choose_method() looks for a "choose_method" method on the classes in "type(self).__mro__". Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: 转发: How to exit program with custom code and custom message?

2023-03-13 Thread Cameron Simpson
Notice that the only call to `sys.exit()` is right at the bottom. Everything else is just regularfunction returns. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Baffled by readline module

2023-03-10 Thread Cameron Simpson
hether it is already imported. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Baffled by readline module

2023-03-10 Thread Cameron Simpson
because I read this the way you read it. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Lambda returning tuple question, multi-expression

2023-03-10 Thread Cameron Simpson
On 09Mar2023 17:55, aapost wrote: On 3/9/23 16:37, Cameron Simpson wrote: Just a note that some code formatters use a trailing comma on the last element to make the commas fold points. Both yapf (my preference) and black let you write a line like (and, indeed, flatten if short enough

Re: Baffled by readline module

2023-03-09 Thread Cameron Simpson
n it on if available. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Baffled by readline module

2023-03-09 Thread Cameron Simpson
xample I found elsewhere that you don't call some module method to fetch the next user-entered line. You call the input() built-in. Ah. That's not overtly stated? [...reads...] Ah, there it is in the last sentence of the opening paragraph. Not quite as in-your-face as I'd have l

Re: Lambda returning tuple question, multi-expression

2023-03-09 Thread Cameron Simpson
b, c, ) in varying flavours of indentation depending on tuning. The point being that if, like me, you often have a code formatter active-on-save it can be hinted to nicely present complex tuples (or parameter lists and imports). It isn't magic, but can be quite effective. Cheers,

Re: Lambda returning tuple question, multi-expression

2023-03-09 Thread Cameron Simpson
;), ...maybe more..., expr)[-1] to embed some debug tracing in a lambda defined expression. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Lambda returning tuple question, multi-expression

2023-03-08 Thread Cameron Simpson
nchronously you arrange to issue an "event", and the GUI mainloop will process that as it happens - the event callback will be fired (called) by the main loop itself and thus the callback gets to do its thing in the main loop. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

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

2023-03-05 Thread Cameron Simpson
acket data to a stream (eg a TCP connection): https://github.com/cameron-simpson/css/blob/00ab1a8a64453dc8a39578b901cfa8d1c75c3de2/lib/python/cs/packetstream.py#L624 Starting at line 640: `if Q.empty():` it optionally pauses briefly to see if more packets are coming on the source queue. If anoth

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

2023-03-05 Thread Cameron Simpson
design something is hanging on to a file while it is waiting for something, then a crash occurs, they lose a portion of what was assumed already complete... f.flush() Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression bug?

2023-03-02 Thread Cameron Simpson
art of the string. You want r0.search(s). - Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.10 Fizzbuzz

2023-03-01 Thread Cameron Simpson
7; and the converse for the other quote character. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.10 Fizzbuzz

2023-03-01 Thread Cameron Simpson
On 28Feb2023 12:54, Greg Ewing wrote: I guess this means I can't use Black. :-( Black's treatment of quotes and docstrings is one of the largest reasons why I won't let it touch my personal code. yapf is far better behaved, and can be tuned as well! Cheers, Cameron Si

Re: How to escape strings for re.finditer?

2023-02-28 Thread Cameron Simpson
it to choose a programming language (eg sed vs awk vs shell vs python in loose order of problem difficulty), but it applies also to choosing tools within a language. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-27 Thread Cameron Simpson
ee what your programme is actually working with, instead of what you thought it was working with. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-27 Thread Cameron Simpson
verkill. Just something to keep in mind. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-27 Thread Cameron Simpson
r_, then you're effectively searching for a _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

Re: Programming by contract.

2023-02-25 Thread Cameron Simpson
lf, fspath): ''' Compute the absolute path used to index a `TaggedPath` instance. This returns `realpath(fspath)` if `self.config.physical`, otherwise `abspath(fspath)`. ''' return realpath(fspath) if self.config.physical else abspath(

Re: Error-Msg Jeannie's charming, teasing ways

2023-02-23 Thread Cameron Simpson
an my code and tell me such (wink,wink) type suggestions There are several type checking programs for Python, with mypy probably being the best known. I seem to recall seeing some mention of tools which will aid inferring types from partially types programmes, usually as

Re: Line continuation and comments

2023-02-23 Thread Cameron Simpson
bles used (self). Constant a class attribute. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Python + Vim editor

2023-02-22 Thread Cameron Simpson
On 21Feb2023 18:00, Hen Hanna wrote: what editor do you (all) use to write Python code? (i use Vim) vim -- https://mail.python.org/mailman/listinfo/python-list

Re: Line continuation and comments

2023-02-22 Thread Cameron Simpson
t = True split_before_expression_after_opening_paren = True split_before_first_argument = True split_before_logical_operator = True split_complex_comprehension = True use_tabs = False So basicly PEP8 with some tweaks. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Tuple Comprehension ???

2023-02-21 Thread Cameron Simpson
x in range(10) ) which makes a tuple from an iterable (such as a list, but anything iterable will do). Here the iterable is the generator expression: x for x in range(10) Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Change the identation base value?

2023-02-15 Thread Cameron Simpson
different linters (via a script named "lint") and turn off quite a few of the `pycodestyle` checks, `E114` included. `pycodestyle` doesn't clean any special "authority", and exlicitly offers ways to turn off whichever checks you find unsuitable to your code. Cheers,

Re: Am I banned from Discuss forum?

2023-02-11 Thread Cameron Simpson
uot;Help" section broadly has the same purpose as this mailing list. I use both, and use Discourse in email mode - the forum's there, but >90% of my interaction is via email - I file it and python-list to the same "python" folder here and lossely treat them the same.

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

2023-01-29 Thread Cameron Simpson
and what happens in a programme once the shell has invoked it for a user. Cheers, Cameron Simpson -- 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-29 Thread Cameron Simpson
On 29Jan2023 07:12, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: On 2023-01-29 at 16:51:20 +1100, Cameron Simpson wrote: They're unrelated. As others have mentioned, "--" is _extremely_ common; almost _all_ UNIX command like programmes

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

2023-01-28 Thread Cameron Simpson
"--" is not:-) They're unrelated. As others have mentioned, "--" is _extremely_ common; almost _all_ UNIX command like programmes which handle -* style options honour the "--" convention. _argparse_ itself honours that convention, as does getopt etc. The "--" convention has nothing to do with the shell. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Custom help format for a choice argparse argument

2023-01-27 Thread Cameron Simpson
t;, choices=pytz.all_timezones) [...] It works, but when I run it with the -h option it dumps all entries in pytz.all_timezones. What happens if you just presupply a `help=` parameter in `add_argument`? Cheers, Cameron Simpson -- 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 Cameron Simpson
if badopts: print(usage, file=sys.stderr) exit(2) ... work with infix as desired ... This: - avoids trying to shoehorn argparse into behaving in a way it was not designed for - avoids users needing to know the standard UNIX/POSIX "--" idiom for marking off the end of options - supports a -h or --help leading option Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >