Re: Help with some python homework...

2014-01-31 Thread Gregory Ewing
sjud9227 wrote: Doesn't assigning seconds/(60*60) mean that calculating 6*hours will give me 6 hours in seconds? No, it's giving you 6 seconds in hours. (That should give you a clue as to what you should have done instead. :-) Also, I don't know what you were trying to do with these two statem

Re: Help with some python homework...

2014-01-31 Thread Chris Angelico
On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing wrote: > sjud9227 wrote: >> >> Doesn't >> assigning seconds/(60*60) mean that calculating 6*hours will give me 6 >> hours >> in seconds? > > No, it's giving you 6 seconds in hours. (That should > give you a clue as to what you should have done > inste

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Mark Lawrence
On 31/01/2014 04:08, Dan Sommers wrote: 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

how to iterate all sub-element in a list

2014-01-31 Thread seaspeak
a list like L = [[1, 2], [3, 4, 5], [6]], which has random numbers of list, which has random numbers. How do I get another list m = [1, 2, 3, 4, 5, 6] in a succinct way? ( or iterate them) I should provide my own solution, but I really can't come out with one. -- https://mail.python.org/mailman/

Re: pytz question: GMT vs. UTC

2014-01-31 Thread wxjmfauth
Le vendredi 31 janvier 2014 08:02:22 UTC+1, Rustom Mody a écrit : > 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 suspec

Re: how to iterate all sub-element in a list

2014-01-31 Thread Skip Montanaro
Google for "python flatten list." This question comes up frequently, though I'm not sure if that's because it's a common homework problem or because people are unaware of the += operator (or extend method) for lists, and so build lists-of-lists when they could just build them flat in the first pla

Re: how to iterate all sub-element in a list

2014-01-31 Thread seaspeak
Skip Montanaro於 2014年1月31日星期五UTC+8下午6時29分27秒寫道: > Google for "python flatten list." > > > > This question comes up frequently, though I'm not sure if that's > > because it's a common homework problem or because people are unaware > > of the += operator (or extend method) for lists, and so buil

Re: how to iterate all sub-element in a list

2014-01-31 Thread Peter Otten
seasp...@gmail.com wrote: > a list like L = [[1, 2], [3, 4, 5], [6]], which has > random numbers of list, which has random numbers. > > How do I get another list m = [1, 2, 3, 4, 5, 6] in a succinct way? ( or > iterate them) I should provide my own solution, but I really can't come > out with one

Re: Help with some python homework...

2014-01-31 Thread Gregory Ewing
Chris Angelico wrote: OP is using 2.7.6, so short of a __future__ directive, that won't actually give 6 seconds in hours Oops, yes, you're right! (I always use future division these days, so I tend to forget about that.) and // is unnecessary. It's still a good habit to get into, though, si

Re: Why this throws an UnboundLocalError ?

2014-01-31 Thread Marc Aymerich
On Thu, Jan 30, 2014 at 11:53 PM, Chris Angelico wrote: > 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():

webbrowser module bug?

2014-01-31 Thread Robert Watson
Sorry. Experiencing same problem in Python 2.6.4 on Ubuntu 10.04 (actually, Puppy Linux 5.2.8 which is based on Ubuntu Lucid) If anyone happens to see this and knows what was settled on as the best workaround, please email me a link to it or something at robertcwat...@yahoo.com. Robert "DocSalvag

Re: how to iterate all sub-element in a list

2014-01-31 Thread Rustom Mody
On Friday, January 31, 2014 4:18:13 PM UTC+5:30, Peter Otten wrote: > seaspeak wrote: > > a list like L = [[1, 2], [3, 4, 5], [6]], which has > > random numbers of list, which has random numbers. > > How do I get another list m = [1, 2, 3, 4, 5, 6] in a succinct way? ( or > > iterate them) I shoul

Re: Why this throws an UnboundLocalError ?

2014-01-31 Thread Chris Angelico
On Fri, Jan 31, 2014 at 10:05 PM, Marc Aymerich wrote: > I can't believe, all these years using Python and never encountered a > situation where I needed to use global ! That might be an indication of good code design :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with some python homework...

2014-01-31 Thread Neil Cerutti
On 2014-01-31, scottw...@gmail.com wrote: > Here is the question that was asked and below that I'll paste > the code I have so far. > > **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 tim

Re: webbrowser module bug?

2014-01-31 Thread Steven D'Aprano
On Fri, 31 Jan 2014 06:07:39 -0500, Robert Watson wrote: > Sorry. Experiencing same problem in Python 2.6.4 on Ubuntu 10.04 > (actually, Puppy Linux 5.2.8 which is based on Ubuntu Lucid) > > If anyone happens to see this and knows what was settled on as the best > workaround, please email me a li

Re: webbrowser module bug?

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 1:24 AM, Steven D'Aprano wrote: > On Fri, 31 Jan 2014 06:07:39 -0500, Robert Watson wrote: > >> Sorry. Experiencing same problem in Python 2.6.4 on Ubuntu 10.04 >> (actually, Puppy Linux 5.2.8 which is based on Ubuntu Lucid) >> >> If anyone happens to see this and knows what

Re: how to iterate all sub-element in a list

2014-01-31 Thread Mark Lawrence
On 31/01/2014 10:42, seasp...@gmail.com wrote: Skip Montanaro於 2014年1月31日星期五UTC+8下午6時29分27秒寫道: Google for "python flatten list." This question comes up frequently, though I'm not sure if that's because it's a common homework problem or because people are unaware of the += operator (or exten

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Mark Lawrence
On 31/01/2014 10:17, wxjmfa...@gmail.com wrote: Is the double line spacing that you still use despite being asked not to ASCII or unicode? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mail

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

2014-01-31 Thread Roy Smith
In article <1a7a822f-569b-4ead-9421-f1dcc5d46...@googlegroups.com>, britt.jonatha...@gmail.com wrote: > I have been assigned by an internship with my university's athletic > department, to create a statistics website to be used by sports media during > games. What this means is that the statist

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Roy Smith
In article <52eb287c$0$29972$c3e8da3$54964...@news.astraweb.com>, 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:

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Roy Smith
In article , Mark Lawrence wrote: > On 31/01/2014 10:17, wxjmfa...@gmail.com wrote: > > Is the double line spacing that you still use despite being asked not to > ASCII or unicode? It's not actually double line spacing. It's single spaced using UNICODE DOUBLE COMBINING LINEFEED WITH QUOTE M

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Robert Kern
On 2014-01-31 15:04, Roy Smith wrote: In article , Mark Lawrence wrote: On 31/01/2014 10:17, wxjmfa...@gmail.com wrote: Is the double line spacing that you still use despite being asked not to ASCII or unicode? It's not actually double line spacing. It's single spaced using UNICODE DOUBL

Re: Why this throws an UnboundLocalError ?

2014-01-31 Thread Skip Montanaro
> That might be an indication of good code design :) Or he got lucky and all his previous globals were mutable. :) Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Python (windows)packet sniffer ARP

2014-01-31 Thread Mark Betz
On Friday, January 31, 2014 2:10:28 AM UTC-5, Ralle wrote: > Hello > > > > I am wondering if it possible to create a packet sniffer in windows using > python that only sniffs for ARP packets. A couple of links to get you started: http://www.winpcap.org/ http://code.google.com/p/winpcapy/ --

RE: Python (windows)packet sniffer ARP

2014-01-31 Thread Frank Cui
> Date: Fri, 31 Jan 2014 07:32:42 -0800 > Subject: Re: Python (windows)packet sniffer ARP > From: betz.m...@gmail.com > To: python-list@python.org > > On Friday, January 31, 2014 2:10:28 AM UTC-5, Ralle wrote: > > Hello > > > > > > > > I am wondering if it possible to create a packet sniffer

Re: Python (windows)packet sniffer ARP

2014-01-31 Thread ElChino
"Mark Betz" wrote: I am wondering if it possible to create a packet sniffer in windows using python that only sniffs for ARP packets. A couple of links to get you started: The OP could use Impacket's libpcap bindings. With one of the examples, it's easy: python examples/sniff.py ether pro

Re: how to iterate all sub-element in a list

2014-01-31 Thread seaspeak
Mark Lawrence於 2014年1月31日星期五UTC+8下午10時48分46秒寫道: > I'm pleased to see that you have answers. In return would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing above, thanks. > My fellow Pythonistas, ask not what our lang

Python shell wont open idle or an exisiting py file

2014-01-31 Thread rpucci2
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import idlelib.idle Exception in Tkinter callback Traceback (most recent call last): File "C:\Python33\lib\tkinter\__init__.py", lin

New facts about the pyramids: a new miracle of the Qur'an

2014-01-31 Thread BV BV
New facts about the pyramids: a new miracle of the Qur'an Last scientific discovery stated the following: French and U.S. researchers assert that the huge stones used by the Pharaohs to build the pyramids are just clay that has been heated at high temperatures... http://www.kaheel7.com/ar/ima

__init__ is the initialiser

2014-01-31 Thread Mark Lawrence
From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the class constructor expression. If a base class has an __init__() method, the derived class’s __init__() method, if any, must explici

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Peter Otten
rpuc...@cox.net wrote: > Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 > bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more > information. import idlelib.idle > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Py

Re: __init__ is the initialiser

2014-01-31 Thread Ned Batchelder
On 1/31/14 2:33 PM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the class constructor expression. If a base class has an __init__() method, the derived class’s

Re: __init__ is the initialiser

2014-01-31 Thread Mark Lawrence
On 31/01/2014 19:52, Ned Batchelder wrote: On 1/31/14 2:33 PM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the class constructor expression. If a base class h

Re: __init__ is the initialiser

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 7:17 AM, Mark Lawrence wrote: > To clarify the situation I think we should call __new__ "the thing that > instanciates an instance of a class" and __init__ "the thing that isn't > actually needed as you can add attributes to an instance anywhere in your > code" :) With a ty

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 11:33 AM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the class constructor expression. If a base class has an __init__() method, the derived c

Re: __init__ is the initialiser

2014-01-31 Thread MRAB
On 2014-01-31 19:52, Ned Batchelder wrote: On 1/31/14 2:33 PM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the class constructor expression. If a base class h

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 11:52 AM, Ned Batchelder wrote: On 1/31/14 2:33 PM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the class constructor expression. If a base clas

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 12:48 PM, MRAB wrote: On 2014-01-31 19:52, Ned Batchelder wrote: Why can't we call __init__ the constructor and __new__ the allocator? The advantage of calling it the "initialiser" is that it explains why it's called "__init__". Hm, yes, good point. Also, __init__ initializes

scipy error invalid path

2014-01-31 Thread e-letter
Readers, Used the community edition service of activepython web site to install python27. Within the 'bin' directory, received the following error: $ ./easy_install-2.7 scipy Searching for scipy Reading https://pypi.python.org/simple/scipy/ Best match: scipy 0.13.2 Downloading https://pypi.pytho

Re: __init__ is the initialiser

2014-01-31 Thread Ned Batchelder
On 1/31/14 3:57 PM, Ethan Furman wrote: On 01/31/2014 12:48 PM, MRAB wrote: On 2014-01-31 19:52, Ned Batchelder wrote: Why can't we call __init__ the constructor and __new__ the allocator? The advantage of calling it the "initialiser" is that it explains why it's called "__init__". Hm, yes

Re: scipy error invalid path

2014-01-31 Thread Mark Lawrence
On 31/01/2014 18:33, e-letter wrote: Readers, Used the community edition service of activepython web site to install python27. Within the 'bin' directory, received the following error: $ ./easy_install-2.7 scipy Searching for scipy Reading https://pypi.python.org/simple/scipy/ Best match: scipy

Re: __init__ is the initialiser

2014-01-31 Thread Cameron Simpson
On 31Jan2014 12:57, Ethan Furman wrote: > On 01/31/2014 12:48 PM, MRAB wrote: > >On 2014-01-31 19:52, Ned Batchelder wrote: > >>Why can't we call __init__ the constructor and __new__ the allocator? > > > >The advantage of calling it the "initialiser" is that it explains why > >it's called "__init_

Re: __init__ is the initialiser

2014-01-31 Thread Ben Finney
Ned Batchelder writes: > On 1/31/14 2:33 PM, Mark Lawrence wrote: > > From http://docs.python.org/3/reference/datamodel.html#object.__init__ > > […] > > Should the wording of the above be changed to clearly reflect that > > we have an initialiser here and that __new__ is the constructor? > > I'm

Re: __init__ is the initialiser

2014-01-31 Thread Cameron Simpson
On 01Feb2014 10:05, Ben Finney wrote: > Ned Batchelder writes: > > Why can't we call __init__ the constructor and __new__ the allocator? > > Because those terms already have meanings, and “__new__” fits the > meaning of “constructor” better. +1 on not giving new conflicting meanings to terms al

Re: __init__ is the initialiser

2014-01-31 Thread Ned Batchelder
On 1/31/14 6:05 PM, Ben Finney wrote: Ned Batchelder writes: On 1/31/14 2:33 PM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ […] Should the wording of the above be changed to clearly reflect that we have an initialiser here and that __new__ is

Re: __init__ is the initialiser

2014-01-31 Thread Ben Finney
Cameron Simpson writes: > > On 01/31/2014 12:48 PM, MRAB wrote: > > >The advantage of calling it the "initialiser" is that it explains > > >why it's called "__init__". > > On this basis, would it suffice to change the opening sentence from: > Called when the instance is created. > > to > Call

Re: __init__ is the initialiser

2014-01-31 Thread Ben Finney
Ned Batchelder writes: > On 1/31/14 6:05 PM, Ben Finney wrote: > > Here we disagree. I think the meaning “… and that returns the new > > instance” is entailed in the meaning of “constructor”. > > […] > > You say these terms already have meanings, and that constructor means > a function that retur

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 03:43 PM, Ned Batchelder wrote: On 1/31/14 6:05 PM, Ben Finney wrote: Ned Batchelder writes: I'm not hoping to change any official terminology. I just think that calling __init__ anything other than a constructor is confusing pedantry. It is a constructor, and Python constructo

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 03:47 PM, Ben Finney wrote: I would prefer it to be clear that “__init__” is called automatically, *during* the constructor's operation. So, instead of: Called when the instance is created. I suggest: Called automatically by the constructor “__new__” during instance

Re: __init__ is the initialiser

2014-01-31 Thread Mark Lawrence
On 01/02/2014 00:13, Ethan Furman wrote: On 01/31/2014 03:43 PM, Ned Batchelder wrote: On 1/31/14 6:05 PM, Ben Finney wrote: Ned Batchelder writes: I'm not hoping to change any official terminology. I just think that calling __init__ anything other than a constructor is confusing pedantry. I

Re: Help with some python homework...

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 11:42 AM, Scott W Dunning wrote: > Also, any help on how to get the hours and seconds into double digits that > would be cool too. 00:00:00 Once you can divide the number of seconds into hours, minutes, and seconds, you can format them like this: time = "%02d:%02d:%02d"

Re: __init__ is the initialiser

2014-01-31 Thread Roy Smith
In article , Ethan Furman wrote: > I found calling __init__ the constructor very confusing. I've heard many people say this, and it's always sort of befuddled me. In C++, a constructor is really an initializer too. By the time C++'s Foo::Foo() or Python's Foo.__init__() get called, memory ha

Re: Help with some python homework...

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 12:14 PM, Scott W Dunning wrote: > Thanks Chris! > > Also, before I forget what is the difference between / and //? I remember > something about floor division? In Python 2, the / operator by default is "floor division". 5 divided by 2 is 2. When you divide two integers,

Re: __init__ is the initialiser

2014-01-31 Thread MRAB
On 2014-02-01 01:10, Roy Smith wrote: In article , Ethan Furman wrote: I found calling __init__ the constructor very confusing. I've heard many people say this, and it's always sort of befuddled me. In C++, a constructor is really an initializer too. By the time C++'s Foo::Foo() or Pytho

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Terry Reedy
On 1/31/2014 2:51 PM, Peter Otten wrote: rpuc...@cox.net wrote: Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. import idlelib.idle Exception in Tkinter callback Traceback (most rec

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 12:45 PM, Terry Reedy wrote: > H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py > caused this message > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: > invalid start byte So... something's interpreting \0 as codepoint U+ (which it shou

Re: __init__ is the initialiser

2014-01-31 Thread Roy Smith
In article , MRAB wrote: > You could argue that construction is not complete until the instance > has been initialised. In the case of C++, all you have is the > initialiser, so doesn't really matter, but Python has __new__ and > __init__, so it _does_ matter. C++ has operator new (which you ca

Re: __init__ is the initialiser

2014-01-31 Thread Ben Finney
Ethan Furman writes: > On 01/31/2014 03:47 PM, Ben Finney wrote: > > I suggest: > > > > Called automatically by the constructor “__new__” during > > instance creation, to initialise the new instance. > > But __new__ does not call __init__, type does [1]. My apologies, you're right and

Re: __init__ is the initialiser

2014-01-31 Thread Ben Finney
Ben Finney writes: > My apologies, you're right and that's made clear at > . And that's a URL to my local filesystem. Clearly it's time for me to step away from the discussion for a while :-) -- \ “I went to the cinema, it said ‘Adults: $5.00, Children $2.50’. | `\ So I said ‘

Re: __init__ is the initialiser

2014-01-31 Thread Terry Reedy
On 1/31/2014 3:41 PM, Ethan Furman wrote: On 01/31/2014 11:52 AM, Ned Batchelder wrote: On 1/31/14 2:33 PM, Mark Lawrence wrote: From http://docs.python.org/3/reference/datamodel.html#object.__init__ which states:- " Called when the instance is created. The arguments are those passed to the c

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 05:10 PM, Roy Smith wrote: In article , Ethan Furman wrote: I found calling __init__ the constructor very confusing. I've heard many people say this, and it's always sort of befuddled me. I have never learned C++, so I don't know its screwy semantics. ;) Nor Java, for tha

Re: __init__ is the initialiser

2014-01-31 Thread Ben Finney
Terry Reedy writes: > User classes lacking .__init__ usually inherit it from something other > than object. So objects are constructed by first calling .__new__ and > then passing the result to .__init__. The Python 3 doc should say so. That matches my understanding, and I agree the docs should

Re: __init__ is the initialiser

2014-01-31 Thread Terry Reedy
On 1/31/2014 7:13 PM, Ethan Furman wrote: On 01/31/2014 03:47 PM, Ben Finney wrote: I would prefer it to be clear that “__init__” is called automatically, *during* the constructor's operation. So, instead of: Called when the instance is created. I suggest: Called automatically by t

Re: Try-except-finally paradox

2014-01-31 Thread Göktuğ Kayaalp
Terry Reedy writes: I do not have any information on the topic, but I *imagine* that the when RETURN_VALUE opcode is evaluated within the context of an except block, it triggers a check for whether a corresponding finally block exists and should it exist, it is triggered, much like a callback. So

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread MRAB
On 2014-02-01 01:52, Chris Angelico wrote: On Sat, Feb 1, 2014 at 12:45 PM, Terry Reedy wrote: H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py caused this message UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: invalid start byte So... something's interpretin

Dunder [was Re: __init__ is the initialiser]

2014-01-31 Thread Steven D'Aprano
On Fri, 31 Jan 2014 20:10:46 -0500, Roy Smith wrote: > In article , > Ethan Furman wrote: > >> I found calling __init__ the constructor very confusing. > > I've heard many people say this, and it's always sort of befuddled me. > > In C++, a constructor is really an initializer too. By the ti

Re: __init__ is the initialiser

2014-01-31 Thread Ned Batchelder
On 1/31/14 9:28 PM, Terry Reedy wrote: Most classes have __init__, only very very few have __new__. *Every* class has .__new__. Mutable builtins and almost all user classes inherit .__new__ from object. Every class also has .__init__, but it is mainly inherited from object by immutable builtin

Re: Dunder [was Re: __init__ is the initialiser]

2014-01-31 Thread MRAB
On 2014-02-01 02:52, Steven D'Aprano wrote: On Fri, 31 Jan 2014 20:10:46 -0500, Roy Smith wrote: In article , Ethan Furman wrote: I found calling __init__ the constructor very confusing. I've heard many people say this, and it's always sort of befuddled me. In C++, a constructor is reall

Re: Help with some python homework...

2014-01-31 Thread Denis McMahon
On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote: > Here is the question that was asked and below that I'll paste the code I > have so far. The following is a reasonably but not highly obfuscated short solution to the problem set in python 2.7. With a bit of luck, after each lesson of your c

Re: __init__ is the initialiser

2014-01-31 Thread Terry Reedy
On 1/31/2014 7:13 PM, Ethan Furman wrote: On 01/31/2014 03:43 PM, Ned Batchelder wrote: On 1/31/14 6:05 PM, Ben Finney wrote: Ned Batchelder writes: I'm not hoping to change any official terminology. I just think that calling __init__ anything other than a constructor is confusing pedantry.

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 1:54 PM, MRAB wrote: > I think that some years ago I heard about a variation on UTF-8 > (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the > null byte can be used as the string terminator. > > I had a look on Wikipedia found this: > > http://en.wikipedia

Re: __init__ is the initialiser

2014-01-31 Thread Steven D'Aprano
On Fri, 31 Jan 2014 14:52:15 -0500, Ned Batchelder wrote: > Why can't we call __init__ the constructor and __new__ the allocator? __new__ constructs the object, and __init__ initialises it. What's wrong with calling them the constructor and initialiser? Is this such a difficult concept that the

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 07:16 PM, Terry Reedy wrote: On 1/31/2014 7:13 PM, Ethan Furman wrote: On 01/31/2014 03:43 PM, Ned Batchelder wrote: On 1/31/14 6:05 PM, Ben Finney wrote: Ned Batchelder writes: I'm not hoping to change any official terminology. I just think that calling __init__ anything other

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 06:28 PM, Terry Reedy wrote: Construct a house: Clear and grade house site. Bring in power and water. Built temporary structures. Built foundation. Built house on foundation. For most classes, __new__ stops with the foundation -- the bare object object (with the cl

Re: __init__ is the initialiser

2014-01-31 Thread Rustom Mody
Not any direct comments on this... Just some thoughts around a couple of questions 1. Declarative and Imperative Terminology 2. Is OOP declarative or imperative 1. Python is an imperative language. It does a good amount of functional stuff. Are its terms neutral? Look at sort sort -- imperativ

Re: __init__ is the initialiser

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 2:42 PM, Steven D'Aprano wrote: > I've met people who have difficulty with OOP principles, at least at > first. But once you understand the idea of objects, it isn't that hard to > understand the idea that: > > - first, the object has to be created, or constructed, or alloca

Re: __init__ is the initialiser

2014-01-31 Thread Steven D'Aprano
On Fri, 31 Jan 2014 22:16:59 -0500, Terry Reedy wrote: > Creating a painting on canvas has two similar phases. Prepare a generic > blank canvas stretched on a frame and coated with a white undercoat. > Paint a particular picture. Would you say that the second step is not > creating anything? A du

Re: __init__ is the initialiser

2014-01-31 Thread Roy Smith
In article <52ec84bc$0$29972$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Fri, 31 Jan 2014 22:16:59 -0500, Terry Reedy wrote: > > > Creating a painting on canvas has two similar phases. Prepare a generic > > blank canvas stretched on a frame and coated with a white undercoat

Re: Help with some python homework...

2014-01-31 Thread David
On 1 February 2014 12:34, Chris Angelico wrote: > On Sat, Feb 1, 2014 at 12:14 PM, Scott W Dunning wrote: > >> Also, I think I found out through a little trial and error that I had two >> different hours, mins, and sec so I had to use one uppercase and one lower >> case. Is that frowned upon?

Re: __init__ is the initialiser

2014-01-31 Thread Rustom Mody
On Saturday, February 1, 2014 10:53:08 AM UTC+5:30, Steven D'Aprano wrote: > On Fri, 31 Jan 2014 22:16:59 -0500, Terry Reedy wrote: > > Creating a painting on canvas has two similar phases. Prepare a generic > > blank canvas stretched on a frame and coated with a white undercoat. > > Paint a parti

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
So, this is what I came up with. It works, which is good but it’s a little different from a few things you guys had mentioned. For one, I got the correct time by calculating the number of time run and converting that into seconds then back out to hr:mn:sc. I didn’t calculate from midnight. T

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
You guys are awesome! I think I was over complicating things for one. Plus I was looking at some code I wrote for another problem that asked to put in the number of seconds to calculate the problem and I didn’t need some of the things I added to this problem. Anyways, you guys have given me a

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Also, can any of you reccommend sites that may have little “projects” that I could work on to help me learn python better? On Jan 31, 2014, at 1:30 AM, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing > wrote: >> sjud9227 wrote: >>> >>> Doesn't >>> assigning seconds/(

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Also, any help on how to get the hours and seconds into double digits that would be cool too. 00:00:00 On Jan 31, 2014, at 1:30 AM, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing > wrote: >> sjud9227 wrote: >>> >>> Doesn't >>> assigning seconds/(60*60) mean that calcu

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
If you’re interested in what the problem is here it is… Suppose the cover price of a book is $24.95, but bookstores get a 40% discount. Shipping costs $3 for the first copy and 75 cents for each additional copy. What is the total wholesale cost for 60 copies? On Jan 31, 2014, at 10:18 PM, Sc

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Thanks Chris! So, this is what I came up with. It works, which is good but it’s a little different from a few things you guys had mentioned. For one, I got the correct time by calculating the number of time run and converting that into seconds then back out to hr:mn:sc. I didn’t calculate

Re: Dunder [was Re: __init__ is the initialiser]

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 1:52 PM, Steven D'Aprano wrote: > "Constructor" is three syllables; "ctor" isn't readily pronounceable in > English at all, rather like Cthulhu. (I can't think of any standard > English words with a "CT" in them at all, let alone at the start of the > word). The best I can c

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Terry Reedy
On 1/31/2014 8:52 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 12:45 PM, Terry Reedy wrote: H:\HP_Documents\0PythonWork\AirplaneKinematics\accel2.py caused this message UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 14: invalid start byte So... something's interpreti

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Ok cool, thanks Denis! On Jan 31, 2014, at 8:02 PM, Denis McMahon wrote: > On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote: > >> Here is the question that was asked and below that I'll paste the code I >> have so far. > > The following is a reasonably but not highly obfuscated short solut

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Any chance you guys could help with another question I have? Below is a code to a different problem. The only thing I don’t understand is why when calculating the 'discounted price’ you have to subtract 1? Thanks again guys! price_per_book = 24.95 discount = .40 quantity = 60 discounted_pri

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Terry Reedy
On 1/31/2014 10:36 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 1:54 PM, MRAB wrote: I think that some years ago I heard about a variation on UTF-8 (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the null byte can be used as the string terminator. I had a look on Wikipe

Re: __init__ is the initialiser

2014-01-31 Thread Ethan Furman
On 01/31/2014 08:35 PM, Chris Angelico wrote: On Sat, Feb 1, 2014 at 2:42 PM, Steven D'Aprano wrote: Thus, two methods. __new__ constructs (creates, allocates) a new object; __init__ initialises it after the event. Yes, but if you think in terms of abstractions, they're both just steps in the

Re: fseek In Compressed Files

2014-01-31 Thread Ayushi Dalmia
On Thursday, January 30, 2014 9:51:28 PM UTC+5:30, Peter Otten wrote: > 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

Re: __init__ is the initialiser

2014-01-31 Thread Steven D'Aprano
On Sat, 01 Feb 2014 15:35:17 +1100, Chris Angelico wrote: > On Sat, Feb 1, 2014 at 2:42 PM, Steven D'Aprano > wrote: >> I've met people who have difficulty with OOP principles, at least at >> first. But once you understand the idea of objects, it isn't that hard >> to understand the idea that: >>

Re: fseek In Compressed Files

2014-01-31 Thread Ayushi Dalmia
On Friday, January 31, 2014 12:16:59 AM UTC+5:30, Dave Angel wrote: > 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 o

Re: Dunder [was Re: __init__ is the initialiser]

2014-01-31 Thread Steven D'Aprano
On Sat, 01 Feb 2014 15:05:34 +1100, Chris Angelico wrote: > On Sat, Feb 1, 2014 at 1:52 PM, Steven D'Aprano > wrote: >> "Constructor" is three syllables; "ctor" isn't readily pronounceable in >> English at all, rather like Cthulhu. (I can't think of any standard >> English words with a "CT" in th

Re: pytz question: GMT vs. UTC

2014-01-31 Thread Dan Sommers
On Fri, 31 Jan 2014 17:42:30 +1100, Chris Angelico wrote: > 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 th

Re: Python shell wont open idle or an exisiting py file

2014-01-31 Thread Chris Angelico
On Sat, Feb 1, 2014 at 4:46 PM, Terry Reedy wrote: > On 1/31/2014 10:36 PM, Chris Angelico wrote: >> >> On Sat, Feb 1, 2014 at 1:54 PM, MRAB wrote: >>> >>> I think that some years ago I heard about a variation on UTF-8 >>> (Microsoft?) where codepoint U+ is encoded as 0xC0 0x80 so that the >>