RE: issue for setup pandas

2021-09-21 Thread Fady Victor Mikhael Abdelmalk


Dear Python Team,

I got the below issue when trying to install python on my user. Kindly assist 
to know how can I solved.


WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 
'NewConnectionError(': Failed to establish a new connection: [Errno 11001] 
getaddrinfo failed')': /simple/pandas/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 
'NewConnectionError(': Failed to establish a new connection: [Errno 11001] 
getaddrinfo failed')': /simple/pandas/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 
'NewConnectionError(': Failed to establish a new connection: [Errno 11001] 
getaddrinfo failed')': /simple/pandas/

Thanks,
Fady Victor
0508510414


Emirates Telecommunications Group Company PJSC (Etisalat) is a Public Joint 
Stock Company registered in the UAE.
This email (and its attachments) contains confidential information. Do not use, 
copy or disclose the information contained in the email or in any attachment. 
If you are not the intended recipient, please permanently delete it. Etisalat 
does not conclude agreements through email communications and nothing in this 
email shall be construed or interpreted as binding Etisalat or creating any 
obligation on Etisalat.
Although Etisalat has taken reasonable precautions to ensure no viruses are 
present in this email, Etisalat cannot accept liability and responsibility for 
any loss or damage sustained as a result of computer viruses or malwares and 
the recipient must ensure that the email (and attachments) are virus free.
-- 
https://mail.python.org/mailman/listinfo/python-list


Free OCR package in Python and selecting appropriate widget for the GUI

2021-09-21 Thread Mohsen Owzar
Hi Guys
Long time ago I've written a program in Malab a GUI for solving Sudoku puzzles, 
which worked not so bad.
Now I try to write this GUI with Python with PyQt5 or TKinter.
First question is:
Is there any free OCR software, packages or code in Python, which I can use to 
recognize the given digits and their positions in the puzzle square.
Second:
Because, I can not attach a picture to this post, I try to describe my picture 
of my GUI.
It is a 3x3 block / matrix (one third of the whole Sudoku 9x9 block).
This block must be placed three times in row and columns.
Each square of this 3x3 block has 3x3 digits from 1 to 9 at the initialization 
time. These digits are spread out in 3x3 equal distances. These are small fonts 
and black.
The values given by the puzzle are red big fonts and not changeable
The digits typed by the user are black big fonts and changeable
If there is a big font from the Puzzle / User, these must be removed from the 
neighboring fields from the 3x3 matrix (1-9).
Now my question is, actually a hint from your side:
What should I take as widget for one of these small squares to have different 
content as I described above?
I thought of a QLineEdit in PyQt5 or LineEdit in TKinter, because the user must 
type some values in there and therefore can not be labels. So again, for the 
sake of the clarity.
•   When the fields are empty, each square has to show digits from 1 to 9 
with small fonts in 3x3 matrix order.
•   Given values in the puzzle are big fonts and red.
•   Digits which are typed by the user are big fonts and black.
Now the question is, can I take only one LineEdit for all these tree 
situations, or I have to implement 9 small squares for small fonts and a big 
one for the big fonts?
Any help and suggestion is welcome and appreciated.

Best regards 
Mohsen
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Free OCR package in Python and selecting appropriate widget for the GUI

2021-09-21 Thread DFS

On 9/21/2021 4:36 AM, Mohsen Owzar wrote:

Hi Guys
Long time ago I've written a program in Malab a GUI for solving Sudoku puzzles, 
which worked not so bad.
Now I try to write this GUI with Python with PyQt5 or TKinter.
First question is:
Is there any free OCR software, packages or code in Python, which I can use to 
recognize the given digits and their positions in the puzzle square.
Second:
Because, I can not attach a picture to this post, I try to describe my picture 
of my GUI.


Draw your GUI in PyQt designer or other graphics tool, then upload a 
screenshot of it to imgur, then post the link to the picture.


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


c extension finding the module in object initialization

2021-09-21 Thread Robin Becker

I have a c extension which is intended to implement a module the looks 
structurally like this



a = 1
b = 2

class T:
def __init__(self):
self.a = a
self.b = b


so when an object of type T is instantiated it can set up defaults based on the 
current module values of a and b.

In the past using old style single phase module creation the init function for the type could look up the module by 
using the PyState_FindModule function. In the new world where we can implement c extensions which might work with 
multiple interpreters (multi-phase creation). The docs say PyState_FindModule won't work for those and indeed it returns 
NULL so is useless.


Is there a way I can set the current module onto the type definition during the module's exec function? I thought it 
would be easy to add at the point in the exec where I'm doing this to the module, m,


TType.tp_base = &PyBaseObject_Type;
if(PyType_Ready(&TType)<0) goto fail;
if(PyModule_AddObject(m,"T", (PyObject *)&TType)<0) goto fail;

but I don't see the place in the type where I can add these sorts of dynamic attributes. The basic_size is for the 
created objects.


The created type does have a __dict__ which is a mappingproxy. I wondered when 
that actually gets instantiated.

I can see that the type has a __module__ attribute after the module is imported and I suppose if I can find the 
'current' interpreter I might use the __module__ to locate the module object via PyImport_GetModuleDict.


Any expertise or advice gratefully received.
--
Robin Becker

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


Re: issue for setup pandas

2021-09-21 Thread Chris Angelico
On Tue, Sep 21, 2021 at 11:53 PM Fady Victor Mikhael Abdelmalk
 wrote:
>
>
> Dear Python Team,
>
> I got the below issue when trying to install python on my user. Kindly assist 
> to know how can I solved.
>
>
> WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, 
> status=None)) after connection broken by 
> 'NewConnectionError(' at 0x01ABB0BDE6A0>: Failed to establish a new connection: [Errno 11001] 
> getaddrinfo failed')': /simple/pandas/
> WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, 
> status=None)) after connection broken by 
> 'NewConnectionError(' at 0x01ABB0BDEDC0>: Failed to establish a new connection: [Errno 11001] 
> getaddrinfo failed')': /simple/pandas/
> WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, 
> status=None)) after connection broken by 
> 'NewConnectionError(' at 0x01ABB0C07070>: Failed to establish a new connection: [Errno 11001] 
> getaddrinfo failed')': /simple/pandas/
>

Looks like a problem with your internet connection. When you try to
install things like pandas, they have to be downloaded from the
internet. If your firewall is blocking this, you'll have to grant
permission before the installation can continue.

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


Re: Explaining exec(globals, separate_locals)

2021-09-21 Thread Dieter Maurer
Terry Reedy wrote at 2021-9-20 12:46 -0400:
>The second paragraph of the current exec entry
>https://docs.python.org/3.11/library/functions.html#exec
>ends with a sentence I wrote.
>
>"If exec gets two separate objects as globals and locals, the code will
>be executed as if it were embedded in a class definition."
>
>Would the following would be clearer?
>
>"If exec gets two separate objects as globals and locals, the code will
>be executed in two namespaces, the same as is done with the suite of a
>class statements."

It is better but the reference to class statements does not help
(at least me) very much.

Instead, I would try to explain how those namespaces are used,
e.g. bindings are stored in the "local" namespace; lookups
are first performed in the "local", then the "global" namespace,
etc. (e.g. about the effect of `global`, `nonlocal`).



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


Polymorphic imports

2021-09-21 Thread Travis Griggs
I guess this is kind of like mocking for testing. I have a simple module that's 
imported in a number of other spots in my program. There's a condition in the 
OS/filesystem where I'd like to import a polymorphically compatible variant of 
the same module. Can this be accomplished in a sort of once-and-only once spot?

For example, consider something like this:

client/
  module_a
  module_a_prime
lib/
  paths
   lib_a
   lib_b
   ...
model/
  model_a
  model_b
  ...
top_level_a
top_level_b
...


I have a number of imports of module_a. I have a paths module that isolates all 
of my file system access, and that's where the determination can be made which 
one to use, so I tried to do something like:

def dynamic_client_module():
   return client.module_a_prime if the_condition_occurs else client.module_a


Hoping that I could do something like

from lib import paths
import paths.dynamic_client_module()

But this seems to not work. Import can only take real modules? Not programatic 
ones?

Is there a Not-Too-Evil-Way(tm) to add a level of programmatic indirection in 
the import declarations? Or some other trick from a different angle? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Polymorphic imports

2021-09-21 Thread Chris Angelico
On Wed, Sep 22, 2021 at 4:59 AM Travis Griggs  wrote:
>
> I guess this is kind of like mocking for testing. I have a simple module 
> that's imported in a number of other spots in my program. There's a condition 
> in the OS/filesystem where I'd like to import a polymorphically compatible 
> variant of the same module. Can this be accomplished in a sort of 
> once-and-only once spot?
>
> For example, consider something like this:
>
> client/
>   module_a
>   module_a_prime
> lib/
>   paths
>lib_a
>lib_b
>...
> model/
>   model_a
>   model_b
>   ...
> top_level_a
> top_level_b
> ...
>
>
> I have a number of imports of module_a. I have a paths module that isolates 
> all of my file system access, and that's where the determination can be made 
> which one to use, so I tried to do something like:
>
> def dynamic_client_module():
>return client.module_a_prime if the_condition_occurs else client.module_a
>
>
> Hoping that I could do something like
>
> from lib import paths
> import paths.dynamic_client_module()
>
> But this seems to not work. Import can only take real modules? Not 
> programatic ones?
>
> Is there a Not-Too-Evil-Way(tm) to add a level of programmatic indirection in 
> the import declarations? Or some other trick from a different angle?

You can dynamically import modules using importlib.import_module(),
but an easier way might just be a conditional import:

# client/__init__.py
if some_condition:
import module_a_default as module_a
else:
import module_a_prime as module_a

Now everything that refers to client.module_a.whatever will get the
appropriate one, either the original or the alternate.

Alternatively, since you are talking about paths, it might be easiest
to give everything the same name, and then use sys.path to control
your import directories. Not sure which would work out best.

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


Re: Polymorphic imports

2021-09-21 Thread 2QdxY4RzWzUUiLuE
On 2021-09-22 at 05:10:02 +1000,
Chris Angelico  wrote:

> You can dynamically import modules using importlib.import_module(),
> but an easier way might just be a conditional import:
> 
> # client/__init__.py
> if some_condition:
> import module_a_default as module_a
> else:
> import module_a_prime as module_a
> 
> Now everything that refers to client.module_a.whatever will get the
> appropriate one, either the original or the alternate.

+1

> Alternatively, since you are talking about paths, it might be easiest
> to give everything the same name, and then use sys.path to control
> your import directories. Not sure which would work out best.

-1

Please don't do that.  Mutable shared and/or global state (i.e.,
sys.paths) is the root of all evil.  And homegrown crypto and date
libraries.  And those funny red hats.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Polymorphic imports

2021-09-21 Thread Chris Angelico
On Wed, Sep 22, 2021 at 6:05 AM <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2021-09-22 at 05:10:02 +1000,
> Chris Angelico  wrote:
>
> > You can dynamically import modules using importlib.import_module(),
> > but an easier way might just be a conditional import:
> >
> > # client/__init__.py
> > if some_condition:
> > import module_a_default as module_a
> > else:
> > import module_a_prime as module_a
> >
> > Now everything that refers to client.module_a.whatever will get the
> > appropriate one, either the original or the alternate.
>
> +1
>
> > Alternatively, since you are talking about paths, it might be easiest
> > to give everything the same name, and then use sys.path to control
> > your import directories. Not sure which would work out best.
>
> -1
>
> Please don't do that.  Mutable shared and/or global state (i.e.,
> sys.paths) is the root of all evil.  And homegrown crypto and date
> libraries.  And those funny red hats.

All depends on whether this is a script/application or a library. If
it's a library, then I agree, don't mutate sys.path, don't change the
working directory, etc, etc, etc. But applications are free to do
those sorts of things. I don't know what the OP's purpose here is, and
it's entirely possible that sys.path switching is the cleanest way to
do it.

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


XML Considered Harmful

2021-09-21 Thread Michael F. Stemper

On the prolog thread, somebody posted a link to:


One thing that it tangentially says is "XML is not the answer."

I read this page right when I was about to write an XML parser
to get data into the code for a research project I'm working on.
It seems to me that XML is the right approach for this sort of
thing, especially since the data is hierarchical in nature.

Does the advice on that page mean that I should find some other
way to get data into my programs, or does it refer to some kind
of misuse/abuse of XML for something that it wasn't designed
for?

If XML is not the way to package data, what is the recommended
approach?
--
Michael F. Stemper
Life's too important to take seriously.
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Jon Ribbens via Python-list
On 2021-09-21, Michael F. Stemper  wrote:
> On the prolog thread, somebody posted a link to:
>
>
> One thing that it tangentially says is "XML is not the answer."
>
> I read this page right when I was about to write an XML parser
> to get data into the code for a research project I'm working on.
> It seems to me that XML is the right approach for this sort of
> thing, especially since the data is hierarchical in nature.
>
> Does the advice on that page mean that I should find some other
> way to get data into my programs, or does it refer to some kind
> of misuse/abuse of XML for something that it wasn't designed
> for?
>
> If XML is not the way to package data, what is the recommended
> approach?

I'd agree that you should not use XML unless the data is being supplied
already in XML format or perhaps if there is already a schema defined in
XML for exactly your purpose.

If there is nothing pre-existing to build upon then I'd suggest JSON.

If anyone suggests YAML, then you should just back slowly away while
speaking in a low calm voice until you have reached sufficient safe
distance, then turn and run.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread alister via Python-list
On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:

> On the prolog thread, somebody posted a link to:
> 
> 
> One thing that it tangentially says is "XML is not the answer."
> 
> I read this page right when I was about to write an XML parser to get
> data into the code for a research project I'm working on.
> It seems to me that XML is the right approach for this sort of thing,
> especially since the data is hierarchical in nature.
> 
> Does the advice on that page mean that I should find some other way to
> get data into my programs, or does it refer to some kind of misuse/abuse
> of XML for something that it wasn't designed for?
> 
> If XML is not the way to package data, what is the recommended approach?

1'st can I say don't write your own XML parser, there are already a 
number of existing parsers that should do everything you will need.  This 
is a wheel that does not need re-inventing.

2nd if you are not generating the data then you have to use whatever data 
format you are supplied

as far as I can see the main issue with XML is bloat, it tries to do too 
many things & is a very verbose format, often the quantity of mark-up can 
easily exceed the data contained within it.

other formats such a JSON & csv have far less overhead, although again 
not always suitable.

As in all such cases it is a matter of choosing the most apropriate tool 
for the job in hand. 

 




-- 
Antonym, n.:
The opposite of the word you're trying to think of.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Joe Pfeiffer
Eli the Bearded <*@eli.users.panix.com> writes:

> In comp.lang.python, Michael F. Stemper  wrote:
>> I've heard of JSON, but never done anything with it.
>
> You probably have used it inadvertantly on a regular basis over the
> past few years. Websites live on it.

If the user has any interaction whatever with the formats being used to
transfer data then something is very, very wrong.  Someone using a
website built on JSON isn't using JSON in any meaningful sense of the
term.

>> How does CSV handle hierarchical data? For instance, I have
>> generators[1], each of which has a name, a fuel and one or more
>> incremental heat rate curves. Each fuel has a name, UOM, heat content,
>> and price. Each incremental cost curve has a name, and a series of
>> ordered pairs (representing a piecewise linear curve).
>> 
>> Can CSV files model this sort of situation?
>
> Can a string of ones and zeros encode the sounds of Bach, the images
> of his sheet music, the details to reproduce his bust in melted plastic
> extruded from nozzle under the control of machines?
>
> Yes, CSV files can model that. But it would not be my first choice of
> data format. (Neither would JSON.) I'd probably use XML.
>
> I rather suspect that all (many) of those genomes that end up in
> Microsoft Excel files get there via a CSV export from a command line
> tool. Once you can model life in CSV, everything seems possible.

Whenever someone asks "can this be done?" in any sort of computer
related question, the real question is "is this practical?"  I have hazy
memories of seeing a Turing Machine implemented in an Excel spreadsheet,
so *anything* can, with sufficiently ridiculous amounts of work.  That's
not really helpful here.

>> [1] The kind made of tons of iron and copper, filled with oil, and
>> rotating at 1800 rpm.
>
> Those are rather hard to model in CSV, too, but I'm sure it could be
> done.

So let's try to point him at representations that are easy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Michael F. Stemper

On 21/09/2021 13.49, alister wrote:

On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:


On the prolog thread, somebody posted a link to:


One thing that it tangentially says is "XML is not the answer."

I read this page right when I was about to write an XML parser to get
data into the code for a research project I'm working on.
It seems to me that XML is the right approach for this sort of thing,
especially since the data is hierarchical in nature.

Does the advice on that page mean that I should find some other way to
get data into my programs, or does it refer to some kind of misuse/abuse
of XML for something that it wasn't designed for?

If XML is not the way to package data, what is the recommended approach?


1'st can I say don't write your own XML parser, there are already a
number of existing parsers that should do everything you will need.  This
is a wheel that does not need re-inventing.


I was going to build it on top of xml.etree.ElementTree


2nd if you are not generating the data then you have to use whatever data
format you are supplied


It's my own research, so I can give myself the data in any format that I
like.


as far as I can see the main issue with XML is bloat, it tries to do too
many things & is a very verbose format, often the quantity of mark-up can
easily exceed the data contained within it.

other formats such a JSON & csv have far less overhead, although again
not always suitable.


I've heard of JSON, but never done anything with it.

How does CSV handle hierarchical data? For instance, I have
generators[1], each of which has a name, a fuel and one or more
incremental heat rate curves. Each fuel has a name, UOM, heat content,
and price. Each incremental cost curve has a name, and a series of
ordered pairs (representing a piecewise linear curve).

Can CSV files model this sort of situation?


As in all such cases it is a matter of choosing the most apropriate tool
for the job in hand.


Naturally. That's what I'm exploring.


[1] The kind made of tons of iron and copper, filled with oil, and
rotating at 1800 rpm.

--
Michael F. Stemper
This sentence no verb.
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Pete Forman
"Michael F. Stemper"  writes:

> On 21/09/2021 13.49, alister wrote:
>> On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:
> It's my own research, so I can give myself the data in any format that I
> like.
>
>> as far as I can see the main issue with XML is bloat, it tries to do
>> too many things & is a very verbose format, often the quantity of
>> mark-up can easily exceed the data contained within it. other formats
>> such a JSON & csv have far less overhead, although again not always
>> suitable.
>
> I've heard of JSON, but never done anything with it.

Then you should certainly try to get a basic understanding of it. One
thing JSON shares with XML is that it is best left to machines to
produce and consume. Because both can be viewed in a text editor there
is a common misconception that they are easy to edit. Not so, commas are
a common bugbear in JSON and non-trivial edits in (XML unaware) text
editors are tricky.

Consider what overhead you should worry about. If you are concerned
about file sizes then XML, JSON and CSV should all compress to a similar
size.

> How does CSV handle hierarchical data? For instance, I have
> generators[1], each of which has a name, a fuel and one or more
> incremental heat rate curves. Each fuel has a name, UOM, heat content,
> and price. Each incremental cost curve has a name, and a series of
> ordered pairs (representing a piecewise linear curve).
>
> Can CSV files model this sort of situation?

The short answer is no. CSV files represent spreadsheet row-column
values with nothing fancier such as formulas or other redirections.

CSV is quite good as a lowest common denominator exchange format. I say
quite because I would characterize it by 8 attributes and you need to
pick a dialect such as MS Excel which sets out what those are. XML and
JSON are controlled much better. You can easily verify that you conform
to those and guarantee that *any* conformant parser can read your
content. XML is more powerful in that repect than JSON in that you can
define and enforce schemas. In your case the fuel name, UOM, etc. can be
validated with standard tools. In JSON all that checking is entirely
handled by the consuming program(s).

>> As in all such cases it is a matter of choosing the most apropriate tool
>> for the job in hand.
>
> Naturally. That's what I'm exploring.

You might also like to consider HDF5. It is targeted at large volumes of
scientific data and its capabilities are well above what you need.
MATLAB, Octave and Scilab use it as their native format. PyTables and
h2py provide Python/NumPy bindings to it.

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


Re: XML Considered Harmful

2021-09-21 Thread alister via Python-list
On Tue, 21 Sep 2021 14:22:52 -0500, Michael F. Stemper wrote:

> On 21/09/2021 13.49, alister wrote:
>> On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:
>> 
>>> On the prolog thread, somebody posted a link to:
>>> 
>>>
>>> One thing that it tangentially says is "XML is not the answer."
>>>
>>> I read this page right when I was about to write an XML parser to get
>>> data into the code for a research project I'm working on.
>>> It seems to me that XML is the right approach for this sort of thing,
>>> especially since the data is hierarchical in nature.
>>>
>>> Does the advice on that page mean that I should find some other way to
>>> get data into my programs, or does it refer to some kind of
>>> misuse/abuse of XML for something that it wasn't designed for?
>>>
>>> If XML is not the way to package data, what is the recommended
>>> approach?
>> 
>> 1'st can I say don't write your own XML parser, there are already a
>> number of existing parsers that should do everything you will need. 
>> This is a wheel that does not need re-inventing.
> 
> I was going to build it on top of xml.etree.ElementTree
> 
so not writing a parser, using one, that's ok

>> 2nd if you are not generating the data then you have to use whatever
>> data format you are supplied
> 
> It's my own research, so I can give myself the data in any format that I
> like.
> 
>> as far as I can see the main issue with XML is bloat, it tries to do
>> too many things & is a very verbose format, often the quantity of
>> mark-up can easily exceed the data contained within it.
>> 
>> other formats such a JSON & csv have far less overhead, although again
>> not always suitable.
> 
> I've heard of JSON, but never done anything with it.
the python json library makes it simple.
it was originally invented for javascript, it looks very much like the 
repl for a list/dictionary but if you are using std libraries you don't 
really need to know except for academic interst
> 
> How does CSV handle hierarchical data?
It dosn't, if you have heirachiacl data it is not a suitable format
> For instance, I have
> generators[1], each of which has a name, a fuel and one or more
> incremental heat rate curves. Each fuel has a name, UOM, heat content,
> and price. Each incremental cost curve has a name, and a series of
> ordered pairs (representing a piecewise linear curve).
> 
> Can CSV files model this sort of situation?
> 
>> As in all such cases it is a matter of choosing the most apropriate
>> tool for the job in hand.
> 
> Naturally. That's what I'm exploring.
> 
> 
> [1] The kind made of tons of iron and copper, filled with oil, and
> rotating at 1800 rpm.





-- 
Riches cover a multitude of woes.
-- Menander
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Joe Pfeiffer
r...@zedat.fu-berlin.de (Stefan Ram) writes:

> - S expressions (i.e., LISP notation)

If you're looking at hierarchical data and you don't have some good
reason to use something else, this is very likely to be your simplest
option.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Jon Ribbens via Python-list
On 2021-09-21, Pete Forman  wrote:
> CSV is quite good as a lowest common denominator exchange format. I say
> quite because I would characterize it by 8 attributes and you need to
> pick a dialect such as MS Excel which sets out what those are. XML and
> JSON are controlled much better. You can easily verify that you conform
> to those and guarantee that *any* conformant parser can read your
> content. XML is more powerful in that repect than JSON in that you can
> define and enforce schemas. In your case the fuel name, UOM, etc. can be
> validated with standard tools. In JSON all that checking is entirely
> handled by the consuming program(s).

That's not true. You can use "JSON Schema" to create a schema
for validating JSON files, and there appear to be at least four
implementations in Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Eli the Bearded
In comp.lang.python, Michael F. Stemper  wrote:
> I've heard of JSON, but never done anything with it.

You probably have used it inadvertantly on a regular basis over the
past few years. Websites live on it.

> How does CSV handle hierarchical data? For instance, I have
> generators[1], each of which has a name, a fuel and one or more
> incremental heat rate curves. Each fuel has a name, UOM, heat content,
> and price. Each incremental cost curve has a name, and a series of
> ordered pairs (representing a piecewise linear curve).
> 
> Can CSV files model this sort of situation?

Can a string of ones and zeros encode the sounds of Bach, the images
of his sheet music, the details to reproduce his bust in melted plastic
extruded from nozzle under the control of machines?

Yes, CSV files can model that. But it would not be my first choice of
data format. (Neither would JSON.) I'd probably use XML.

I rather suspect that all (many) of those genomes that end up in
Microsoft Excel files get there via a CSV export from a command line
tool. Once you can model life in CSV, everything seems possible.

> [1] The kind made of tons of iron and copper, filled with oil, and
> rotating at 1800 rpm.

Those are rather hard to model in CSV, too, but I'm sure it could be
done.

Elijah
--
for bonus round, use punched holes in paper to encode the ones and zeros
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread Ethan Furman

On 9/21/21 11:12 AM, Michael F. Stemper wrote:

> It seems to me that XML is the right approach for this sort of
> thing, especially since the data is hierarchical in nature.

If you're looking for a format that you can read (as a human) and possibly 
hand-edit,
check out NestedText:

  https://nestedtext.org/en/stable/

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


Re: XML Considered Harmful

2021-09-21 Thread Dan Stromberg
On Tue, Sep 21, 2021 at 7:26 PM Michael F. Stemper <
michael.stem...@gmail.com> wrote:

> If XML is not the way to package data, what is the recommended
> approach?
>

I prefer both JSON and YAML over XML.

XML has both elements and tags, but it didn't really need both. This
results in more complexity than necessary.  Also, XSLT and XPath are not
really all that simple.

But there's hope.  If you're stuck with XML, you can use xmltodict, which
makes XML almost as easy as JSON.

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


Re: Free OCR package in Python and selecting appropriate widget for the GUI

2021-09-21 Thread Mohsen Owzar
DFS schrieb am Dienstag, 21. September 2021 um 15:45:38 UTC+2:
> On 9/21/2021 4:36 AM, Mohsen Owzar wrote: 
> > Hi Guys 
> > Long time ago I've written a program in Malab a GUI for solving Sudoku 
> > puzzles, which worked not so bad. 
> > Now I try to write this GUI with Python with PyQt5 or TKinter. 
> > First question is: 
> > Is there any free OCR software, packages or code in Python, which I can use 
> > to recognize the given digits and their positions in the puzzle square. 
> > Second: 
> > Because, I can not attach a picture to this post, I try to describe my 
> > picture of my GUI.
> Draw your GUI in PyQt designer or other graphics tool, then upload a 
> screenshot of it to imgur, then post the link to the picture.
Thanks, for your answer.
But, what is "imgur"?
I'm not so familiar with handling of pictures in this group.
How can I call "imgur" or how can I get there?

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


Re: Free OCR package in Python and selecting appropriate widget for the GUI

2021-09-21 Thread Igor Korot
imgur.com
Then you upload your image and post a perma-link here in reply.


On Tue, Sep 21, 2021, 22:03 Mohsen Owzar  wrote:

> DFS schrieb am Dienstag, 21. September 2021 um 15:45:38 UTC+2:
> > On 9/21/2021 4:36 AM, Mohsen Owzar wrote:
> > > Hi Guys
> > > Long time ago I've written a program in Malab a GUI for solving Sudoku
> puzzles, which worked not so bad.
> > > Now I try to write this GUI with Python with PyQt5 or TKinter.
> > > First question is:
> > > Is there any free OCR software, packages or code in Python, which I
> can use to recognize the given digits and their positions in the puzzle
> square.
> > > Second:
> > > Because, I can not attach a picture to this post, I try to describe my
> picture of my GUI.
> > Draw your GUI in PyQt designer or other graphics tool, then upload a
> > screenshot of it to imgur, then post the link to the picture.
> Thanks, for your answer.
> But, what is "imgur"?
> I'm not so familiar with handling of pictures in this group.
> How can I call "imgur" or how can I get there?
>
> Regards
> Mohsen
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list