Function to call a extern command as a filter

2019-09-25 Thread Ulrich Goebel

Hello,

what I want:

I want a function which converts a markdown-formatted string to a 
latex-formatted string, like


def markdown_to_latex (m : string)
make a latex-formatted string l
from the given markdown-formatted string m
return (l)

What I have:

I have a extern tool pandoc which does exactly what I want, but it
works on files. This tool is able to work as a pipe, so it uses
the standard input and standard outpu.

What I could do:

def markdown_to_latex (m : string)
write the string m to a file
call pandoc to work on that file
read the outputfile into the string l
return (l)

What would be nice:

I would like to avoid the extra steps writing an reading extern files.

Can anybody help me?

Thanks
Ulrich


--
Ulrich Goebel
Am Büchel 57, 53173 Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Function to call a extern command as a filter

2019-09-25 Thread Rhodri James

On 25/09/2019 12:04, Ulrich Goebel wrote:

Hello,

what I want:

I want a function which converts a markdown-formatted string to a 
latex-formatted string

[snip]

I have a extern tool pandoc which does exactly what I want, but it
works on files. This tool is able to work as a pipe, so it uses
the standard input and standard outpu.

What I could do:

def markdown_to_latex (m : string)
 write the string m to a file
 call pandoc to work on that file
 read the outputfile into the string l
 return (l)

What would be nice:

I would like to avoid the extra steps writing an reading extern files.


subprocess is your friend here.  Something like:

import subprocess
def mardown_to_latex(markdown_string):
  latex = subprocess.run(cmd_string_for_pandoc,
 input=markdown_string,
 string=True,
 capture_output=True)
  return latex.output

The above is completely untested and not in the least bit robust, but 
that's the area of the standard library you should be looking at.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python in The Economist

2019-09-25 Thread Rhodri James

On 25/09/2019 07:37, Frank Millman wrote:
"Since chip design is expensive, and chip designers scarce, he and his 
team have been working on software tools to simplify that task. The idea 
is to describe a new algorithm in Python, a widely used programming 
language, and then have software turn it into a circuit diagram that can 
be fed into Pragmatic's chipmaking machines. That approach has attracted 
interest from DARPA ..."


It is an interesting approach.  Our experience as IoT consultants is 
that clients want what they want, and chip manufacturers produce what 
they produce, and the overlap isn't as big as you would hope.  Making 
chip design simpler would certainly help.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python in The Economist

2019-09-25 Thread Chris Angelico
On Wed, Sep 25, 2019 at 9:33 PM Rhodri James  wrote:
> Our experience as IoT consultants is
> that clients want what they want, and chip manufacturers produce what
> they produce, and the overlap isn't as big as you would hope.

Thank you for validating my inherent cynicism :)

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


Re: Python in The Economist

2019-09-25 Thread Gene Heskett
On Wednesday 25 September 2019 08:27:32 Chris Angelico wrote:

> On Wed, Sep 25, 2019 at 9:33 PM Rhodri James  
wrote:
> > Our experience as IoT consultants is
> > that clients want what they want, and chip manufacturers produce
> > what they produce, and the overlap isn't as big as you would hope.
>
> Thank you for validating my inherent cynicism :)
>
> ChrisA

You have this disparity demonstrated every time you go to the grocery 
store.  After about a year, all the time wasteing are you sure crap has 
been removed from the card processing. Stuff that never should have been 
in the code path in the first place.  Then a new card processor with his 
own card readers wins the next contract, and we repeat the same rodeo 
all over again.  Except he bought the readers from a BBLB maker, and the 
failure rate is, predictably, astronomical.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CSV reader ignore brackets

2019-09-25 Thread Skip Montanaro
> Besides, the point isn't the shortest code but to illustrate the idea 
> of handling special syntax.

In my defense, I was typing on my phone while watching a show on
Netflix. I was hardly in a position to test any code. :-)

As you indicated though, the problem is under-specified (nesting?,
presence of quotation marks?, newlines between balanced parens? input
size?, etc). It probably does little good to try and cook up a
comprehensive solution to such a problem. Better to just toss out some
ideas for the OP and let them mull it over, maybe try to solve the
problem themselves.

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


Re: Function to call a extern command as a filter

2019-09-25 Thread lain.mailinglist via Python-list

> On 25/09/2019 12:04, Ulrich Goebel wrote:
>
> > Hello,
> > what I want:
> > I want a function which converts a markdown-formatted string to a
> > latex-formatted string
>
> [snip]
>
> > I have a extern tool pandoc which does exactly what I want, but it
> > works on files. This tool is able to work as a pipe, so it uses
> > the standard input and standard outpu.
> > What I could do:
> > def markdown_to_latex (m : string)
> > write the string m to a file
> > call pandoc to work on that file
> > read the outputfile into the string l
> > return (l)
> > What would be nice:
> > I would like to avoid the extra steps writing an reading extern files.
>
> subprocess is your friend here. Something like:
>
> import subprocess
> def mardown_to_latex(markdown_string):
> latex = subprocess.run(cmd_string_for_pandoc,
> input=markdown_string,
> string=True,
> capture_output=True)
> return latex.output
>
> The above is completely untested and not in the least bit robust, but
> that's the area of the standard library you should be looking at.
>
> --
>
> Rhodri James - Kynesim Ltd
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list

You can also use the io.StringIO class of the stdlib, which is more suitable 
for this use case.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Function to call a extern command as a filter

2019-09-25 Thread Rhodri James

On 25/09/2019 18:00, lain.mailinglist via Python-list wrote:



On 25/09/2019 12:04, Ulrich Goebel wrote:


Hello,
what I want:
I want a function which converts a markdown-formatted string to a
latex-formatted string


[snip]


I have a extern tool pandoc which does exactly what I want, but it
works on files. This tool is able to work as a pipe, so it uses
the standard input and standard outpu.
What I could do:
def markdown_to_latex (m : string)
 write the string m to a file
 call pandoc to work on that file
 read the outputfile into the string l
 return (l)
What would be nice:
I would like to avoid the extra steps writing an reading extern files.


subprocess is your friend here. Something like:

[snip myself]



You can also use the io.StringIO class of the stdlib, which is more suitable 
for this use case.


Not for running external tools, surely?

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Function to call a extern command as a filter

2019-09-25 Thread Terry Reedy

On 9/25/2019 7:27 AM, Rhodri James wrote:

On 25/09/2019 12:04, Ulrich Goebel wrote:

Hello,

what I want:

I want a function which converts a markdown-formatted string to a 
latex-formatted string

[snip]

I have a extern tool pandoc which does exactly what I want, but it
works on files. This tool is able to work as a pipe, so it uses
the standard input and standard outpu.


I was not familiar with pandoc, but it seems to be a major m to n (where 
n > m) markup translator. https://pandoc.org/index.html


https://github.com/jgm/pandoc (search 'pandoc github') says "Pandoc is a 
Haskell library for converting from one markup format to another, and a 
command-line tool that uses this library. "


If you were writing in Haskell or if pandoc were written in Python or if 
pandoc were wrapped as a Python library, you could use it as an 
importable library.  The third is true, as it is for so many useful 
libraries written in other languages.


https://pypi.org/project/pypandoc/ (https://github.com/bebraw/pypandod) 
(search 'python pandoc') says it can use an existing pandoc installation 
or pandoc included with its Windows and Mac wheels (for pip install).


https://github.com/applecrazy/pyandoc is another wrapping.

One can write custom filters in Python (and other languages).
https://pandoc.org/scripting-1.12.html
https://github.com/jgm/pandocfilters
https://pypi.org/project/pandocfilters/


What I could do:

def markdown_to_latex (m : string)
 write the string m to a file
 call pandoc to work on that file
 read the outputfile into the string l
 return (l)

What would be nice:

I would like to avoid the extra steps writing an reading extern files.


subprocess is your friend here.  Something like:


Short of using pypandoc or pyandoc, this is probably the best thing.


import subprocess
def mardown_to_latex(markdown_string):
   latex = subprocess.run(cmd_string_for_pandoc,
  input=markdown_string,
  string=True,
  capture_output=True)
   return latex.output

The above is completely untested and not in the least bit robust, but 
that's the area of the standard library you should be looking at.





--
Terry Jan Reedy


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


HELP NEEDED application error 0xc000005

2019-09-25 Thread arshad ali via Python-list
Note: Forwarded message attached

-- Original Message --

From: "arshad ali"[email protected]
To: [email protected]
Subject: HELP  NEEDED application error 0xc05--- Begin Message ---
Respected sir,
  In my laptop with windows 7 ultimate 64 bit, when python 3.7.4  
executable 64 bit installed 
it is giving me the error " THE APPLICATION WAS UNABLE TO START CORRECTLY 
(0xc005) CLICK OK TO CLOSE" 
I tried many times.

But python 2.7.16 is working in my laptop.

please help me in getting out of this error for which i will be highly grateful 
to you.

Dr. Arshad
Hyderabad, INDIA--- End Message ---
-- 
https://mail.python.org/mailman/listinfo/python-list


Funny code

2019-09-25 Thread ast

Hello

A line of code which produce itself when executed

>>> s='s=%r;print(s%%s)';print(s%s)
s='s=%r;print(s%%s)';print(s%s)

Thats funny !
--
https://mail.python.org/mailman/listinfo/python-list