[Tutor] new line to list of strings send by email

2016-01-08 Thread Emil Natan
Hello list, I have a function which receives a string and sends it as a body of an email. It is a part of a program which does certain checks on network infrastructure. When a check fails I append error message to a error_collector list: if self.check_axfr_refused(ip):

Re: [Tutor] new line to list of strings send by email

2016-01-08 Thread Bob Gailer
On Jan 8, 2016 11:03 AM, "Emil Natan" wrote: > > Hello list, > > I have a function which receives a string and sends it as a body of an > email. > > It is a part of a program which does certain checks on network > infrastructure. When a check fails I append error message to a >

[Tutor] New to this list ....

2012-03-30 Thread Barry Drake
Hi there I've just joined this list and thought I'd introduce myself. I used to be fairly competent in c but never made the grade to c++. I've done very little programming in the last couple of years or so. I'm getting a Raspberry-pi for our local Junior school and am starting to

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 15:04, Barry Drake wrote: One of the things I wanted to do is to use a four integer array to get four integers returned from a function. I ended up using what I think is a list. (I'm not really sure of the datatypes yet). This is what I did, and it works, but looks very inelegant

Re: [Tutor] New to this list ....

2012-03-30 Thread Evert Rol
Hi and welcome Barry, One of the things I wanted to do is to use a four integer array to get four integers returned from a function. I ended up using what I think is a list. (I'm not really sure of the datatypes yet). This is what I did, and it works, but looks very inelegant to me:

Re: [Tutor] New to this list ....

2012-03-30 Thread Mark Lawrence
On 30/03/2012 15:13, Barry Drake wrote: On 30/03/12 15:04, Barry Drake wrote: One of the things I wanted to do is to use a four integer array to get four integers returned from a function. I ended up using what I think is a list. (I'm not really sure of the datatypes yet). This is what I

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 16:19, Evert Rol wrote: Not sure. In the sense that you can optimise (refactor) it in the same way you could do with C. Eg: results = [0, 0, 0] flags = [0, 1, 2, 3] for flag in flags: results = getflag(flag, results) That's exactly what I hoped for. I hadn't realised I can

Re: [Tutor] New to this list ....

2012-03-30 Thread Asokan Pichai
On Fri, Mar 30, 2012 at 9:12 PM, Barry Drake bdr...@crosswire.org wrote: On 30/03/12 16:19, Evert Rol wrote: Not sure. In the sense that you can optimise (refactor) it in the same way you could do with C. Eg: results = [0, 0, 0] flags = [0, 1, 2, 3] for flag in flags:     results =

Re: [Tutor] New to this list ....

2012-03-30 Thread Russel Winder
Barry, On Fri, 2012-03-30 at 16:42 +0100, Barry Drake wrote: [...] def getflag(thisflag, results): if (thisflag == 2): results[0] += 1 elif (thisflag == 1): results[1] += 1 elif (thisflag == 0): results[2] += 1 return(results) Two thoughts

Re: [Tutor] New to this list ....

2012-03-30 Thread Peter Otten
Barry Drake wrote: On 30/03/12 16:19, Evert Rol wrote: Not sure. In the sense that you can optimise (refactor) it in the same way you could do with C. Eg: results = [0, 0, 0] flags = [0, 1, 2, 3] for flag in flags: results = getflag(flag, results) That's exactly what I hoped for.

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
Hi there I've just joined this list and thought I'd introduce myself. Welcome! correct = 0 match = 0 wrong = 0 results = [correct, match, wrong] results = getflag(flag_1, results) results = getflag(flag_2, results) results = getflag(flag_3,

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
Furthermore, the way Python binds names means that modifying the list in getflags modifies it in the callee. No need to return and reassign results. I correct myself. It has nothing to do with name binding, but entirely to do with Python's object model. Ramit Ramit Prasad | JPMorgan Chase

Re: [Tutor] New to this list ....

2012-03-30 Thread Russel Winder
Ramit, On Fri, 2012-03-30 at 16:22 +, Prasad, Ramit wrote: [...] C switch is just a different way of doing an if/elif tree, I do not really see any real difference. Although, if there is you can feel free to enlighten me. :) [...] 'fraid not -- though it depends on which compiler and

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
[...] C switch is just a different way of doing an if/elif tree, I do not really see any real difference. Although, if there is you can feel free to enlighten me. :) [...] 'fraid not -- though it depends on which compiler and how many cases. For 3 or more cases compilers will generate

Re: [Tutor] New to this list ....

2012-03-30 Thread Mark Lawrence
On 30/03/2012 15:04, Barry Drake wrote: One of the few c things I miss is the switch/case statement. if and elif in it's place is a bit cumbersome. Still, it works. The recipe here http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ refers to

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 17:58, Mark Lawrence wrote: The recipe here http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ refers to several other recipes which you might want to take a look at, sorry I meant to mention this earlier. Oh, that's neat. Not worth

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 17:22, Prasad, Ramit wrote: Unlike C, the parenthesis in if statements and returns are not necessary. Furthermore, the way Python binds names means that modifying the list in getflags modifies it in the callee. No need to return and reassign results. This is lovely. It's so

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
[snip] I'm used to c variables going out of scope once you leave the called function. I imagine if you want to leave the variables unchanged, you have to re-assign them inside the function. [snip] Lists are mutable objects. When you pass a list to a function you bind a name in the functions

Re: [Tutor] New to this list ....

2012-03-30 Thread Emile van Sebille
On 3/30/2012 10:56 AM Prasad, Ramit said... Lists are mutable objects. When you pass a list to a function you bind a name in the functions namespace to the list object. Every name binding to that object will have the ability to modify the list. If you want to modify the list but not change it

Re: [Tutor] New to this list ....

2012-03-30 Thread Russel Winder
Barry, On Fri, 2012-03-30 at 18:27 +0100, Barry Drake wrote: On 30/03/12 17:58, Mark Lawrence wrote: The recipe here http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ refers to several other recipes which you might want to take a look

[Tutor] New to this list ....

2012-03-30 Thread Cranky Frankie
Message: 1 Date: Fri, 30 Mar 2012 15:04:09 +0100 Barry Drake bdr...@crosswire.org wrote: I'm getting a Raspberry-pi for our local Junior school and am starting to learn Python so I can show the year five and year six kids how to write simple games. Here's what you need - he starts simple and

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 19:18, Cranky Frankie wrote: Here's what you need - he starts simple and winds up with some nice games: http://www.amazon.com/Python-Programming-Absolute-Beginner-Edition/dp/1435455002/ref=sr_1_6?ie=UTF8qid=1333131438sr=8-6 Wow! I found an e-book copy online and got it. Looks

Re: [Tutor] New to this list ....

2012-03-30 Thread Emile van Sebille
On 3/30/2012 2:41 PM Barry Drake said... On 30/03/12 19:18, Cranky Frankie wrote: Here's what you need - he starts simple and winds up with some nice games: http://www.amazon.com/Python-Programming-Absolute-Beginner-Edition/dp/1435455002/ref=sr_1_6?ie=UTF8qid=1333131438sr=8-6 If you

Re: [Tutor] new on the list

2008-02-28 Thread Alan Gauld
[EMAIL PROTECTED] wrote This is my first post to this list. Welcome Tony. I started learning to write bash scripts in November, first, and started learning Tcl in January Good starts, although Python is a little different to Tcl its generally easier to read. But their capabilities are

Re: [Tutor] new on the list

2008-02-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Hi, I'm Tony. I'm a translator. This is my first post to this list. Welcome! tcl.tk makes it easy to build a gui, as easy as writing html, really). Python has a version of tk also, called Tkinter. You might want to learn about it:

Re: [Tutor] new on the list

2008-02-28 Thread bhaaluu
On Thu, Feb 28, 2008 at 4:51 AM, Alan Gauld [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote (I wrote these using a simple text editor that I made with Tcl, too, http://www.linguasos.org/tcltext.html ) Fine but it will be easier to use a syntax aware full featured editor like vim or

[Tutor] new on the list

2008-02-27 Thread tonytraductor
Hi, I'm Tony. I'm a translator. This is my first post to this list. I've been using Linux, pretty well exclusively, for about 8 years, but I never got under the hood more than learning the shell basics to do basic stuff that I needed to do, manipulating config files. (Although I did recently