Re: pytz question: GMT vs. UTC

2014-01-30 Thread wxjmfauth
Le jeudi 30 janvier 2014 04:27:54 UTC+1, Chris Angelico a écrit : > On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: > > >> How cruel... I suspect the smack at 0degC is much more painful > > >> than one > > >> at room temperature > > >> > > > It's the 21st century; you should be making u

Re: Python shell wont open IDLE or an exisiting .py files

2014-01-30 Thread Terry Reedy
On 1/29/2014 11:16 PM, Ben Finney wrote: Terry Reedy writes: On 1/29/2014 6:26 PM, shangonich...@sbcglobal.net wrote: > If I launch the Python GUI it opens a Python Shell fine. But as > soon as I try to open a file (including a "new" file), it closes > the Shell. This I do not. What i

Re: buggy python interpretter or am I missing something here?

2014-01-30 Thread Terry Reedy
On 1/30/2014 12:13 AM, Gregory Ewing wrote: Steven D'Aprano wrote: On Mon, 27 Jan 2014 12:22:22 -0800, Rick Johnson wrote: Why do we even need an "input" function anyway if all it is going to do is read from stdin? That's not all it does. What else it does is print a prompt before reading

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Christian Heimes
On 30.01.2014 04:27, Chris Angelico wrote: > On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: >>> How cruel... I suspect the smack at 0degC is much more painful >>> than one >>> at room temperature >>> >> It's the 21st century; you should be making use of Unicode: 0°C. > > I started to read

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Chris Angelico
On Thu, Jan 30, 2014 at 8:49 PM, Christian Heimes wrote: > On 30.01.2014 04:27, Chris Angelico wrote: >> On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: How cruel... I suspect the smack at 0degC is much more painful than one at room temperature >>> It's the 21st century;

Re: pytz question: GMT vs. UTC

2014-01-30 Thread wxjmfauth
Le jeudi 30 janvier 2014 10:49:11 UTC+1, Christian Heimes a écrit : > On 30.01.2014 04:27, Chris Angelico wrote: > > > On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: > > >>> How cruel... I suspect the smack at 0degC is much more painful > > >>> than one > > >>> at room temperature > >

Work on Call for Participation for EuroPython 2015 has started

2014-01-30 Thread M.-A. Lemburg
[Please help spread the word by forwarding to other relevant mailing lists, user groups, etc.; thanks :-)] The EuroPython Society (EPS) has started work on preparing the Call for Participation (CFP) for organizing the EuroPython 2015 conference: http://www.europython-society.org/ For 2015,

fseek In Compressed Files

2014-01-30 Thread Ayushi Dalmia
Hello, I need to randomly access a bzip2 or gzip file. How can I set the offset for a line and later retreive the line from the file using the offset. Pointers in this direction will help. -- https://mail.python.org/mailman/listinfo/python-list

Re: fseek In Compressed Files

2014-01-30 Thread Peter Otten
Ayushi Dalmia wrote: > I need to randomly access a bzip2 or gzip file. How can I set the offset > for a line and later retreive the line from the file using the offset. > Pointers in this direction will help. with gzip.open(filename) as f: f.seek(some_pos) print(f.readline()) f.seek(s

1 > 0 == True -> False

2014-01-30 Thread Thibault Langlois
Hello, $ python Python 2.7.4 (default, Sep 26 2013, 03:20:26) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1 > 0 == True False >>> (1 > 0) == True True >>> 1 > (0 == True) True >>> What am I missing here ? T. -- https://mail.python.org/mailma

Re: 1 > 0 == True -> False

2014-01-30 Thread Thomas Mlynarczyk
Thibault Langlois schrieb: 1 > 0 == True False What am I missing here ? This, perhaps: http://www.primozic.net/nl/chaining-comparison-operators-in-python/ Greetings, Thomas -- Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison! (Coluche) -- https://mail.python.org/mailman

Re: 1 > 0 == True -> False

2014-01-30 Thread Jussi Piitulainen
Thibault Langlois writes: > Hello, > > $ python > Python 2.7.4 (default, Sep 26 2013, 03:20:26) > [GCC 4.7.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> 1 > 0 == True > False > >>> (1 > 0) == True > True > >>> 1 > (0 == True) > True > >>> > > What a

Re: pytz question: GMT vs. UTC

2014-01-30 Thread MRAB
On 2014-01-30 08:45, wxjmfa...@gmail.com wrote: Le jeudi 30 janvier 2014 04:27:54 UTC+1, Chris Angelico a écrit : On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: >> How cruel... I suspect the smack at 0degC is much more painful >> than one >> at room temperature >> > It's the 21st ce

Re:fseek In Compressed Files

2014-01-30 Thread Dave Angel
Ayushi Dalmia Wrote in message: > Hello, > > I need to randomly access a bzip2 or gzip file. How can I set the offset for > a line and later retreive the line from the file using the offset. Pointers > in this direction will help. > Start with the zlib module. Note that it doesn't handle all

Re:Try-except-finally paradox

2014-01-30 Thread Dave Angel
Jessica Ross Wrote in message: > I found something like this in a StackOverflow discussion. def paradox(): > ... try: > ... raise Exception("Exception raised during try") > ... except: > ... print "Except after try" > ... return True > ... fina

Re: 1 > 0 == True -> False

2014-01-30 Thread Peter Otten
Jussi Piitulainen wrote: > Thibault Langlois writes: > >> Hello, >> >> $ python >> Python 2.7.4 (default, Sep 26 2013, 03:20:26) >> [GCC 4.7.3] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> 1 > 0 == True >> False >> >>> (1 > 0) == True >> True >> >>>

Re: 1 > 0 == True -> False

2014-01-30 Thread Jussi Piitulainen
Peter Otten writes: > Jussi Piitulainen wrote: > > > Thibault Langlois writes: > > > >> Hello, > >> > >> $ python > >> Python 2.7.4 (default, Sep 26 2013, 03:20:26) > >> [GCC 4.7.3] on linux2 > >> Type "help", "copyright", "credits" or "license" for more information. > >> >>> 1 > 0 == True > >>

Add directory to sys.path based on variable

2014-01-30 Thread loial
I want to add a path to sys.path based upon a variable Can I do that? Hardcodeing the path works fine, but I want to set it based upon a variable. I know I can set PYTHONPATH, but just wondering if I can add a directory on the fly to sys.path using a variable -- https://mail.python.org/ma

Re: Add directory to sys.path based on variable

2014-01-30 Thread Tim Golden
On 30/01/2014 12:39, loial wrote: > I want to add a path to sys.path based upon a variable > > Can I do that? > > Hardcodeing the path works fine, but I want to set it based upon a > variable. > > I know I can set PYTHONPATH, but just wondering if I can add a > directory on the fly to sys.path u

Re:1 > 0 == True -> False

2014-01-30 Thread Dave Angel
Thibault Langlois Wrote in message: > Hello, > > $ python > Python 2.7.4 (default, Sep 26 2013, 03:20:26) > [GCC 4.7.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. 1 > 0 == True > False (1 > 0) == True > True 1 > (0 == True) > True > >

Re: Try-except-finally paradox

2014-01-30 Thread Chris Angelico
On Thu, Jan 30, 2014 at 11:05 PM, Dave Angel wrote: > The finally has to happen before any return inside the try or the > except. And once you're in the finally clause you'll finish it > before resuming the except clause. Since it has a return, that > will happen before the other returns. Th

Re: Try-except-finally paradox

2014-01-30 Thread MRAB
On 2014-01-30 13:02, Chris Angelico wrote: On Thu, Jan 30, 2014 at 11:05 PM, Dave Angel wrote: The finally has to happen before any return inside the try or the except. And once you're in the finally clause you'll finish it before resuming the except clause. Since it has a return, that wi

Re: Try-except-finally paradox

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 12:11 AM, MRAB wrote: > One of the reasons that the 'with' statement was added was to prevent > the mistake that you've just done. ;-) > > What if the file can't be opened? Yeah, whoops. The open shouldn't be inside try/finally. def func(): output = open("output.txt",

end quote help for a newbie

2014-01-30 Thread Peter Clark
There is probably an easy solution to this – but I have not found it. Trying to terminate a literal in a print statement (from the tutorial). The literal should be enclosed in double quotes “ “ the initial double quote seems to be OK (if I use a different character it flags it) but the ending

Re: fseek In Compressed Files

2014-01-30 Thread Ayushi Dalmia
On Thursday, January 30, 2014 4:20:26 PM UTC+5:30, Ayushi Dalmia wrote: > Hello, > > > > I need to randomly access a bzip2 or gzip file. How can I set the offset for > a line and later retreive the line from the file using the offset. Pointers > in this direction will help. This is what I hav

Re: end quote help for a newbie

2014-01-30 Thread Skip Montanaro
Not sure if this is exactly what you're asking, but perhaps you want triple quotes? >>> print "now is the time for all good men ..." now is the time for all good men ... >>> print '''now is the time for "all good men" ...''' now is the time for "all good men" ... It's not easy to visually disting

Re: end quote help for a newbie

2014-01-30 Thread MRAB
On 2014-01-30 13:26, Peter Clark wrote: There is probably an easy solution to this – but I have not found it. Trying to terminate a literal in a print statement (from the tutorial). The literal should be enclosed in double quotes “ “ the initial double quote seems to be OK (if I use a different c

Re: 1 > 0 == True -> False

2014-01-30 Thread Thibault Langlois
On Thursday, January 30, 2014 12:49:19 PM UTC, Dave Angel wrote: > Thibault Langlois Wrote in message: > > > Hello, > > > > > > $ python > > > Python 2.7.4 (default, Sep 26 2013, 03:20:26) > > > [GCC 4.7.3] on linux2 > > > Type "help", "copyright", "credits" or "license" for more informati

Convert NTP timestamp from NTP packet to System time and date format

2014-01-30 Thread Sadia Bashir
Hello everyone; I want to write NTP client which sends and receives NTP packet to NTP server and should read the value from one of the four offsets and convert it to user readable local or GMT time format, I specifically want to know which offsets should I read in order to get correct timestamp fr

Re: fseek In Compressed Files

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 12:34 AM, Ayushi Dalmia wrote: > where temp.txt is the posting list file which is first written in a > compressed format and then read later. Unless you specify otherwise, a compressed file is likely to have sub-byte boundaries. It might not be possible to seek to a spec

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 12:40 AM, Thibault Langlois wrote: > The recommendations to student are 1) do not assume True == 1 and do not use > operator chaining. Not "do not use", but "do not misuse". Python's operator chaining is awesome for bounds checking: if 3 < x < 20: print("x is between 3

Re: Convert NTP timestamp from NTP packet to System time and date format

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 12:34 AM, Sadia Bashir <11msccssbas...@seecs.edu.pk> wrote: > Hello everyone; > > I want to write NTP client which sends and receives NTP packet to NTP server > and should read the value from one of the four offsets and convert it to > user readable local or GMT time format,

Re: Add directory to sys.path based on variable

2014-01-30 Thread loial
Ok, that works fine with the apth hard coded, but I want to do something like the code below. i.e I am trying to dynamically add a path that is relative to the path of the current executing python script. In this case the import fails. import sys import os from os.path import * scriptpath=os.p

Re: 1 > 0 == True -> False

2014-01-30 Thread Roy Smith
In article <3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com>, Thibault Langlois wrote: > You are right. I should have given some context. > I am looking at this from the perspective of the teacher that has to explain > idiosyncrasies of the language to inexperienced students. > There are

Re: Add directory to sys.path based on variable

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 1:03 AM, loial wrote: > In this case the import fails. > > import sys > import os > from os.path import * Not sure why you need that, since you're explicitly naming "os.path.dirname". The base "import os" shoul cover that for you. > scriptpath=os.path.dirname(sys.argv[0])

Re: Add directory to sys.path based on variable

2014-01-30 Thread Tim Golden
On 30/01/2014 14:03, loial wrote: > Ok, that works fine with the apth hard coded, but I want to do something like > the code below. i.e I am trying to dynamically add a path that is relative to > the path of the current executing python script. > > In this case the import fails. > > import sys

Re: end quote help for a newbie

2014-01-30 Thread Zachary Ware
On Thu, Jan 30, 2014 at 7:26 AM, Peter Clark wrote: > There is probably an easy solution to this – but I have not found it. > > Trying to terminate a literal in a print statement (from the tutorial). > > The literal should be enclosed in double quotes “ “ > > the initial double quote seems to be O

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith wrote: > Better than that, do what I do. > > 1) Assume that you don't have the full operator precedence table > memorized and just parenthesize everything. Or: 1a) Assume that you don't have the full operator precedence table memorized and just look it

Re: Add directory to sys.path based on variable

2014-01-30 Thread loial
Idiot that I am...I was not calling the script with the full path ! Thanks for your help -- https://mail.python.org/mailman/listinfo/python-list

Re: 1 > 0 == True -> False

2014-01-30 Thread Devin Jeanpierre
On Thu, Jan 30, 2014 at 6:08 AM, Roy Smith wrote: > 1) Assume that you don't have the full operator precedence table > memorized and just parenthesize everything. > > 2) In cases where the expression is so simple, you couldn't possibly be > wrong, see rule #1. Also, assume you don't have the func

Re: end quote help for a newbie

2014-01-30 Thread Steven D'Aprano
On Thu, 30 Jan 2014 13:26:16 +, Peter Clark wrote: > There is probably an easy solution to this – but I have not found it. > > Trying to terminate a literal in a print statement (from the tutorial). I don't understand the problem. Perhaps if you show us what you have tried, and the error yo

Re: 1 > 0 == True -> False

2014-01-30 Thread Thibault Langlois
On Thursday, January 30, 2014 2:08:58 PM UTC, Roy Smith wrote: > In article <3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com>, > > Thibault Langlois wrote: > > > > > You are right. I should have given some context. > > > I am looking at this from the perspective of the teacher that has

Re: 1 > 0 == True -> False

2014-01-30 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith wrote: > > Better than that, do what I do. > > > > 1) Assume that you don't have the full operator precedence table > > memorized and just parenthesize everything. > > Or: > > 1a) Assume that you don't have the fu

Re: 1 > 0 == True -> False

2014-01-30 Thread Jussi Piitulainen
Roy Smith writes: > In article <3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com>, > Thibault Langlois wrote: > > > You are right. I should have given some context. I am looking at > > this from the perspective of the teacher that has to explain > > idiosyncrasies of the language to inexpe

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 1:49 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith wrote: >> > Better than that, do what I do. >> > >> > 1) Assume that you don't have the full operator precedence table >> > memorized and just parenthesize ev

Re: fseek In Compressed Files

2014-01-30 Thread Serhiy Storchaka
30.01.14 13:28, Peter Otten написав(ла): Ayushi Dalmia wrote: I need to randomly access a bzip2 or gzip file. How can I set the offset for a line and later retreive the line from the file using the offset. Pointers in this direction will help. with gzip.open(filename) as f: f.seek(some_p

Re: 1 > 0 == True -> False

2014-01-30 Thread Steven D'Aprano
On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote: > 1) Assume that you don't have the full operator precedence table > memorized and just parenthesize everything. Oh really? Do you actually write stuff like this? b = ((2*a) + 1) if (b >= (-1)): ... I would hope not. > 2) In cases wher

Re: Convert NTP timestamp from NTP packet to System time and date format

2014-01-30 Thread Johannes Findeisen
On Thu, 30 Jan 2014 18:34:04 +0500 Sadia Bashir wrote: > Hello everyone; > > I want to write NTP client which sends and receives NTP packet to NTP > server and should read the value from one of the four offsets and convert > it to user readable local or GMT time format, I specifically want to kno

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Larry Martell
On Thu, Jan 30, 2014 at 10:23 AM, Grant Edwards wrote: > On 2014-01-30, Christian Heimes wrote: >> On 30.01.2014 04:27, Chris Angelico wrote: >>> On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: > How cruel... I suspect the smack at 0degC is much more painful > than one > at room

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Grant Edwards
On 2014-01-30, Christian Heimes wrote: > On 30.01.2014 04:27, Chris Angelico wrote: >> On Thu, Jan 30, 2014 at 1:40 PM, MRAB wrote: How cruel... I suspect the smack at 0degC is much more painful than one at room temperature >>> It's the 21st century; you should be mak

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Grant Edwards
On 2014-01-30, wxjmfa...@gmail.com wrote: > The temperature unit is the "Kelvin", not the "Degree Kelvin". > One writes: 0 K, 275.15 K And remember to say "Kelvins" not "Kelvin" when speaking about temperatures other than 1 K. -- Grant Edwards grant.b.edwardsYow! BELA LUG

Re: end quote help for a newbie

2014-01-30 Thread Zachary Ware
Please reply to the list, rather than to me directly. You can use "Reply to List" if you have that option, or "Reply to All" to make sure you include the list. On Thu, Jan 30, 2014 at 8:52 AM, Peter Clark wrote: > I do not know how to dump the screen - it will not let me select anything > with t

Re: 1 > 0 == True -> False

2014-01-30 Thread Rustom Mody
On Thursday, January 30, 2014 8:39:03 PM UTC+5:30, Steven D'Aprano wrote: > On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote: > > 1) Assume that you don't have the full operator precedence table > > memorized and just parenthesize everything. > Oh really? Do you actually write stuff like this?

Re: fseek In Compressed Files

2014-01-30 Thread Ayushi Dalmia
On Thursday, January 30, 2014 4:20:26 PM UTC+5:30, Ayushi Dalmia wrote: > Hello, > > > > I need to randomly access a bzip2 or gzip file. How can I set the offset for > a line and later retreive the line from the file using the offset. Pointers > in this direction will help. We are not allowed

[ANN] Last news from Python FOSDEM 2014

2014-01-30 Thread Stéphane Wirtel
Python @ FOSDEM 2014 Hi all, Last news about the Python devroom at FOSDEM 2014 [1] Schedule There is a last change in the schedule, "PyPy: a fast Python Virtual Machine" will replace "Web Scraping 101 in Python". Yasoob can't be present in Belgium :/ +

[ANN] Last news from Python FOSDEM 2014

2014-01-30 Thread Stéphane Wirtel
Python @ FOSDEM 2014 Hi all, Last news about the Python devroom at FOSDEM 2014 [1] Schedule There is a last change in the schedule, "PyPy: a fast Python Virtual Machine" will replace "Web Scraping 101 in Python". Yasoob can't be present in Belgium :/ +

Re: fseek In Compressed Files

2014-01-30 Thread Peter Otten
Serhiy Storchaka wrote: > 30.01.14 13:28, Peter Otten написав(ла): >> Ayushi Dalmia wrote: >> >>> I need to randomly access a bzip2 or gzip file. How can I set the offset >>> for a line and later retreive the line from the file using the offset. >>> Pointers in this direction will help. >> >> with

Another surprise from the datetime module

2014-01-30 Thread Roy Smith
I was astounded just now to discover that datetime.timedelta doesn't have a replace() method (at least not in Python 2.7). Is there some fundamental reason why it shouldn't, or is this just an oversight? My immediate use case was wanting to print a timedelta without the fractions of seconds. The

Re: 1 > 0 == True -> False

2014-01-30 Thread Mark Lawrence
On 30/01/2014 14:46, Thibault Langlois wrote: On Thursday, January 30, 2014 2:08:58 PM UTC, Roy Smith wrote: In article <3dcdc95d-5e30-46d3-b558-afedf9723...@googlegroups.com>, Thibault Langlois wrote: You are right. I should have given some context. I am looking at this from the pers

Re: Another surprise from the datetime module

2014-01-30 Thread Mark Lawrence
On 30/01/2014 17:32, Roy Smith wrote: I was astounded just now to discover that datetime.timedelta doesn't have a replace() method (at least not in Python 2.7). Is there some fundamental reason why it shouldn't, or is this just an oversight? My immediate use case was wanting to print a timedelt

Re: Try-except-finally paradox

2014-01-30 Thread Rotwang
On 30/01/2014 06:33, Andrew Berg wrote: On 2014.01.29 23:56, Jessica Ross wrote: I found something like this in a StackOverflow discussion. def paradox(): ... try: ... raise Exception("Exception raised during try") ... except: ... print "Except after try" ...

Re: Another surprise from the datetime module

2014-01-30 Thread Neil Cerutti
On 2014-01-30, Roy Smith wrote: > I was astounded just now to discover that datetime.timedelta > doesn't have a replace() method (at least not in Python 2.7). > Is there some fundamental reason why it shouldn't, or is this > just an oversight? > > My immediate use case was wanting to print a timed

Re: fseek In Compressed Files

2014-01-30 Thread Dave Angel
Ayushi Dalmia Wrote in message: > On Thursday, January 30, 2014 4:20:26 PM UTC+5:30, Ayushi Dalmia wrote: >> Hello, >> >> >> >> I need to randomly access a bzip2 or gzip file. How can I set the offset for >> a line and later retreive the line from the file using the offset. Pointers >> in th

Re: 1 > 0 == True -> False

2014-01-30 Thread Roy Smith
On Thursday, January 30, 2014 9:56:19 AM UTC-5, Jussi Piitulainen wrote: > There's nothing to parenthesize in x <= y < z = w Hmm >>> x <= y < z = w File "", line 1 SyntaxError: can't assign to comparison I don't think any number of parentheses will help that :-) -- https://mail.python.or

Re: Try-except-finally paradox

2014-01-30 Thread Ethan Furman
On 01/30/2014 10:12 AM, Rotwang wrote: On 30/01/2014 06:33, Andrew Berg wrote: On 2014.01.29 23:56, Jessica Ross wrote: I found something like this in a StackOverflow discussion. --> def paradox(): ... try: ... raise Exception("Exception raised during try") ... except: ...

Re: 1 > 0 == True -> False

2014-01-30 Thread Roy Smith
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote: > On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote: > > > 1) Assume that you don't have the full operator precedence table > > memorized and just parenthesize everything. > > Oh really? Do you actually write stuff like thi

Re: 1 > 0 == True -> False

2014-01-30 Thread Roy Smith
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote: > E.g. `x+1 > 0 and y >= 5` is potentially as many as 9 distinct > items to keep in short-term memory. But bracketing some terms > as in `(x+1 > 0) and (y >= 5)` can reduce that down to as few > as two items.

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith wrote: > On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote: > >> E.g. `x+1 > 0 and y >= 5` is potentially as many as 9 distinct >> items to keep in short-term memory. But bracketing some terms >> as in `(x+1 > 0) and (y >=

Re: end quote help for a newbie

2014-01-30 Thread Peter Clark
Thank-you.  Please no-one reply to this post.  I just want to put on record my complete p-offed-ness, that having spent 10 days sorting out and hypertexting a library of documentation, I now have to start all over. Please do not respond, I am sure it is all my fault. Please do not respond - it

Re: 1 > 0 == True -> False

2014-01-30 Thread Rotwang
On 30/01/2014 12:49, Dave Angel wrote: [...] For hysterical reasons, True and False are instances of class bool, which is derived from int. So for comparison purposes False==0 and True==1. But in my opinion, you should never take advantage of this, except when entering obfuscation cont

Re: 1 > 0 == True -> False

2014-01-30 Thread Ethan Furman
On 01/30/2014 11:03 AM, Chris Angelico wrote: On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith wrote: Yes, that's probably how I would write that, although, this is even simpler: (x > -1) and (y >= 5) Be careful; that's not the same thing. How so? -- ~Ethan~ -- https://mail.python.org/mailman/l

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
Fri, Jan 31, 2014 at 6:22 AM, Ethan Furman wrote: > On 01/30/2014 11:03 AM, Chris Angelico wrote: > >> On Fri, Jan 31, 2014 at 5:56 AM, Roy Smith wrote: >>> >>> >>> Yes, that's probably how I would write that, although, this is even >>> simpler: >>> >>> (x > -1) and (y >= 5) >> >> >> Be careful;

Re: 1 > 0 == True -> False

2014-01-30 Thread Dave Angel
Rotwang Wrote in message: > On 30/01/2014 12:49, Dave Angel wrote: >> [...] >> >> For hysterical reasons, True and False are instances of class >> bool, which is derived from int. So for comparison purposes >> False==0 and True==1. But in my opinion, you should never take >> advantage of

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 7:08 AM, Dave Angel wrote: >> 'You have scored %i point%s' % (score, 's'*(score != 1)) >> > > Here I'd probably do something like > > 'You have scored {} {}' .format (score, 'point' if score==1 else > 'points') Bah, what's the fun in that? 'You have scored %i point%.*s'

Re: 1 > 0 == True -> False

2014-01-30 Thread Jussi Piitulainen
Roy Smith writes: > On Thursday, January 30, 2014 9:56:19 AM UTC-5, Jussi Piitulainen wrote: > > > There's nothing to parenthesize in x <= y < z = w > > Hmm > > >>> x <= y < z = w > File "", line 1 > SyntaxError: can't assign to comparison > > I don't think any number of parentheses will

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 7:14 AM, Jussi Piitulainen wrote: >> I don't think any number of parentheses will help that :-) > > Er, sorry about that. Here: > x <= y < z == w > Traceback (most recent call last): > File "", line 1, in > NameError: name 'x' is not defined > > Much better :) See,

Re: 1 > 0 == True -> False

2014-01-30 Thread Ian Kelly
On Thu, Jan 30, 2014 at 1:08 PM, Dave Angel wrote: > Rotwang Wrote in message: >> Really? I take advantage of it quite a lot. For example, I do things >> like this: >> >> 'You have scored %i point%s' % (score, 's'*(score != 1)) >> > > I also did that kind of thing when computer resources > were

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly wrote: > Of course if you're at all concerned about i18n then the proper way to > do it would be: > > ngettext("You have scored %d point", "You have scored %d points", score) % > score Ugh, so much duplication! We can totally do better than that. ngett

Re: 1 > 0 == True -> False

2014-01-30 Thread Ian Kelly
On Jan 30, 2014 1:40 PM, "Chris Angelico" wrote: > > On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly wrote: > > Of course if you're at all concerned about i18n then the proper way to > > do it would be: > > > > ngettext("You have scored %d point", "You have scored %d points", score) % score > > Ugh, s

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 8:17 AM, Ian Kelly wrote: >> Why is tuple unpacking limited to the last argument? Is it just for >> the parallel with the function definition, where anything following it >> is keyword-only? > > Lack of a convincing use case, and the position of the following arguments > wo

Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread CM
This is puzzling. (Using Python 2.5, WinXP, Boa Constructor 0.6.1 definitely running the code through Python 2.5) If I run these lines in my program, through my IDE (Boa Constructor), fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] fake_result = not all(i == '[omitted]' for

Re: 1 > 0 == True -> False

2014-01-30 Thread Roy Smith
On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote: > `(x+1 > 0) and (y >= 5)` Me: > this is even simpler: > (x > -1) and (y >= 5) On Thursday, January 30, 2014 2:03:42 PM UTC-5, Chris Angelico wrote: > Be careful; that's not the same thing. In what way? I'm assuming x is so

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread Peter Otten
CM wrote: > This is puzzling. (Using Python 2.5, WinXP, Boa Constructor 0.6.1 > definitely running the code through Python 2.5) > > If I run these lines in my program, through my IDE (Boa Constructor), > > fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] > fake_result = not a

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 9:09 AM, Roy Smith wrote: > On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote: >> `(x+1 > 0) and (y >= 5)` > > Me: >> this is even simpler: >> (x > -1) and (y >= 5) > > On Thursday, January 30, 2014 2:03:42 PM UTC-5, Chris Angelico wrote: >> Be careful;

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 9:04 AM, CM wrote: > fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] > fake_result = not all(i == '[omitted]' for i in fake_data) > print 'This is fake result: ', fake_result Trying to get my head around this. You want to see if all the values in fa

Why this throws an UnboundLocalError ?

2014-01-30 Thread Marc Aymerich
Dear all, I have a very simple module glic3@e4200:# cat globalstate.py GLOBAL = 0 def update(): GLOBAL += 1 however it doesn't work!! glic3@e4200:# python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more informat

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread CM
On Thursday, January 30, 2014 5:14:57 PM UTC-5, Peter Otten wrote: > Hint: > > >>> def demo(): > ... fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] > ... fake_result = not all(i == '[omitted]' for i in fake_data) > ... print 'This is fake result: ', fake_result > > >>> d

Re: Why this throws an UnboundLocalError ?

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 9:46 AM, Marc Aymerich wrote: > GLOBAL = 0 > > def update(): > GLOBAL += 1 If you assign to a name, Python makes it local, unless you explicitly tell it that you want it to be global: def update(): global GLOBAL GLOBAL += 1 But be aware that the ALL_CAPS name

Re: Why this throws an UnboundLocalError ?

2014-01-30 Thread Mark Lawrence
On 30/01/2014 22:46, Marc Aymerich wrote: Dear all, I have a very simple module glic3@e4200:# cat globalstate.py GLOBAL = 0 def update(): GLOBAL += 1 however it doesn't work!! glic3@e4200:# python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyrig

Re: Why this throws an UnboundLocalError ?

2014-01-30 Thread Ned Batchelder
On 1/30/14 5:46 PM, Marc Aymerich wrote: Dear all, I have a very simple module glic3@e4200:# cat globalstate.py GLOBAL = 0 def update(): GLOBAL += 1 however it doesn't work!! glic3@e4200:# python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyrigh

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 9:48 AM, CM wrote: > builtin_all = __builtins__.all > > but I got the error: > > AttributeError: 'dict' object has no attribute 'all' Try using square brackets notation instead. Apparently your __builtins__ is a dictionary, not a module, though I don't know why (probably s

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread CM
> Try using square brackets notation instead. Apparently your > __builtins__ is a dictionary, not a module, though I don't know why > (probably something to do with numpy, which I've never actually used). > > But try this: > builtin_all = __builtins__["all"] > > It might work. Yes, it does. Tha

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread CM
On Thursday, January 30, 2014 5:25:31 PM UTC-5, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 9:04 AM, CM wrote: > > > fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] > > > fake_result = not all(i == '[omitted]' for i in fake_data) > > > print 'This is fake result: ',

HOW EVOLUTIONISTS MISUSE SCIENCE

2014-01-30 Thread CHAIRMAN THRINAXODON OF THE COMMUNIST PARTY OF CANADA
http://www.talkorigins.org/ > Vs > http://www.trueorigin.org/ > WHICH ONE'S TRUE? > This one!: http://www.trueorigin.org/ -- Thrinaxodon, The Ultimate Defender of USENET -- https://mail.python.org/mailman/listinfo/python-list

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread Peter Otten
CM wrote: > On Thursday, January 30, 2014 5:14:57 PM UTC-5, Peter Otten wrote: > >> Hint: >> >> >>> def demo(): >> ... fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] >> ... fake_result = not all(i == '[omitted]' for i in fake_data) >> ... print 'This is fake result: ', f

Re: Statement evals as False in my IDE and True elsewhere

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 10:00 AM, CM wrote: > Essentially, if ALL the items in that list are '[omitted]', I must not > process the list, but if even one of them is something other than > '[omitted]', I need to process it. Okay. The set example that I gave will work, then - as long as all items

Re: 1 > 0 == True -> False

2014-01-30 Thread Joshua Landau
On 30 January 2014 20:38, Chris Angelico wrote: > > Why is tuple unpacking limited to the last argument? Is it just for > the parallel with the function definition, where anything following it > is keyword-only? You're not the first person to ask that: http://www.python.org/dev/peps/pep-0448/ If

Re: 1 > 0 == True -> False

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 10:36 AM, Joshua Landau wrote: > On 30 January 2014 20:38, Chris Angelico wrote: >> >> Why is tuple unpacking limited to the last argument? Is it just for >> the parallel with the function definition, where anything following it >> is keyword-only? > > You're not the first

Re: 1 > 0 == True -> False

2014-01-30 Thread Rotwang
On 30/01/2014 23:36, Joshua Landau wrote: On 30 January 2014 20:38, Chris Angelico wrote: Why is tuple unpacking limited to the last argument? Is it just for the parallel with the function definition, where anything following it is keyword-only? You're not the first person to ask that: http:

Removal of iterable unpacking in function calls (was: 1 > 0 == True -> False)

2014-01-30 Thread Ben Finney
Rotwang writes: > On a vaguely-related note, does anyone know why iterable unpacking in > calls was removed in Python 3? This is explained in the PEP which described its removal http://www.python.org/dev/peps/pep-3113/>, especially http://www.python.org/dev/peps/pep-3113/#why-they-should-go>. -

  1   2   >