Chris Angelico <ros...@gmail.com> writes: > On Wed, Jan 11, 2012 at 10:44 AM, HoneyMonster > <someone@someplace.invalid> wrote: > > Hi, > > > > I'm new to Python and recently completed my first project. I used > > wxPython with wxGlade to generate the GUI bits.The application seems to > > work well, but I am entirely self-taught, so have undoubtedly committed a > > number of howlers in terms of style, design, standards, best practice and > > so forth. > > Welcome! > > Ian has already offered some excellent tips, so I'll not repeat him. > > > log = os.environ['HOME'] + "/log/bbc.log" > log = os.environ['HOMEPATH'] + "\\log\\bbc.log" > > Python on Windows will support / for paths
Even better, you don't need to worry about what separator to use:: top_dir = os.environ['HOME'] log_filepath = os.path.join(top_dir, "log", "bbc.log") > I'd do this with a triple-quoted string: > > about = """Built by Walter Hurry using Python and wxPython, > with wxGlade to generate the code for the GUI elements. > Phil Lewis' get_iplayer does the real work. > > Version 1.05: January 10, 2012""" Which you can get indented nicely in the source, and strip off the indentation at run-time: import textwrap about = textwrap.dedent("""\ Built by Walter Hurry using Python and wxPython, with wxGlade to generate the code for the GUI elements. Phil Lewis' get_iplayer does the real work. Version 1.05: January 10, 2012 """) > self.add = self.file.AppendItem(wx.MenuItem(self.file, > wx.NewId(), "&Add to Queue", "Add a programme to the queue (for > download later)", wx.ITEM_NORMAL)) Which is a whole lot more readable using the recommendations in PEP 8:: self.add = self.file.AppendItem( wx.MenuItem( self.file, wx.NewId(), "&Add to Queue", "Add a programme to the queue (for download later)", wx.ITEM_NORMAL)) -- \ “I distrust those people who know so well what God wants them | `\ to do to their fellows, because it always coincides with their | _o__) own desires.” —Susan Brownell Anthony, 1896 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list