tee chwee liong wrote:
hi,
i would like to know the time taken to execute a certain task in python. i used time.time and time.clock and i see the time taken is different? what is the right method to use?
Neither, or either. For timing small code snippets, the right tool is
the timeit module
Shane O'Connor wrote:
Hi,
First-time poster here. I've a question about loop efficiency - I was
wondering whether this code:
i = 0
while i < 1000:
do something
i+=1
is more efficient than:
for i in range(1000):
do something
or:
for i in xrange(1000):
do something
You can
> Only really glanced at this, but you seem to be checking only the last
>> thread *after* the loop? Surely you should be storing all the threads in a
>> list (or someplace) as you create them, and then check them all for liveness
>> and if so join them each in turn, to ensure you only print 'FINI
>
> Only really glanced at this, but you seem to be checking only the last
> thread *after* the loop? Surely you should be storing all the threads in a
> list (or someplace) as you create them, and then check them all for liveness
> and if so join them each in turn, to ensure you only print 'FINIS
Hi tutors!
I'm not a hard-core programmer but have used Python in systems
administration (it makes sense to me to use a scripting language which
supports both Windows and Unix).
The code below is an excerpt from a module I have written to collect
information about hosts on my network and populate
On 3/17/2011 1:19 PM, Jeff Goodwin wrote:
I'm trying to run the below program and get it to print out feedback
as the loop goes. However, if you enter a number too high or too low,
it skips the print statement under the if and elif clauses and asks
the user to "Guess a number between 1-100" aga
On Thu, Mar 17, 2011 at 1:19 PM, Jeff Goodwin wrote:
> I'm trying to run the below program and get it to print out feedback as the
> loop goes. However, if you enter a number too high or too low, it skips the
> print statement under the if and elif clauses and asks the user to "Guess a
> number be
Hi Jeff how are you today?
Well about your question... I copy and pasted your code and it worked fine for
me. Well except for in the code bit you posted you forgot to give a guess a
value before it was referred to. So under number = 44 I just wrote guess = 0
and
it worked fine.
But perhaps
I'm trying to run the below program and get it to print out feedback as the
loop goes. However, if you enter a number too high or too low, it skips the
print statement under the if and elif clauses and asks the user to "Guess a
number between 1-100" again. Any suggestions on how to get it to print
Alan,
Ah ha, ungetch(), that is what I was needing. I had be trying to simulate
kbhit() with getch() and keep being left with unhandled data in the buffer.
I had resorted to a trash=raw_input() to clear it.
Many thanks,
Bill
On Thu, Mar 17, 2011 at 04:01, Alan Gauld wrote:
>
> "Bill All
The counter is there so that it limits the iteration to only the first rows,
i actually left it there because i used it earlier to print out specific
rows.
On Thu, Mar 17, 2011 at 2:04 PM, Joel Goldstick wrote:
>
>
> On Thu, Mar 17, 2011 at 8:53 AM, Dipo Elegbede wrote:
>
>>
>> Thanks Tim, that w
On Thu, Mar 17, 2011 at 8:53 AM, Dipo Elegbede wrote:
>
> Thanks Tim, that worked like magic.
>
> I now have another challenge on the same file, in this case, i am trying to
> extract just a column as PARTY, I successfully wrote the header but instead
> of having each element in a single excel blo
Thanks Tim, that worked like magic.
I now have another challenge on the same file, in this case, i am trying to
extract just a column as PARTY, I successfully wrote the header but instead
of having each element in a single excel block like this:
A
ACD
ACN
ACPN
AD
ADC
ALP
ANPP
APGA
APS
ARP
BNPP
CA
On 17/03/2011 11:56, Dipo Elegbede wrote:
i wrote a code for extracting information from a csv file into another
csv file.
it worked well but i have an immediate challenge i can't seem to fix.
the new file that is created has an row and then an empty row and then a
row all through the file. how c
i wrote a code for extracting information from a csv file into another csv
file.
it worked well but i have an immediate challenge i can't seem to fix.
the new file that is created has an row and then an empty row and then a row
all through the file. how can i make the empty rows not be part of the
Profiling is really intended to profile a complex set of operations
not a single statement, for that timeit() would be a better choice.
However in this case, it may be that the time is so low it simply
doesn't register. Have you already imported math for example?
In which case you are effective
On 16/03/2011 17:12, Susana Iraiis Delgado Rodriguez wrote:
Thank you for your help!
Once I read your comments I tried both corrections in my code, but none
of them we're sucessful.
Ok, Susana, your problem (here) is the use of the csv module
so can I suggest we back away from your wider progr
hi,
i used profiler. but it gives 0 sec? is this expected? tq
>>> profile.run('import math')
3 function calls in 0.000 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
10.0000.0000.0000.000 :0(set
"Bill Allen" wrote
I have found that for the Windows build of Python the msvcrt library
provides getch() and kbhit() functions. Is there a library
available for
the Linux Python build that provides the same or similar functions?
curses.
Take a look at the event handling topic in my tuto
"tee chwee liong" wrote
i would like to know the time taken to execute a
certain task in python. i used time.time and time.clock
and i see the time taken is different?
what is the right method to use?
Neither of those, either use timeit() or the Python profiler.
They are both specifically
On Thu, Mar 17, 2011 at 8:45 AM, Stefan Behnel wrote:
> Note that a web application involves many things outside of your own code
> that seriously impact the performance and/or resource requirements. Database
> access can be slow, excessively dynamic page generation and template engines
> can bec
Shane O'Connor, 17.03.2011 01:32:
In particular, I'm using Python 2.4.3 on a web server which needs to run as
fast as possible using as little memory as possible (no surprises there!).
Note that a web application involves many things outside of your own code
that seriously impact the performan
22 matches
Mail list logo