Thread: [Pythoncad-developer] coding convention
CAD Application entire developed in Python
Status: Beta
Brought to you by:
matteoboscolo
From: Gertwin G. <ger...@gm...> - 2010-02-03 20:43:11
|
Hi all, Now the we start working on the best PythonCAD ever it is time to think about some coding convention. In the old wiki this is mentioned but it is not followed by us in the last months. I think the easiest thing to do is to follow the PyGTK coding conventions: example: class gtk.CellEditable(gobject.GInterface): def start_editing(event) def editing_done() def remove_widget() Lower case package, module (and file) names. Mixed upper and lower case for class names, each word starts with a capital letter. Functions and class members are lower case, words are divided by a underscore. Variable names are lower case, words are divided by a underscore. See the pygtk-demo for examples. Any comments? Regards, Gertwin |
From: Yagnesh D. <yn...@gm...> - 2010-02-04 06:07:36
|
Gretwin; I know the coding done by me needs lot of touch up. I need to improve my coding skills as this is the first time I am doing any coding for such project. I only used to do editing of recorded macros. Also I am not good at OOP and whatever coding I did was with good help of Matteo. Hope to improve and learn more while contributing to PythonCAD. If the convention in old wiki is what can be followed we must use it for there must not be any difference in the way old and new one. On Thu, Feb 4, 2010 at 2:07 AM, Gertwin Groen <ger...@gm...> wrote: > Hi all, > > Now the we start working on the best PythonCAD ever it is time to > think about some coding convention. > In the old wiki this is mentioned but it is not followed by us in the > last months. > > I think the easiest thing to do is to follow the PyGTK coding conventions: > > example: > > class gtk.CellEditable(gobject.GInterface): > def start_editing(event) > def editing_done() > def remove_widget() > > Lower case package, module (and file) names. > Mixed upper and lower case for class names, each word starts with a > capital letter. > Functions and class members are lower case, words are divided by a underscore. > Variable names are lower case, words are divided by a underscore. > > See the pygtk-demo for examples. > > Any comments? > > Regards, > Gertwin > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > Pythoncad-developer mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncad-developer > -- Best regards Yagnesh Desai Save a tree...please don't print this e-mail. |
From: <ger...@gm...> - 2010-02-04 06:55:40
|
Hi Yagnesh, That's all right, your skills will improve. We all can learn from each other. I saw Arts coding conventions just recently. It is good to have some unity in our code. Regards, Gertwin Op schreef Yagnesh Desai <yn...@gm...>: > Gretwin; > I know the coding done by me needs lot of touch up. > I need to improve my coding skills as this is the first time > I am doing any coding for such project. I only used to > do editing of recorded macros. > Also I am not good at OOP and whatever coding I did > was with good help of Matteo. > Hope to improve and learn more while contributing to > PythonCAD. > If the convention in old wiki is what can be followed > we must use it for there must not be any difference > in the way old and new one. > On Thu, Feb 4, 2010 at 2:07 AM, Gertwin Groen ger...@gm...> > wrote: > > Hi all, > > > > Now the we start working on the best PythonCAD ever it is time to > > think about some coding convention. > > In the old wiki this is mentioned but it is not followed by us in the > > last months. > > > > I think the easiest thing to do is to follow the PyGTK coding > conventions: > > > > example: > > > > class gtk.CellEditable(gobject.GInterface): > > def start_editing(event) > > def editing_done() > > def remove_widget() > > > > Lower case package, module (and file) names. > > Mixed upper and lower case for class names, each word starts with a > > capital letter. > > Functions and class members are lower case, words are divided by a > underscore. > > Variable names are lower case, words are divided by a underscore. > > > > See the pygtk-demo for examples. > > > > Any comments? > > > > Regards, > > Gertwin > > > > > ------------------------------------------------------------------------------ > > The Planet: dedicated and managed hosting, cloud storage, colocation > > Stay online with enterprise data centers and the best network in the > business > > Choose flexible plans and management services without long-term > contracts > > Personal 24x7 support from experience hosting pros just a phone call > away. > > http://p.sf.net/sfu/theplanet-com > > _______________________________________________ > > Pythoncad-developer mailing list > > Pyt...@li... > > https://lists.sourceforge.net/lists/listinfo/pythoncad-developer > > > -- > Best regards > Yagnesh Desai > Save a tree...please don't print this e-mail. > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the > business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > Pythoncad-developer mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncad-developer |
From: Matteo B. <mat...@bo...> - 2010-02-05 08:07:17
|
For me the convention is ok, But insted of using an underscore for the function name I prefer to have the Upper case letter of the first word ..like this: For Function: def getLineFromSegment(): instead of def get_line_form_segment(): For Classes: Class Segment(object): and I like to have the descriprion on each functions/class like this def line(x,y,x1,y1): """ Create a line x: double coordinate of the x point """ For me it's very important the documentation of each function / class In case of global variable we can use the UPPER Case and the underline to separate the words DEBUG_GUI=True Let me know if for you this conversion is ok Regards, Matteo From: ger...@gm... [mailto:ger...@gm...] Sent: 04 February 2010 07:56 To: Yagnesh Desai; pythoncad-developer Subject: Re: [Pythoncad-developer] coding convention Hi Yagnesh, That's all right, your skills will improve. We all can learn from each other. I saw Arts coding conventions just recently. It is good to have some unity in our code. Regards, Gertwin Op schreef Yagnesh Desai <yn...@gm...>: > Gretwin; > > > > I know the coding done by me needs lot of touch up. > > > > I need to improve my coding skills as this is the first time > > I am doing any coding for such project. I only used to > > do editing of recorded macros. > > > > Also I am not good at OOP and whatever coding I did > > was with good help of Matteo. > > > > Hope to improve and learn more while contributing to > > PythonCAD. > > > > If the convention in old wiki is what can be followed > > we must use it for there must not be any difference > > in the way old and new one. > > > > > > On Thu, Feb 4, 2010 at 2:07 AM, Gertwin Groen ger...@gm...> wrote: > > > Hi all, > > > > > > Now the we start working on the best PythonCAD ever it is time to > > > think about some coding convention. > > > In the old wiki this is mentioned but it is not followed by us in the > > > last months. > > > > > > I think the easiest thing to do is to follow the PyGTK coding conventions: > > > > > > example: > > > > > > class gtk.CellEditable(gobject.GInterface): > > > def start_editing(event) > > > def editing_done() > > > def remove_widget() > > > > > > Lower case package, module (and file) names. > > > Mixed upper and lower case for class names, each word starts with a > > > capital letter. > > > Functions and class members are lower case, words are divided by a underscore. > > > Variable names are lower case, words are divided by a underscore. > > > > > > See the pygtk-demo for examples. > > > > > > Any comments? > > > > > > Regards, > > > Gertwin > > > > > > ---------------------------------------------------------------------------- -- > > > The Planet: dedicated and managed hosting, cloud storage, colocation > > > Stay online with enterprise data centers and the best network in the business > > > Choose flexible plans and management services without long-term contracts > > > Personal 24x7 support from experience hosting pros just a phone call away. > > > http://p.sf.net/sfu/theplanet-com > > > _______________________________________________ > > > Pythoncad-developer mailing list > > > Pyt...@li... > > > https://lists.sourceforge.net/lists/listinfo/pythoncad-developer > > > > > > > > > > > -- > > Best regards > > > > Yagnesh Desai > > > > Save a tree...please don't print this e-mail. > > > > ---------------------------------------------------------------------------- -- > > The Planet: dedicated and managed hosting, cloud storage, colocation > > Stay online with enterprise data centers and the best network in the business > > Choose flexible plans and management services without long-term contracts > > Personal 24x7 support from experience hosting pros just a phone call away. > > http://p.sf.net/sfu/theplanet-com > > _______________________________________________ > > Pythoncad-developer mailing list > > Pyt...@li... > > https://lists.sourceforge.net/lists/listinfo/pythoncad-developer > |
From: Matteo B. <mat...@bo...> - 2010-02-05 08:18:08
|
Hi All, Before starting coding in pythoncad I would like to create a single module for debugging purpose. This module will have some global variable that will switch on and off the print of the debug and will have the possibility to write the log in IO windows or in a log file. This will be very important for debugging porpoise. The module will be something like this Class PythonCadTracer(object): def info(msg): def debug(msg): def error(msg): def in(msg): def out(msg): def warning(msg): def onWriteFile(self): def onWriteIO(self): the in and out function take care of the time spent doing the operation so in case of function this will be def myFunc(): pyTracer.in("myFunc") pyTracer.out("myFunc") the output will be Start function myFunc End function myFunc in 10 s Let me know ... Regards, Matteo |