quot;abc", 123))
Or would you require that tuple-formation is "special"?
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
i+=1
Or the following:
indices = [i for i,d in enumerate(l) if d['title']=='ti']
for i in reversed(indices): # so del doesn't affect later positions
del l[i]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ar to commit is equivalent
to an infinite loop for all applications that I have interacted with
(and yes, I have worked allowing four day transactions to commit).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
"backward compatible."
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
lder().method if you have no other use for the instance of
your Holder instance.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
1.667)
and, as they so often say, "lather, rinse, repeat."
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
27;import from package.possible: %s' % __file__)
__init__.py
-
print('package initialized: %s' % __file__)
A.py
--
print('A started: %s' % __file__)
import possible
print('A running: %s' % __file__)
--Scott David Da
comp.lang.python for a while, you'll see this is the
norm for messages here, and these behaviors help make this a more
pleasant place to read and write.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.",
and examining the patters with print(somestring), you'll ease your life.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
e strict and report the first line as "foo\n\n"; I was
wrong.
Here's how I'd do it:
with open('deheap/deheap.py', 'rU') as source:
for line in source:
print line.rstrip() # Avoid trailing spaces as well.
This should handle \n, \r
e seen looks like its fit will feel more like a suit of armor
than a shirt.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
lled in data switched class,
and invoked their corresponding method.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
n't
remember the details, but I remember my work-around. If you do have
troubles, try using almost the same code you now use, but substitute for
the obvious lines above:
d = weakref.WeakValueDictionary()
and
d[id(x)] = x
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.py
Paul Rubin wrote:
Scott David Daniels writes:
But, the research on the language "Self" shows that even in the face
of a language with more dynamism than Smalltalk (or Python), performance
can be obtained using compiler technology
I'd be interested in seeing any publicat
dle on it, otherwise it may get recycled and reused.
That is, id(var1) == id(var2) implies var1 is var2,
but id(expr1) == id(expr2) does not even imply expr1 == expr2
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
e sort order is not a particularly useful one (except for the fact
that there is an order).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
27; % (1 + n, line.rstrip())
Be careful with your assertion that a regex is faster, it is certainly
not always true. Measure speed, don't take mantras as gospel.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Grant Edwards wrote:
On 2009-01-30, MRAB wrote:
Eric Kang wrote:
In two's complement representation, can adding one positive
and one negative give you overflow?
No.
AFAIK, in Python adding integers never gives you overlow
regardless of sign.
Right, but he wants his homework answer.
--
http
27;
What am I missing?
There is no way to write a raw string for text ending in a single
backslash. r'd:\\' == 'd:'
What you want is relpath(r'd:\jho', 'd:\\')
But it turns out this doesn't work, either.
File a bug.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
stuck with.
Well, what are your arg constraints? Integers in 0 .. 2**53?
math.frexp(n)[1]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
trickier than the above
seems to show. Here is how to get the full behavior:
>>> import operator
>>> operator.add(1,[])
Traceback (most recent call last):
File "", line 1, in
operator.add(1,[])
TypeError: unsupported operand type(s) f
or:
main(sys.arg[1:] or ['default', 'args'])
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
you may need to write it differently.
You can use this as a source of lines for your parser.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
o No GUI toolkit would be available out of the box.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
handle.close()
>>> archive = zipfile.ZipFile(zipdata)
or:
>>> with urllib2.urlopen("http://...file.zip";) as remotehandle:
...zipdata = StringIO.StringIO(remotehandle.read())
...archive = zipfile.ZipFile(zipdata)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
't followed for more than couple of decades.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.
Otherwise, the advice is spot-on.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
modules/application.py ...
your import should work.
You need to make the package layering to application explicit.
Similarly, you can start Idle with:
python -m idlelib.idle ...
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Class()
...
reload(classes)
from classes import *
instance = SomeClass()
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ton(frame1,text='close',bg='light gray',
command=on_click)
close_frame1.pack_propagate(0)
close_frame1.pack(side=TOP, anchor=N,pady=25)
The "global" lines are needed so that on_click and MainWin (which both
set the two names) are talking about the same objects.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ng point behave a
little bit like real numbers. The reason it is tough is that addition
is not associative in real numbers, and associativity is at the core
of a lot of proofs in arithmetic (and group theory).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ges.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
uot;
as "mes in the first line quoted above).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
/7868588.stm
I know, Titanoboa might not have actually been a python, but it
may well have been a precursor to our Python.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ocuments describe
their code without the module name. I believe that such behavior
is because, when working to produce prose about a package, it
feels too much like useless redundancy when describing each function
or class as "package.name".
--Scott David Daniels
scott.dani...@acm.org
OdarR wrote:
On 6 fév, 10:56, Agile Consulting wrote:
Explain ADO and RDO
RU a bot ?
I expect someone is experimenting with their spam generator.
--
http://mail.python.org/mailman/listinfo/python-list
solutions to some problems as we switch to
Unicode strings from byte strings. You are comparing a .0 version to
.5 versions. I expect the polishing that follows as we go up through
.1, .2, and so on will lower those redundancy measures.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.p
exit from Idle and restart it. If this diesn't work, get back to me
and we can try something more drastic.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
I (Scott David Daniels) wrote:
choha...@gmail.com wrote:
Is there a way to adjust the default font size in IDLE, in MacPython
2.5? The default now is too tiny.
I have to use this version of MacPython. As far as I searched, I can't
find how I do this.
If you can read what you have at all
lePath)
TypeError: super() argument 1 must be type, not classobj"
What have I done wrong? Thanks in advance for any help.
To use super, you must work with descendants of "object".
So, just change your first line to:
class Parent(object):
and you should find your world back in
nittest.main()
Note this gives you less information (the traceback doesn't go down
to the actual error), but it shows you what step failed.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
rt 0 < ip_number < 1 << 48
bytes = []
while ip_number:
bytes.append(ip_number & 255)
ip_number >>= 8
assert len(bytes) in (4, 6)
return '.'.join(str(n) for n in reversed(bytes))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
vote for two cans.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
o
nasty problem guessing what to parameterize and what to fix in stone.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
raise ValueError
return 1
return fact(n - 1) * n
But really, iteration is the solution to this, and avoiding the
right answer is a mistake. I couldn't resist fixing your test
so you do one less layer of recursion.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.
Travis wrote:
On Tue, Feb 10, 2009 at 01:36:21PM -0800, Scott David Daniels wrote:
I personally would like it and bz2 to get closer to each other...
Well, I like this idea; perhaps this is a good time to discuss the
equivalent of some "abstract base classes", or "i
Paul Rubin wrote:
Scott David Daniels writes:
Seems like we may want to say things like, "synchronization points are
too be silently ignored."
That would completely break some useful possible applications, so should
be avoided.
No, I mean that we, _the_users_of_the_interface_, m
Paul Rubin wrote:
Scott David Daniels writes:
I suspect that is why such an interface never came up (If
you can clone states, then you can say: "compress this, then use the
resultant state to compress/decompress others."
The zlib C interface supports something like that. It i
Scott David Daniels wrote:
... I've wanted to do some low-level (C-coded) search w/o bothering
to create strings until a match
Here's a more common use case: signature gathering on the contents.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listi
are available
for a price. ActiveState, for example, sells one.
The issue in each case is sharing things that the programs have
every right to expect that they "own." To wit, Display refresh points,
the main program, the keyboard, tcp/ip ports, the mouse.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Can someone explain to me what's going on here?
>>> __import__('some.package.module', {}, {}, [])
>>> __import__('some.package.module', {}, {}, [''])
(Note that '' is two single quotes)
Thanks,
Scott
--
http://mail.python.org/mailman/listinfo/python-list
distutils, and write a setup.py. You will want to use mingw32.
Searching for "building python25 C extensions mingw32" should point you
right.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
me.
OK, you are using the oldest and least useful revision control system,
"rename and remember." I'd suggest you get and use bazaar, but you'll
just ask for shortcuts on how to use it without understanding what it does.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ook into the numpy external package, because
those arrays are _far_ superior for actual calculation. With numpy you
can do array_1 + array_2 without requiring a Python loop. I'm sure
it has a way to read in binary arrays of the various data types.
--Scott David Daniels
scott.dani...@acm.org
input)
return True
except ValueError:
try:
num = int(input, 0) # Convert to int, base spec in arg
return True
except ValueError:
return False
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.pytho
andrew cooke wrote:
Thanks a lot for writing this, I'll be pointing to it from time to time.
Were I writing such a thing I'd focus too much on the how (issues I know
that non-GIL true concurrency faces), and not enough on the high level
view.
Bravo.
--Scott David Daniels
scott.dani.
t sys
class MyFakeStdout(object):
def flush(self):
pass
def write(self, text):
sys.stderr = sys.stdout = MyFakeStdout()
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
sending a picture, for example, all possible byte sequences might
show up. If the default encoding is "utf-8", for example, there
are byte sequences which are illegal. I suspect you are confused
by thinking each byte must map to a character; such an encoding
could never suffice for
r = "r" + r.replace('', '\\')
assert not r.endswith('\\')
return r
...
The big issue I see is that lots of values cannot be represented
as raw strings. Your code checks for a final '\', but many "control"
cha
se mode (You will get a _lot_ of output).
Then, when you (finally) get a ">>>" prompt, type:
>>> import pygame
and you will see eaxctly what lookups are tried.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
t;> t = turtle.pen()
>>> print(repr(t))
The pen returned (which you named t) is a simple dictionary.
You can, however, follow up with:
>>> turtle.forward(23)
>>> turtle.right(90)
>>> turtle.forward(32)
>>> turtle.right(90)
>>> turtle.forward(23
t="Exit", command=root.destroy)
button.pack(side=TK.BOTTOM)
reader = Weegbrug(frame, svar, filename)
button = Tkinter.Button(frame, text="Go", command=reader.start)
button.pack(side=TK.BOTTOM)
root.mainloop()
if __name__ == '__main__':
main(__f
merge back. Most checkins to the central repository _are_ merges.
That is why everyone talks about merge speed.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
names).
2) The last statement could more easily be written:
root.after(500, display)
...
root.after(500, lambda:display())
Again you can write this:
root.after(500, display)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
wards consistency in spelling over correctness. Spelling "recievers"
the same way 1000 times is better than getting it correct 999 times and
"wrong" once. :-)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ance bug
vector.fromstring(n * 8 * '\0')
return vector
Once numpy is up and running on 2.6, this should be easy to convert
to a call to zeroes.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ancient floating points did not use all-0 bytes for 0.0).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Wed, 18 Jul 2007 19:32:35 +, George Sakkis wrote:
...
Wow, can you make a coffee in.. 57ms ?
[snip demonstration of xrange raising an exception]
Of course! Can't you?
And if I use a microwave oven,
[*** deleted section outlining Guido's time machine structur
messages to the command window that
help diagnose.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
):
print obj
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
y
Dr. André Roberge
88. Seven ways to use Python's new turtle module
Mr. Gregor Lingl
But make no mistake, you need to mingle when you are there to get the
inspiration you'll want.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
y about affecting the
standard environment.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
location without having to cook up a custom
PYTHONPATH.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
lack presidents of the
US. Which one was the tallest?
I know the answer to that one:
All of them!
Heh. Mysteries of the empty set.
_and_, as it turns out, sets of cardinality 1.
--Scott David Daniels (pleased about the change in cardinality)
[EMAIL PROTECTED]
--
http://mail.python.org/m
ode to produce the same hashes, say that.
A hash is a means to an end, and it is hard to give advice without
knowing the goal.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
to 2.5. If you
can wait until early next year (and/or have the round tuits to help), go
with 2.6.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ors (UTF-32BE and UTF-32LE), and whatever your current
Python, you may well switch between UTF-16 and UTF-32 internally at some
point as you do regular upgrades (or BE vs. LE if you switch CPUs).
--Scott David Daniels
[EMAIL PROTECTED]
you'll have to decide
, but you could
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Hi All,
I dont understand why the following code never finds "tree".
I could not find the answer in the Python tutorials.
Here is the code, test43.in, and runtime:
#!/usr/bin/python
fname = open("test43.in")
var = 'tree'
for item in fname:
print "item: ", item,
Python mode (the current one does not work well in a "leave tabs
alone" mode). Even for me, the Komodo debugger is the bee's knees.
I have never worked at ActiveState; I am only a (mostly) satisfied
customer.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Test = new.classobj(
^^^ replace with:
Test = type(
'Test', (FirstBase, SecondBase), attr)
class MyNewClass(Test):
pass
a = MyNewClass()
print a.foo, a.buz, a.fiz, type(a)
> ...
It's really that simple.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
...
If you now, and for all time, decide that the only source you will take
is cp1252, perhaps you should decode to cp1252 before hashing.
Of course my dyslexia sticks out here as I get encode and decode exactly
backwards -- Marc 'BlackJack' Rintsch ha
Stef Mientki wrote:
The debugging ability of the Komodo IDE is _significantly_ better than
the freely available debuggers. If you like the Komodo Editor, you'll
love the debugger.
hi Scott, can you tell us, > why Komodo debugger is better than PyScripter
or even Winpdb(rpdb2) used
running on 2.6.
The next few months should change that situation. So, if you are
using numpy or scipy, for example, you'd do better to go with 2.5
for now, and only move over when the full set of packages you use
are working on 2.6.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.pyth
ecognize
subdirs. Then maybe you'll type: \wi <^D> \sy \<^D> <^D> \dr <^D>
A directory-specific recog char was one of MS's nice improvements.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
it on, as I remember.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
nd the recipient decodes the nonsense back into the message.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
"", line 1, in
hashlib.md5(b.decode('utf-8')).hexdigest()
File "C:\Python26\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 4: ordinal not in range(128)
Incidentally, MD5 has fallen and SHA-1 is falling. Python's hashlib also
includes the stronger SHA-2 family.
Well, the choice of hash always depends on the app.
-Scott
--
http://mail.python.org/mailman/listinfo/python-list
"just selected recipes" -- the
recipes are picked in subject groups, edits applied, and introductions
to each section are written by someone chosen for their expertise in
that area. You defintely get more than the list of recipes to examine.
--Scott David Daniels
[EMAIL PROTECTE
7;toc.html', '01.html', '05.html', '07.html', '02.html', '08.html']
>>> test[4]
'toc.html'
>>> test[4].strip('.html')
'oc'
>>> test[2].strip('.html')
'questions'
Well, why does ' a b c '.strip() leave two spaces?
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Mark Dufour wrote:
Hi all,
I have just released version 0.0.30 of Shed Skin, ...
Normally, including a link is a good idea.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
nds', [x for x in (b, c) if not 10 <= x <= 21]
I do advise working through the tutorial before asking.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
for results in iter(combined_results.get, None):
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
lls like homework without a particular application.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
feb...@gmail.com wrote:
...
elif bank >= 1 and bank <= 24999:
rate = 0.0085
> ...
Also, (although not useful here as others have pointed out),
note that particular code means the same thing as:
...
elif 1 <= bank <= 24999:
rate = 0.008
f.label.destroy()
and seeing if that quick-fix lets you go farther.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ed
"Unique Transparency Program Uncovers Problems with Voting Software"
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
to rename during that period. So, a failure should retry in a
second a couple of times before giving up. This is my understanding,
but someone deeply familiar with Windows internals might reveal that
I am operating on older information.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.
clearer code, but by nowhere near as much.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
head + [element] + tail):
yield row
break
else:
if source: # Just to make expands([]) return an empty list)
yield source
def answer(source):
'''Do the requested printing'''
for row in expands(source):
print
mini, maxi))
These changes are mostly:
(1) Negated tests are harder yo read
(2) raise and return change the flow of control, so
if ...:
else:
...
is "fat" (more trouble to read).
(3) Adopting to the new 3.0 string formatting.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
1401 - 1500 of 2114 matches
Mail list logo