Re: Tuple Comprehension ???

2023-02-21 Thread Axy via Python-list
On 21/02/2023 19:11, avi.e.gr...@gmail.com wrote: In your own code, you may want to either design your own functions, or use them as documented or perhaps create your own wrapper functions that carefully examine what you ask them to do and re-arrange as needed to call the function(s) you want

Re: Tuple Comprehension ???

2023-02-21 Thread Axy via Python-list
On 21/02/2023 04:13, Hen Hanna wrote: (A) print( max( * LisX )) (B) print( sum( * LisX ))<--- Bad syntax !!! What's most surprising is (A) is ok, and (B) is not. even tho' max() and sum() have (basically) the same

Re: File write, weird behaviour

2023-02-19 Thread Axy via Python-list
Looks like the data to be written is buffered, so actual write takes place after readlines(), when close() flushes buffers. See io package documentation, BufferedIOBase. The solution is file.flush() after file.write() Can't deny, such a behaviour looks utterly weird. Try to avoid designing

Fun with python string formatting

2022-12-18 Thread Axy via Python-list
Hi all, what do you see looking at format string syntax https://docs.python.org/3/library/string.html#formatstrings ? In particular, at something like this: {h[1].red.jumbo-header:Hello, World!} Yes, this is syntactically correct statement and if we tweak Formatter methods, we can generate

Announcing Clabate 0.5.0: minimalistic class-based templates for Python

2022-12-09 Thread Axy via Python-list
Hi there, although it's quite old my side project, it has reached the point where I don't want to add anything more. It's a simple template system based on standard string formatting. You declare your template strings as class attributes and they are formatted in the right order. For

Re: Panoptisch - A way to understand your project's dependencies and find malicious packages

2022-12-08 Thread Axy via Python-list
On 08/12/2022 17:52, Aarnav Mahavir Bos wrote: Hello all, I would like to share Panoptisch, a FOSS(Free and Open Source Software) tool I've been working on. Hi there, I added your project to my watch list, keep on your work. A couple of points: First, I glanced at the code and in the very

Re: Passing information between modules

2022-11-18 Thread Axy via Python-list
On 18/11/2022 10:53, Stefan Ram wrote: Can I use "sys.argv" to pass information between modules as follows? in module A: import sys sys.argv.append( "Hi there!" ) in module B: import sys message = sys.argv[ -1 ] This idea has a couple of flaws so can be regarded as bad.

Re: Are these good ideas?

2022-11-14 Thread Axy via Python-list
On 15/11/2022 04:36, Dan Stromberg wrote: On Mon, Nov 14, 2022 at 11:33 AM Axy via Python-list wrote: On 14/11/2022 17:14, Stephen Tucker wrote: > Hi, > > I have two related issues I'd like comments on. > > Issue 1 - Global Values Your "glob

Re: Are these good ideas?

2022-11-14 Thread Axy via Python-list
On 14/11/2022 17:14, Stephen Tucker wrote: Hi, I have two related issues I'd like comments on. Issue 1 - Global Values Your "global variables" module acts exactly as a singleton class. Funny, you could (and maybe you do) write in your functions import global_vars_module as self as the

Re: Superclass static method name from subclass

2022-11-13 Thread Axy via Python-list
On 11/11/2022 16:21, Ian Pilcher wrote: Is it possible to access the name of a superclass static method, when defining a subclass attribute, without specifically naming the super- class? Contrived example:   class SuperClass(object):   @staticmethod   def foo():   pass   class

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Axy via Python-list
I have no idea why, I used to remove namespaces, following the advice from stackoverflow: https://stackoverflow.com/questions/4255277/lxml-etree-xmlparser-remove-unwanted-namespace _ns_removal_xslt_transform = etree.XSLT(etree.fromstring('''    

Re: xml.etree and namespaces -- why?

2022-10-19 Thread Axy via Python-list
I mean, it's worth to look at BeautifulSoup source how do they do that. With BS I work with attributes exactly as you want, and I explicitly tell BS to use lxml parser. Axy. On 19/10/2022 14:25, Robert Latest via Python-list wrote: Hi all, For the impatient: Below the longish text is a fully

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

2022-10-16 Thread Axy via Python-list
On 16/10/2022 18:43, Antoon Pardon wrote: Op 16/10/2022 om 17:03 schreef Avi Gross: Interesting idea, Anton. I would be interested in hearing more detail on how it would work. Although much of programming has been centered on the Latin alphabet and especially English, that may change. I can

Re: Fwd: Can you help me with this Python question?

2022-10-13 Thread Axy via Python-list
Well, although I never used pandas and never will, if that's about artworks, that's mine. Obviously, you need to iterate columns and sum values returned by the snippet you provided. A quick search tells us to use colums property. So, it might look like this: na_sum =

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

2022-10-11 Thread Axy via Python-list
On 10/10/2022 06:15, avi.e.gr...@gmail.com wrote: Chris, a short(er) answer to your addition below. I did not at first share your perception but maybe do now. If the argument was that ELSE and other constructs like FINALLY or CATCH are horrible because they follow other code and important

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

2022-10-10 Thread Axy via Python-list
On 10/10/2022 19:25, Weatherby,Gerard wrote: pylint, at least, provides a warning: fe.py:4:0: W0120: Else clause on loop without a break statement (useless-else-on-loop) I'm using flake8, it does not, alas. Axy. -- https://mail.python.org/mailman/listinfo/python-list

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

2022-10-10 Thread Axy via Python-list
On 10/10/2022 15:52, Weatherby,Gerard wrote: I wonder if for/else could have been less confusing if it was referred to as for-break-else and if the else clause was only valid syntax if the for loop actually contained a break statement in the first place. Sounds reasonable. It would be

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

2022-10-10 Thread Axy via Python-list
On 10/10/2022 15:52, Weatherby,Gerard wrote: Core developer Raymond Hettinger explains the history starting at 15:40 https://www.youtube.com/watch?v=OSGv2VnC0go (which I found on stackoverflow https://stackoverflow.com/questions/9979970/why-does-python-use-else-after-for-and-while-loops )

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

2022-10-10 Thread Axy via Python-list
On 10/10/2022 12:24, Chris Angelico wrote: On Mon, 10 Oct 2022 at 21:57, Axy via Python-list wrote: Not sure what you mean, but a for-else without a break is quite useless. What exactly ARE you arguing here? The else is associated with the break to the exact extent that one is essential

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

2022-10-10 Thread Axy via Python-list
Not sure what you mean, but a for-else without a break is quite useless. What exactly ARE you arguing here? The else is associated with the break to the exact extent that one is essential to the other's value. I'm not arguing. That was just for the record, how things are done in Python.

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

2022-10-10 Thread Axy via Python-list
On 09/10/2022 03:33, Jach Feng wrote: Axy 在 2022年10月8日 星期� �上午11:39:44 [UTC+8] 的信中寫道: Hi there, this is rather a philosophical question, but I assume I miss something. I don't remember I ever used else clause for years I was with python and my expectation was it executed only if the the main

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

2022-10-09 Thread Axy via Python-list
Since many languages allow placing multiple statements on one line or spreading one over many lines, it seems that the number of lines in code can be adjusted. If I have a line like: Alpha, beta, gamma, delta = 1, 2, 3, 4 Could that be rewritten as 4 or more lines? Surely! Especially if

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

2022-10-09 Thread Axy via Python-list
Yes, I'm aware that code readability becomes irrelevant for short-duration projects. Beside the point. I'm wondering how important it really is to have the shortest block first. I also might be wrong in terminology, anyway, there are many rules that make programmer's life easier, described

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

2022-10-08 Thread Axy via Python-list
On 09/10/2022 05:47, Chris Angelico wrote: On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: Got it, thanks! Actually the reason I never used "else" was the violation of the rule of beauty "shortest block first". With if--else you can easily follow th

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

2022-10-08 Thread Axy via Python-list
Got it, thanks! Actually the reason I never used "else" was the violation of the rule of beauty "shortest block first". With if--else you can easily follow this rule by inverting "if" expression, but with for--else you can't. The loop body of the simplest example is already three lines, in

for -- else: what was the motivation?

2022-10-07 Thread Axy via Python-list
Hi there, this is rather a philosophical question, but I assume I miss something. I don't remember I ever used else clause for years I was with python and my expectation was it executed only if the the main body was never run. Ha-ha! I was caught by this mental trap. So, seriously, why they

Re: Asynchronous execution of synchronous functions

2022-09-26 Thread Axy via Python-list
Did you check the ThreadPoolExecutor or the ProcessPoolExecutor? They won't give you atomic writes unless you add a Lock or a Condition, but they will execute your code in another thread or process. Yes, I did, but they are too complicated to use. I'd like something for humans, such as

Asynchronous execution of synchronous functions

2022-09-26 Thread Axy via Python-list
Hi there, is there a library to call functions in context of a thread? For example, as in asyncsqlite which has a thread and a queue I mean has anyone generalized such an approach already? If not, I'll do it myself, no problem. It's a kind of tiny stuff, like atomicwrites, which is quite

Re: Conecting to MySQL

2022-08-09 Thread Axy via Python-list
trying to connect to MYSQL it appears the error msg below: InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused) [image: conexao.png] How can i fix that.? What do you use for connection? Does the firewall interfere with the connection? Firewall

Clabate: minimalistic class-based templates for Python

2022-08-02 Thread Axy via Python-list
Hi all, this is a test message after tweaking my self-hosted mail server and the subject is just in case if you receive it https://declassed.art/en/blog/2022/06/29/clabate-class-based-templates Previously I tried to reply to someone here but the message was rejected. Did not post to mail