Mailing

2021-01-21 Thread TheGemmyGuy
A quick question; for mailing, do I send a message through e-mail or the
Python Mailman page?


Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Can I earn a lot of money by learning and mastering the Python programming language?

2021-01-21 Thread Turritopsis Dohrnii Teo En Ming
Subject: Can I earn a lot of money by learning and mastering the Python
programming language?

Good day from Singapore,

I am an IT consultant with a System Integrator (SI)/computer firm in
Singapore, specializing in Systems/Infrastructure and Computer Networking.
I am thinking of creating an extra avenue/stream of income by learning
extra skills and becoming a programmer or software developer/engineer. I
hope it is not too late for a person of my age. Can I earn a lot of money
by learning and mastering the Python programming language? Thought I would
like to find out first before I jump into the bandwagon and investing my
time into learning Python. Besides Python, what other programming languages
can make me earn a lot of money? Are Python, Java and C++ the most popular
and most sought after (by employers) programming languages in the world?

I am looking forward to your advice.

Thank you very much.

Mr. Turritopsis Dohrnii Teo En Ming, 42 years old as of 21 Jan 2021
Thursday, is a TARGETED INDIVIDUAL living in Singapore. He is an IT
Consultant with a System Integrator (SI)/computer firm in Singapore. He is
an IT enthusiast.





-BEGIN EMAIL SIGNATURE-

The Gospel for all Targeted Individuals (TIs):

[The New York Times] Microwave Weapons Are Prime Suspect in Ills of
U.S. Embassy Workers

Link:
https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html



Singaporean Targeted Individual Mr. Turritopsis Dohrnii Teo En Ming's
Academic
Qualifications as at 14 Feb 2019 and refugee seeking attempts at the
United Nations Refugee Agency Bangkok (21 Mar 2017), in Taiwan (5 Aug
2019) and Australia (25 Dec 2019 to 9 Jan 2020):

[1] https://tdtemcerts.wordpress.com/

[2] https://tdtemcerts.blogspot.sg/

[3] https://www.scribd.com/user/270125049/Teo-En-Ming

-END EMAIL SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: etree, gzip, and BytesIO

2021-01-21 Thread Kushal Kumaran
On Thu, Jan 21 2021 at 08:22:08 AM, Frank Millman  wrote:
> Hi all
>
> This question is mostly to satisfy my curiosity.
>
> In my app I use xml to represent certain objects, such as form
> definitions and process definitions.
>
> They are stored in a database. I use etree.tostring() when storing
> them and etree.fromstring() when reading them back. They can be quite
> large, so I use gzip to compress them before storing them as a blob.
>
> The sequence of events when reading them back is -
>- select gzip'd data from database
>- run gzip.decompress() to convert to a string
>- run etree.fromstring() to convert to an etree object
>
> I was wondering if I could avoid having the unzipped string in memory,
> and create the etree object directly from the gzip'd data. I came up
> with this -
>
>- select gzip'd data from database
>- create a BytesIO object - fd = io.BytesIO(data)
>- use gzip to open the object - gf = gzip.open(fd)
>- run etree.parse(gf) to convert to an etree object
>
> It works.
>
> But I don't know what goes on under the hood, so I don't know if this
> achieves anything. If any of the steps involves decompressing the data
> and storing the entire string in memory, I may as well stick to my
> present approach.
>
> Any thoughts?
>

etree.parse will hold the entire uncompressed content in memory
regardless of how you supply it input.  If your question is whether you
can avoid holding an extra copy in memory, you can take a look at the
ElementTree code in
https://github.com/python/cpython/blob/3.9/Lib/xml/etree/ElementTree.py
(linked from the documentation of the library module).  The parse method
appears to read 64k at a time from the underlying stream, so using the
gzip.open stream instead of gzip.decompress should limit the duplicated
data being held in memory.

It is possible to use the XMLPullParser or iterparse etree features to
incrementally parse XML without ever holding the entire content in
memory.  But that will not give you an ElementTree object, and might not
be feasible without an entire rewrite of the rest of the code.

-- 
regards,
kushal
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Mailing

2021-01-21 Thread David Lowry-Duda
On Thu, Jan 21, 2021 at 06:19:03AM -0500, TheGemmyGuy wrote:
> A quick question; for mailing, do I send a message through e-mail or the
> Python Mailman page?

Whatever you did here works. I use email. - DLD
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Mailing

2021-01-21 Thread Grant Edwards
On 2021-01-21, David Lowry-Duda  wrote:
> On Thu, Jan 21, 2021 at 06:19:03AM -0500, TheGemmyGuy wrote:
>> A quick question; for mailing, do I send a message through e-mail or the
>> Python Mailman page?
>
> Whatever you did here works. I use email. - DLD

NNTP client (slrn) via nntp://news.gmane.io/gmane.comp.python.general

--
Grant

-- 
https://mail.python.org/mailman/listinfo/python-list


Python flask logging: two different formats, but want one format

2021-01-21 Thread Dan Stromberg
I am working on a REST API using Flask.

The API is currently divided across two Python 3.6 modules: update.py and
vmware_exporters_support.py.

update.py logs the way I want. vmware_exporters_support.py does not log the
way I want. I want vmware_exporters_support.py to use update.py's logging
format without logging things twice.

In update.py, the logging is set up with:
from flask.logging import create_logger
app = Flask('collector_api')
logger = create_logger(app)
import vmware_exporters_support

And create_logger, which is part of Flask, is at
https://github.com/pallets/flask/blob/1.1.x/src/flask/logging.py

Then in vmware_exporters_support.py I'm setting up logging with:
logger = logging.getLogger()

It seems like this should just get the root logger from update.py, but I'm
not sure it does really considering how differently it's acting.

An illustrative log snippet looks like:

[2021-01-21 12:12:29,810] INFO in update: Writing container yaml
/data/vmware-exporter/vmware_exporter_1
2021-01-21.12:12:29  INFO Writing container yaml
/data/vmware-exporter/vmware_exporter_1

The [2021-01-21 12:12:29,810] (with the square brackets) is coming from
update.py, and the 2021-01-21.12:12:29 (without the square brackets) is
coming from vmware_exporters_support.py

What do I need to do to get vmware_exporters_support.py to use the same
logging format as update.py?

BTW, update.py is the __main__, not vmware_exporters_support.py.

And I'm using Flask 1.1.2.

Thanks in advance!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python flask logging: two different formats, but want one format

2021-01-21 Thread Cameron Simpson
On 21Jan2021 15:37, Dan Stromberg  wrote:
>I am working on a REST API using Flask.
>
>The API is currently divided across two Python 3.6 modules: update.py and
>vmware_exporters_support.py.
>
>update.py logs the way I want. vmware_exporters_support.py does not log the
>way I want. I want vmware_exporters_support.py to use update.py's logging
>format without logging things twice.
>
>In update.py, the logging is set up with:
>from flask.logging import create_logger
>app = Flask('collector_api')
>logger = create_logger(app)
>import vmware_exporters_support
>
>And create_logger, which is part of Flask, is at
>https://github.com/pallets/flask/blob/1.1.x/src/flask/logging.py
>
>Then in vmware_exporters_support.py I'm setting up logging with:
>logger = logging.getLogger()
>
>It seems like this should just get the root logger from update.py, but I'm
>not sure it does really considering how differently it's acting.

Is logger-from_flask and logger_in_vmware_exporters_support the same 
using "is"? Have you printed them? Usually loggers have names indicating 
their position in a logger tree - print should show this.

Loggers have handlers to deal with log requests, and it is the handlers 
which have the formats attached. Can you see the handlers for the root 
logger (which looks to be what vmware_exporters_support uses) and for 
the one from flask?

It doesn't seem documents, but dir() on a Logger shows a .handlers 
attribute which is a list of Handlers.

>The [2021-01-21 12:12:29,810] (with the square brackets) is coming from
>update.py, and the 2021-01-21.12:12:29 (without the square brackets) is
>coming from vmware_exporters_support.py
>
>What do I need to do to get vmware_exporters_support.py to use the same
>logging format as update.py?
>
>BTW, update.py is the __main__, not vmware_exporters_support.py.

Can you pass the logger you get from create_logger(app) to the 
vmware_exporters_support setup function? That way you could tell it to 
use your preferred logger.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Force Python ast to emit lines no longer than $length

2021-01-21 Thread Samuel Marks
I ended up adding word-wrap support directly to my code-generation:
https://github.com/SamuelMarks/doctrans/commit/6147b21e168b66623aa1be95cb38b1969daa5147

Samuel Marks
Charity  | consultancy 
| open-source  | LinkedIn



On Wed, Jan 20, 2021 at 2:05 PM Samuel Marks  wrote:

> I've written a library that works at the ast level. Sometimes the
> generated output goes over the linter line length limit.
>
>
> "foo_bar_can_haz_foo_bar_can_haz_foo_bar_can_haz_foo_bar_can_haz_foo_bar_can_haz_foo_bar_can_haz"
>
> How do I generate this kind of code instead?
>
> "foo_bar_can_haz_foo_bar_can_haz_foo_bar_can_haz_"
> "foo_bar_can_haz_foo_bar_can_haz_foo_bar_can_haz"
>
> (also happy with the \ and parenthesised variants) [cross-posted:
> stackoverflow.com/q/65800797]
>
> The only thing I can think of doing—retaining support for 3.6, 3.7,
> 3.8, 3.9, and 3.10a4—is to contribute to both astor and the builtin
> ast.unparse…
>
-- 
https://mail.python.org/mailman/listinfo/python-list