Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-09 Thread Weatherby,Gerard
That’s actually more of a shell question than a Python question. How you pass 
certain control characters is going to depend on the shell, operating system, 
and possibly the keyboard you’re using. (e.g. https://www.alt-codes.net).

Here’s a sample program. The dashes are to help show the boundaries of the 
string

#!/usr/bin/env python3
import argparse
import logging


parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('data')
args = parser.parse_args()
print(f'Input\n: -{args.data}- length {len(args.data)}')
for c in args.data:
print(f'{ord(c)} ',end='')
print()


Using bash on Linux:

./cl.py '^M
'
Input
  -
- length 3
13 32 10


From: Python-list  on 
behalf of Jach Feng 
Date: Thursday, December 8, 2022 at 9:31 PM
To: [email protected] 
Subject: Re: How to convert a raw string r'xdd' to 'xdd' more gracefully?
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

Jach Feng 在 2022年12月7日 星期三上午10:23:20 [UTC+8] 的信中寫道:
> s0 = r'\x0a'
> At this moment it was done by
>
> def to1byte(matchobj):
> return chr(int('0x' + matchobj.group(1), 16))
> s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0)
>
> But, is it that difficult on doing this simple thing?
>
> --Jach
The whold story is,

I had a script which accepts an argparse's positional argument. I like this 
argument may have control character embedded in when required. So I make a post 
"How to enter escape character in a positional string argument from the command 
line? on DEC05. But there is no response. I assume that there is no way of 
doing it and I have to convert it later after I get the whole string from the 
command line.

I made this convertion using the chr(int(...)) method but not satisfied with. 
That why this post came out.

At this moment the conversion is done almost the same as Peter's 
codecs.decode() method but without the need of importing codecs module:-)

def to1byte(matchobj):
return matchobj.group(0).encode().decode("unicode-escape")
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hcg9ULzmtVUzMJ87Emlfsf6PGAfC-MEzUs3QQNVzWwK4aWDEtePG34hRX0ZFVvWcqZXRcM67JkkIg-l-K9vB$
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Panoptisch - A way to understand your project's dependencies and find malicious packages

2022-12-09 Thread Dan Kolis
I think it needs a built in viewer or at least a human readable output, or 
nobody will go through the trouble to use it.

Other that that, maybe a pretty good idea, sure

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


New computer, new Python

2022-12-09 Thread [email protected]


 
Hello.  I've downloaded the new Python to my new Computer,  and the new Python 
mystifies me.
 
Instead of an editor, it looks like a Dos executable program.
 
How can I write my own Python Functions and subroutines in the new Python?
 
It is version 3.11 (64 bit).
 
Kermit
 
 
 
 
-Original Message-
From: [email protected]
Sent: Friday, December 9, 2022 12:00pm
To: [email protected]
Subject: Python-list Digest, Vol 231, Issue 9



Send Python-list mailing list submissions to
 [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
 https://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
 [email protected]

You can reach the person managing the list at
 [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."


Today's Topics:

 1. Re: How to convert a raw string r'\xdd' to '\xdd' more
 gracefully? (Jach Feng)
 2. Re: Nonuniform PRNG? (Stefan Ram)
 3. Panoptisch - A way to understand your project's dependencies
 and find malicious packages (Aarnav Mahavir Bos)
 4. MinecraftEdu (Jelena Ili?)
 5. Re: MinecraftEdu (Cameron Simpson)
 6. Re: How to convert a raw string r'\xdd' to '\xdd' more
 gracefully? (Jach Feng)
 7. Re: Panoptisch - A way to understand your project's
 dependencies and find malicious packages (Axy)
 8. Re: How to convert a raw string r'\xdd' to '\xdd' more
 gracefully? (Weatherby,Gerard)
 9. Re: Panoptisch - A way to understand your project's
 dependencies and find malicious packages (Dan Kolis)


--

Message: 1
Date: Thu, 8 Dec 2022 00:56:42 -0800 (PST)
From: Jach Feng 
To: [email protected]
Subject: Re: How to convert a raw string r'\xdd' to '\xdd' more
 gracefully?
Message-ID: 
Content-Type: text/plain; charset="UTF-8"

Jach Feng ? 2022?12?7? ?10:23:20 [UTC+8] ??
> s0 = r'\x0a' 
> At this moment it was done by 
> 
> def to1byte(matchobj): 
> return chr(int('0x' + matchobj.group(1), 16)) 
> s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) 
> 
> But, is it that difficult on doing this simple thing? 
> 
> --Jach
I find another answer on the web.

>>> s0 = r'\x0a'
>>> s0.encode('Latin-1').decode('unicode-escape')
'\n'


--

Message: 2
Date: 8 Dec 2022 12:17:22 GMT
From: [email protected] (Stefan Ram)
To: [email protected]
Subject: Re: Nonuniform PRNG?
Message-ID: 
Content-Type: text/plain; charset=UTF-8

"Robert E. Beaudoin"  writes:
>One thing you could do is to apply von Neumann de-biasing to convert a
>string of output bits from your biased PRNG to an unbiased string, and
>test the de-biased output.

 Some non-uniform generators are based on uniform generators
 whose output then is warped by the application of some function.

 If one has access to the underlying uniform generator used,
 one can test this with the algorithms for uniform generators.




--

Message: 3
Date: Thu, 8 Dec 2022 18:52:29 +0100
From: Aarnav Mahavir Bos 
To: [email protected]
Subject: Panoptisch - A way to understand your project's dependencies
 and find malicious packages
Message-ID:
 
Content-Type: text/plain; charset="UTF-8"

Hello all,

I would like to share Panoptisch, a FOSS(Free and Open Source Software)
tool I've been working on.

We all may have encountered the issue of not having a clear dependency tree
or not being sure of the modules our dependencies and sub-dependencies are
using.

Some of us may have also heard of supply chain attacks, where open source
projects are hijacked to distribute malicious code masquerading as the
original package. This can happen deep down in the dependency chain.

Panoptisch was born out of the need to accurately verify the modules used
in my project.
It recursively scans a Python module or file to find modules used and
exports a report in JSON which can be parsed for analysis.

For example, should your yaml parser, or it's sub-dependencies import
socket/os? should your markdown renderer or it's sub-dependencies import
sys/importlib? *Probably not.*

Panoptisch is in early stages, has known limitations and is looking for
help! I would love feedback, contributions, and most important of all,
rigorous testing!

I would also love to help you integrate this tool in your workflow to write
more secure software.

Link: https://github.com/R9295/panoptisch
Short Demo: https://www.youtube.com/watch?v=bDJWl_odXx0

Thanks and Regards,
aarnav


--

Message: 4
Date: Thu, 8 Dec 2022 12:12:47 -0800 (PST)
From: Jelena Ili? 
To: [email protected]
Subject: MinecraftEdu
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"

Hello,
I'm new to MinecraftEDU programming with Python. I'm wondering if anyone can 
recommend how to get started with cr

Re: New computer, new Python

2022-12-09 Thread dn

On 10/12/2022 06.13, [email protected] wrote:


  
Hello.  I've downloaded the new Python to my new Computer,  and the new Python mystifies me.
  
Instead of an editor, it looks like a Dos executable program.
  
How can I write my own Python Functions and subroutines in the new Python?
  
It is version 3.11 (64 bit).



Have you invested time in the documentation? 
https://docs.python.org/3/using/windows.html


--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: New computer, new Python

2022-12-09 Thread DFS

On 12/9/2022 12:13 PM, [email protected] wrote:


  
Hello.  I've downloaded the new Python to my new Computer,  and the new Python mystifies me.
  
Instead of an editor, it looks like a Dos executable program.


python.exe is a Windows executable.




How can I write my own Python Functions and subroutines in the new Python?


Open a text editor and write your own functions and subs.  Save the file 
as prog.py.


From the command line (not from inside the Python shell), type:

$ python prog.py




It is version 3.11 (64 bit).


The latest and greatest.  Significantly sped up vs 3.10.

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


Re: New computer, new Python

2022-12-09 Thread Weatherby,Gerard
Python in an IDE is much easier in the long run. We use PyCharm – there’s a 
free version: https://www.jetbrains.com/pycharm/download/#section=windows

From: Python-list  on 
behalf of DFS 
Date: Friday, December 9, 2022 at 4:36 PM
To: [email protected] 
Subject: Re: New computer, new Python
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

On 12/9/2022 12:13 PM, [email protected] wrote:
>
>
> Hello.  I've downloaded the new Python to my new Computer,  and the new 
> Python mystifies me.
>
> Instead of an editor, it looks like a Dos executable program.

python.exe is a Windows executable.



> How can I write my own Python Functions and subroutines in the new Python?

Open a text editor and write your own functions and subs.  Save the file
as prog.py.

 From the command line (not from inside the Python shell), type:

$ python prog.py



> It is version 3.11 (64 bit).

The latest and greatest.  Significantly sped up vs 3.10.

--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!ncQETnsgLM_I29jKwV8WUZPhvn7g3Q5jBnkT_S0CmOf0KCORpl5xSLtMM8ZtE8gMsORNxCKhq01pCww$
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New computer, new Python

2022-12-09 Thread rbowman
On Fri, 9 Dec 2022 12:13:16 -0500 (EST), [email protected] wrote:

> How can I write my own Python Functions and subroutines in the new
> Python?

Personally, I would go with VS Code:

https://learn.microsoft.com/en-us/training/modules/python-install-vscode/

It supports virtual environments nicely:

https://code.visualstudio.com/docs/python/environments
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New computer, new Python

2022-12-09 Thread Mats Wichmann

On 12/9/22 14:56, rbowman wrote:

On Fri, 9 Dec 2022 12:13:16 -0500 (EST), [email protected] wrote:


How can I write my own Python Functions and subroutines in the new
Python?


Personally, I would go with VS Code:

https://learn.microsoft.com/en-us/training/modules/python-install-vscode/

It supports virtual environments nicely:

https://code.visualstudio.com/docs/python/environments


Possibly in some previous setup, IDLE was the thing you opened. IDLE 
*is* an IDE - maybe not the fanciest one available, but it's written in 
Python and comes with the Python distribution.  I don't disagree with 
the two fine editors/IESs suggested previously (I use both of them, in 
slightly different circumstances), but IDLE works well too.


Try telling windows to find and open idle and see if that's more what 
you are expecting?



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


Re: New computer, new Python

2022-12-09 Thread Thomas Passin
It sounds like on your old computer, you used some kind of program to 
write python code and perhaps to run it too.  It would help if you could 
say what that program was.  Python itself - the actual program called 
"python.exe" on Windows - runs a Python interpreter inside a Windows 
console window.  That's what you see when you run "python".  You 
probably would like to run the same editor as you used on the old 
computer, but unless you can say what that program was, we can't help 
you.  The best we can do is to suggest various alternative programs and 
editors, as several people have already done.


On 12/9/2022 12:13 PM, [email protected] wrote:


  
Hello.  I've downloaded the new Python to my new Computer,  and the new Python mystifies me.
  
Instead of an editor, it looks like a Dos executable program.
  
How can I write my own Python Functions and subroutines in the new Python?
  
It is version 3.11 (64 bit).
  
Kermit
  
  
  
  
-Original Message-

From: [email protected]
Sent: Friday, December 9, 2022 12:00pm
To: [email protected]
Subject: Python-list Digest, Vol 231, Issue 9



Send Python-list mailing list submissions to
  [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
  https://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
  [email protected]

You can reach the person managing the list at
  [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-list digest..."


Today's Topics:

  1. Re: How to convert a raw string r'\xdd' to '\xdd' more
  gracefully? (Jach Feng)
  2. Re: Nonuniform PRNG? (Stefan Ram)
  3. Panoptisch - A way to understand your project's dependencies
  and find malicious packages (Aarnav Mahavir Bos)
  4. MinecraftEdu (Jelena Ili?)
  5. Re: MinecraftEdu (Cameron Simpson)
  6. Re: How to convert a raw string r'\xdd' to '\xdd' more
  gracefully? (Jach Feng)
  7. Re: Panoptisch - A way to understand your project's
  dependencies and find malicious packages (Axy)
  8. Re: How to convert a raw string r'\xdd' to '\xdd' more
  gracefully? (Weatherby,Gerard)
  9. Re: Panoptisch - A way to understand your project's
  dependencies and find malicious packages (Dan Kolis)


--

Message: 1
Date: Thu, 8 Dec 2022 00:56:42 -0800 (PST)
From: Jach Feng 
To: [email protected]
Subject: Re: How to convert a raw string r'\xdd' to '\xdd' more
  gracefully?
Message-ID: 
Content-Type: text/plain; charset="UTF-8"

Jach Feng ? 2022?12?7? ?10:23:20 [UTC+8] ??

s0 = r'\x0a'
At this moment it was done by

def to1byte(matchobj):
return chr(int('0x' + matchobj.group(1), 16))
s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0)

But, is it that difficult on doing this simple thing?

--Jach

I find another answer on the web.


s0 = r'\x0a'
s0.encode('Latin-1').decode('unicode-escape')

'\n'


--

Message: 2
Date: 8 Dec 2022 12:17:22 GMT
From: [email protected] (Stefan Ram)
To: [email protected]
Subject: Re: Nonuniform PRNG?
Message-ID: 
Content-Type: text/plain; charset=UTF-8

"Robert E. Beaudoin"  writes:

One thing you could do is to apply von Neumann de-biasing to convert a
string of output bits from your biased PRNG to an unbiased string, and
test the de-biased output.


  Some non-uniform generators are based on uniform generators
  whose output then is warped by the application of some function.

  If one has access to the underlying uniform generator used,
  one can test this with the algorithms for uniform generators.




--

Message: 3
Date: Thu, 8 Dec 2022 18:52:29 +0100
From: Aarnav Mahavir Bos 
To: [email protected]
Subject: Panoptisch - A way to understand your project's dependencies
  and find malicious packages
Message-ID:
  
Content-Type: text/plain; charset="UTF-8"

Hello all,

I would like to share Panoptisch, a FOSS(Free and Open Source Software)
tool I've been working on.

We all may have encountered the issue of not having a clear dependency tree
or not being sure of the modules our dependencies and sub-dependencies are
using.

Some of us may have also heard of supply chain attacks, where open source
projects are hijacked to distribute malicious code masquerading as the
original package. This can happen deep down in the dependency chain.

Panoptisch was born out of the need to accurately verify the modules used
in my project.
It recursively scans a Python module or file to find modules used and
exports a report in JSON which can be parsed for analysis.

For example, should your yaml parser, or it's sub-dependencies import
socket/os? should your markdown renderer or it's sub-dependencies import
sys/importlib? *Probably not.*

Panoptisch is in early stages, has known limitations and is looking for
help! I would love feedback, contributio

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-09 Thread Jach Feng
moi 在 2022年12月9日 星期五晚上11:41:20 [UTC+8] 的信中寫道:
> PS C:\humour> py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z 
> cp1252 
> a 
> b c 
> €uro 
> z 
> 
> PS C:\humour> $a = py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z 
> cp1252 
> 
> PS C:\humour> licp($a) 
> a U+0061 
> b U+0062 
> U+0009 
> c U+0063 
> € U+20AC 
> u U+0075 
> r U+0072 
> o U+006F 
> x U+0078 
> U+0008 
> z U+007A 
> 
> PS C:\humour> 
> 
> PS C:\humour> py38 sysargwithliteral.py 
> a\u000ab\u0009c\u000a\u20acuro\u000ax\u0008z\u000aend\U0001f60a unicode 
> a 
> b c 
> €uro 
> z 
> end😊 
> 
> PS C:\humour> 
> 
> PS C:\humour> py38 sysargwithliteral.py a\x0ab\x09c\x0a\x80uro\x0ax\x08z 
> cp1252 | py38 -c "import sys; s = sys.stdin.read(); print(s.rstrip())" 
> a 
> b c 
> €uro 
> z 
> 
> PS C:\humour> 
> Note: In a terminal "\t" is correct.
Where is the sysargwithliteral.py?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-09 Thread Jach Feng
Weatherby,Gerard 在 2022年12月9日 星期五晚上9:36:18 [UTC+8] 的信中寫道:
> That’s actually more of a shell question than a Python question. How you pass 
> certain control characters is going to depend on the shell, operating system, 
> and possibly the keyboard you’re using. (e.g. https://www.alt-codes.net). 
> 
> Here’s a sample program. The dashes are to help show the boundaries of the 
> string 
> 
> #!/usr/bin/env python3 
> import argparse 
> import logging 
> 
> 
> parser = 
> argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
>  
> parser.add_argument('data') 
> args = parser.parse_args() 
> print(f'Input\n: -{args.data}- length {len(args.data)}') 
> for c in args.data: 
> print(f'{ord(c)} ',end='') 
> print() 
> 
> 
> Using bash on Linux: 
> 
> ./cl.py '^M 
> ' 
> Input 
> - 
> - length 3 
> 13 32 10
> From: Python-list  on 
> behalf of Jach Feng  
> Date: Thursday, December 8, 2022 at 9:31 PM 
> To: [email protected]  
> Subject: Re: How to convert a raw string r'xdd' to 'xdd' more gracefully? 
> *** Attention: This is an external email. Use caution responding, opening 
> attachments or clicking on links. ***
> Jach Feng 在 2022年12月7日 星期三上午10:23:20 [UTC+8] 的信中寫道: 
> > s0 = r'\x0a' 
> > At this moment it was done by 
> > 
> > def to1byte(matchobj): 
> > return chr(int('0x' + matchobj.group(1), 16)) 
> > s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) 
> > 
> > But, is it that difficult on doing this simple thing? 
> > 
> > --Jach 
> The whold story is, 
> 
> I had a script which accepts an argparse's positional argument. I like this 
> argument may have control character embedded in when required. So I make a 
> post "How to enter escape character in a positional string argument from the 
> command line? on DEC05. But there is no response. I assume that there is no 
> way of doing it and I have to convert it later after I get the whole string 
> from the command line. 
> 
> I made this convertion using the chr(int(...)) method but not satisfied with. 
> That why this post came out. 
> 
> At this moment the conversion is done almost the same as Peter's 
> codecs.decode() method but without the need of importing codecs module:-) 
> 
> def to1byte(matchobj): 
> return matchobj.group(0).encode().decode("unicode-escape")
> -- 
> https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hcg9ULzmtVUzMJ87Emlfsf6PGAfC-MEzUs3QQNVzWwK4aWDEtePG34hRX0ZFVvWcqZXRcM67JkkIg-l-K9vB$

> That’s actually more of a shell question than a Python question. How you pass 
> certain control characters is going to depend on the shell, operating system, 
> and possibly the keyboard you’re using. (e.g. https://www.alt-codes.net).

You are right, that's why I found later that it's easier to enter it using a 
preferred pattern. But there is a case, as moi mentioned in his previous post, 
will cause failure when a Windows path in the form of \xdd just happen in the 
string:-(
-- 
https://mail.python.org/mailman/listinfo/python-list


Announcing Clabate 0.5.0: minimalistic class-based templates for Python

2022-12-09 Thread Axy via Python-list

Hi there,

although it's quite old my side project, it has reached the point where 
I don't want to add anything more.


It's a simple template system based on standard string formatting. You 
declare your template strings as class attributes and they are formatted 
in the right order. For dynamic content you can use class properties, 
and inline invocations, such as 'hello, {my_db:get_name({person_id!r})}'


https://github.com/declassed-art/clabate

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