Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-19 Thread Loris Bennett
"Peter J. Holzer" writes: > On 2022-04-16 20:35:22 -, Jon Ribbens via Python-list wrote: >> On 2022-04-16, Peter J. Holzer wrote: >> > On 2022-04-16 14:22:04 -, Jon Ribbens via Python-list wrote: >> >> ... although now having looked into the new 'zoneinfo' module slightly, >> >> it reall

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-19 Thread Loris Bennett
Jon Ribbens writes: > On 2022-04-19, Loris Bennett wrote: >> Jon Ribbens writes: >>> On 2022-04-19, Loris Bennett wrote: >>>> I now realise that timedelta is not really what I need. I am interested >>>> solely in pure periods, i.e. numbers of seconds

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-19 Thread Loris Bennett
Jon Ribbens writes: > On 2022-04-19, Loris Bennett wrote: >> I now realise that timedelta is not really what I need. I am interested >> solely in pure periods, i.e. numbers of seconds, > > That's exactly what timedelta is. > >> that I can convert back and for

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-19 Thread Loris Bennett
Jon Ribbens writes: > On 2022-04-19, Loris Bennett wrote: >> If I am merely trying to represent part a very large number of seconds >> as a number of years, 365 days per year does not seem that controversial >> to me. Obviously there are issues if you expect all periods of

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-20 Thread Loris Bennett
Random832 writes: > On Tue, Apr 19, 2022, at 07:11, Loris Bennett wrote: >> I now realise that timedelta is not really what I need. I am >> interested solely in pure periods, i.e. numbers of seconds, that I >> can convert back and forth from a format such as > > A t

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-20 Thread Loris Bennett
Dennis Lee Bieber writes: > On Tue, 19 Apr 2022 15:51:09 +0200, "Loris Bennett" > declaimed the following: > >>If I am merely trying to represent part a very large number of seconds >>as a number of years, 365 days per year does not seem that controversial >

matplotlib: scatterplot and histogram with same colour scale

2022-04-26 Thread Loris Bennett
Hi, I am using matplotlib to create scatterplot where the colour depends on the y-value. Additionally I want to project the y-values onto a rotated histogram along the right side of the scatterplot. My problem is that with my current code, the colours used for the histogram are normalised to th

Re: matplotlib: scatterplot and histogram with same colour scale

2022-04-26 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I am using matplotlib to create scatterplot where the colour depends on > the y-value. Additionally I want to project the y-values onto a rotated > histogram along the right side of the scatterplot. > > My problem is that with my

Instatiating module / Reusing module of command-line tool

2022-04-29 Thread Loris Bennett
Hi, I have a command-line script in Python to get the correct salutation for a user name in either English or German from a 'salutation server': $ get_salutation alice Dear Professor Müller $ get_salutation alice -l de Sehr geehrte Frau Professorin Müller The hostname, port, user and pas

Match.groupdict: Meaning of default argument?

2022-04-29 Thread Loris Bennett
Hi, If I do import re pattern = re.compile(r'(?P\d*)(-?)(?P\d\d):(?P\d\d):(?P\d\d)') s = '104-02:47:06' match = pattern.search(s) match_dict = match.groupdict('0') I get match_dict {'days': '104', 'hours': '02', 'minutes': '47', 'seconds': '06'} However, if the string has no in

Re: Match.groupdict: Meaning of default argument?

2022-05-03 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>I thought that 'days' would default to '0'. > > It will get the value '0' if (?P\d*) does > /not/ participate in the match. > > In your case, it /d

Re: Match.groupdict: Meaning of default argument?

2022-05-03 Thread Loris Bennett
Julio Di Egidio writes: > On Friday, 29 April 2022 at 09:50:08 UTC+2, Loris Bennett wrote: >> Hi, >> >> If I do >> >> import re >> pattern = >> re.compile(r'(?P\d*)(-?)(?P\d\d):(?P\d\d):(?P\d\d)') >> s = '104-02:47:06&

Re: Match.groupdict: Meaning of default argument?

2022-05-03 Thread Loris Bennett
"Loris Bennett" writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> "Loris Bennett" writes: >>>I thought that 'days' would default to '0'. >> >> It will get the value '0' if (?P\d*) does >>

Re: Instatiating module / Reusing module of command-line tool

2022-05-06 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>My question: What is the analogue to initialising an object via the >>constructor for a module? > > If you need a class, you can write a class. > > When one imports a modu

Re: Request for assistance (hopefully not OT)

2022-05-17 Thread Loris Bennett
o1bigtenor writes: > Greetings > > I was having space issues in my /usr directory so I deleted some > programs thinking that the space taken was more an issue than having > older versions of the program. > > So one of the programs I deleted (using rm -r) was python3.9. Deleting anything from /us

Re: Request for assistance (hopefully not OT)

2022-05-17 Thread Loris Bennett
[snip (26 lines)] > I think you had a problem before that. Debian testing is not an > operating system you should be using if you have a fairly good > understanding of how Debian (or Linux in general) works. Should be I think you had a problem before that. Debian testing is not an operatin

Re: Request for assistance (hopefully not OT)

2022-05-18 Thread Loris Bennett
Chris Angelico writes: > On Wed, 18 May 2022 at 04:05, Loris Bennett > wrote: >> >> [snip (26 lines)] >> >> > I think you had a problem before that. Debian testing is not an >> > operating system you should be using if you have a fairly good >

Re: Python & nmap

2022-05-20 Thread Loris Bennett
Lars Liedtke writes: > Ansible has got a shell module, so you could run custom commands on all > hosts. But it gets more difficult in parsing the output afterwards. If you just want to copy files, pdsh[1] or clush[2] might be enough. Cheers, Loris Footnotes: [1] https://github.com/chaos/pdsh

poetry script fails to find module

2022-07-28 Thread Loris Bennett
Hi, The following is a little bit involved, but I hope can make the problem clear. Using poetry I have written a dummy application which just uses to typer to illustrate a possible interface design. The directory structure is a follows: $ tree -P *.py . |-- dist |-- stoat | |-- hpc

Re: poetry script fails to find module

2022-07-28 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > The following is a little bit involved, but I hope can make the problem clear. > > Using poetry I have written a dummy application which just uses to typer > to illustrate a possible interface design. The directory structure is a

Re: poetry script fails to find module

2022-07-29 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>However, this raises the question of why it worked in the first place >>in the poetry shell. > > It might have had a different or extended sys.path. In the poetry shell sys.path has this

Re: poetry script fails to find module

2022-07-29 Thread Loris Bennett
Hi Stefan, r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>Why is the module 'hpc' not found by the poetry script? > > I have tried to execute the following sequence of shell > commands to understand your problem. Here they

Re: poetry script fails to find module

2022-07-29 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>However, in the development environment, if I run >> python stoat/main.py hpc user --help >>then is >> stoat/hpc/main.py >>being found via >> import hpc.main >>becau

2 options both mutually exclusive with respect to 3rd option

2022-08-03 Thread Loris Bennett
Hi, I want to plot some data which are collected over time. I either want to specify start and/or end times for the plot, or specify last week, month or year. So the usage would look like: plot_data [[--start START --end END] | --last LAST ] I know about argsparse's mutually exclusive group,

Re: Exclude 'None' from list comprehension of dicts

2022-08-04 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>data = [get_job_efficiency_dict(job_id) for job_id in job_ids] > ... >>filtered_data = list(filter(None, data)) > > You could have "get_job_efficiency_dict" return an iterable

Exclude 'None' from list comprehension of dicts

2022-08-04 Thread Loris Bennett
Hi, I am constructing a list of dictionaries via the following list comprehension: data = [get_job_efficiency_dict(job_id) for job_id in job_ids] However, get_job_efficiency_dict(job_id) uses 'subprocess.Popen' to run an external program and this can fail. In this case, the dict should jus

Re: Exclude 'None' from list comprehension of dicts

2022-08-05 Thread Loris Bennett
Antoon Pardon writes: > Op 4/08/2022 om 13:51 schreef Loris Bennett: >> Hi, >> >> I am constructing a list of dictionaries via the following list >> comprehension: >> >>data = [get_job_efficiency_dict(job_id) for job_id in job_ids] >> >&g

poetry: local dependencies in dev and prod environments

2022-09-13 Thread Loris Bennett
Hi, Say I have two modules: main application and a utility. With poetry I can add the utility as local dependency to the main application thus: poetry add ../utilities/mailer/dist/my_mailer-0.1.0-py3-none-any.whl This then generates the following in the pyproj.toml of the main application:

Re: Gdal

2022-10-07 Thread Loris Bennett
Hi Conrado, "\"Jorge Conrado Conforte\"" writes: > Hi, > > > > > I installed GDAL using the pip command and conda. But, I did: > > import gdal and I had: Depending on your GDAL version, you might find you have to do from osgeo import gdal See https://gdal.org/api/python_bindings.html#

Preprocessing not quite fixed-width file before parsing

2022-11-23 Thread Loris Bennett
Hi, I am using pandas to parse a file with the following structure: Name filesettype KB quota limit in_doubt grace |files quotalimit in_doubtgrace shortname sharedhome USR14097664 524288000 545259520 0 none | 107110

Re: Preprocessing not quite fixed-width file before parsing

2022-11-24 Thread Loris Bennett
Thomas Passin writes: > On 11/23/2022 11:00 AM, Loris Bennett wrote: >> Hi, >> I am using pandas to parse a file with the following structure: >> Name filesettype KB quota limit >> in_doubtgrace |files quotalimit in_

Re: Preprocessing not quite fixed-width file before parsing

2022-11-25 Thread Loris Bennett
Thomas Passin writes: > On 11/24/2022 9:06 AM, Loris Bennett wrote: >> Thomas Passin writes: >> >>> On 11/23/2022 11:00 AM, Loris Bennett wrote: >>>> Hi, >>>> I am using pandas to parse a file with the following structure: >>>> Nam

Re: argparse — adding a --version flag in the face of positional args

2022-11-28 Thread Loris Bennett
Mats Wichmann writes: > On 11/27/22 16:40, Skip Montanaro wrote: >> I have a script to which I'd like to add a --version flag. It should print >> the version number then exit, much in the same way --help prints the help >> text then exits. I haven't been able to figure that out. I always get a >>

Re: putting JUNK at the end of a [.py] file

2023-02-24 Thread Loris Bennett
Hen Hanna writes: > in a LaTeX file, after the (1st) \end{document} line, > i can put any random Junk i want(afterwards) until the end of the > file. > > > Is there a similar Method for a.py file ? > > Since i know of no such trick, i sometimes put this (be

Distributing program for Linux

2023-03-14 Thread Loris Bennett
Hi, If I write a system program which has Python >= 3.y as a dependency, what are the options for someone whose Linux distribution provides Python 3.x, where x < y? I am aware that an individual user could use (mini)conda to install a more recent version of Python in his/her home directory, but I

Re: Distributing program for Linux

2023-03-15 Thread Loris Bennett
versions to do the right thing. Cheers, Loris > From: Python-list > on behalf of Loris Bennett > Date: Tuesday, March 14, 2023 at 12:27 PM > To: python-list@python.org > Subject: Distributing program for Linux > *** Attention: This is an external email. Use caution responding,

Re: Distributing program for Linux

2023-03-15 Thread Loris Bennett
Anssi Saari writes: > "Loris Bennett" writes: > >> I am aware that an individual user could use (mini)conda to install a >> more recent version of Python in his/her home directory, but I am >> interested in how root would install such a program. > > Ro

Implementing a plug-in mechanism

2023-03-15 Thread Loris Bennett
Hi, I have written a program which, as part of the non-core functionality, contains a module to generate email. This is currently very specific to my organisation, so the main program contains import myorg.mailer This module is specific to my organisation in that it can ask an internal serv

Re: Implementing a plug-in mechanism

2023-03-16 Thread Loris Bennett
Simon Ward writes: > On Thu, Mar 16, 2023 at 07:45:18AM +1300, dn via Python-list wrote: >> There is a PyPi library called pluggy (not used it). I've used >> informal approaches using an ABC as a framework/reminder (see >> @George's response). > > typing.Protocol is also useful here as the plugin

Standard class for time *period*?

2023-03-27 Thread Loris Bennett
Hi, I have been around long enough to know that, due to time-zones, daylight saving and whatnot, time-related stuff is complicated. So even if I think something connected with time should exist, there may well be a very good reason why it does not. My problem: I need to deal with what I call

Re: Standard class for time *period*?

2023-03-27 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: >>d = datetime_diff.days >>h, rem = divmod( datetime_diff.seconds, 3600 ) >>m, s = divmod( rem, 60 ) >>print( f'{d:02}-{h:02}:{m:02}:{s:02}' ) > > If the default formatting is acceptable to you, you can a

Re: Standard class for time *period*?

2023-03-28 Thread Loris Bennett
Dennis Lee Bieber writes: > On Tue, 28 Mar 2023 08:14:55 +0200, "Loris Bennett" > declaimed the following: > >> >>No, it doesn't. I already know about timedelta. I must have explained >>the issue badly, because everyone seems to be fixating on the &

Re: Standard class for time *period*?

2023-03-28 Thread Loris Bennett
Thomas Passin writes: > On 3/27/2023 11:34 AM, rbowman wrote: >> On Mon, 27 Mar 2023 15:00:52 +0200, Loris Bennett wrote: >> >>>I need to deal with what I call a 'period', which is a span of time >>>limited by two dates, start and end. The p

Re: Standard class for time *period*?

2023-03-29 Thread Loris Bennett
Cameron Simpson writes: > On 28Mar2023 08:05, Dennis Lee Bieber wrote: >> So far, you seem to be the only person who has ever asked for >> asingle >>entity incorporating an EPOCH (datetime.datetime) + a DURATION >>(datetime.timedelta). > > But not the only person to want one. I've got a

Re: Python file location

2023-03-30 Thread Loris Bennett
windhorn writes: > I have an older laptop I use for programming, particularly Python and > Octave, running a variety of Debian Linux, and I am curious if there > is a "standard" place in the file system to store this type of program > file. OK, I know they should go in a repository and be managed

When is logging.getLogger(__name__) needed?

2023-03-31 Thread Loris Bennett
Hi, In my top level program file, main.py, I have def main_function(): parser = argparse.ArgumentParser(description="my prog") ... args = parser.parse_args() config = configparser.ConfigParser() if args.config_file is None: config_file = DEFAULT_CONFI

Re: When is logging.getLogger(__name__) needed?

2023-04-04 Thread Loris Bennett
Peter Otten <__pete...@web.de> writes: > On 31/03/2023 15:01, Loris Bennett wrote: [snip (53 lines)] > Your problem has nothing to do with logging -- it's about visibility > ("scope") of names: > >>>> def use_name(): > print(name) &

Re: When is logging.getLogger(__name__) needed?

2023-04-05 Thread Loris Bennett
dn writes: > On 01/04/2023 02.01, Loris Bennett wrote: >> Hi, >> In my top level program file, main.py, I have >>def main_function(): >>parser = argparse.ArgumentParser(description="my prog") >>... >>

Re: When is logging.getLogger(__name__) needed?

2023-04-05 Thread Loris Bennett
"Loris Bennett" writes: > dn writes: > >> On 01/04/2023 02.01, Loris Bennett wrote: >>> Hi, >>> In my top level program file, main.py, I have >>>def main_function(): >>>parser = argparse.ArgumentParser(description=&qu

Initialising a Config class

2023-04-11 Thread Loris Bennett
Hi, Having solved my problem regarding setting up 'logger' such that it is accessible throughout my program (thanks to the help on this list), I now have problem related to a slightly similar issue. My reading suggests that setting up a module with a Config class which can be imported by any part

Re: convert script awk in python

2021-03-25 Thread Loris Bennett
"Avi Gross" writes: > Just to be clear, Cameron, I retired very early and thus have had no reason > to use AWK in a work situation and for a while was not using UNIX-based > machines. I have no doubt I would have continued using WK as one part of my > toolkit for years albeit less often as I foun

Re: convert script awk in python

2021-03-25 Thread Loris Bennett
Peter Otten <__pete...@web.de> writes: > On 25/03/2021 08:14, Loris Bennett wrote: > >> I'm not doing that, but I am trying to replace a longish bash pipeline >> with Python code. >> >> Within Emacs, often I use Org mode[1] to generate date via some bas

Re: convert script awk in python

2021-03-29 Thread Loris Bennett
Michael Torrie writes: > On 3/25/21 1:14 AM, Loris Bennett wrote: >> Does any one have a better approach? > > Not as such. Running a command and parsing its output is a relatively > common task. Years ago I wrote my own simple python wrapper function > that would make it ea

Canonical conversion of dict of dicts to list of dicts

2021-03-30 Thread Loris Bennett
Hi, If I have dict of dicts, say dod = { "alice": { "lang": "python", "level": "expert" }, "bob": { "lang": "perl", "level": "noob" } } is there a canonical, or more pythonic, way of converting the outer key to a val

Re: Canonical conversion of dict of dicts to list of dicts

2021-03-30 Thread Loris Bennett
Jon Ribbens writes: > On 2021-03-30, Loris Bennett wrote: >> If I have dict of dicts, say >> >> dod = { >> "alice": >> { >> "lang": "python", >> "level": "expert"

Re: Canonical conversion of dict of dicts to list of dicts

2021-03-30 Thread Loris Bennett
dn writes: > On 31/03/2021 01.22, Loris Bennett wrote: >> Jon Ribbens writes: >>> On 2021-03-30, Loris Bennett wrote: >>>> If I have dict of dicts, say >>>> >>>> dod = { >>>> "alice": &

Retrieving non-/etc/passwd users with Python 3?

2021-03-31 Thread Loris Bennett
Hi, I want to get a list of users on a Linux system using Python 3.6. All the users I am interested in are just available via LDAP and are not in /etc/passwd. Thus, in a bash shell I can use 'getent' to display them. When I try to install the PyPi package getent I get the error File "/

Re: Retrieving non-/etc/passwd users with Python 3?

2021-03-31 Thread Loris Bennett
Chris Angelico writes: > On Wed, Mar 31, 2021 at 11:21 PM Loris Bennett > wrote: >> >> Hi, >> >> I want to get a list of users on a Linux system using Python 3.6. All >> the users I am interested in are just available via LDAP and are not in >> /et

Re: Retrieving non-/etc/passwd users with Python 3?

2021-03-31 Thread Loris Bennett
Christian Heimes writes: > On 31/03/2021 14.45, Loris Bennett wrote: >> Chris Angelico writes: >> >>> On Wed, Mar 31, 2021 at 11:21 PM Loris Bennett >>> wrote: >>>> >>>> Hi, >>>> >>>> I want to get a list of use

Current thinking on required options

2021-04-19 Thread Loris Bennett
Hi, I have various small programs which tend to have an interface like the following example: usage: grocli [-h] [-o {check,add,delete}] [-u USERS [USERS ...]] [-g GROUP] Command line grouper tool optional arguments: -h, --helpshow this help message and exit -o {check,

Re: Current thinking on required options

2021-04-19 Thread Loris Bennett
Gisle Vanem writes: > Loris Bennett wrote: > >>usage: grocli [-h] [-o {check,add,delete}] [-u USERS [USERS ...]] [-g >> GROUP] >> >>Command line grouper tool >> >>optional arguments: >> -h, --helpshow this he

Re: Current thinking on required options

2021-04-20 Thread Loris Bennett
Roel Schroeven writes: > Avi Gross via Python-list schreef op 20/04/2021 om 1:56: >> Sidestepping the wording of "options" is the very real fact that providing >> names for even required parts can be helpful in many cases. > > Very true. It's very much like named arguments in Python function call

Problems deploying from poetry development environment

2021-04-26 Thread Loris Bennett
Hi, I am developing using poetry and deploying to a directory on an NFS server. The steps I have been using are 1. poetry build 2. poetry install 3. PYTHONUSERBASE=/my/nfs/dir pip3 install --user ~/git/funky_prog/dist/funky_prog-0.2.0-py3-none-any.whl --upgrade This worked. The programs

Re: Problems deploying from poetry development environment

2021-04-26 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I am developing using poetry and deploying to a directory on an NFS > server. The steps I have been using are > > 1. poetry build > 2. poetry install > 3. PYTHONUSERBASE=/my/nfs/dir pip3 install --user > ~/git/funk

Data structure for plotting monotonically expanding data set

2021-05-27 Thread Loris Bennett
Hi, I currently a have around 3 years' worth of files like home.20210527 home.20210526 home.20210525 ... so around 1000 files, each of which contains information about data usage in lines like namekb alice 123 bob 4 ... zebedee 999 (there are actually more colum

SettingWithCopyWarning despite df.loc

2021-06-16 Thread Loris Bennett
Hi, I have read a CSV file into a pandas DataFrame. The data contain a column for disk-space usage in KB. To plot the data, I would like to scale the date to, say, GB. What I have is the following: size_unit = "GB" factor = {"GB": 1/(1024*1024)} usage.loc[:, size_unit] = usage.loc[:, 'K

Simple SSL client hangs

2021-07-13 Thread Loris Bennett
Hi, In Perl I have the following use IO::Socket::SSL; my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere, PeerPort => 12345, ); my $line = <$my_socket>; print("$line\n"); say $my_socket 'ECH

Re: Simple SSL client hangs

2021-07-14 Thread Loris Bennett
Hi, MRAB writes: > On 2021-07-13 08:50, Loris Bennett wrote: >> Hi, >> >> In Perl I have the following >> >>use IO::Socket::SSL; >> >>my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere, &g

Re: Making command-line args available to deeply-nested functions

2021-08-20 Thread Loris Bennett
Julio Di Egidio writes: > On Friday, 20 August 2021 at 11:54:00 UTC+2, Loris Bennett wrote: >> Hi, >> >> TL;DR: >> >> If I have a command-line argument for a program, what is the best way >> of making this available to a deeply-nested[1] function

Making command-line args available to deeply-nested functions

2021-08-20 Thread Loris Bennett
Hi, TL;DR: If I have a command-line argument for a program, what is the best way of making this available to a deeply-nested[1] function call without passing the parameter through every intermediate function? Long version: If I have, say, a command-line program to send an email with a personali

Re: Making command-line args available to deeply-nested functions

2021-08-23 Thread Loris Bennett
George Fischhof writes: > Loris Bennett ezt írta (időpont: 2021. aug. > 20., P 17:54): > >> Julio Di Egidio writes: >> >> > On Friday, 20 August 2021 at 11:54:00 UTC+2, Loris Bennett wrote: >> >> Hi, >> >> >> >> TL;DR: >&g

Decoding of EmailMessage text

2021-08-23 Thread Loris Bennett
Hi, I have written a command-line program to send email using from email.message import EmailMessage which has an option '--verbose' which prints the email via if args.verbose: print(f"{mail.as_string()}") If I run this with $ poetry run send_email loris -l en -s "Another t

Re: Decoding of EmailMessage text

2021-08-23 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I have written a command-line program to send email using > > from email.message import EmailMessage > > which has an option '--verbose' which prints the email via > > if args.verbose: > print(f&

Re: Decoding of EmailMessage text

2021-08-23 Thread Loris Bennett
Jon Ribbens writes: > On 2021-08-23, Loris Bennett wrote: >> If instead of >> >> mail.set_content(body) >> >> I do >> >> mail.set_content(body, cte="quoted-printable") > > Try print(mail.get_content()) rather than print(ma

Re: Decoding of EmailMessage text

2021-08-24 Thread Loris Bennett
jak writes: > Il 23/08/2021 13:12, Loris Bennett ha scritto: >> Jon Ribbens writes: >> >>> On 2021-08-23, Loris Bennett wrote: >>>> If instead of >>>> >>>>mail.set_content(body) >>>> >>>> I do >>&g

configargparse - reading option from config only

2021-08-26 Thread Loris Bennett
Hi, When using configargparse, it seems that if a value is to be read from a config file, it also has to be defined as a command-line argument in order to turn up as an attribute in the parser namespace. I can sort of see why this is the case, but there are also some options I would like to rea

Re: Making command-line args available to deeply-nested functions

2021-08-26 Thread Loris Bennett
George Fischhof writes: [snip (79 lines)] >> > Hi, >> > >> > Also you can give a try to click and / or typer packages. >> > Putting args into environment variables can be a solution too >> > All of these depends on several things: personal preferences, colleagues >> / >> > firm standards, the p

Re: configargparse - reading option from config only

2021-08-27 Thread Loris Bennett
Richard Damon writes: > On 8/26/21 6:01 AM, Loris Bennett wrote: >> Hi, >> >> When using configargparse, it seems that if a value is to be read from a >> config file, it also has to be defined as a command-line argument in >> order to turn up as an attribute i

Re: configargparse - reading option from config only

2021-08-27 Thread Loris Bennett
before. However, I was hoping to just use configargparse instead. Cheers, Loris > > Cheers > > > [1]: https://docs.python.org/3/library/argparse.html > [2]: https://docs.python.org/3/library/configparser.html -- Dr. Loris Bennett (Hr./Mr.) ZEDAT, Freie Universität Berl

Re: configargparse - reading option from config only

2021-08-30 Thread Loris Bennett
Richard Damon writes: > On 8/27/21 3:37 AM, Loris Bennett wrote: >> Richard Damon writes: >> >>> On 8/26/21 6:01 AM, Loris Bennett wrote: >>>> Hi, >>>> >>>> When using configargparse, it seems that if a value is to be read from a &

Trouble propagating logging configuration

2021-08-31 Thread Loris Bennett
Hi, I am having difficulty getting the my logging configuration passed on to imported modules. My initial structure was as follows: $ tree blorp/ blorp/ |-- blorp | |-- __init__.py | |-- bar.py | |-- foo.py | `-- main.py `-- pyproject.toml whereby the logging configurati

Re: Trouble propagating logging configuration

2021-08-31 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I am having difficulty getting the my logging configuration passed on > to imported modules. > > My initial structure was as follows: > > $ tree blorp/ > blorp/ > |-- blorp > | |-- __init__.py > | |--

Re: Trouble propagating logging configuration

2021-09-01 Thread Loris Bennett
"Dieter Maurer" writes: > Loris Bennett wrote at 2021-8-31 15:25 +0200: >>I am having difficulty getting the my logging configuration passed on >>to imported modules. >> >>My initial structure was as follows: >> >> $ tree blorp/

Re: Trouble propagating logging configuration

2021-09-02 Thread Loris Bennett
"Dieter Maurer" writes: > Loris Bennett wrote at 2021-9-1 13:48 +0200: >> ... >>Yes, but to quote from >>https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial: >> >> A good convention to use when naming loggers is to use a module-

Re: Making command-line args available to deeply-nested functions

2021-09-10 Thread Loris Bennett
George Fischhof writes: > George Fischhof ezt írta (időpont: 2021. aug. 29., V, > 21:27): > >> >> >> Loris Bennett ezt írta (időpont: 2021. aug. >> 26., Cs, 16:02): >> >>> George Fischhof writes: >>> >>> [snip (79 lines)] >&

argparse - 3rd arg only valid for one of two mutually exclusive args?

2021-11-03 Thread Loris Bennett
Hi, With argparse's add_mutually_exclusive_group() I can add mutually exclusive args, but how do I deal with a 3rd arg which only makes sense for one of the mutually exclusive args? More generally I suppose I am interested in having something like [ --foo (--foobar) | --bar (--barfoo) ] if th

Re: Alternatives to Jupyter Notebook

2021-11-15 Thread Loris Bennett
Martin Schöön writes: > Den 2021-10-20 skrev Shaozhong SHI : >> >> My Jupyter notebook becomes unresponsive in browsers. >> > Odd, I never had any problems like that. I use Firefox on Linux. > >> Are there alternatives to read, edit and run Jupyter Notebook? >> > I know some people use emacs orgm

Re: How to package a Python command line app?

2021-12-08 Thread Loris Bennett
Hi Manfred, Manfred Lotz writes: > The are many possibilities to package a Python app, and I have to admit > I am pretty confused. > > Here is what I have: > > A Python command line app which requires some packages which are not in > the standard library. > > I am on Linux and like to have an ex

Re: How to package a Python command line app?

2021-12-09 Thread Loris Bennett
Hi Manfred, Manfred Lotz writes: > Hi Loris, > > On Wed, 08 Dec 2021 15:38:48 +0100 > "Loris Bennett" wrote: > >> Hi Manfred, >> >> Manfred Lotz writes: >> >> > The are many possibilities to package a Python app, and I have to >

SQLAlchemy: When to initialise a session

2022-02-08 Thread Loris Bennett
Hi, I am writing a fairly simple command-line application which will just add or delete an entry in a database and then generate a corresponding email. I am using SQLAlchemy to wrap a class around a database and have class DatebaseWrapper(): """Encapsulation of the database""" def

Re: SQLAlchemy: When to initialise a session

2022-02-08 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I am writing a fairly simple command-line application which will just > add or delete an entry in a database and then generate a corresponding > email. > > I am using SQLAlchemy to wrap a class around a database and h

Abstraction level at which to create SQLAlchemy ORM object

2022-02-10 Thread Loris Bennett
Hi, I am writing a command line program which will modify entries in a database and am trying out SQLAlchemy. A typical command might look like um --operation add --uid ada --gid coders --lang en Parsing the arguments I get, ignoring the operation, a dict {uid: "ada", gid: "coders", lang:

Re: Abstraction level at which to create SQLAlchemy ORM object

2022-02-11 Thread Loris Bennett
Hi Cameron, Cameron Simpson writes: > On 10Feb2022 14:14, Loris Bennett wrote: >>I am writing a command line program which will modify entries in a >>database and am trying out SQLAlchemy. >> >>A typical command might look like >> >> um --operati

When to use SQLAlchemy listen events

2022-02-25 Thread Loris Bennett
Hi, I am wondering whether SQLAlchemy listen events are appropriate for the following situation: I have a table containing users and a table for events related to users class User(Base): __tablename__ = "users" uid = Column('uid', String(64), primary_key=True) gid = Column('

SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-02-28 Thread Loris Bennett
Hi, I have an SQLAlchemy class for an event: class UserEvent(Base): __tablename__ = "user_events" id = Column('id', Integer, primary_key=True) date = Column('date', Date, nullable=False) uid = Column('gid', String(64), ForeignKey('users.uid'), nullable=False) info

Re: When to use SQLAlchemy listen events

2022-02-28 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I am wondering whether SQLAlchemy listen events are appropriate for the > following situation: > > I have a table containing users and a table for events related to users > > class User(Base): > __tablename__

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-01 Thread Loris Bennett
Cameron Simpson writes: > On 28Feb2022 10:11, Loris Bennett wrote: >>I have an SQLAlchemy class for an event: >> >> class UserEvent(Base): >> __tablename__ = "user_events" >> >> id = Column('id', Integer, primary_k

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-01 Thread Loris Bennett
Robert Latest writes: > Loris Bennett wrote: >> Thanks for the various suggestions. The data I need to store is just a >> dict with maybe 3 or 4 keys and short string values probably of less >> than 32 characters each per event. The traffic on the DB is going to be >&g

Re: SQLAlchemy: JSON vs. PickleType vs. raw string for serialised data

2022-03-02 Thread Loris Bennett
Dennis Lee Bieber writes: > On Tue, 01 Mar 2022 08:35:05 +0100, Loris Bennett > declaimed the following: > >>Thanks for the various suggestions. The data I need to store is just a >>dict with maybe 3 or 4 keys and short string values probably of less >>than 32 char

How to test input via subprocess.Popen with data from file

2022-03-10 Thread Loris Bennett
Hi, I have a command which produces output like the following: Job ID: 9431211 Cluster: curta User/Group: build/staff State: COMPLETED (exit code 0) Nodes: 1 Cores per node: 8 CPU Utilized: 01:30:53 CPU Efficiency: 83.63% of 01:48:40 core-walltime Job Wall-clock time: 00:13:35

  1   2   >