It would be nice if the Black formatter could be added natively to Pythonista.
For those who don't know about Black: this is a code formatter that makes your code PEP8 compatible and very consistent: highly recommended. See https://black.readthedocs.io/en/stable/ for details.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Best posts made by upwart
-
Feature request: Native support for Black
-
Any chance that the greenlet module would be supported in Pythonista?
I am developing a package which uses the excellent greenlet module (https://pypi.org/project/greenlet/).
Alas, this seems not to be supported by Pythonista.
Can we expect this to be included in a future version? -
RE: Change black linelength
This is to tell that I have managed to get black to use an alternative line length (160 in my case), by pip installing black. It will be installed in the site-packages (user) folder. And there, I can just patch the const.py file.
It seems to work perfectly. Hooray! -
RE: iOS 13
And PyTo is open source, so even if the developer is not anymore supporting the product (like seems the case with Pythonista) others can continue the product (at least in theory).
-
RE: Properties that are more fun
@mikael
Thanks for this great idea.
I have renamed your decorator to getter_setter, to make the purpose of it more clear.Thus we define a decorator function:
def getter_setter(func): return property(func, func)
and then we can redo the example as:
class Example:
@getter_setter def my_property(self, *value): if value: self._my_property = value[0] else: return self._my_property
or EAFP style:
class Example: @getter_setter def my_property(self, *value): try: self._my_property = value[0] except IndexError: return self._my_property
Optionally, we could define two more decorators for getter only and setter only properties:
def getter(func): def raise_attribute_error(*args): raise AttributeError("can't set attribute") return property(func, raise_attribute_error) def setter(func): def raise_attribute_error(*args): raise AttributeError("can't get attribute") return property(raise_attribute_error, func)
Here is an example of a Circle class demonstrating the three decorators.
radius can be used to get the radius and set the radius (thus updating the _area attribute)
area can be used to get the area only. Setting will raise an error.
diameter can only be used to set the radius. You can’t get it.Here is an implementation with getter_setter only:
import math class Circle: def __init__(self, radius): self.radius = radius @getter_setter def radius(self, *value): if value: self._radius = value[0] self._area = math.pi * self._radius ** 2 else: return self._radius @getter_setter def area(self, *value): if value: raise AttributeError("can't set attribute") else: return self._area @getter_setter def diameter(self, *value): if value: self.radius = value[0] / 2 else: raise AttributeError("can't get attribute") And if we use getter and setter as well: import math class Circle: def __init__(self, radius): self.radius = radius @getter_setter def radius(self, *value): if value: self._radius = value[0] self._area = math.pi * self._radius ** 2 else: return self._radius @getter def area(self): return self._area @setter def diameter(self, value): self.radius = value / 2
-
RE: Load PIL image in scene with retina resolution
@mikael
I just found out that if change the file format from PNG to BMP speeds up the animation significantly: from 4 to > 16 fps.