Fundamental Function Question (beginner)

2010-01-11 Thread Scott
When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if required. Does it matter at all that

Re: Fundamental Function Question (beginner)

2010-01-11 Thread MRAB
Scott wrote: When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if required. Does it

Re: Fundamental Function Question (beginner)

2010-01-11 Thread r0g
Scott wrote: When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if required. Does it

Re: Fundamental Function Question (beginner)

2010-01-11 Thread r0g
r0g wrote: Scott wrote: When creating a function is there any difference between putting everything under the def or not? Here I created a function called CscoPortNum to convert the network port number field in a Cisco syslog string from a an ascii name back into its numeric form if

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Phlip
MRAB wrote: Scott wrote: for prtnmS in open(portfpth): prtnmS = prtnmS.rstrip() There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called. However, please consider writing complete,

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Philip Semanchuk
On Jan 11, 2010, at 2:50 PM, Phlip wrote: MRAB wrote: Scott wrote: for prtnmS in open(portfpth): prtnmS = prtnmS.rstrip() There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called.

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Scott
On Jan 11, 1:50 pm, Phlip phlip2...@gmail.com wrote: MRAB wrote: Scott wrote: for prtnmS in open(portfpth):     prtnmS = prtnmS.rstrip() There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Steven D'Aprano
On Mon, 11 Jan 2010 18:57:09 +, MRAB wrote: There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called. Actually there is, but the benefit (avoiding the re-creation of the table) may be worth

Re: Fundamental Function Question (beginner)

2010-01-11 Thread Scott
There's nothing wrong with building dicts or other lookup tables outside a function in order to avoid re-creating them every time the function is called. Brilliant! I didn't think of that. I guess I accidentally did it right this time as I query that dictionary quite a few times from the