Single leading dash in member variable names?
All Python noob here. Trying to understand a particular syntax: class stuff: def __init__(self): self._bongo = "BongoWorld" --- What is the significance of the leading underscore in "self._bongo"? I've seen this a few times and, after looking through PEP 8, I didn't see anything relevant, but I could have missed it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Single leading dash in member variable names?
On Tuesday, September 11, 2012 2:06:45 PM UTC-5, Ian wrote: > On Tue, Sep 11, 2012 at 12:45 PM, I wrote: > > > All > > > > > > Python noob here. Trying to understand a particular syntax: > > > > > > class stuff: > > > def __init__(self): > > > self._bongo = "BongoWorld" > > > > > > --- > > > > > > What is the significance of the leading underscore in "self._bongo"? I've > > seen this a few times and, after looking through PEP 8, I didn't see > > anything relevant, but I could have missed it. > > > > Single leading underscore is a convention indicating that the name > > should be considered private and not used externally. It's a softer > > version of the double leading underscore that means basically the same > > thing but has syntactic significance. Thank you! PEP 8 says this is bad form. What do you think? -- http://mail.python.org/mailman/listinfo/python-list
Re: Single leading dash in member variable names?
On Tuesday, September 11, 2012 5:02:31 PM UTC-5, Erik Max Francis wrote: > On 09/11/2012 01:53 PM, me wrote: > > > On Tuesday, September 11, 2012 2:06:45 PM UTC-5, Ian wrote: > > >> On Tue, Sep 11, 2012 at 12:45 PM, I wrote: > > >>> What is the significance of the leading underscore in "self._bongo"? > >>> I've seen this a few times and, after looking through PEP 8, I didn't see > >>> anything relevant, but I could have missed it. > > >> > > >> Single leading underscore is a convention indicating that the name > > >> should be considered private and not used externally. It's a softer > > >> version of the double leading underscore that means basically the same > > >> thing but has syntactic significance. > > > > > > Thank you! > > > > > > PEP 8 says this is bad form. What do you think? > > > > Where does it say that? Apologies. It's in David Goodger's "Code Like A Pythonista" in the "Naming" section. (http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#naming) -- http://mail.python.org/mailman/listinfo/python-list
pyRTF and Footers
Hi All I've been using the pyRTF module to generate some documents that I need for work. In general, the module is good, and pretty simple to use. However, I am running into a problem with footers that doesn't quite make sense to me. My question is this: Is it possible to change the text of a footer throughout an RTF document? The data that I am using to produce my document is organized in a simple header/detail relationship. The document I want to produce looks roughly like this: --- USER001 detail data line 1 detail data line 2 detail data line 3 page footer that says "USER001, plus some other information" **page break** USER002 detail data line 1 detail data line 2 detail data line 3 page footer that says "USER002, plus some other information" **page break** USERnnn detail data line 1 detail data line 2 detail data line 3 page footer that says "USERnnn, plus some other information" END OF DOCUMENT --- I've gotten everything the way I want, except for the footer. The footer appears on the first page, but not on any other page. The code that generates the footer is (apologies in advance for poor style): --- def MakeFooter(self, facilitatir, startDate, endDate, tuID): section = Section() self.doc.Sections.append( section ) p = Paragraph( "%s - %s (%s - %s)" % ( facilitator, tuID, startDate, endDate ), LINE ) p.append( 'Page', PAGE_NUMBER, ' of ', TOTAL_PAGES ) section.Footer.append( p ) --- The logic that calls MakeFooter is: --- tuDoc = MakeTUDoc() DR = Renderer() for i in range( start, end + 1 ): key = "Traininguser%03d" % ( i ) tuDoc.MakeFooter( facilitator, startDate, endDate, key ) tuDoc.MakeHeader( key, module ) < code to populate the document with detail data > DR.Write( tuDoc.doc, tuDoc.OpenFile( 'JUNK' ) ) print( 'DONE!' ) --- (Note: the MakeHeader() method doesn't put an actual RTF header in the document-- it just puts text in a Heading1 format into a section at the top of the page, before the detail data.) I had a look at the RTF 1.5 specification (http://www.biblioscope.com/rtf15_spec.htm), and regarding headers and footers and it's pretty thin. I didn't see anything in the specification regarding support for changing footer text throughout the document. Nothing in there that said I could do it, either. Any ideas, anyone? Thanks in advance. This is an extremely helpful discussion group. -Doc -- http://mail.python.org/mailman/listinfo/python-list
Re: pyRTF and Footers
Gabriel Genellina wrote: > At Wednesday 15/11/2006 20:08, [EMAIL PROTECTED] wrote: > > >I've been using the pyRTF module to generate some documents that I need > >for work. In general, the module is good, and pretty simple to use. > >However, I am running into a problem with footers that doesn't quite > >make sense to me. > > First, I don't use pyRTF. The app sketch and code snippet you have > posted look reasonable. Thanks :) > At least using Word, you can configure a page footer for each section > in the document, so I think it should be posible. I edited the document in Word without problems. I put in several different footers into my generated RTF document. > If you don't get the output you want, it may be a bug in the module, =:-O > you are using it in the wrong way, This is a possibility. I took a look at the raw RTF text, and the multiple footers are in the text. I'm going to have to edit the document with word and compare it to the original to see what the difference is, I guess. >...the feature is unsupported, etc. Say it ain't so! > but most likely not a bug in Python itself. =:-O > So a better place to ask would be... well, it appears there is no better > place except asking > the author directly :) Anyone got his number? > (BTW, thanks for pointing me towards pyRTF - it may be useful, so > I'll give it a try...) It's very useful. I can see several applications in my job where I can use this module. Thanks -Doc -- http://mail.python.org/mailman/listinfo/python-list