473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Re: Style questions

David,

Here's a "good" example (NB: subjective):

http://hg.softcircuit.com.au/index.w...rcuits/core.py

On Fri, Oct 24, 2008 at 10:04 AM, David Di Biase <da**********@gmail.comwrote:
I have a few simple questions regarding python style standards. I have a
class contained in a module...I'm wondering if I should perform any imports
that are relevant to the class within the constructor of the class or at the
top of the module page.
Normally imports are conventionally done at the top of the module.
Within the module's scope.
Some people import the entire module while others
import only bits that they need.
Also if I'm creating a docstring for the class I should list all my public
methods, should I just list them or should I just summarise what they do?
ie:

"""Displays a graphical game of variant of Connect4.
Supports two players on a 6x7 game board.

Public methods:
__init__()
clear_screen()
draw_header()
draw_board()
play()
prompt_for_move()

"""
Don't write what can be easily dispalyed
with pydoc or some other documentation tool.
The methods are already clearly there.
See my core.py above.
Last question, sometimes I have a simple function with no keyword arguments
and returns none. According to the styleguide we are to include return None
at the end of the function regardless, so should I also explicitly state
that the function returns this in the one line description? ie:
Not generally. Most python developers
know that functions that do not have a return
statement, actually implicitly returns None.

You're documenting for developers (python developers) not users.

cheers
James

--
--
-- "Problems are solved by method"
Oct 24 '08 #1
0 864

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
3
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting...
16
by: Harlan Messinger | last post by:
1. CSS has five generic font family specifiers: serif, sans-serif, cursive, fantasy, monospace. IE lets the users select a default proportional font and a default monospace font. Is there any way...
3
by: Kalle Anke | last post by:
I'm confused by the concepts of old-style vs new-style classes, I've read most of the documents I found about this but it doesn't "click". Probably because I wasn't around before 2.2. Anyway,...
54
by: Sander | last post by:
1. I was having a discussion with somebody and I think it's just religious. We are developing some software and he was looking through my code. I use if (pointer) to test a pointer for NULL. He...
1
by: Dgates | last post by:
I'm learning ASP.NET, C# and VB.NET, and hoping to get some feedback from more experienced programmers on a few issues regarding efficient, readable, well-organized code. I'm trying to program...
18
by: pocmatos | last post by:
Hi all, While I was programming 5 minutes ago a recurring issue came up and this time I'd like to hear some opinions on style. Although they are usually personal I do think that in this case as...
8
by: Gary Wessle | last post by:
Hi while I am reading this C++ book, I noticed the iterator is being used to loop through a container, say a vector. I am used to use "for(int=0;i<vec.size();++i)" which is better to use? ...
8
by: Ganesh Muthuvelu | last post by:
Hello, I am a ASPX page where I have defined the style for the head element. ****************** <head runat="server" > <style type="text/css"> .MyClass { background-color: aqua; } </style>
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.