On Mon, 28 Jun 2010 06:04:31 pm Adam Bark wrote:
> I'm sure this "work it out yourself" answer is much more helpful.
Unfortunately, the only correct answer is that there is no One True
Answer.
A bit like life, really.
--
Steven D'Aprano
__
y need
it, and how to avoid needing it:
http://www.artima.com/weblogs/viewpost.jsp?thread=246341
http://www.artima.com/weblogs/viewpost.jsp?thread=246483
http://www.artima.com/forums/flat.jsp?forum=106&thread=237121
http://www.artima.com/forums/flat.jsp?forum=106&thread=246488
--
Steven
On Mon, 28 Jun 2010 10:52:03 am Richard D. Moores wrote:
> On Sun, Jun 27, 2010 at 16:25, Steven D'Aprano
wrote:
> > On Mon, 28 Jun 2010 03:07:47 am Richard D. Moores wrote:
> >> A "feature" very important to me
> >> is that with Gmail, my mail is just a
e .pyc file (byte code) and re-compile it from the .py file.
But if there is no .py file, then Python is stuck with using only the
pre-compiled .pyc file, but it needs to have been compiled for the same
version of Python. You can't have Python 2.6 run a .pyc file from 2.5
or 3.1 (say). The &quo
t;>> print(x)
1e+15
>>> str(x)
'1e+15'
If you want more control over the string conversion, you can do
something like this:
>>> print(repr(x))
1017.0
>>> print('%.5f' % x)
1017.0
--
Steven D'Aprano
__
gt; Therefore you should probably use the integer division operator: "//"
And the reminder (or modulo) operator %, together with the combination
function divmod(a, b) which returns (a//b, a%b). The advantage of
divmod is that it is faster than calling a//b followed by
;p", [1[3]])
> TypeError: 'int' object is not subscriptable
To Python, it looks like you're passing as the start argument a list
containing a single value, which is the 3rd element of the int 1. But
ints don't have elements and so can't be subscripted like 1[3], hence
the error.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
utputfile, increment)
> '''increment
> is originally supposed to be an int for the line number being read'''
This line gives a syntax error. What is it supposed to be? What is the
purpose of the string? It looks like it is meant to be a comment, but
why have you
And one last comment... your attachment (HANGMAN.py) is severely broken.
For some reason it is base-64 encoded, which shouldn't be necessary for
a plain-text file, and furthermore it doesn't decode in my mail client.
--
Steven D'Aprano
_
rouble you with my
> denseness.
s = some_string_value()
if not s:
print "Empty string"
else:
print "The string starts with", s[0]
people_with_red_hair = "Phil George Susan Samantha".split()
people_with_glasses = "Henry Felicity Michelle Mary-Anne Bi
and then work from
them. Example:
keys = mydict.keys()
keys.sort()
for key in keys:
value = mydict[key]
print "the value of key %s is %s" (key, value)
I'm sure you can adapt that example to what you're trying to do :)
--
Steven D'Aprano
_
On Fri, 9 Jul 2010 06:20:13 pm Григор wrote:
> Which module can I use to do a script for testing video card
Tell us how you want to test the video card.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subs
n for quite small sizes
of the input list. It seems to me that you're doing a lot
of unnecessary copying of lists and inserting. But don't
take that as gospel, I'd need to think about it a bit more
to be sure of that.
* However the basic approach -- to generate all th
What pops up an error dialog? The launcher?
Which file does it claim doesn't exist? Python? The Python script? The
image file? What is the exact error message it gives?
There's probably a way to tell the launcher which working directory to
use, but of course that depends on the a
"Father's and Sons": [100],
"Anna Karenina": [1, 2, 4, 7, 9],
"Where's Wally?": [],
}
Now each key is simply the title, and the value is a list of page
numbers.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
the approach I've outlined in my initial post be the
> best for sorting them?
Ten million items isn't much for modern computers with gigabytes of
memory. It's *approaching* "much", but hasn't quite reached it yet, and
for most applications, it doesn't matter if it takes 2 seconds to
pre-process your data instead of 0.5 second, so long as that's a
one-off cost. If you have to do it again and again, that's another
thing!
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Wed, 14 Jul 2010 11:53:38 pm Siren Saren wrote:
> Steven D'Aprano,
>
> Your response was profoundly helpful to me.
[...]
Thank you for the kind words, and cheers! I wish you good fortunate and
a lot of fun in your endeavour.
> I thought something in the culture o
ning of it, except it says global name self is not
> defined.
You can't just "tack" self at the beginning of variables and expect it
to work, any more than you could tack on "akjfhbcvgsaj" and hope for
the best! You need to understand *where* the variable self exis
nto
IDLE, and then do this:
from timeit import Timer
t = Timer('RepAdd(10)', 'from __main__ import RepAdd')
print(min(t.repeat()))
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
multiply_by
):
return first_number_to_multiply_by*second_number_to_multiply_by + 1
The more terse version is simple enough to understand:
def mult_plus_one(x, y):
return x*y + 1
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.or
(10,000,000 each of 00, 01, 02, ..., 98, 99), trigraphs (1,000,000 each
of 000, ..., 999) and so forth.
The interesting question is, if you measure a deviation from the
equality (and you will), is it statistically significant? If so, it is
because of a problem with the random number generator
his error?
The return statement can only be inside a function. Here is an example:
def f():
return "This is inside a function."
You have it outside a function, just like the error message says.
--
Steven D'Aprano
___
Tutor maillist
your version to write to a file on the local hard drive instead of a
remote file, but the speed hardly changed: 15 minutes instead of 16.
The best I was able to get my version down to is 14 minutes, so I guess
I just have to accept that my PC is seven times slower than your
e with one
> gulp without running out of memory.
Why? One billion bytes is less than a GB. It's a lot, but not *that*
much.
> Memory usage went to 80% (from
> the usual 35%), but no higher except at first, when I saw 98% for a
> few seconds, and then a drop to 78-80% where
ample, of course. As they say, the devil is in the
details.
> >> Memory usage went to 80% (from
> >> the usual 35%), but no higher except at first, when I saw 98% for
> >> a few seconds, and then a drop to 78-80% where it stayed.
> >
> > That suggests to
i'm missing with this
> module? I'll take another look anyway.
Tell the function what prompt to use:
>>> import getpass
>>> s = getpass.getpass("Please enter your secret word: ")
Please enter your secret wor
t;Nested arguments and more complex examples" just before the
section on Template Strings here:
http://docs.python.org/py3k/library/string.html#format-specification-mini-language
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
template, compared to (b) it
being unknown when you write the template:
>>> template = "(a) %05d | (b) %0*d"
>>> template % (42, 5, 42)
'(a) 00042 | (b) 00042'
This is how you would do it with the asterisk: you need a meta-template
to m
On Tue, 20 Jul 2010 09:53:25 am Steven D'Aprano wrote:
> This is how you would do it with the asterisk: you need a
> meta-template to make a template.
Doh! I meant *without* the asterisk.
> >>> meta = "(a) %%05d | (b) %%0%dd"
> >>> template = meta
mere pagan superstition, while the three-as-one nature of
Father/Son/Spirit is self-evidently true, at least according to those
Christian sects which believe in a trinity.
[2] So rare that it ought to count as a superpower.
--
Steven D'Aprano
) ):
c[a[i]] = b[i]
Here's the sensible way that makes Python do all the heavy lifting:
c = dict(zip(a, b))
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
return hash(self.value)
If x and y are instances of your class, and x equals y, then hash(x)
*must* equal hash(y). (The opposite doesn't apply though... if x and y
hash equal, they don't necessarily have to equal.)
--
Steven D'Aprano
___
d("o") will return the index of the first "o", or -1 if not
found.
str1.rfind("o") does the same, but searches from the right instead of
the left.
str1.index("o") is like find, but it raises an exception instead of
s is not foolproof. If you have a decorator like this:
@decorator("this takes a string argument with a # inside it")
the filter will return:
@decorator("this takes a string argument with a
But, and I repeat myself like a broken record, if you want fool-proof,
you need a proper parser, and that's hard.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
()
print "Your answer is", answer
although this needs better error checking, particularly where it tries
to write the config file.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
interpreter, or install a tab-completion
module, provide history which survives shutting down the interpreter
(like most Linux shells already do), or otherwise provide added
functionality such as that provided by (e.g.) IPython.
http://ipython.scipy.org/moin
So there are plenty of reasons to
a :)
> Should I just use 'config' or
> something similar as root, and the information elements 1 through 3
> as child elements? And should the manual edits be stored as an
> element 'edit' with various attributes (the ed
ere. You (generic you, not you personally) almost certainly
wouldn't write:
def mystr(x):
return str(x)
n = 42
s = mystr(n)
instead of the more obvious s = str(n). But bring map() into it, and
people make that exact mistake, writing:
map(lambda x: str(x), L)
instead of the simpler
approach and is doomed
to failure. I fear that you are taking a problem that can be solved
very simply, and making it much, much, much more complicated than it
needs to be.
Please read my email sent in response to your last question about this,
and good luck!
--
Steven D'Aprano
_
)
# Waiting 2 seconds is not annoying enough,
# waiting 2.2 seconds is too annoying.
sleep(2.1) # Just annoying enough!
return
main()
Hope this helps!
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
unction has a serious bug. To see it, call gcd(5, 5) and see
what it doesn't do.
4. Code duplication. Your function repeats fairly major chunks of code.
Copy-and-paste programming is one of the Deadly Sins for programmers.
The way to get rid of that is by encapsulating code in functions (se
nd"
print
you could write:
print "Menu Selections: \n1 - Attack\n2 - Defend\n\n"
but I don't really see that as an advantage. Probably better to wrap
common code into a function, then call the function:
def print_menu():
print "Menu Selections: "
first
thing you teach an absolute newbie who has never programmed before, but
they're pretty close.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
int winner
print
def main():
playerOne, playerTwo = get_names()
play_again = True
while play_again:
print "Rolling dice..."
winner = dice_game(playerOne, playerTwo)
displayWinner(winner)
answer = raw_input("Would you like to play agai
quoted strings?
*slinks off in shame*
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Sun, 1 Aug 2010 01:11:41 pm bob gailer wrote:
> On 7/31/2010 8:24 PM, Steven D'Aprano wrote:
> > On Sun, 1 Aug 2010 04:35:03 am bob gailer wrote:
> >> Continue to avoid writing functions. They are not necessary for
> >> such a simple program.
> >
> >
r when you call open. So the right way is to
ignore os.file.exists and just open the file, catching errors:
try:
f = open(filename)
except IOError:
do_something_when_the_file_isnt_there()
else:
do_something_with_file(f)
--
Steven D'Aprano
___
write your own quit() function that
asks the user and then calls sys.exit if they say yes.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
a)
else:
data = pickle.load(f)
f.close()
return data
used_page_numbers = load(path)
unused_page_numbers = [n for n in pool if n not in used_page_numbers]
if not unused_page_numbers:
print("All pages checked.")
print("Program will now close.")
sleep(2.1)
sys.exit()
and now that you have a list of unused page numbers, continue on with
the rest of your program.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Tue, 3 Aug 2010 10:52:27 am Richard D. Moores wrote:
> On Mon, Aug 2, 2010 at 16:57, Steven D'Aprano
wrote:
> > # File *probably* doesn't exist. Consider better error checking.
>
> Steve, before I dig into your detailed reply, please tell me what you
> meant by
On Sun, 8 Aug 2010 01:43:25 am Chris King wrote:
> Dear Tutors,
> How do you convert a string into a sound object.
What do you mean by "sound object"?
Can you give an example of what you want to do?
--
Steven D'Aprano
_
thing. Generally
people want to remember their passwords, in which case you want
passwords which are random enough to be hard for others to guess while
non-random enough for the owner to remember them.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
#x27;
(The above examples are from Python 2.5 rather than 3.1, where byte
strings aren't flagged with a leading b.)
> How were we supposed to know that all the hexes have 2 digits? How
> did you?
Because that's what they do. Numbers between 0 and
n my
> PYTHONPATH, it was not there. Does anyone know what might be causing
> this?
Modifying sys.path doesn't update PYTHONPATH. If you modify sys.path,
the changes disappear when you exit and re-enter and the unmodified
PYTHONPATH is read.
--
Steven D'Aprano
put file. Then read four
more lines, and throw them away. If you read a line, and it's empty,
then you've reached End Of File (EOF) and you can break out of the
loop.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To uns
On Mon, 9 Aug 2010 04:44:37 am David Hutto wrote:
> Four words... Software is python's propaganda.
Four more words: please trim unnecessary quoting.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
en-source project with you, or
just looking for a kind and generous soul who is happy to donate many,
many hours of work teaching you application development in Python?
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubsc
On Mon, 9 Aug 2010 07:21:03 pm Ranjith Kumar wrote:
> On Mon, Aug 9, 2010 at 12:23 PM, Steven D'Aprano
wrote:
> > On Mon, 9 Aug 2010 12:16:11 pm Ranjith Kumar wrote:
> > > Hi all,
> > > I`m doing a python based project, I need a mentor who can
> >
en't always 8 bits. Of
course, on just about all machines that have Python on them, they will
be, but there are still machines and devices such as signal processors
where bytes are something other than 8 bits. Historically, common
values included 5, 6, 7, 9, or 16 bits, and the C and C++ s
On Mon, 9 Aug 2010 11:51:34 pm you wrote:
> Steven D'Aprano wrote:
> > On Mon, 9 Aug 2010 07:23:56 pm Dave Angel wrote:
> >> Big difference between 2.x and 3.x. In 3.x, strings are Unicode,
> >> and may be stored either in 16bit or 32bit form (Windows usually
>
that let you set it.
Googling led me to this page:
which, if I've read it right, suggests that you should be able to type:
chcp 65001
at the DOS prompt before launching Python, and it theoretically will use
UTF-8.
Good luck.
--
Steven D'Aprano
On Wed, 11 Aug 2010 12:33:11 am Steven D'Aprano wrote:
> > Any suggestions how to fix the Windows console to interpret utf8?
>
> I don't know about Windows, but under Linux there is a menu command
> for most xterms that let you set it.
>
> Googling led me to this p
y larger than the initial string you pass,
what would be the point?
The string part of str.join is the string which is used to join the rest
of the arguments. This:
"spam".join([ "a", "b", "c" ])
is equivalent to:
"a" + "spam" + &quo
true result if all three numbers are different, otherwise it
gives a false result.
Negative conditions are often hard to reason with. It might be better to
write that as:
nummer == reeks[-1] and nummer == reeks[-2]
and swap the if/else clauses. But even better is to use Python's chained
comp
e enough, it can be caught:
[st...@sylar ~]$ python -c "
import sys
try:
sys.exit(42)
except SystemExit:
print 'Caught'
"
Caught
[st...@sylar ~]$ echo $?
0
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
except (AttributeError, RecursionError): # or whatever
pass
By the way, don't be tempted to write a bare except clause:
try:
...
except:
...
There are very few reasons for such a thing, as they are too broad and
catch too many things, masking errors, pre
On Mon, 16 Aug 2010 08:20:15 am aug dawg wrote:
> Hey all,
>
> Does anyone know of any modules to help my program parse RSS feeds?
Yes, many people know of modules to parse RSS feeds. If you google
for "Python RSS feed" you will find them.
eed it.
Other alternatives are traits and generic functions:
http://www.artima.com/weblogs/viewpost.jsp?thread=246488
http://www.artima.com/weblogs/viewpost.jsp?thread=237764
Lastly, I should mention automatic delegation as an alternative to
inheritance. It's not clear to me that this would
your best approach is for you to
upgrade to 2.5.4 rather than trying to get the neophyte to downgrade to
2.5.2.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
if value == target:
if first_only: return key
found.append(key)
return found
Or if you want a one-liner, use a list-comp:
[k for (k,v) in d.items() if v == target]
--
Steven D'Aprano
___
Tutor maillist - Tut
= MyInt(42)
>>> print n
My Integer 42
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Wed, 18 Aug 2010 09:21:51 pm Laurens Vets wrote:
> On 8/12/2010 1:26 AM, Steven D'Aprano wrote:
> > On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote:
> >> I need to generate a list of 30 numbers randomly chosen from 1, 2,
> >> 3, 4, 5& 6. However, I canno
ough. Immutability is by cooperation, not
enforced.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
python -m timeit "dict([(k,k+1) for k in xrange(2)])"
10 loops, best of 3: 4.78 usec per loop
Here, using a generator expression is a pessimation, not an
optimization.
> Sure it will eventually be garbage collected, but "waste not, want
> not", as my grandmother
an this:
seq = xrange(1000)
result = [i%2 for i in seq if i < 10]
Other than that, the speed of the loop itself is virtually the same as
the speed of the list comprehension.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
On Fri, 20 Aug 2010 05:28:42 pm nitin chandra wrote:
> try:
>fp6 = open(FileA,'r')
>except IOError:
You need to outdent the except line:
try:
fp6 = open(FileA,'r')
except IOError:
sys.exit('Could not open file: %s
On Fri, 20 Aug 2010 06:10:59 pm Alan Gauld wrote:
> "Steven D'Aprano" wrote
>
> > the purpose). No matter how fast you can perform a loop, it's
> > always faster to avoid it altogether, so this:
> >
> > seq = xrange(1000)
> >
can't do that, then get a better editor, or use a
single tab instead of four spaces.
Some people will say don't use tabs. I say phooey to them. It's better
to use tabs than to have inconsistent indentation.
--
Steven D'Aprano
___
y, adding two points to get a third).
But you can't expect me to do all your work :)
An alternative would be to have the named ordinates return 0 rather than
raise an error. Something like this would work:
@property
def y(self):
try: return self[1]
except IndexError:
e truck.go() method, they will get an exception if you give
them a KeylessTruck instead of a Truck. This is a Bad Thing.
Secondly, changing method interfaces is not compatible with multiple
inheritance and super(). You can probably get away with it if you stick
to single inh
;10, seq):
result.append(i)
as well.
Next time some Perl hacker accuses Python of being "Only one way to do
it", you can just laugh at them :)
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Sat, 21 Aug 2010 11:50:40 am Steven D'Aprano wrote:
> On Sat, 21 Aug 2010 08:08:56 am Alan Gauld wrote:
> > Every time you change the interface of inherited methods you
> > create for yourself extra work in converting types to match the
> > superclass. But that is o
or 7.
Then generalise that third program.
Off you go. Come back when you have some code. Even if it isn't working
code, at least try something.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscr
ng lists to be worse than
useless. I recommend that you change to individual mail, but of course
that's up to you.
Regards,
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
can't possibly divide into 99, or 57 into 59. The largest
number we need to check is the square root of n. The reason is a little
subtle, so think about it, don't just take my word.
Hint: write down the factors of, say, 60: Can you see the pattern?
2*30, 3*10, 5*6, 6*5, 10*3, 30*2
1000, check if it is a
multiple of 3, 5, 7, 9, ... and IF NOT, put it in the list "primes".
See, they are very nearly the same problem. The tricky bits are:
* dealing with 2 is a special case;
* you don't want to exclude (say) 3 from being a pri
ue
elif (n % 2 == 0) or (n < 2):
return False
# If we get here, we know that n is an odd number.
is_prime() is not complete. You have to write the rest.
(Note: this approach isn't the most efficient way of doing it, but it is
probably the simplest. Once you have thi
asteful.
That is exactly the same, only slower and more complicated, as:
list(xrange(20))
or
range(20)
Any time you write [x for x in SOMETHING] just drop the list
comprehension and use SOMETHING on it's own. (You might need to call
list(SOMETHING), but
On Wed, 25 Aug 2010 01:44:22 am Evert Rol wrote:
> Why are you returning -1 here?
> -1 is a valid list index.
So? str.find() does the same thing. It guarantees to only return 0 or
positive indexes if it finds the substring, and only returns -1 to
indicate not found.
--
Steven D&
using reduce like that, it will probably be much
faster to do this:
import operator
reduce(operator.add, lis)
particularly on the older versions where sum() isn't available.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
T
It also warns that os.access doesn't take into account network file
sharing permissions.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
eck interval to a ridiculously high value.
You can force Python to give even more time to threads by calling
time.sleep(0). Other than that, you're not likely to need to care about
this. Just write your code in the most straightforward way and leave
the rest to Python and the OS.
--
n't care about the difference between "True"
and "true").
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ice guy. (Or maybe a sucker.) If you still need "URGENT"
support, contact me and we'll make arrangements.
Either that, or just wait until somebody feels like answering.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
e OS will remain responsive while
you're looking for the burn cream for your lap!
> Busywaiting my cpu makes your program an instant candidate for
> immediate deletion. Maybe that's just me :)
Ah, I take it you've deleted the Flash plugin then? Or maybe it's
27;s more work.
I believe the simplest solution is to use the bound methods as first
class functions:
pt = Point(23, 42)
# choose a distance
if today == "Tuesday":
dist = pt.manhattan_distance
else:
dist = pt.euclidean_distance
for other in list_of_other_points:
pri
a beginners question, and you may benefit from having a lit
more eyes on your question :)
Have you tried python-l...@python.org or its newsgroup mirror
comp.lang.python ?
http://mail.python.org/mailman/listinfo/python-list
--
Steven D'Aprano
_
reserve the right to change or remove without
notice.
Only the first goes into __all__. Only the third start with an
underscore.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
rhaps this example will help:
u = [1, 10, 100]
v = [2, 11, 111]
add_vectors(u, v)
=> [3, 21, 211]
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
7;t forget that there can be repeated factors.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
201 - 300 of 3304 matches
Mail list logo