Python (windows)packet sniffer ARP

2014-01-30 Thread Ralle
Hello I am wondering if it possible to create a packet sniffer in windows using python that only sniffs for ARP packets. -- https://mail.python.org/mailman/listinfo/python-list

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Rustom Mody
On Thursday, January 30, 2014 2:15:20 PM UTC+5:30, jmf 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 > > > It's the 21st centu

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

2014-01-30 Thread Gregory Ewing
Steven D'Aprano wrote: Can you explain what's going on here then? import sys, os import tty, termios, fcntl def getch(): """Get a single character from standard input. Does not echo to the screen. This will block waiting for a keypress. """ fd = sys.stdin.fileno() old_setti

Re: Help with some python homework...

2014-01-30 Thread sjud9227
On Thursday, January 30, 2014 11:38:05 PM UTC-7, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 5:24 PM, sjud9227 wrote: > > > Thank you so much Chris. However, i'm still a little confused. Doesn't > > assigning seconds/(60*60) mean that calculating 6*hours will give me 6 > > hours in second

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 5:28 PM, Dan Sommers wrote: > ObPython: My program retrieves temperatures (in Kelvins) from an > external device (the details of which I am not at liberty to discuss) > and stores them in the cloud (because that's where all the cool kids > store data these days), and there

Re: Help with some python homework...

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 5:24 PM, sjud9227 wrote: > Thank you so much Chris. However, i'm still a little confused. Doesn't > assigning seconds/(60*60) mean that calculating 6*hours will give me 6 hours > in seconds? Also, why calculate how many seconds from midnight? wouldn't it > just be fr

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Dan Sommers
On Fri, 31 Jan 2014 04:37:16 +, Steven D'Aprano wrote: > On Fri, 31 Jan 2014 04:08:46 +, Dan Sommers wrote about temperatures: > >> And -1 K. > > You josh, but there are negative temperatures in Kelvin. They're hotter > than infinitely hot. > > http://en.wikipedia.org/wiki/Negative_tem

Re: Help with some python homework...

2014-01-30 Thread sjud9227
On Thursday, January 30, 2014 10:30:11 PM UTC-7, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 4:12 PM, wrote: > > > **If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per > > mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again, > > what time do I ge

Re: Would Python be suitable for a sports statistics website?

2014-01-30 Thread Jeff Sandvik
Python is definitely suitable for that sort of task. Django is good for this sort of thing, but I’d also like to mention using Flask (http://flask.pocoo.org), especially if you are a beginner. I use it for some of my work, and you could potentially get your project up and running that much quic

Re: Help with some python homework...

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 4:12 PM, wrote: > **If I leave my house at 6:52 am and run 1 mile at an easy pace (8:15 per > mile), then 3 miles at tempo (7:12 per mile) and 1 mile at easy pace again, > what time do I get home for breakfast?** > > > > seconds = 1 > hours = seconds / (60*60)

Re: Try-except-finally paradox

2014-01-30 Thread Terry Reedy
On 1/30/2014 7:05 AM, Dave Angel wrote: 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" ...

Help with some python homework...

2014-01-30 Thread scottwd80
Here is the question that was asked and below that I'll paste the code I have so far. Any pointers would be great. Please keep in mind this is only my second week with python (or any programming for that matter) so I have no idea what I'm doing. How would you code this? Anyways, any help is

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

2014-01-30 Thread Terry Reedy
On 1/30/2014 6:00 PM, CM wrote: 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) Trying to get

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

2014-01-30 Thread Kushal Kumaran
Steven D'Aprano writes: > On Thu, 30 Jan 2014 18:13:54 +1300, 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 a

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

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 4:05 PM, Terry Reedy wrote: > On 1/30/2014 5:55 PM, Chris Angelico wrote: >> >> 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 sq

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

2014-01-30 Thread Terry Reedy
On 1/30/2014 5:55 PM, Chris Angelico wrote: 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 mod

Would Python be suitable for a sports statistics website?

2014-01-30 Thread britt . jonathan89
First off I wanted to apologize for the lack of specificity in my subject title. I am a relative newbie to programming and need some advice. I tried StackOverflow but was sort of turned away for not having code in my post. I have been assigned by an internship with my university's athletic depa

Re: Another surprise from the datetime module

2014-01-30 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > > > Cameron Simpson writes: > >> Firstly, replace is a verb, and I would normally read > >> td.replace(microseconds=0) as an instruction to modify td in place. > >> Traditionally, such methods in python return None

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Steven D'Aprano
On Fri, 31 Jan 2014 04:08:46 +, Dan Sommers wrote about temperatures: > And -1 K. You josh, but there are negative temperatures in Kelvin. They're hotter than infinitely hot. http://en.wikipedia.org/wiki/Negative_temperature -- Steven -- https://mail.python.org/mailman/listinfo/python-

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

2014-01-30 Thread Steven D'Aprano
On Thu, 30 Jan 2014 18:13:54 +1300, 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. >> >> For example, it h

Re: pytz question: GMT vs. UTC

2014-01-30 Thread Dan Sommers
On Thu, 30 Jan 2014 15:21:35 +, Grant Edwards wrote: > 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.

Re: Another surprise from the datetime module

2014-01-30 Thread Dan Sommers
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > However, the existing ‘replace’ methods ‘datetime.date.replace’, > ‘datetime.datetime.replace’, ‘datetime.time.replace’ already work this > way: they create a new value and return it, without modifying the > original object. That's how str.r

Re: Another surprise from the datetime module

2014-01-30 Thread Roy Smith
In article <52eb1e37$0$29972$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > "replace" is a perfectly reasonable name for a method which performs a > replacement, whether it replaces in place (for mutable objects) or makes > a copy with replacement (for immutable objects). What e

Re: Another surprise from the datetime module

2014-01-30 Thread Steven D'Aprano
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > Cameron Simpson writes: > >> Hmm. I do not like the replace() as suggested. >> >> Firstly, replace is a verb, and I would normally read >> td.replace(microseconds=0) as an instruction to modify td in place. >> Traditionally, such methods in

Re: 1 > 0 == True -> False

2014-01-30 Thread Rustom Mody
On Friday, January 31, 2014 12:23:42 AM UTC+5:30, Roy Smith wrote: > 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 paren

Re: Improving support for timezones in Python (was: UTC "timezone" causing brain explosions)

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 1:26 PM, Ben Finney wrote: > He also reinforces the message that UTC is the canonical timezone for > storing and manipulating timestamp values, and we should be converting > to/from those canonical values as early/late as possible in our programs. Call it a "UTC Sandwich",

Improving support for timezones in Python (was: UTC "timezone" causing brain explosions)

2014-01-30 Thread Ben Finney
Ben Finney writes: > Time zones are a hairy beast to manage, made all the more difficult > because national politicians continually fiddle with them which means > they can't just be a built-in part of the Python standard library. PyCon 2013 had a good talk on calendaring and timezone issues http

Re: Another surprise from the datetime module

2014-01-30 Thread Cameron Simpson
On 31Jan2014 11:35, Ben Finney wrote: > Cameron Simpson writes: > > Hmm. I do not like the replace() as suggested. > > > > Firstly, replace is a verb, and I would normally read > > td.replace(microseconds=0) as an instruction to modify td in place. > > Traditionally, such methods in python return

Re: Another surprise from the datetime module

2014-01-30 Thread Ben Finney
Cameron Simpson writes: > Hmm. I do not like the replace() as suggested. > > Firstly, replace is a verb, and I would normally read > td.replace(microseconds=0) as an instruction to modify td in place. > Traditionally, such methods in python return None. I agree with this objection. A method that

Re: Removal of iterable unpacking in function calls

2014-01-30 Thread Rotwang
On 31/01/2014 00:21, Ben Finney wrote: 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

Re: 1 > 0 == True -> False

2014-01-30 Thread Joshua Landau
On 31 January 2014 00:10, Rotwang wrote: > > On a vaguely-related note, does anyone know why iterable unpacking in calls > was removed in Python 3? I mean things like > > def f(x, (y, z)): > return (x, y), z > > I don't have a use case in mind, I was just wondering. http://www.python.org/dev/

Re: Another surprise from the datetime module

2014-01-30 Thread Cameron Simpson
On 30Jan2014 18:36, Neil Cerutti wrote: > 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? > >

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>. -

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:

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 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: 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: 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

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 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: ',

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 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: 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: 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 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: 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

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 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

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 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 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

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 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

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 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 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: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 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: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 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
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 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 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: 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 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: 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 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: 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 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: 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: 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: 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 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: 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

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: 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

[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 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

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: 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: 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: 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 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: 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: 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: 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 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: 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 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 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: 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 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: 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 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: 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: 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: 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: 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 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

  1   2   >