Re: [Tutor] Pythonic way of concatenation of elements in an array

2012-01-27 Thread Blockheads Oi Oi
On 27/01/2012 06:44, Andre' Walker-Loud wrote: Hi Steven, (5) When assembling strings from substrings, never use repeated concatenation using + as that can be EXTREMELY slow. Use str.join to build the string in one assignment, instead of multiple assignments. Your code shown above is *very*

Re: [Tutor] Pythonic way of concatenation of elements in an array

2012-01-27 Thread Alan Gauld
On 27/01/12 06:44, Andre' Walker-Loud wrote: ... I have only had one programming class, and that was 15 years ago or so, > ...so these are not issues I am aware of. I often find myself joining strings (and have mostly used + to do it). String addition is OK in some languages, or at least bet

Re: [Tutor] Question regarding setup.py

2012-01-27 Thread Evert Rol
> I had a question regarding installing packages that I posted a couple of days > ago. But I'm re-sending the question again.. this time with output so that it > is clearer. > > I am unable to install libraries using 'python setup.py install' > > Say that I'm installing a package "kando". I ext

[Tutor] compile time calculator

2012-01-27 Thread Surya K
Hi, I want to calculate compile time for my puzzles. Although I read about timeit(), I didn't really understand how it should be applied it.So, can anyone write a function for me please!! I am looking for a function which should solve my puzzle and also show compile time. (Later, I should be ab

Re: [Tutor] compile time calculator

2012-01-27 Thread Blockheads Oi Oi
On 27/01/2012 15:46, Surya K wrote: Hi, I want to calculate compile time for my puzzles. Although I read about timeit(), I didn't really understand how it should be applied it. So, can anyone write a function for me please!! I am looking for a function which should solve my puzzle and also show

Re: [Tutor] compile time calculator

2012-01-27 Thread Alan Gauld
On 27/01/12 15:46, Surya K wrote: I want to calculate compile time for my puzzles. I'm pretty sure from what follows you don't! But just to be clear, compile time is the time Python spends converting your modules into .pyc files the first time they are imported after a change. Why you would

Re: [Tutor] Socket Programming

2012-01-27 Thread Navneet
On 1/26/2012 4:22 PM, Navneet wrote: Hi, I am trying to create a chat program.(Programs are attached) Please find the code below, where I am having the problem. def run( self ): while 1: print "Hello There " print self.descriptors # Await an event on a readab

Re: [Tutor] compile time calculator

2012-01-27 Thread Steven D'Aprano
Surya K wrote: can anyone write a program for me? please... Certainly. My rate is AUD$80 per hour. Please write to me privately to discuss financial arrangements. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscr

Re: [Tutor] Socket Programming

2012-01-27 Thread Steven D'Aprano
Navneet wrote: One more thing I want to add here is, I am trying to create the GUI based chat server.(Attached the programs.) Please do not send large chunks of code like this, unless asked. Instead, you should try to produce a minimal example that demonstrates the problem. It should be:

[Tutor] ignoring certain lines while reading through CSV

2012-01-27 Thread Abhishek Pratap
Hi Guys I am wondering if there is a keyword to ignore certain lines ( for eg lines starting with # ) when I am reading them through stl module csv. Example code: input_file = sys.argv[1] csv.register_dialect('multiplex_info',delimiter=' ') with open(input_file, 'rb') as fh: reader= csv.rea

Re: [Tutor] ignoring certain lines while reading through CSV

2012-01-27 Thread Joel Goldstick
On Fri, Jan 27, 2012 at 5:13 PM, Abhishek Pratap wrote: > Hi Guys > > I am wondering if there is a keyword to ignore certain lines ( for eg > lines starting with # ) when I am reading them through stl module csv. > > Example code: > > input_file = sys.argv[1] > csv.register_dialect('multiplex_info

Re: [Tutor] ignoring certain lines while reading through CSV

2012-01-27 Thread Abhishek Pratap
Hi Joel Here is a sample ['1', 'AAA', '4344', '0.001505'] : want to keep this one ['#', 'AAA', '4344', '0.001505'] : and throw this one You are right I am checking after parsing. I dint find an option in csv.reader to ignore lines. -Abhi On Fri, Jan 27, 2012 at 2:42 PM, Joel Gold

Re: [Tutor] ignoring certain lines while reading through CSV

2012-01-27 Thread Joel Goldstick
On Fri, Jan 27, 2012 at 5:48 PM, Abhishek Pratap wrote: > Hi Joel > > Here is a sample > > ['1', 'AAA', '4344', '0.001505'] : want to keep this one > > ['#', 'AAA', '4344', '0.001505'] : and throw this one Ok, so you are getting single quotes around your data. So do row[0].startswith("#"

Re: [Tutor] ignoring certain lines while reading through CSV

2012-01-27 Thread Abhishek Pratap
Thansk Joel. Thats exactly what I am doing. -A On Fri, Jan 27, 2012 at 3:04 PM, Joel Goldstick wrote: > On Fri, Jan 27, 2012 at 5:48 PM, Abhishek Pratap > wrote: >> Hi Joel >> >> Here is a sample >> >> ['1', 'AAA', '4344', '0.001505'] : want to keep this one >> >> ['#', 'AAA', '4344',

Re: [Tutor] compile time calculator

2012-01-27 Thread Marc Tompkins
On Fri, Jan 27, 2012 at 7:46 AM, Surya K wrote: > Hi, > > I want to calculate compile time for my puzzles. > Since nobody else has mentioned it yet... http://xkcd.com/303/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

[Tutor] Rounding Error

2012-01-27 Thread Michael Lewis
I am trying to round a float to two decimals, but I am getting the following error: Traceback (most recent call last): File "", line 1, in PaintingProject() File "C:/Python27/Homework/Labs/Lab 03_5.py", line 42, in PaintingProject print 'That will cost you $%f.' %(round(5.6523),2) Typ

Re: [Tutor] Rounding Error

2012-01-27 Thread Michael Lewis
Update I am trying to round a float to two decimals. > > Basically, I am writing a program to ask a user how many square feet they > need to paint. I then calculate how many cans of paint they need and will > also show the total purchase price. I've tried this two ways, and both ways > I am semi-s

Re: [Tutor] Rounding Error

2012-01-27 Thread Steven D'Aprano
Michael Lewis wrote: I am trying to round a float to two decimals, but I am getting the following error: Traceback (most recent call last): File "", line 1, in PaintingProject() File "C:/Python27/Homework/Labs/Lab 03_5.py", line 42, in PaintingProject print 'That will cost you $%f.'

Re: [Tutor] Rounding Error

2012-01-27 Thread Devin Jeanpierre
On Sat, Jan 28, 2012 at 1:20 AM, Steven D'Aprano wrote: > And finally, we come all the way back to the beginning again and say That's > not the right way to do it! Don't round the number *outside* of the string > formatting, get the string formatting to do it for you: Reason being because repr(ro