Videos
What is a Python Beautifier?
What are the benefits of using a Python Beautifier?
How does a Python Beautifier work?
I am searching for a formatter for Python3 which takes a few simple styling parameters and yet is very easy to use. All I found so far where tons of formatters, which ansolutely enforce one and only one formatting style.
Example input:
def deleteSubnet(ipAddress, cidrMask, interface = defaultNetworkInterface):
if subprocess.run(["ip","a","d",ipAddress+"/"+cidrMask,"dev",interface], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode != 0:
quit(color.red+" ERROR:"+color.stop+" IP could not be cleared. You need to manually remove "+color.blue+ipAddress+"/"+cidrMask+color.stop+" from "+color.blue+interface+color.stop+"!!! Terminating...")
print(color.green+" Success: deleted IP "+color.stopcolor.blue+ipAddress+"/"+cidrMask+color.stop+" from interface "+color.blue+interface+color.stop+".")Example output (NOT WANTED):
def deleteSubnet(ipAddress, cidrMask, interface=defaultNetworkInterface):
if (
subprocess.run(
["ip", "a", "d", ipAddress + "/" + cidrMask, "dev", interface]
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
).returncode
!= 0
):
quit(
color.red
+ " ERROR:"
+ color.stop
+ " IP could not be cleared. You need to manually remove "
+ color.blue
+ ipAddress
+ "/"
+ cidrMask
+ color.stop
+ " from "
+ color.blue
+ interface
+ color.stop
+ "!!! Terminating..."
)
print(
color.green
+ " Success: deleted IP "
+ color.stopcolor.blue
+ ipAddress
+ "/"
+ cidrMask
+ color.stop
+ " from interface "
+ color.blue
+ interface
+ color.stop
+ "."
)Yes it is ugly. Does not matter. If reddit does word-wrap the lines, it will be horrible. But if the line just overflows, it just looks great for me.
All I want to do is a simple tool that understands the indentations and allows me to configure a target indentation. I do not care for the standard that tools like pylint try to enforce - i dislike it.
However what is way worse than not breaking lines, is uneven indentations. And that I need to fix - but please not manually. Is there an easy to use tool, that can fix my *variable* indentations to exactly 2 spaces per indent without changing the rest of the content of the lines? (yes I want 2 spaces, period)
For javascript there are amazing tools, like beautifier.io which handles it perfectly. Why can't I find something like that for python? And yes, I prefer a simple online tool actually, that does not require a login or download.
As to why it is uneven: It is a copy&paste collection from different sources.
Thanks for your help.
I just want to reformat everything so it's perfect. Is there anything like that in Python? What's the best?