On 3/16/11, 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?
>
> import time
> def testtime(num):
> start=time.time()
> #pr
On Wed, Mar 16, 2011 at 9:40 PM, 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?
>
> import time
> def testtime(num):
> start=
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? I have
found lots of recipes out there to do these, but have not yet found a canned
l
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?
import time
def testtime(num):
start=time.time()
#print start
for n in range(num):
#print
"Shane O'Connor" wrote
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
It is impossible to tell and 99% of the time irrelevant si
On 03/16/2011 08:32 PM, 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
On Wed, Mar 16, 2011 at 7:32 PM, 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
>
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
In my mind, the while loop should
"Donald Bedsole" wrote
False or thing = thing
Thanks for your response and for the rules, but for some reason I'm
not understanding. In the above quote, what is meant by "thing"?
Any Boolean value, and in Python that means pretty much
anything at all because Python has a set of rules ove
"Donald Bedsole" wrote
The first argument was "True", so "True" was returned and negated by
the "not" with a final result of "False" for the expression.
Is this correct?
Yes. Its called Short Circuit Evaluation.
You will find an explanation on the Functional Programming topic
of my tutor
HT
Hi Jack,
On Wed, Mar 16, 2011 at 1:55 AM, Jack Trades wrote:
'and' evaluates one argument at a time and returns immediately if the
argument is False.
>
And "or" works in the inverse manner? It "evaluates one argument at
a time and returns immediately if the argument is [True]." ?
For examp
On Wed, Mar 16, 2011 at 5:53 PM, bob gailer wrote:
>
> Thing in this context means 'anything". could be a string, number, list, any
> Python object.
>
Ok, thanks Bob.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options
On 3/16/2011 4:26 PM, Donald Bedsole wrote:
Hi Allen,
Boolean algebra can be a weird thing to get your head around
the first time you come across it :-)
Yes, :-)
Here are some of the standard rules:
True and thing = thing
False and thing = False
True or thing = True
False or thing = thing
Hi Allen,
> Boolean algebra can be a weird thing to get your head around
> the first time you come across it :-)
Yes, :-)
> Here are some of the standard rules:
>
> True and thing = thing
> False and thing = False
> True or thing = True
> False or thing = thing
>
Thanks for your response and fo
Hi,
I'm still working on a program that uses a .dll to read SPSS system files.
It's getting somewhere already, but I'm still struggling with one thing.
When using the C function spssGetVarNames I'm having trouble
translating C arrays to Python lists. I want to translate an
array that holds the
hi,
While I was trying to learn python by doing it. I created a really
primitive app, called best buy. You can find it here:
http://ug.bcc.bilkent.edu.tr/~y_arabaci/best_buy.tar.gz
Here is what this code suppossed to do:
*You add products with its name, price and rating:
Note : Rating defin
Thank you for your help!
Once I read your comments I tried both corrections in my code, but none of
them we're sucessful.
Tim's idea kept the quotes at the moment I open the csv in Excel, quotues
appeared at the beggining and the end of the row for Excel.
Joel's idea wrote just tha variable name '
* Steven D'Aprano [110316 05:26]:
> Tim Johnson wrote:
> > What is the difference between using
> > hasattr(object, name)
> > and
> > name in dir(object)
> > ?
>
> Did you read the Fine Manual?
No but I will :)
> http://docs.python.org/library/functions.html#dir
>
> "The default dir() mechanis
For all of these, I wrote my own class with methods to create the correct
output. there is not built in python functionality that I know, although
there may be a package.
For IRR, the method expects a list and at least one negative value. I
believe the way I did NPV was a dictionary, where the key
Tom Zych wrote:
I suppose there must be some reliable way to get a list of *all* an
object's attributes, but I don't see it.
Nope, there isn't, because Python allows classes to define arbitrary
attributes at runtime.
>>> import random
>>> class Funny:
... def __getattr__(self, name):
.
On 03/16/2011 09:15 AM, bhavanasi sarath wrote:
i want to learn how to compress a folder which is having some text
filesbut compress that from another directory..
http://docs.python.org/library/zipfile.html
(Sorry for the HTML email, getting things set up on new workstation)
_
bhavanasi sarath wrote:
i want to learn how to compress a folder which is having some text
filesbut compress that from another directory..
http://docs.python.org/library/archiving.html
Let us know if this doesn't help.
--
Steven
___
Tutor mail
On Thu, 17 Mar 2011 00:12 +1100, "Steven D'Aprano"
wrote:
> And here's an example:
>
> >>> class C(object):
> ... pass
> ...
> >>> hasattr(C, '__eq__')
> True
> >>> '__eq__' in dir(C)
> False
OTOH, I got True in 3.1.1. As the docs say, detailed behavior may change
across releases.
I supp
Wayne Werner wrote:
However, rare is the occasion that you should use either of these. If you're
doing something like:
if hasattr(myobj, 'something'):
myobj.something()
else:
print "blah blah blah"
then what you really should be doing is:
try:
myobj.something()
except AttributeErro
i want to learn how to compress a folder which is having some text
filesbut compress that from another directory..
--
$$$ Bhavanasi $$$
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org
Tim Johnson wrote:
What is the difference between using
hasattr(object, name)
and
name in dir(object)
?
Did you read the Fine Manual?
http://docs.python.org/library/functions.html#dir
"The default dir() mechanism behaves differently with different types of
objects, as it attempts to pro
"Donald Bedsole" wrote
most part. But, could someone make sure I'm understanding this one
expression correctly?
not (False and True)
Python evaluates it as "True"
Is it because:
1)You evaluate what's in the parentheses first. A thing can not be
false and true at the same time, so the answ
"Ryan McAdam" wrote
I saved this module to my desktop
You probably need to create a Folder for your Python
code or you will soon have a very busy desktop! :-)
# File: chaos.py
# A simple program illustrating chaotic behavior.
def main():
print("This program illustrates a chaotic func
28 matches
Mail list logo