Re: Python Interview Questions

2012-11-18 Thread Steven D'Aprano
On Sun, 18 Nov 2012 21:09:36 -0500, Roy Smith wrote: > In article <50a97de0$0$29983$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > > >> > The stack that's returned is a list. It's inherently a list, per the >> > classic definition: >> >> Er, no, it's inherently a blob of mul

Re: Python Interview Questions

2012-11-18 Thread Ian Kelly
On Sun, Nov 18, 2012 at 7:42 PM, Mark Lawrence wrote: > To throw a chiseldriver into the works, IIRC a tuple is way faster to create > but accessing a list is much faster. The obvious snag is that may have been > Python 2.7 whereas 3.3 is completely different. Sorry but I'm currently > wearing m

Re: Question on Socket Timeouts

2012-11-18 Thread Cameron Simpson
On 19Nov2012 14:40, I wrote: | Not the time you set up the socket, or when you accept the client's | connection. Thereafter, ever time you get some data, look at the clock. | If enough time has elapsed, close the socket yourself. That would be "Note", not "Not". Sorry. -- Cameron Simpson No key

Yet another Python textbook

2012-11-18 Thread Pavel Solin
I would like to introduce a new Python textbook aimed at high school students: http://femhub.com/textbook-python/. The textbook is open source and its public Git repository is located at Github: g...@github.com:femhub/nclab-textbook-python.git Feedback and contributions are very much welcome, e

Re: Question on Socket Timeouts

2012-11-18 Thread Abhijeet Mahagaonkar
I also tried looking at SO_RCVTIMEO option. Turns out that also resets if data is received. And yeah I implemented that as a separate logic in my code. I was wondering if sockets natively provided this functionality. Thanks again for clarifying. Cheers, Abhijeet On Mon, Nov 19, 2012 at 12:40 A

Re: Question on Socket Timeouts

2012-11-18 Thread Cameron Simpson
On 18Nov2012 03:27, Abhijeet Mahagaonkar wrote: | I'm new to network programming. | I have a question. | | Can we set a timeout to limit how long a particular socket can read or | write? On the socket itself? Probably not. But... | I have used a settimeout() function. | The settimeout() works f

Getting a seeded value from a list

2012-11-18 Thread Graham Fielding
Hello! Clueless noob again! :) This time around, I'm trying to figure out the random.seed() function -- specifically, I'd like to retrieve the seeded values from a list (which I've called levelSeed), and use them in a random-dungeon generator. The numbers are generating and storing properl

Re: Python Interview Questions

2012-11-18 Thread Mark Lawrence
On 19/11/2012 02:09, Roy Smith wrote: The theorist understands that a chisel and a screwdriver were intended for different purposes, but the pragmatist gets the paint can open. To throw a chiseldriver into the works, IIRC a tuple is way faster to create but accessing a list is much faster.

Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-18 Thread Gene Heskett
On Sunday 18 November 2012 21:18:16 Robert Miles did opine: > On Sunday, November 18, 2012 1:35:00 PM UTC-6, Terry Reedy wrote: > > The question was raised as to how much spam comes from googlegroups. > > > > Not all, but more that half, I believe. This one does. > > > > > > > > From: MoneyMak

Re: Problems on these two questions

2012-11-18 Thread Dave Angel
On 11/18/2012 09:15 PM, su29090 wrote: > > I'm using Python 3.2 In Python 3.2, xrange has been renamed to range. So have you tried to solve problem #2 yet? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems on these two questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 12:52 PM, su29090 <129k...@gmail.com> wrote: > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > evenly.) > > 2.An arithmetic progression is a sequence of numbers in

Re: Problems on these two questions

2012-11-18 Thread su29090
On Sunday, November 18, 2012 8:52:35 PM UTC-5, su29090 wrote: > I did all of the other problems but I have issues with these: > > > > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > eve

Re: Problems on these two questions

2012-11-18 Thread Dave Angel
On 11/18/2012 08:52 PM, su29090 wrote: > I all of the other problems but I have issues with these: > > 1.Given a positive integer n , assign True to is_prime if n has no factors > other than 1 and itself. (Remember, m is a factor of n if m divides n > evenly.) if is_a_prime(n): is_p

Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-18 Thread Mark Lawrence
On 18/11/2012 19:31, Terry Reedy wrote: The question was raised as to how much spam comes from googlegroups. I don't know the answer but I take the greatest pleasure in hurtling onto the dread googlegroups and gmane to report spam. Thankfully it's easy as the amount I receive via gmane is ef

Re: Python Interview Questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 1:09 PM, Roy Smith wrote: > The theorist understands that a chisel and a screwdriver were intended > for different purposes, but the pragmatist gets the paint can open. A good tool can always be used in ways its inventor never intended - and it will function as its user ex

Re: Python Interview Questions

2012-11-18 Thread Roy Smith
In article <50a97de0$0$29983$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > The stack that's returned is a list. It's inherently a list, per the > > classic definition: > > Er, no, it's inherently a blob of multiple text lines. No, it's a list that looks like (taken from the

Re: Problems on these two questions

2012-11-18 Thread Mark Lawrence
On 19/11/2012 01:52, su29090 wrote: I all of the other problems but I have issues with these: 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) 2.An arithmetic progression is a se

Re: Unpaking Tuple

2012-11-18 Thread Hans Mulder
On 9/10/12 08:07:32, Bob Martin wrote: > in 682592 20121008 232126 "Prasad, Ramit" wrote: >> Thomas Bach wrote:=0D=0A> Hi there,=0D=0A> =0D=0A> On Sat, Oct 06, 2012 at = >> 03:08:38PM +, Steven D'Aprano wrote:=0D=0A> >=0D=0A> > my_tuple =3D my_= >> tuple[:4]=0D=0A> > a,b,c,d =3D my_tuple if le

Problems on these two questions

2012-11-18 Thread su29090
I all of the other problems but I have issues with these: 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) 2.An arithmetic progression is a sequence of numbers in which the distan

Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-18 Thread Robert Miles
On Sunday, November 18, 2012 1:35:00 PM UTC-6, Terry Reedy wrote: > The question was raised as to how much spam comes from googlegroups. > > Not all, but more that half, I believe. This one does. > > > > From: MoneyMaker > > ... > > Message-ID: <2d2a0b98-c587-4459-9489-680b1ddc4...@googlegro

Re: Unpaking Tuple

2012-11-18 Thread Robert Miles
On 10/9/2012 1:07 AM, Bob Martin wrote: in 682592 20121008 232126 "Prasad, Ramit" wrote: Thomas Bach wrote:=0D=0A> Hi there,=0D=0A> =0D=0A> On Sat, Oct 06, 2012 at = 03:08:38PM +, Steven D'Aprano wrote:=0D=0A> >=0D=0A> > my_tuple =3D my_= tuple[:4]=0D=0A> > a,b,c,d =3D my_tuple if len(my_tu

Re: Python Interview Questions

2012-11-18 Thread Steven D'Aprano
On Sun, 18 Nov 2012 12:53:50 -0500, Roy Smith wrote: > I've got a script which trolls our log files looking for python stack > dumps. For each dump it finds, it computes a signature (basically, a > call sequence which led to the exception) and uses this signature as a > dictionary key. Here's th

Testers please for CodeInvestigator

2012-11-18 Thread martien . friedeman
I have released version 3 of CodeInvestigator. It is a web-application that allows you to visualize the flow of data through your program. It is intended as a way to easily learn about how your program does its thing. Softoxi has done a review of the previous version: http://www.softoxi.com/code

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-18 Thread jkn
Hi Hans [...] > > > However, once he does that, it's simpler to cut out xargs and invoke > > "sh" directly. Or even cut out "sh" and "test" and instead use > > os.path.isfile and then call md5sum directly. And once he does that, > > he no longer needs to worry about single quotes. > Yes i

Re: Python Interview Questions

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 4:16 AM, D'Arcy J.M. Cain wrote: > On 18 Nov 2012 16:50:52 GMT > Steven D'Aprano wrote: >> On Sun, 18 Nov 2012 08:53:25 -0500, Roy Smith wrote: >>> > Use a list when you need an ordered collection which is mutable >> > (i.e. can be altered after being created). Use a tupl

Spam source (Re: Horror Horror Horror!!!!!)

2012-11-18 Thread Terry Reedy
The question was raised as to how much spam comes from googlegroups. Not all, but more that half, I believe. This one does. From: MoneyMaker ... Message-ID: <2d2a0b98-c587-4459-9489-680b1ddc4...@googlegroups.com> -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Point of idle curiosity

2012-11-18 Thread Terry Reedy
On 11/18/2012 6:45 AM, Chris Angelico wrote: (if you'll forgive the pun) Is IDLE named after Eric of that name, or is it pure coincidence? Officially, I believe it is I(ntegrated) D(eve)L(opement) E(nvironment). However, now that you mention it, I would not be surprised if Eric was in the bac

Re: Python Interview Questions

2012-11-18 Thread Roy Smith
In article <50a911ec$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Oh I'm sorry, did something I say suggest that the couple of examples I > gave are the *only* acceptable uses? My apologies for not giving an > exhaustive list of every possible use of lists and tuples,

Re: Python Interview Questions

2012-11-18 Thread D'Arcy J.M. Cain
On 18 Nov 2012 16:50:52 GMT Steven D'Aprano wrote: > On Sun, 18 Nov 2012 08:53:25 -0500, Roy Smith wrote: >> > Use a list when you need an ordered collection which is mutable > > (i.e. can be altered after being created). Use a tuple when you > > need an immutable list (such as for a dictionary k

Re: Python Interview Questions

2012-11-18 Thread Steven D'Aprano
On Sun, 18 Nov 2012 08:53:25 -0500, Roy Smith wrote: > In article <50a8acdc$0$29978$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Use a list when you want a list of items that should all be treated the >> same way [...] or when you need a collection of items where the order

Re: Problem with subprocess.call and windows schtasks

2012-11-18 Thread Chris Rebert
On Sun, Nov 18, 2012 at 5:48 AM, Tom Borkin wrote: > Hi, > I have this code: > > #!\Python27\python > > import subprocess > #subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program > Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'], shell=True) > subprocess.call([

Re: Problem with subprocess.call and windows schtasks

2012-11-18 Thread Tim Golden
On 18/11/2012 13:48, Tom Borkin wrote: import subprocess #subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'], shell=True) subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py" /ST 07:50'],

Re: Point of idle curiosity

2012-11-18 Thread Chris Angelico
On Mon, Nov 19, 2012 at 3:08 AM, Mark Lawrence wrote: > On 18/11/2012 15:59, Steven D'Aprano wrote: >> >> On Sun, 18 Nov 2012 22:45:43 +1100, Chris Angelico wrote: >> >>> (if you'll forgive the pun) >>> >>> Is IDLE named after Eric of that name, or is it pure coincidence? >> >> >> Well, IDLE is an

Re: Point of idle curiosity

2012-11-18 Thread Mark Lawrence
On 18/11/2012 15:59, Steven D'Aprano wrote: On Sun, 18 Nov 2012 22:45:43 +1100, Chris Angelico wrote: (if you'll forgive the pun) Is IDLE named after Eric of that name, or is it pure coincidence? Well, IDLE is an IDE. The L doesn't seem to mean anything, so it's plausible that it is named af

Re: xml data or other?

2012-11-18 Thread rusi
On Nov 18, 8:54 pm, rusi wrote: > Start with cgi.escape perhaps?http://docs.python.org/2/library/cgi.html This may be a better link for starters http://wiki.python.org/moin/EscapingHtml (Note the escaping xml at the bottom) -- http://mail.python.org/mailman/listinfo/python-list

Re: Point of idle curiosity

2012-11-18 Thread Steven D'Aprano
On Sun, 18 Nov 2012 22:45:43 +1100, Chris Angelico wrote: > (if you'll forgive the pun) > > Is IDLE named after Eric of that name, or is it pure coincidence? Well, IDLE is an IDE. The L doesn't seem to mean anything, so it's plausible that it is named after Eric Idle. -- Steven -- http://ma

Re: xml data or other?

2012-11-18 Thread rusi
On Nov 18, 6:32 pm, Artie Ziff wrote: > Unfortunately, xml parsing fails due to angle brackets inside > description tags. In particular, xml.etree.ElementTree.parse() > aborts on '<' inside xml data such as the following: > > >       >          This testcase tests if crontab installs the cronjob

Re: Python Interview Questions

2012-11-18 Thread Roy Smith
In article <50a8acdc$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Use a list when you want a list of items that should all be treated the > same way [...] or when you need a collection of items where the order they > are in is > important: > > Use a tuple when you wan

Problem with subprocess.call and windows schtasks

2012-11-18 Thread Tom Borkin
Hi, I have this code: #!\Python27\python import subprocess #subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'], shell=True) subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py" /ST 07:50']

Re: xml data or other?

2012-11-18 Thread Artie Ziff
On 11/9/12 5:50 AM, rusi wrote: On Nov 9, 5:54 pm, Artie Ziff wrote: # submit correctedinput to etree I was very grateful to get the "leg up" on getting started down that right path with my coding. Many thanks to you, rusi. I took your excellent advices and have this working. class Converte

Horror Horror Horror!!!!!

2012-11-18 Thread MoneyMaker
Welcome to the site of horror: http://horrorhorrorhorror.webs.com/ Join now free !!! Free Horror Movies!! Free Horror Games -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-11-18 Thread Steven D'Aprano
On Sat, 17 Nov 2012 10:01:01 -0800, chinjannisha wrote: > Hi I had one doubt.. I know very little bit of python .I wanted to know > when to use list,tuple,dictionary and set? Please reply me asap Use a list when you want a list of items that should all be treated the same way: list_of_numbers =

Question on Socket Timeouts

2012-11-18 Thread Abhijeet Mahagaonkar
Hi all, I'm new to network programming. I have a question. Can we set a timeout to limit how long a particular socket can read or write? I have used a settimeout() function. The settimeout() works fine as long as the client doesnt send any data for x seconds. The data that I receive in the serve