使我的代码在阅读和性能方面更好

时间:2018-12-21 19:38:45

标签: python django python-3.x

我有一个python django代码,我想使其在阅读和性能上更好,因为我想将其添加到我的辅助项目中,而我是python和django的新手。有人可以帮我吗

if "__repr__" in vars(cls):
    # repr overriden in class. Don't mess with it
else:
    cls.__repr__ = AutoRepr.__repr__

1 个答案:

答案 0 :(得分:1)

  //--------
    render() {

        let formIn  = this.props.form;                                  // JSON description of FORM
        let formOut = null;                                             // contructed REACT/Javascript form


        switch (formIn.format) {                                        // what type of operation is this
            case 'accordion': {                                         // Accordion in a FORM, OK
                let children = this.pages(formIn.pages,
                                          formIn.format);               // build the children
                formOut = React.createElement(Accordion,                // construct the parent with ALL nested CHILDREN after
                                            {key: formIn.formName},     // just a unique key 
                                            children);                  // N ACCORDION pages, N2 input fields
                break;
            }
            case 'workflow': {
                let children = this.pages(formIn.pages,                 // build the children
                                          formIn.format);               // build the children
                formOut = React.createElement(Workflow,                 // and create the complex sheet element
                                            { key: formIn.formName},
                                            children);                  // N SLIDING pages, N2 input fields
                break;
            }
            case 'simple': {
                let children = this.pages(formIn.pages,                 // build the children
                                          formIn.format);               // build the children
                formOut = React.createElement(Simple,
                                            { key: formIn.formName},
                                            children);                  // One page, N input fields
                break;
            }
        }

        return( <div>
                    {formOut}
                </div>
        );
    }
}

export default SmartForm;

//-----------------   EOF -------------------------------------------------