Shows how to structure a python app using arg parse that goes down many levels.
The "trick" is to
- add a subparsers
S1[] - add parsers
P1[]to your subparserS1[x] - add a new set of subparsers
S2[]to one of those parsersP1[x]
| # Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/ | |
| # Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join()) | |
| class Image(Media): | |
| image = models.ImageField( | |
| upload_to=image_folder | |
| ) | |
| thumbnail = models.ImageField( |
| #Resizes an image and keeps aspect ratio. Set mywidth to the desired with in pixels. | |
| import PIL | |
| from PIL import Image | |
| mywidth = 300 | |
| img = Image.open('someimage.jpg') | |
| wpercent = (mywidth/float(img.size[0])) | |
| hsize = int((float(img.size[1])*float(wpercent))) |
| // General hints on defining types with constraints or invariants | |
| // | |
| // Just as in C#, use a private constructor | |
| // and expose "factory" methods that enforce the constraints | |
| // | |
| // In F#, only classes can have private constructors with public members. | |
| // | |
| // If you want to use the record and DU types, the whole type becomes | |
| // private, which means that you also need to provide: | |
| // * a constructor function ("create"). |
// default exports
export default 42;
export default {};
export default [];
export default (1 + 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}First of all, you need to understand you are not writing documentation for you, nor for your current team. You are writing documentation for the future developers that were not there when you first wrote this code. Worst of it, they might think it is bad code for many reasons and won’t understand why you wrote this way.
Taken from: How to write good software technical documentation
Verified Spec-Driven Development (VSDD) is a unified software engineering methodology that fuses three proven paradigms into a single AI-orchestrated pipeline: