Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form

Peter J. Holzer hjp-python at hjp.at
Tue May 17 11:21:29 EDT 2022


On 2022-05-16 20:48:02 -0400, Dennis Lee Bieber wrote:
> On Mon, 16 May 2022 17:22:17 -0700 (PDT), "hongy... at gmail.com"
> <hongyi.zhao at gmail.com> declaimed the following:
> >a=re.sub(r"'","",a)
> 
> 	Explain what you believe this operation is doing, show us the input and
> the output.
> 
> 	The best I can make out of that is that it is looking for single quote
> characters within whatever "a" is, and replacing them with nothing.
> Something much more understandable, without invoking a regular expression
> library (especially when neither the search nor the replacement terms are
> regular expressions) with simple string operations...
> 
> 	stripped = "".join(quoted.split("'"))

Whether that's easier to understand it very much in the eye of the
beholder.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20220517/7d129197/attachment.sig>


More information about the Python-list mailing list