Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Mark Lawrence
On 29/09/2013 22:15, Denis McMahon wrote: Nick, you have now spent 4 days arguing over a minor coding problem that you were given solutions to on the first day, primarily because you feel that the solutions you are being offend some programming aesthetic you have. I suggest that it's time for y

Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Mark Lawrence
On 29/09/2013 18:44, MRAB wrote: On 29/09/2013 18:24, Piet van Oostrum wrote: Antoon Pardon writes: Why? What is so important about this particular way, that you are willing to spend/waste so much time on it? You act like someone who want to get from Brussels to London and when asked how to d

Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Neil Cerutti
On 2013-09-30, Chris Angelico wrote: > You actually need the tool that was used on King Edward > II. >>> >>> To be clear, Mark, you are calling for ?? to be >>> tortured to death with a red hot poker, yes? >>> >>> I'm going to go out on a limb and suggest that such a >>> suggesti

Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Chris Angelico
On Mon, Sep 30, 2013 at 9:32 PM, Neil Cerutti wrote: > On 2013-09-28, Zero Piraeus wrote: >>: >> >>> On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence >>> wrote: >>> > You actually need the tool that was used on King Edward II. >> >> To be clear, Mark, you are calling for ?? to be tortured

Re: Handling 3 operands in an expression without raising an exception

2013-09-30 Thread Neil Cerutti
On 2013-09-28, Zero Piraeus wrote: >: > >> On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence >> wrote: >> > You actually need the tool that was used on King Edward II. > > To be clear, Mark, you are calling for ?? to be tortured to death > with a red hot poker, yes? > > I'm going to go out o

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread giacomo boffi
giacomo boffi writes: > it.comp.python oops, it.comp.LANG.python -- I do desire we may be better strangers. -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread giacomo boffi
Joel Goldstick writes: > On Sun, Sep 29, 2013 at 11:28 AM, giacomo boffi wrote: > > Νίκος writes: > > > IF it can also be written in one-line > > def f(x,n,w):return(lambda y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w > [::2]):reduce(lambda x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Denis McMahon
On Sun, 29 Sep 2013 14:34:02 +0300, Νίκος wrote: > Στις 29/9/2013 2:27 μμ, ο/η Dave Angel έγραψε: >> On 29/9/2013 07:14, Νίκος wrote: >> >> >>> Dave's way though seems better. >>> Assign the vars default string and if they get re-assinged correctly >>> that would be ideal, otherwise we have alread

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Denis McMahon
On Sun, 29 Sep 2013 13:17:36 +0300, Νίκος wrote: > Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε: >> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or >> os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) >> try: >> gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') >> city = gi.tim

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Gene Heskett
On Sunday 29 September 2013 13:03:17 Chris Angelico did opine: > On Mon, Sep 30, 2013 at 2:07 AM, Joel Goldstick > > wrote: > > Here's my question: I wonder if Nikos has ever been employed to write > > software. If so, I wonder how long he lasted before he was let go. > > Unfortunately that p

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Joel Goldstick
On Sun, Sep 29, 2013 at 1:44 PM, MRAB wrote: > On 29/09/2013 18:24, Piet van Oostrum wrote: > >> Antoon Pardon writes: >> >> Why? What is so important about this particular way, that you are >>> willing to spend/waste so much time on it? You act like someone >>> who want to get from Brussels to

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread MRAB
On 29/09/2013 18:24, Piet van Oostrum wrote: Antoon Pardon writes: Why? What is so important about this particular way, that you are willing to spend/waste so much time on it? You act like someone who want to get from Brussels to London and when asked how to do that gets advise on how to take

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Piet van Oostrum
Antoon Pardon writes: > Why? What is so important about this particular way, that you are > willing to spend/waste so much time on it? You act like someone > who want to get from Brussels to London and when asked how to > do that gets advise on how to take the boat or plane at which > point you r

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Chris Angelico
On Mon, Sep 30, 2013 at 2:07 AM, Joel Goldstick wrote: > Here's my question: I wonder if Nikos has ever been employed to write > software. If so, I wonder how long he lasted before he was let go. Unfortunately that proves nothing. My boss used to have another employee besides me - he lasted for

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Joel Goldstick
On Sun, Sep 29, 2013 at 11:28 AM, giacomo boffi wrote: > Νίκος writes: > > > IF it can also be written in one-line > > def f(x,n,w):return(lambda > y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w[::2]):reduce(lambda > x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[k]) for k in range(n/2)])))()if > n>1 else

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread giacomo boffi
Νίκος writes: > IF it can also be written in one-line def f(x,n,w):return(lambda y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w[::2]):reduce(lambda x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[k]) for k in range(n/2)])))()if n>1 else x -- anch'io la penso come me, ma -- SteO153,

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 8:57 PM, Dave Angel wrote: > Try help(globals()) at the interpreter prompt. > > Help on built-in function globals in module builtins: > > globals(...) > globals() -> dictionary > > Return the dictionary containing the current scope's global variables. Insignificant

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Jussi Piitulainen
Νίκος writes: > Σ�ις 29/9/2013 2:04 μμ, ο/η Jussi Piitulainen > έγ�α�ε: > > > Let's see. The task is to assign a default value to city and host, > > if they haven't a value yet; on one line (which I take to mean one > > statement); in an "except" block where we may not know which > > assignment fai

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος
Στις 29/9/2013 2:27 μμ, ο/η Dave Angel έγραψε: On 29/9/2013 07:14, Νίκος wrote: Dave's way though seems better. Assign the vars default string and if they get re-assinged correctly that would be ideal, otherwise we have already given them the defaults. ipval = ( os.environ.get('HTTP_CF_CONNEC

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 07:14, Νίκος wrote: > Dave's way though seems better. > Assign the vars default string and if they get re-assinged correctly > that would be ideal, otherwise we have already given them the defaults. > > ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_A

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος
Στις 29/9/2013 2:04 μμ, ο/η Jussi Piitulainen έγραψε: Steven D'Aprano writes: On Sun, 29 Sep 2013 12:35:17 +0300, Jussi Piitulainen wrote: try: ... except socket.gaierror as e: # watch out, a composition of bad advice (on demand) city, host = ( ('city' in locals() or "blabla"),

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος
Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_addr( ipval ) host = socket.gethostbyaddr

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Sun, 29 Sep 2013 12:35:17 +0300, Jussi Piitulainen wrote: > > > try: > > ... > > except socket.gaierror as e: > > # watch out, a composition of bad advice (on demand) city, host = ( > > ('city' in locals() or "blabla"), > > ('host' in locals() o

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Antoon Pardon
Op 29-09-13 09:35, Νίκος schreef: Στις 29/9/2013 2:04 πμ, ο/η Chris Angelico έγραψε: On Sun, Sep 29, 2013 at 4:45 AM, Mark Lawrence wrote: Not tortured, simply murdered so we don't have to put up with his completely unacceptable behaviour, which sadly is thriving owing to so many people ignori

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 06:17, Νίκος wrote: > Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε: >> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or >> os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) >> try: >> gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') >> city = gi.time_zone_by_addr(

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος
Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) try: gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') city = gi.time_zone_by_addr( ipval ) host = socket.gethostbyaddr

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 03:35, Νίκος wrote: > > ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) > > try: > gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') > city = gi.time_zone_by_addr( ipval ) > host = socket.gethostbyaddr( ipv

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Steven D'Aprano
On Sun, 29 Sep 2013 12:35:17 +0300, Jussi Piitulainen wrote: > try: > ... > except socket.gaierror as e: > # watch out, a composition of bad advice (on demand) city, host = ( > ('city' in locals() or "blabla"), > ('host' in locals() or "blablabla") ) Bad advice, and buggy a

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Jussi Piitulainen
Νίκος writes: > And i don't mean like this: > > if not city: > city ="blabla" > if not host: > host="blablabla" > > > Can thes be witten without and if perhaps with the use of 'or' > operator in 1-line within the except clause? try: ... except socket.gaierror as e: # watch out,

Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος
Στις 29/9/2013 2:04 πμ, ο/η Chris Angelico έγραψε: On Sun, Sep 29, 2013 at 4:45 AM, Mark Lawrence wrote: Not tortured, simply murdered so we don't have to put up with his completely unacceptable behaviour, which sadly is thriving owing to so many people ignoring the "do not feed this moron" sig

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Ben Finney
Mark Lawrence writes: > On 28/09/2013 19:38, Zero Piraeus wrote: > > To be clear, Mark, you are calling for Νίκος to be tortured to death > > with a red hot poker, yes? > > Not tortured, simply murdered so we don't have to put up with his > completely unacceptable behaviour Regardless of the beh

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Chris Angelico
On Sun, Sep 29, 2013 at 4:45 AM, Mark Lawrence wrote: > Not tortured, simply murdered so we don't have to put up with his completely > unacceptable behaviour, which sadly is thriving owing to so many people > ignoring the "do not feed this moron" signs. You miss one important factor in these disc

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Steven D'Aprano
On Sat, 28 Sep 2013 19:45:40 +0100, Mark Lawrence wrote: > Not tortured, simply murdered If your aim was to prove that you're a waste of space than Nikos, you've admirably succeeded. *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Mark Lawrence
On 28/09/2013 19:38, Zero Piraeus wrote: : On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence wrote: You actually need the tool that was used on King Edward II. To be clear, Mark, you are calling for Νίκος to be tortured to death with a red hot poker, yes? I'm going to go out on a limb and sugg

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Zero Piraeus
: > On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence wrote: > > You actually need the tool that was used on King Edward II. To be clear, Mark, you are calling for Νίκος to be tortured to death with a red hot poker, yes? I'm going to go out on a limb and suggest that such a suggestion is outside wh

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Joel Goldstick
On Sat, Sep 28, 2013 at 1:53 PM, Mark Lawrence wrote: > On 28/09/2013 17:14, Νίκος wrote: > > I know what he has said bit this is now what i need. >> > > You actually need the tool that was used on King Edward II. > > > -- > Cheers. > > Mark Lawrence > > -- > https://mail.python.org/**mailman/lis

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Mark Lawrence
On 28/09/2013 17:14, Νίκος wrote: I know what he has said bit this is now what i need. You actually need the tool that was used on King Edward II. -- Cheers. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread rusi
On Friday, September 27, 2013 4:13:52 PM UTC+5:30, Dave Angel wrote: > You should study APL. Many functions were written in one line, with > twenty lines of explanation. The function itself was considered > unreadable nonsense. And if a function stopped working, general wisdom > was to throw it o

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Νίκος
Στις 28/9/2013 6:02 μμ, ο/η Andreas Perstinger έγραψε: Νίκος wrote: Στις 28/9/2013 1:19 μμ, ο/η Chris Angelico έγραψε: [ROLL] Rosuav rolls his eyes: 1, 1, totalling 2. Then split your try blocks! You've already been told this. No we didn't have said this. if you are referring to this: At

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Joel Goldstick
On Sat, Sep 28, 2013 at 9:53 AM, Antoon Pardon wrote: > Op 28-09-13 00:06, Νίκος schreef: > > Στις 27/9/2013 8:00 μμ, ο/η Grant Edwards έγραψε: >> >>> On 2013-09-27, ?? wrote: >>> >>> Sure your method follows the the logic in a straighforward way step-by-step but i just dont want

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Antoon Pardon
Op 28-09-13 00:06, Νίκος schreef: Στις 27/9/2013 8:00 μμ, ο/η Grant Edwards έγραψε: On 2013-09-27, ?? wrote: Sure your method follows the the logic in a straighforward way step-by-step but i just dont want to spent almost 20 lines of code just to calculate 2 variables(city and host).

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Andreas Perstinger
Νίκος wrote: >Στις 28/9/2013 1:19 μμ, ο/η Chris Angelico έγραψε: >> [ROLL] Rosuav rolls his eyes: 1, 1, totalling 2. >> >> Then split your try blocks! You've already been told this. >> >No we didn't have said this. if you are referring to this: At least Denis told you about 24 hours ago: https:/

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Νίκος
Στις 28/9/2013 1:19 μμ, ο/η Chris Angelico έγραψε: On Sat, Sep 28, 2013 at 7:33 PM, Νίκος wrote: It woould be nice if we could write it as: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) try: gi = pygeoip.GeoIP('/usr/local/share

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Robert Kern
On 2013-09-27 11:43, Dave Angel wrote: You should study APL. Many functions were written in one line, with twenty lines of explanation. The function itself was considered unreadable nonsense. And if a function stopped working, general wisdom was to throw it out, and re-implement the explanatio

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Chris Angelico
On Sat, Sep 28, 2013 at 7:33 PM, Νίκος wrote: > It woould be nice if we could write it as: > > > ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) > try: > gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') > city = gi.time_z

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Νίκος
Στις 28/9/2013 1:26 πμ, ο/η Dave Angel έγραψε: On 27/9/2013 18:06, Νίκος wrote: city = "Άγνωστη Πόλη" host = "Άγνωστη Προέλευση" If they were to have the same string assigned to them it should be okey but they do not. Or perhaps you can even still think of writing the above into 1-liner wha

Re: Handling 3 operands in an expression without raising an exception

2013-09-28 Thread Νίκος
Στις 28/9/2013 4:59 πμ, ο/η Chris Angelico έγραψε: On Sat, Sep 28, 2013 at 8:06 AM, Νίκος wrote: Well to tell the truth no matter what you say to me if something can be written in less lines than another implementation but still retain its simplicity and straightforward logic behind it i would

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Chris Angelico
On Sat, Sep 28, 2013 at 8:06 AM, Νίκος wrote: > Well to tell the truth no matter what you say to me if something can be > written in less lines than another implementation but still retain its > simplicity and straightforward logic behind it i would prefer it! > I don't know why you think otherwis

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Dave Angel
On 27/9/2013 18:06, Νίκος wrote: > > city = "Άγνωστη Πόλη" > host = "Άγνωστη Προέλευση" > > If they were to have the same string assigned to them it should be okey > but they do not. > > Or perhaps you can even still think of writing the above into 1-liner > whatsoever! I already did earlier i

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Νίκος
Στις 27/9/2013 8:00 μμ, ο/η Grant Edwards έγραψε: On 2013-09-27, ?? wrote: Sure your method follows the the logic in a straighforward way step-by-step but i just dont want to spent almost 20 lines of code just to calculate 2 variables(city and host). Does your provider charge you per

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Joel Goldstick
On Fri, Sep 27, 2013 at 2:54 PM, Grant Edwards wrote: > On 2013-09-27, Denis McMahon wrote: > > On Fri, 27 Sep 2013 18:32:23 +0100, Mark Lawrence wrote: > > > >> On 27/09/2013 18:00, Grant Edwards wrote: > >>> On 2013-09-27, ?? wrote: > >>> > Sure your method follows the the logic i

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Grant Edwards
On 2013-09-27, Denis McMahon wrote: > On Fri, 27 Sep 2013 18:32:23 +0100, Mark Lawrence wrote: > >> On 27/09/2013 18:00, Grant Edwards wrote: >>> On 2013-09-27, ?? wrote: >>> Sure your method follows the the logic in a straighforward way step-by-step but i just dont want to spen

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Denis McMahon
On Fri, 27 Sep 2013 18:32:23 +0100, Mark Lawrence wrote: > On 27/09/2013 18:00, Grant Edwards wrote: >> On 2013-09-27, ?? wrote: >> >>> Sure your method follows the the logic in a straighforward way >>> step-by-step but i just dont want to spent almost 20 lines of code >>> just to calcula

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Mark Lawrence
On 27/09/2013 18:00, Grant Edwards wrote: On 2013-09-27, ?? wrote: Sure your method follows the the logic in a straighforward way step-by-step but i just dont want to spent almost 20 lines of code just to calculate 2 variables(city and host). Does your provider charge you per line of

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Joel Goldstick
On Fri, Sep 27, 2013 at 1:00 PM, Grant Edwards wrote: > On 2013-09-27, ?? wrote: > > > Sure your method follows the the logic in a straighforward way > > step-by-step but i just dont want to spent almost 20 lines of code just > > to calculate 2 variables(city and host). > > Does your prov

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Grant Edwards
On 2013-09-27, ?? wrote: > Sure your method follows the the logic in a straighforward way > step-by-step but i just dont want to spent almost 20 lines of code just > to calculate 2 variables(city and host). Does your provider charge you per line of code? If all that matters is the num

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Neil Cerutti
On 2013-09-27, ?? wrote: > Sure your method follows the the logic in a straighforward way > step-by-step but i just dont want to spent almost 20 lines of > code just to calculate 2 variables(city and host). Sure, eating with my mouth is straightforward and step-by-step, but I just want to

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Νίκος
Στις 27/9/2013 6:16 μμ, ο/η Denis McMahon έγραψε: On Fri, 27 Sep 2013 12:19:53 +0300, Νίκος wrote: This is my code as i have it at the moment: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) try: gi = pygeoip.GeoIP('/usr/local/shar

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Grant Edwards
On 2013-09-27, Denis McMahon wrote: > Note that there is nothing special about writing it in as few lines as > code as possible. Hah! That's what they _want_ you to think. First they get you hooked on newlines, then the newline mine owners form a cartel and start jacking up the prices. Then y

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Denis McMahon
On Fri, 27 Sep 2013 12:19:53 +0300, Νίκος wrote: > This is my code as i have it at the moment: > > ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) try: > gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') > city = gi.time_zone

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Νίκος
Στις 27/9/2013 3:17 μμ, ο/η Dave Angel έγραψε: On 27/9/2013 07:15, Νίκος wrote: Στις 27/9/2013 1:43 μμ, ο/η Dave Angel έγραψε: ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) city = "Άγνωστη Πόλη" host = "Άγνωστη Προέλευση" try:

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Dave Angel
On 27/9/2013 07:15, Νίκος wrote: > Στις 27/9/2013 1:43 μμ, ο/η Dave Angel έγραψε: > >> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or >> os.environ.get('REMOTE_ADDR', "Cannot Resolve") ) >> city = "Άγνωστη Πόλη" >> host = "Άγνωστη Προέλευση" >> try: >> city = gi.time_zone_by_addr(

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Νίκος
Στις 27/9/2013 1:43 μμ, ο/η Dave Angel έγραψε: Στις 27/9/2013 1:55 πμ, ο/η Dave Angel έγραψε: Simply assign the default values BEFORE the try block, and use pass as the except block. That still doesn't get around the inadvisability of putting those 3 lines in the try block. You still haven't d

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Dave Angel
On 27/9/2013 05:19, Νίκος wrote: > Στις 27/9/2013 1:55 πμ, ο/η Dave Angel έγραψε: >> >> Simply assign the default values BEFORE the try block, and use pass as >> the except block. >> >> That still doesn't get around the inadvisability of putting those 3 >> lines in the try block. >> >> You still

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Νίκος
Στις 27/9/2013 12:26 μμ, ο/η Steven D'Aprano έγραψε: On Fri, 27 Sep 2013 12:19:53 +0300, Νίκος wrote: I'am not sure what you mean though when you say: Simply assign the default values BEFORE the try block, and use pass as the except block. Can you please make it more clear for me? variab

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Steven D'Aprano
On Fri, 27 Sep 2013 12:19:53 +0300, Νίκος wrote: > I'am not sure what you mean though when you say: > >> Simply assign the default values BEFORE the try block, and use pass as >> the except block. > > Can you please make it more clear for me? variable = "default value" try: variable = some

Re: Handling 3 operands in an expression without raising an exception

2013-09-27 Thread Νίκος
Στις 27/9/2013 1:55 πμ, ο/η Dave Angel έγραψε: On 26/9/2013 18:14, Νίκος wrote: Στις 26/9/2013 11:16 μμ, ο/η Denis McMahon έγραψε: On Thu, 26 Sep 2013 19:58:02 +0300, Νίκος wrote: except socket.gaierror as e: city = host = "UnKnown Origin" But then what if in case of an error i need

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread alex23
On 26/09/2013 6:39 PM, Νίκος wrote: You dont have to be ironic. I dont have the experience you do. This is bulshytt. You only just a few days ago started a thread in which handling lookups in dictionaries with potentially non-existent keys was dealt with. At length. And now you're restructuri

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 18:14, Νίκος wrote: > Στις 26/9/2013 11:16 μμ, ο/η Denis McMahon έγραψε: >> On Thu, 26 Sep 2013 19:58:02 +0300, Νίκος wrote: >> >>> except socket.gaierror as e: >>> city = host = "UnKnown Origin" >>> >>> But then what if in case of an error i needed different string set to be >>>

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 11:16 μμ, ο/η Denis McMahon έγραψε: On Thu, 26 Sep 2013 19:58:02 +0300, Νίκος wrote: except socket.gaierror as e: city = host = "UnKnown Origin" But then what if in case of an error i needed different string set to be assigned on city and host respectively? Oh FFS Are

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 12:58, Νίκος wrote: > But actually i have 2 variables that relay on a proper ip address. > > ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_ADDR', "UnKnown Origin") ) > try: > gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat') > city

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Denis McMahon
On Thu, 26 Sep 2013 19:58:02 +0300, Νίκος wrote: > except socket.gaierror as e: > city = host = "UnKnown Origin" > > But then what if in case of an error i needed different string set to be > assigned on city and host respectively? Oh FFS Are you serious when you ask this? Simply change:

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 5:22 μμ, ο/η Dave Angel έγραψε: On 26/9/2013 09:34, Νίκος wrote: Στις 26/9/2013 3:53 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 14:39, Νίκος schreef: Yes, you are right, in my shell it fails too givign the same error message as yours, while on the other had in the websste is wor

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Denis McMahon
On Thu, 26 Sep 2013 12:56:19 +0300, Νίκος wrote: > Its logic is simple and straightforward but too many lines: There is no "too many lines." > this is much better in my opinion and straighforward also and more clear > to read ... it doens't work though: This is just a stupid attitude for a code

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Denis McMahon
On Thu, 26 Sep 2013 14:25:55 +0300, Νίκος wrote: > Okey then please tell me, what do you see wrong in it: > > socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP') If os.environ.get('HTTP_CF_CONNECTING_IP') is false > or os.environ.get('REMOTE_ADDR') and os.environ.get('REMOTE_ADDR')

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Denis McMahon
On Thu, 26 Sep 2013 12:56:19 +0300, Νίκος wrote: > host = socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_ADDR') or "Άγνωστη Προέλευση" ) Perhaps you need something that looks more like: some_value = some_function_of( some_value ) or some_function_of (

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 09:34, Νίκος wrote: > Στις 26/9/2013 3:53 μμ, ο/η Antoon Pardon έγραψε: >> Op 26-09-13 14:39, Νίκος schreef: >>> Yes, you are right, in my shell it fails too givign the same error >>> message as yours, while on the other had in the websste is working. >>> >>> Can you explain this plea

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 3:53 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 14:39, Νίκος schreef: Yes, you are right, in my shell it fails too givign the same error message as yours, while on the other had in the websste is working. Can you explain this please? why doesnt it fail to both enviroments? Your

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 14:39, Νίκος schreef: > Yes, you are right, in my shell it fails too givign the same error > message as yours, while on the other had in the websste is working. > > Can you explain this please? > why doesnt it fail to both enviroments? Your site and your shell are two different enviro

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 2:24 μμ, ο/η Dave Angel έγραψε: On 26/9/2013 06:51, Νίκος wrote: socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR') or "Άγνωστη Προέλευση" )[0] Traceback (most recent call last): File "", line 1, in socket.gaierror: [Errno -

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 13:25, Νίκος schreef: >> > Okey then please tell me, what do you see wrong in it: > > socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP') or > os.environ.get('REMOTE_ADDR') or "Άγνωστη Προέλευση" )[0] > > the [0] at then end in case the statemnt default to the string? > ple

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 2:07 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 12:51, Νίκος schreef: Στις 26/9/2013 1:41 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 12:18, Νίκος schreef: Στις 26/9/2013 1:12 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 11:56, Νίκος schreef: It is far better than the ifs, even eas

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Dave Angel
On 26/9/2013 06:51, Νίκος wrote: > socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP') or >> os.environ.get('REMOTE_ADDR') or "Άγνωστη Προέλευση" )[0] >> Traceback (most recent call last): >>File "", line 1, in >> socket.gaierror: [Errno -2] Name or service not known >> >>

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 12:51, Νίκος schreef: > Στις 26/9/2013 1:41 μμ, ο/η Antoon Pardon έγραψε: >> Op 26-09-13 12:18, Νίκος schreef: >>> Στις 26/9/2013 1:12 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 11:56, Νίκος schreef: >>> >>> It is far better than the ifs, even easier to read, i was just missing a >>

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread James Harris
"?" wrote in message news:l20utg$278$1...@dont-email.me... > 26/9/2013 12:07 ??, ?/? Antoon Pardon ??: >> Experiment and find out for yourself. That is the only way you will >> acquire the experience and understanding you need. Sure we could >> spoon feed you the line you need, but t

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 1:41 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 12:18, Νίκος schreef: Στις 26/9/2013 1:12 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 11:56, Νίκος schreef: Στις 26/9/2013 11:55 πμ, ο/η Nobody έγραψε: On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: How can i wrote the two follow

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 12:18, Νίκος schreef: > Στις 26/9/2013 1:12 μμ, ο/η Antoon Pardon έγραψε: >> Op 26-09-13 11:56, Νίκος schreef: >>> Στις 26/9/2013 11:55 πμ, ο/η Nobody έγραψε: On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: > How can i wrote the two following lines so for NOT to throw out

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 1:12 μμ, ο/η Antoon Pardon έγραψε: Op 26-09-13 11:56, Νίκος schreef: Στις 26/9/2013 11:55 πμ, ο/η Nobody έγραψε: On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: How can i wrote the two following lines so for NOT to throw out KeyErrors when a key is missing? city = gi.time_zon

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 11:56, Νίκος schreef: > Στις 26/9/2013 11:55 πμ, ο/η Nobody έγραψε: >> On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: >> >>> How can i wrote the two following lines so for NOT to throw out >>> KeyErrors when a key is missing? >>> >>> city = gi.time_zone_by_addr( os.environ['HTTP_CF_CO

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 11:31, Νίκος schreef: > Στις 26/9/2013 12:07 μμ, ο/η Antoon Pardon έγραψε: >> Experiment and find out for yourself. That is the only way you will >> acquire the experience and understanding you need. Sure we could >> spoon feed you the line you need, but that will only result in you >>

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 11:55 πμ, ο/η Nobody έγραψε: On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: How can i wrote the two following lines so for NOT to throw out KeyErrors when a key is missing? city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) or gi.time_zone_by_addr( os.environ['

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Maarten
On Thursday, September 26, 2013 11:31:29 AM UTC+2, Ferrous Cranus wrote: > I have tried code and also provided alternative code to solve my problem > which also doesn't solve it. > > So, you cannot accuse me that i'm not trying, that would be the case to > just ask for a line without trying any

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 12:04 μμ, ο/η Jussi Piitulainen έγραψε: Up until now i have this: city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) or gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or "�γν���η Π�λη" can this be written as: city = gi.time_zone_by_addr( os.environ.get('HTTP

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 12:07 μμ, ο/η Antoon Pardon έγραψε: Experiment and find out for yourself. That is the only way you will acquire the experience and understanding you need. Sure we could spoon feed you the line you need, but that will only result in you using that line without any understanding of w

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Jussi Piitulainen
Νίκος writes: > > because it raises KeyError exceptions to this: > > > > city = gi.time_zone_by_addr( os.environ.get('HTTP_CF_CONNECTING_IP', > > 'REMOTE_ADDR') )or "�γν���η Π�λη" > > > > host = socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP', > > 'REMOTE_ADDR') )[0] or "�γν���η Π

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Antoon Pardon
Op 26-09-13 10:39, Νίκος schreef: > Στις 26/9/2013 11:12 πμ, ο/η Jussi Piitulainen έγραψε: >> Νίκος writes: >> >>> Σ�ις 26/9/2013 10:48 πμ, ο/η Jussi Piitulainen >>> έγ�α�ε: > ί�ος writes: > How can i wrote the two following lines so for NOT to throw out > KeyErrors when a key is missi

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Jussi Piitulainen
Νίκος writes: > Σ�ις 26/9/2013 11:12 πμ, ο/η Jussi Piitulainen > έγ�α�ε: > ί�ος writes: > > > >> Σ�ις 26/9/2013 10:48 πμ, ο/η Jussi Piitulainen > >> έγ�α�ε: > ί�ος writes: > >>> > How can i wrote the two following lines so for NOT to throw out > KeyErrors when a key is missing? > >

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 11:39 πμ, ο/η Νίκος έγραψε: Στις 26/9/2013 11:12 πμ, ο/η Jussi Piitulainen έγραψε: Νίκος writes: Σ�ις 26/9/2013 10:48 πμ, ο/η Jussi Piitulainen έγ�α�ε: > ί�ος writes: How can i wrote the two following lines so for NOT to throw out KeyErrors when a key is missing? city = gi.t

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Nobody
On Thu, 26 Sep 2013 10:26:48 +0300, Νίκος wrote: > How can i wrote the two following lines so for NOT to throw out > KeyErrors when a key is missing? > > city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) or > gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or > "Άγνωστη

Re: Handling 3 operands in an expression without raising an exception

2013-09-26 Thread Νίκος
Στις 26/9/2013 11:46 πμ, ο/η Νίκος έγραψε: Στις 26/9/2013 11:39 πμ, ο/η Νίκος έγραψε: Στις 26/9/2013 11:12 πμ, ο/η Jussi Piitulainen έγραψε: Νίκος writes: Σ�ις 26/9/2013 10:48 πμ, ο/η Jussi Piitulainen έγ�α�ε: > ί�ος writes: How can i wrote the two following lines so for NOT to throw out K

  1   2   >