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

2024-05-29 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

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())

Re: How to Add ANSI Color to User Response

2024-04-11 Thread Cameron Simpson via Python-list
meone else are probably `colourise` and `colourise_patterns`. Link: https://github.com/cameron-simpson/css/blob/26504f1df55e1bbdef00c3ff7f0cb00b2babdc01/lib/python/cs/ansi_colour.py#L96 I particularly use it to automatically colour log messages on a terminal, example code: https://github.com/camer

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

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
) 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
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(value)}') or whatever fits your code. Cheers, Cameron Simpson

Re: A question about import

2024-02-16 Thread Cameron Simpson via Python-list
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
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

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

Re: Type hints - am I doing it right?

2023-12-13 Thread Cameron Simpson via Python-list
() 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
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-02 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
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 online TV streaming service who

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

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

2023-09-17 Thread Cameron Simpson via Python-list
s 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
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
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 suggesting where yo

Re: isinstance()

2023-08-02 Thread Cameron Simpson via Python-list
kets) and frugal use of the meaning of what values can occur there. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

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 automatic

Re: Should NoneType be iterable?

2023-06-20 Thread Cameron Simpson via Python-list
-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 Simpson

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

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

2023-04-28 Thread Cameron Simpson
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
... 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
e 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
ll 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.python.org

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
s.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
://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 Simpson -- https://mail.python.org

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-simpson/css/blob

Re: Standard class for time *period*?

2023-03-28 Thread Cameron Simpson
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

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

2023-03-26 Thread Cameron Simpson
ens 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
e ".__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
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
imported. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Baffled by readline module

2023-03-10 Thread Cameron Simpson
ou 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
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
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 liked it. That paragraph could do with being a bullet li

Re: Lambda returning tuple question, multi-expression

2023-03-09 Thread Cameron Simpson
, ) 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, Cameron Simpson

Re: Lambda returning tuple question, multi-expression

2023-03-09 Thread Cameron Simpson
, 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
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
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 another arrives

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

2023-03-05 Thread Cameron Simpson
by 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
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
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 Simpson -- https

Re: How to escape strings for re.finditer?

2023-02-28 Thread Cameron Simpson
ng 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
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
ust 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
ed_ 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
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(fspath) You can stack the decorators just like deal. Cheers, Ca

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

2023-02-23 Thread Cameron Simpson
(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 an aid to completing the type annotations.

Re: Line continuation and comments

2023-02-23 Thread Cameron Simpson
t 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
_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
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, Camer

Re: Am I banned from Discuss forum?

2023-02-11 Thread Cameron Simpson
roadly 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. Cheers, Cameron Simpson --

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 which

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

2023-01-28 Thread Cameron Simpson
emely_ 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
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

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

2023-01-23 Thread Cameron Simpson
;. Not personally a fan of argparse myself, but then I have my own elaborate command line framework which generally uses getopt for the option stuff. 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-23 Thread Cameron Simpson
saying that what follows from here is not an argument. So the user is expected to type: your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" where there are -x and -y options, then end of options, then an argument, which would look like an option if there wasn't the "--" argument.

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

2023-01-22 Thread Cameron Simpson
ingle character strings which it has taken to be individual arguments. Try this: parser.parse_args(["-4^2+5.3*abs(-2-1)/2"]) and of course: parser.parse_args(["--", "-4^2+5.3*abs(-2-1)/2"]) You can see this behaviour of strings as: print(list("abc")) or: for s in "abc": print("s =", repr(s)) Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP-8, Line Length, And All That

2023-01-21 Thread Cameron Simpson
I've got docstrings with _example_ code which doubles as a doctest. Making it easier to understand how to easily use this thing. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Improvement to imports, what is a better way ?

2023-01-19 Thread Cameron Simpson
can themselves call update etc and ... Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Cameron Simpson
uot; point where the tk gui updates widgets and polls for user actions. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Cameron Simpson
don't think you've described this. I don't know what you mean here. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Mailing-Lists (pointer)

2023-01-11 Thread Cameron Simpson
On 11Jan2023 19:10, Dieter Maurer wrote: Cameron Simpson wrote at 2023-1-11 08:37 +1100: ... There's a Discourse forum over at discuss.python.org. I use it in "mailing list mode" and do almost all my interactions via email, exactly as I do for python-list. [...] I am also using

Re: Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

2023-01-10 Thread Cameron Simpson
work, just not in a separate thread. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Mailing-Lists (pointer)

2023-01-10 Thread Cameron Simpson
lder I use for python-list. My replies land on the forum as expected (and of course also go by email to those members who have turned that mode on). So I'm using both the new forum and the currently mailing list still, and broadly in exactly the same way. Cheers, Cameron Simpson -- https://mail.

Re: Suggestion: Regex string specifier like r and f

2023-01-08 Thread Cameron Simpson
and one could argue that type annotations already form a "has no effect" syntax extension to Python, so we're already in that playground :-) Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Cameron Simpson
do that globally (eg in the root logger) it will affect _all_ logging calls, not merely your own, and other libraries will assume they can log at whatever level and not pollute stdout with their logs. Basicly, logging isn't "output". Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: String to Float, without introducing errors

2022-12-18 Thread Cameron Simpson
On 19Dec2022 08:53, Cameron Simpson wrote: I'm no expert on floating point coding for precision, but I believe that trying to work with values "close together" in magnitude is important because values of different scales inherently convert one of them to the other scale (i.e. sim

Re: String to Float, without introducing errors

2022-12-18 Thread Cameron Simpson
imilar sized exponent part) with corresponding loss of precision in the mantissa part. That may require you to form your calcutations carefully. See if you can locate a source for the jerkiness (by printing intermediate results) and then maybe rephrase that step? Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Cameron Simpson
ing, it is needn't be utf-8). (For the OP: `UnicodeDecodeError` doesn't necessarily mean you're decoding Unicode data, you're decoding _into_ a Python string which is a Unicode string.) Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: MinecraftEdu

2022-12-08 Thread Cameron Simpson
/computer-science-subject-kit/python-101 That's just from a web search, I've not used it. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Python coding

2022-11-27 Thread Cameron Simpson
to copy and save this “logistics.py“ file? It sounds like you're follow some tutorial? Can you provide the URL of the tutorial you're following? Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging

2022-11-19 Thread Cameron Simpson
On 20Nov2022 12:36, Chris Angelico wrote: On Sun, 20 Nov 2022 at 12:27, Cameron Simpson wrote: But really, is there any problem which cannot be solved with a decorator? I've even got a @decorator decorator for my decorators. Do you have a @toomanydecorators decorator to reduce the number

Re: Logging

2022-11-19 Thread Cameron Simpson
problem which cannot be solved with a decorator? I've even got a @decorator decorator for my decorators. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Passing information between modules

2022-11-19 Thread Cameron Simpson
want to do this? Often this kind of response ("yes but don't!") can be a clue that you're chasing the wrong (sorry, "suboptimal/poor") solution to a problem which can be solved in another way. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging

2022-11-19 Thread Cameron Simpson
ing levels logging.INFO, logging.WARNING etc, and then called logging.log() with the official level. Then adjust the calling code to call your new function. The alternative is to just replace every calling function which uses my_ugly_debug() to directly call a logging.whatever() call. Cheers, Camer

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

2022-11-15 Thread Cameron Simpson
target for complaint by a linter, whose task is to point out dodgy looking stuff for review by the author. Cheers, Cameron Simpson -- 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 Cameron Simpson
at this: clearx = x.clear is more valid than: x.clear which discards the return value of the expression. Cheers, Cameron Simpson -- 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 Cameron Simpson
will it just show up here? Or do the actual Python devs intercept it? Nah, it'll go through. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list

Re: Dealing with non-callable classmethod objects

2022-11-12 Thread Cameron Simpson
On 13Nov2022 10:08, Cameron Simpson wrote: On 13Nov2022 07:57, Cameron Simpson wrote: # replace fctory with a function calling factory.__func__ factory = lambda arg: factory.__func__(classmethod, arg) It just occurred to me that you might need to grab the value

  1   2   3   4   5   6   7   8   9   10   >