do it:
#1: modify the list in a for-loop
for i, item in enumerate(mylist):
mylist[i] = item.rstrip()
#2: make a new list with a list comprehension
mylist = [item.rstrip() for item in mylist]
Of the two, I prefer the second.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
strings "1", "2" etc.
>>> li = map(int, li) # convert the strings to actual ints
>>> print li
[1, 2, 3, 4]
Naturally the string s would come from the shell, otherwise there is no
point! If you are typing the data directly into the Python interpreter,
you wou
" as needed, each with
their own state:
>>> f = FuncCalculator()
>>> g = FuncCalculator()
>>> h = FuncCalculator()
>>> f()
0.5
>>> f()
0.83326
>>> f()
1.0833
>>> g()
0.5
>>> g()
0.83326
>>> h()
0.5
>>> f()
1.2832
Hope this helps!
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
be more than 32 bits, but since
I'm a fallible human, I'd rather find out about an error in my logic as
soon as possible").
(2) If the caller cares enough about speed to object to the tiny little
cost of the assertion, he or she can disable it by passing the -O (O
for Optimise) switc
e same?
Yes!
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Python makes it
really easy to accidentally hide a class attribute with an instance
attribute with the same name, but fortunately having shared data like
this is quite rare, so it's unusual to be a problem.
Hope this helps,
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
>>> e.filename
'no such file.txt'
> And this is not enough for developer : where that error happened ?
> what class ? what method ?
All these things are displayed by the default traceback mechanism.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ero results. What next? I had been modifying the
> program repeatedly over several hours, and executing it without any
> trouble like this.
Can you copy and paste the exact error message displayed?
--
Steven D'Aprano
___
Tutor maillist - T
any of my Pythons (2.5,2.6 and
> 3.1)
It won't work in 2.5 or 2.6. You're probably trying this:
123.bit_length()
and getting a syntax error. That's because the Python parser sees the .
and interprets it as a float, and 123.bit_length is not a valid decimal
float.
You need to ei
sage if the
test never becomes true:
for i in range(10, 0, -1): # 10, 9, 8, ... , 1
if i <= 4: # the test
print "we exit the loop early"
break
print "Loop number", i
else: # for...else
print
tegers.
> Actually, what I need is a kind of __subtype__ magic method that acts
> for subtyping the same way __init__ does for instanciation.
That's what metaclasses are for.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.o
lose()
>>> i
2
My guess is one of two things:
(1) You are mistaken that the file is bigger than 4311 lines.
(2) You are using Windows, and somehow there is a Ctrl-Z (0x26)
character in the file, which Windows interprets as End Of File when
reading files in text mode. Try ch
raise ValueError('unsafe string')
If your needs are more complicated, then sanitising the string becomes
exponentially more difficult. It will probably be less work to write
your own safe parser than to sanitise the input.
Have I scared you about using eval? If so, good. Don
__init__(self)
That has the effect of passing self *twice*, when __init__ expects to
get self *once*, hence the error message you see:
> When the super().__init__ line runs I get the error "__init__() takes
> exactly 1 positional argum
nd
> then replace sometihing, and join them together again.
>
> But - wouldn't it make more sense to do this with re.sub?
Heavens no! Why do you need a 80 pound sledgehammer to crack a peanut???
"Some people, when confronted with a pro
ame)
if os.name == 'nt':
fullpath.replace('\\', '/')
print '' % (fullpath, fullpath)
Hope that helps.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
;>> g()
1
>>> g.func_defaults[0]
0
The answer is that ints are immutable: you can't change their value.
When you do x+=1, it doesn't modify the int 0 in place, turning it into
1. It leaves 0 as zero, and gives you a new int equal to one. So the
e in sample_with_replacement() much more than any other function
> or method. Thanks in advance for any advice you can give me.
You don't tell us whether that actually matters. Is it taking 3 hours in
a 6 hour run time? If so, then it is worth spendi
r: '_sre.SRE_Pattern' object is not callable
The error is the line
findImages = imageRx(someFiles)
You don't call regexes, you have to use the match or search methods. And
you can't call it on a list of file names, you have to call it on each
fi
end a
raw string with a backslash.
>>> path = r'C:\directory\'
File "", line 1
path = r'C:\directory\'
^
SyntaxError: EOL while scanning single-quoted string
The best advice is to remember that Windows allows both forward and
backwards slashes as the path separator, and just write all your paths
using the forward slash:
'C:/directory/'
'C:textfile.txt'
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
.
> I want the function to be able to draw three differnet faces in a
> single window,when i invoke drawFace(center,size,win) into def
> main().
> thanks
> kola
Do you actually have a question?
Please show the code you have already written, and tell us what doesn&
ages like bash and (I think) C++.
There are three main ways to deal with an unrecognised escape sequence:
* raise an error
* ignore the backslash, e.g. \d -> d
* keep the backslash, e.g. \d -> \d
There are good arguments for all three, so I don't t
te are
not up to modern standards and are NOT cryptographically secure. Do not
use this where serious security is required.
Otherwise, google for "python encryption". You might also like to ask on
the Python newsgroup comp.lang.python for advice.
--
Steven D'Aprano
_
to get numpy and scipy?
If you need to go back to the 2.x series, you should use 2.6 not 2.5.
The Windows installer for numpy only supports 2.5, but the source
install should work with any recent Python 2.x version.
--
Steven D'Aprano
___
Tutor m
ist integer from 10 to 29, we can write:
> range(10,30). I was going to show a list of number from 1.0 to 1.9,
> and I did this in the same way as integer: range(1.0,2.0,0.1), but it
> doesn't work. Can you help me? Thank you!
Hope this helps:
http://code.activestate.com/recipes/57
r
at the console, and then process it in reverse:
>>> s = raw_input("Please enter a decimal number: ")
Please enter a decimal number: 123.456
>>>
>>> print s
123.456
>>>
>>> for c in reversed(s):
... print c
...
6
5
4
.
3
2
1
Hope this helps
rapper around the native C maths
library. The builtin pow function has more capabilities, and came
before the ** operator.
> Did they create a sum function
As a matter of fact they did:
http://docs.python.org/library/math.html#math.fsum
--
Steven
6.0. Is that about right?
Pretty much, but the builtin pow also takes an optional third argument:
>>> pow(4, 4, 65) # same as 4**4 % 65 only more efficient
61
By the way, are you aware that you can get help in the interactive
interpreter?
help(pow)
gram in folder1 (one).
What? "Pointing back", as in a Shortcut? Or a symlink?
If you've created a shortcut instead of a copy, I'm not surprised you
are executing it in the "wrong" folder. That's what shortcuts do.
--
Steven D'Aprano
__
t even know they exist, even though some of them go back all
the way to Windows NT. But as far as I can tell, there is no way for
you to have created a symlink from Explorer.)
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
in
radians. No, you can't change that anywhere, but you can do this:
>>> math.cos(math.radians(45))
0.70710678118654757
So of course you can write your own function:
def cos(x):
return math.cos(math.radians(x))
and call that.
--
Steven D'Aprano
___
on, used by
people wanting to experiment with Python compilers.
"Python for S60" is a version of Python written for Nokia's S60 devices.
CapPython is an experimental version of Python designed for security.
There are many others, they are all Python, but they
g merged with CPython too, which will be a great benefit.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
en("my_file.dat", "r")
data = {} # don't shadow the built-in dict
non_blank_lines = skip_blanks(fp)
sections = collate_sections(non_blank_lines)
for (header, lines) in sections:
data[header] = lines
Of course you can add your own error checking.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
't a mistake.
Likewise for "item != None" versus "item is not None".
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Thu, 4 Mar 2010 04:27:23 am C.T. Matsumoto wrote:
> Hello,
>
> Can someone tell me the difference between unittests assertEqual and
> assertEquals?
assertEqual, assertEquals and failUnless are three spellings for the
same thing. There is no difference.
--
Ste
sort is that the algorithm is easy to code.
Otherwise it is horrible in just about every imaginable way.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ely above a function definition:
@error_handling
def some_function():
...
Otherwise, you use the decorator like a function, you give the name of
another function as argument, and it returns a new function:
new_function = error_handling(some_function)
--
Steven D'Aprano
__
On Thu, 4 Mar 2010 05:18:40 am Alan Gauld wrote:
> "Steven D'Aprano" wrote
>
> > Comparisons with None almost always should be one of:
> >
> > item is None
> > item is not None
>
> Yes, but the reason I changed it (I originally had "is no
On Thu, 4 Mar 2010 05:32:22 pm you wrote:
> Steven D'Aprano wrote:
> > On Thu, 4 Mar 2010 04:27:23 am C.T. Matsumoto wrote:
> >> Hello,
> >>
> >> Can someone tell me the difference between unittests assertEqual
> >> and assertEquals?
> >
.__getitem__(0), __getitem__(1), __getitem__(2), and so on, until
it raises IndexError.
If thing doesn't have a __getitem__ method either, then the loop fails
with TypeError.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
to this as "the type", and ignore the fact that it's
actually a pointer. The type data structure (which itself will be an
object) itself is not embedded in every object! And of course, other
Pythons may use some other mechanism for linking objects back to their
type.
--
re, which
means bigger code and more bugs. They don't fit in very well with
CPython's memory management system. And they use a large number of
pointers, which can be wasteful.
E.g. a trie needs six pointers just to represent the single
key "python":
'' ->
hanic.
> Is there some relationship between modules and objects that I'm not
> seeing that could be of value?
Modules are themselves objects. Everything in Python is an object:
strings, ints, floats, lists, tuples, everything.
Modules are compound objects, in that th
t exception:
time.sleep(t)
t *= 2
raise exception("no connection after %d attempts" % numretries)
result = exponential_backoff(check_some_website,
("http://example.com";, 42), HTTPError, 8)
Any time you think you need e
url, x):
...
I haven't tested the above code, but it should do the trick.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
ch a yield, execution is
halted, but the state of the generator is remembered. Then when you
call the next() method, execution resumes.
> (But then, is it at all possible to have a call in a
> generator? Or does the issue only appear whan the callee is a
> generator itself?) Else, the must be an obvious error in my code.
I don't understand what you mean.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Mon, 8 Mar 2010 01:49:21 am Stefan Behnel wrote:
> Steven D'Aprano, 07.03.2010 14:27:
> > __iter__ should be an ordinary function, not a generator. Something
> > like this should work:
[...]
> That's just an unnecessarily redundant variation on the above. It's
and preferably only one --obvious way to do
> it" http://www.python.org/dev/peps/pep-0020/
This doesn't mean that there should be *only* one way to do something.
It means that the should be one OBVIOUS way to do it.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
active interpreter, when
the final quit message is printed: the interpreter doesn't notice it
needs to redraw the prompt. But other than that, it should be fine.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
if errors is None: errors = cls._ERRORS
obj = super(Unicode, cls).__new__(
Unicode, string, encoding, errors)
else: # Never attempt decoding.
obj = super(Unicode, cls).__new__(Unicode, string)
assert isinstance(obj, Unicode)
return obj
&g
where __new__ returns something else, __init__ is
never called:
>>> class AnotherClass(MyClass):
... def __new__(cls):
... ignore = super(AnotherClass, cls).__new__(cls)
... return 42
...
>>> o = AnotherClass()
Calling __new__ on object
>
On Fri, 12 Mar 2010 11:53:16 am Steven D'Aprano wrote:
> I have tried to match the behaviour of the built-in unicode as close
> as I am able. See here:
> http://docs.python.org/library/functions.html#unicode
And by doing so, I entirely forgot that you want to change the default
st():
assert Unicode() == u''
assert Unicode('abcd') == u'abcd'
u = 'cdef'.decode('utf-16')
assert u == u'\u6463\u6665'
s = u.encode('utf-8')
assert Unicode(s) == u
try:
hen it will work correctly:
>>> class K(Unicode):
... pass
...
>>> type(K())
You might be tempted to change the first reference to Unicode to cls as
well, but sadly that does not work. The reason is complicated, and to
be honest I don't remember it, but you will probably
rt
sentences!
Thank you.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
set it to ISO 8859-1, I get this:
>>> list("éâÄ")
['\xe9', '\xe2', '\xc4']
As far as I know, the behaviour of stuffing unicode characters into
byte-strings is not well-defined in Python, and will depend on external
factors like the terminal you are running in, if any. It may or may not
work as you expect. It is better to do this:
u = u"éâÄ"
s = u.encode('uft-8')
which will always work consistently so long as you declare a source
encoding at the top of your module:
# -*- coding: UTF-8 -*-
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
teError: 'str' object has no attribute 'format'
The original poster is using Python 3.0 or 3.1, you are using an earlier
version.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
s to str(), it isn't clear what is the
template and what is being inserted into the template. It is too easy
to miss a quote and get a SyntaxError, or to forget to add spaces where
needed. To me, this is MUCH easier:
template = "The area of a %s is %s x %s equals %s sq
functionality to do everything for the user. That is a bad idea.
> Anyway, all that source of troubles
> disappears with py3 :-)
> Then, I only need __str__ to produce nice, clear, unpolluted output.
>
> > which will always work consistently so long as you declare a source
> > encoding at the top of your module:
> >
> > # -*- coding: UTF-8 -*-
>
> Yes, this applies to my own code. But what about user code calling my
> lib? (This is the reason for Unicode.ENCODING config param).
That is their responsibility, not yours.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
he string includes:
* wrap the string contents in single quotes '
* unless the string contains single quotes, in which case wrap it
in double quotes " and display the single quotes unescaped
* unless the string contains double quotes as well, in which case
wrap it in single quotes and escape the inner single quotes.
But remember: this is only the display of the string, not the contents.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
entry = entries.get(date, {})
x = entry.get(address, {})
x.append(visitor)
entry[address] = x
entries[date] = entry
The trick is to use get to look up the dictionary:
entries.get(date, {})
looks up date in entries, and if it isn't found, it returns
s "A":
def condition(line):
line = line.strip()
fields = line.split('\t')
return fields[7].strip().upper() == "A"
datafile = open("somefile.data", "r")
for line in datafile:
if condition(line):
print
On Tue, 16 Mar 2010 10:22:55 am kumar s wrote:
> thanks Benno.
>
> supplying 3.6 GB file is over-kill for the script.
Then supply a smaller file.
> This is the reason I chose to input lines on fly.
I don't understand what you are trying to say.
--
generator, right? So I don't think it's a problem -
> correct me if I'm wrong.
No, you are correct -- "for line in file" reads one line at a time.
Beware, though, if the file isn't line-oriented, then each "line"
(separate
command.com or cmd.exe
or whatever it is called) and run:
opcenum.exe/IOPCServerList/EnumClassesofCategory
63D5F432-CFE4-11d1-B2C8-0060083BA1FB
and see what it does.
Once you get the syntax right in the shell, then use the exact same
syntax in popen4.
--
Steven D'Aprano
__
perate string-objects instead of
> writing them to files?
Use StringIO objects, which are fake files that can be read as strings.
Untested and entirely from memory, use:
from StringIO import StringIO
fromfile = StringIO("some text goes here")
tofile = StringIO("some different t
owser via my code, and preferably
> auto-submit the form.
You might like to look at Mechanize, which is a third-party Python
project for dealing with just that sort of problem.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To u
1
> 2
> 2
> 3
> 4
> 4
> 5
> 6
> 6
>
> The newly revised file should be:
>
> 1
> 2
> 3
> 4
> 5
> 6
Unless the file is huge, something like this should do:
# Untested
lines = open("myfile").readlines()
f = open("myfi
ng that *maybe* you want to get rid of.
index() is an O(N) operation -- slow but not painfully slow. Unless your
list is short, this is another "maybe" to remove.
remove() is another expensive operation. Unless your list is very short,
this is something else you want to avoid when possible.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
2)
2
If z is not in the bins, returns -1:
>>> search_bins(bins, 5.1)
-1
"""
for i, value in enumerate(nx):
if z > value:
return i-1
return -1
--
Steven D'Aprano
___
in text part
and a HTML part. Any decent mail client I know of gives you the choice
of which to view.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
de which is
different from the version they actually ran, then run it on the same
data. If it doesn't give the exact same results, send it back with this
link:
http://en.wikipedia.org/wiki/Scientific_misconduct
--
Steven D'Aprano
___
Tutor
38 STORE_FAST 1 (y)
41 JUMP_ABSOLUTE 19
>> 44 POP_BLOCK
5 >> 45 LOAD_FAST 0 (x)
48 LOAD_FAST1 (y)
51 BINARY_ADD
52 RETURN_VALUE
--
Steven D'Aprano
_
to quit')
> sys.exit()
What yes/no prompt? How do you select No?
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
sophisticated. Unless there happens to be an experienced numpy/scipy
user hanging around here, any answer we give would be just guessing.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription option
hings. See
what they do. See if you can predict what they will do before you do
them. For example, what would these give?
range(1, 101, 3)
range(2, 101, 4)
Try it yourself and see if you predicted correctly.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
t; > #A way to display all odd numbers
> > odd = numbers[::2]
>
> instead i do this:
> odd=[]
> for y in range(1,101,2):
> odd.append(y)
This does just as much unnecessary work as above.
--
Steven D'Aprano
__
this instead:
class Code(object):
w = None # Better to define default settings here.
def __init__(self, w=None):
if w is not None:
self.w = w
If no w is provided, then lookups for instance.w will find the shared
class attribute w.
[...]
> But the '###' line looks like an ugly trick to me. (Not the fact
> that it's a class attribute; as a contrary, I often use them eg for
> config, and find them a nice tool for clarity.) The issue is that
> Code.w has to be exported.
It is ugly, and fragile. It means any caller is *expected* to modify the
w used everywhere else, in strange and hard-to-predict ways.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
eport any errors. You can also run:
which python
and see what it says.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
, filename, tarname):
print "Processing ..."
tar_bzip2_directories(...)
if __name__ == '__main__':
try:
main()
except ... # as above
Now anyone can import the module and call individual functions, or even
call main, or they can run
s to call that function with every item
in the sequence.
There's nothing special about callbacks, except that they have to take
the arguments which the library function promises to supply.
--
Steven D'Aprano
___
Tutor maillist - Tu
^
SyntaxError: invalid syntax
>>> print("Hello world")
Hello world
Alternatively, sometimes if you have an error on one line, the
interpreter doesn't see it until you get to the next, and then you get
a SyntaxError on one line pas
extra. Again, inheritance makes it easy:
def affiche_solde(self):
# Display everything the super class understands.
CompteBancaire.affiche_soldeafficheself)
# Display the parts that only the subclass understands.
print "Le solde de votre marge de crédit est de %d $CAD" %
(self.mar
re
the "rich text" (HTML) attachment and just display the plain text?
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
the fine
existing IP address modules already written), or write functions in the
module and just call them:
import ISPdetector
ipAddress = "123.123.123.123"
emails = find_email_from(ipAddress)
Remember, in Python methods are just syntactic sugar for function calls.
obj.method(arg) is just
"??? What on earth does it do? It's worse than Perl code!!!
*half a wink*
> What fine manual should I be reading? I am not
> asking for code, rather just a link to the right documentation.
See the shell utilities module:
import shutil
--
Steven D'Aprano
___
using Python 2.6 or better:
>>> import itertools
>>> for x in itertools.product('abc', 'abc', 'abc'):
... print ''.join(x)
...
aaa
aab
aac
aba
abb
abc
[many more lines...]
ccc
If you don't like the repeated 'abc' in the call
oks", "a SET of spanners", or "a GROUP of
people". The term you are thinking of is mass noun.
See:
http://en.wikipedia.org/wiki/Collective_noun
http://en.wikipedia.org/wiki/Mass_noun
http://en.wikipedia.org/wiki/Data
> How to denote a single
> unit of data
, you
need to operate on all of them. So what is the purpose of the names?
Just drop the names, and work on a collection of objects:
objects = []
for row in csvimport:
tuple = (row[0],row[1],row[2])
objects.append(Classname(tuple))
# more code goes here
# ...
# much later
for obj in objects:
+ 101 + 101 + ... 101
= 100*101
so sum = 1/2 * 100 * 101 = 5050
While it is uncertain whether this specific story is actually true, it
is certain that Gauss was a child prodigy and a genius of the first
degree.
--
Steven D'Aprano
___
T
2.5. The joys of low end hardware!
Are you sure you got the right number of zeroes?
> whereas the same with
> "range" gives an error due to insufficient memory.
I'm not even going to try...
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
because the file doesn't exist. If you actually have a file called
Programs\rating in the C:/Python25/ directory, you will open it.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
18.2541666
which compares well to my HP-48GX:
18.15 HMS->
gives 18.25, and:
18.1515 HMS->
gives 18.254167.
Note though that this still fails with some valid input. I will leave
fixing it as an exercise (or I might work on it later, time
permitting).
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
bject was introduced in Python 2.4 and is re-written
in C for speed.
Functionally, they are identical. Speed-wise, the built-in version is
much faster, so unless you need to support Python 2.3, always use the
built-in set type.
--
Steven D'Aprano
___
> traverse-accumulating little computer errors along the way-the end
> result could be catastrophically wrong.
YES!!!
And just by being aware of this potential problem, you are better off
than 90% of programmers who are blithely unaware that floats are not
real numbers.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
sys.html#sys.path
So the answer to your question is, Yes.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
e
>>> turtle.ScrolledCanvas
> As a sidenote, I ended up removing the from turtle import *
> line from Tkinter which resolved the problem(the example I was using
> didn't have a canvas, and I'm pretty sure Tkinter was defaulting
> to the ScrolledCanvas).
I should say so! Tkinter doesn't have a "from turtle import *" line, as
that would set up a circular import dependency. No wonder you have had
problems, making random changes to libraries without understanding
them.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
t mytkinter as TK
class ScrolledCanvas(TK.Frame):
pass
> P.S. I bet you've been waiting since you got your first condescending
> response to a similar question, to lay it on someone about touching
> the Almighty Library.
>
> Way to keep up the cycle.
Don't try to psychoanalyse people you've never met, you aren't any good
at it.
--
Steven D'Aprano
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
too large, you hunt in the opposite
direction, with i-1 to i, i-2 to i, etc.)
Once you have bracketed the item you are searching for, you *search* for
it within those limits, using binary search or even a linear search. If
your searches are clustered, most of the hunt phases will be short an
1 - 100 of 3304 matches
Mail list logo