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
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
ure allows simple
implementation of debugging software, rather than the black arcana
that is the normal fare of trying to weld debuggers into the compilers.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ine as the $.
one
The space separates the 'one' from the '$ ' that it output to stdout
above.
one
one
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
seems like
there should be very little additional bus contention vs a normal add
instruction.
The opcode cannot simply talk to its cache, it must either go directly
to off-chip memory or communicate to other processors that it (and it
alone) owns the increment target.
--Scott David Daniel
ng it, he has accidentally changed the version of the
code. This you could forestall by invoking your function at packaging
time, and writing a file with the version string in it.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
vedrandeko...@yahoo.com said:
> ... when I run these two threads,
> I think they don't start at the same time
In response,
Diez B. Roggisch wrote:
... Even if you managed to get two threads started simultaneously
(which the OS doesn't even offer IINM), the would soon run out of sync
And th
waltbrad wrote:
I want to upgrade from 2.5 to 2.6. Do I need to uninstall 2.5 before
I do that? If so, what's the best way to uninstall it? Thanks.
The answer to your question may depend on your operating system and
setup.
--
http://mail.python.org/mailman/listinfo/python-list
I think I set it a long time ago to get the python VTK bindings working...
On Mon, Jan 19, 2009 at 5:58 AM, Gabriel Genellina
wrote:
> En Sun, 18 Jan 2009 16:08:07 -0200, Scott MacDonald <
> scott.p.macdon...@gmail.com> escribió:
>
> Ah yes, with your help I seem to have sol
Ah yes, with your help I seem to have solved my own problem. I had
PYTHONPATH defined to point to the 2.5 directory.
Thanks!
Scott
On Sun, Jan 18, 2009 at 11:01 AM, Scott MacDonald <
scott.p.macdon...@gmail.com> wrote:
> Yes, I see your point. Not sure how that would happen. It is
something like that?
Thanks,
Scott
On Sun, Jan 18, 2009 at 12:44 AM, Gabriel Genellina
wrote:
> En Sat, 17 Jan 2009 17:13:00 -0200, Scott MacDonald
> escribió:
>
> I googled a bit this morning search for an answer to this problem but have
>> come up empty so far. Can anyone
310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>>
Whats going on??
Thanks,
Scott
--
http://mail.python.org/mailman/listinfo/python-list
a favor and go to a bookstore and read a chapter or
two of the cookbook. While you can see the recipes on activestate,
there is a _lot_ of value added in (1) the selection, (2) the
editing for a more consistent style, and (3) the chapter intros
by people chosen for their knowledge on the chapter'
ehaviour?
It is the defined behavior.
For what you want:
import itertools as it
def count_from(base):
for n in it.count():
yield n + base
itlist = [count_from(n) for n in range(2)]
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinf
= defaultdict(lambda: defaultdict(int))
or
my_dict = defaultdict(functools.partial(defaultdict, int))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
the code you write
naturally. The way to get to such performance on Python is through
efforts like PyPy.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
lusively in the headers.
Readers sometimes select by subject, but only read content.
However the answer the OP is looking for with his ill-formed
question could be revealed if his final print were:
print('%s on reply %r' % (complaint, password))
He'd realize he wanted:
password = input(prompt).rstrip()
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
vailable as locals that encompasses the locals
of both f and f_nested, so you'll have to be explicit about what
you mean.
So, the code wants you to say something like:
def f():
def f_nested():
exec "a=2" in globals(), locals()
print a
return f
an encoded form (bytes) from
the abstract "Unicode is characters". What you want in Python is:
u'abc'.encode('UTF-16')
So look for something returning a string by invoking the decode method.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
imageguy wrote:
1) >>> n = None
2) >>> c,d = n if n is not None else 0,0
...
This is more easily expressed as:
c, d = n or (0, 0)
--
http://mail.python.org/mailman/listinfo/python-list
p numpy arrays to test the
set of ranges in listA in a pair of operations.
I hope I haven't helped you with your homework.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
for i in range(count):
yield None
raise exception
You can do your loop as:
check_infinite = Fuse(200, ValueError('Infinite Loop')).next
while True:
...
check_infinite()
but I agree with Tim that a for ... else loop for the limit is clearer.
--
nfused. You need to
show us enough so that we can discover what might, or might not, be
going wrong. At the least, what was your code, what happened, and
what did you expect to happen.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
er
if checking:
my_var = 'string'
else:
my_var = 'other string'
remember, vertical space only kills trees if printed.
--Scott David Daniels (who still prints this too frequently).
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
rchive by looking at the start of the file is that the zip file
format is meant to allow you to append a zip file to another file (such
as an executable) and treat the combination as an archive.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
by parameter %r.' % (order_by,))
if not:
raise ValueError('Bad order_by = %r (should be in %r).' % (
order_by, ['asc', 'desc']))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ave needed validation is in setting callbacks, since
the callback typically gets called asynchronously, and I have
trouble discovering why those things blew up. If I can, I manage
to try the callback once first, hoping for an early explosion.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.
(4) You could give us a clue about your operating environment.
(To wit: os, version, python version)
A printer is nothing Python has or controls, it is a standard thing for
a computer system, so details about your computing environment are
necessary in order to give you good
John Machin wrote:
On Jan 8, 6:23 am, Scott David Daniels wrote:
...some stuff perhaps too cranky...
Have you read the entire time module document? If so, which functions
in that module take strings as arguments? then even more cranky stuff...
Indeed. Be not cranky at clueless bludgers
sking your question you might have found the answer.
Perhaps I am being too cranky this morning.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
_time
then use things like:
print elapsed
print elapsed.seconds
...How do I get the 0.141000 out of that or any time object ?
On line docs are arcane to a novice.
Try this:
print dir(elapsed)
The answer should become obvious.
--Scott David Daniels
scott.dani...@ac
;> p = Image.open('~/VPython.png')
>>> r, g, b = p.split()
>>> q = Image.merge('RGB', [b, r, g])
>>> q.save('~/VPython1.png')
Should be plenty fast.
Read the PIL docs before rolling your own solutions.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
David Lemper wrote:
... Python. Using version 3.0
# script23
from array import array
< see failed initialization attempts below >
tally = array('H',for i in range(75) : [0])
tally = array('H',[for i in range(75) : 0])
tally = array('H',range(75) : [0])
tally = array('H',range
how your TCP/IP packets leave your machine, there is no guarantee
they will reach the destination in the same clumps. It is the stream,
and not the packets, that is provided by TCP/IP.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
but each corresponding value is incorrectly the default of 0.
What am I doing wrong?
How is this code supposed to count?
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
On Dec 29, 5:01 pm, scsoce wrote:
I have a function return a reference,
Stop right there. You don't have (and can't have, in Python) a
function which returns a reference that acts like a pointer in C or C+
+. Please tell us what manual, tutorial, book, blog or Usenet postin
n anyway.
Right, but why bother to do the conversion in C where you'll have to
fiddle with refcounts and error propogation? convert in python, and
go to the underlying data in C.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ing python
lists, you are stuck with extracting data element by element from
its Python language wrap.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
y([1, 2, 3]) + numpy.array([2, 3, 4])
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Dan wrote:
Wanted to learn python, got Mark Summerfield's new book "Programming in
Python 3". Having a hard time getting python 3 and IDLE working on my
Mac with Leopard. The mac "resources" on the python.org site seem a bit
out of date, and don't really mention python 3. Are there any resou
specifically Numpy kind of answer is:
import numpy
a = numpy.array([0, 1, 2])
print a * 3
-Scott
--
http://mail.python.org/mailman/listinfo/python-list
ot;))
root = math.sqrt(value)
print('root(%s) == %s' % (value, root))
I avoid using single-letter variables except where I know the types
from the name (so I use i, j, k, l, m, n as integers, s as string,
and w, x, y, and z I am a little looser with (but usually float or
complex).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
could replace the __str__ function with:
def __str__(self):
return self.address or "NULL"
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
g the DOS
Box on Windows.
Absolutely right. Vy the way, naming your "main" program file
something.pyw, rather than something.py is one of the ways ro do this.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers wrote:
... Now improvements are always welcomes, and if you compare 1.5.2 with
2.5.1, you'll find out that the core developpers did improve Python's
perfs.
Cool, palindromic inverses as compatible versions!
--
http://mail.python.org/mailman/listinfo/python-list
o from id to object, the whole idea of garbage
collection and reference counts would fly out the window, leading to
nasty crashes (or you might get to an object that is the re-used id of
an older object).
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
rvalues
print v
For extra credit, explain why values is better.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
n 2.x)
And, in fact, a dictionary iterates its keys, so:
k1 = set(dict1)
works in 2.4, 2.5, 2.6, and 3.0
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
ode solves your problems.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
but for internationalization, you can change the format
string to take args in a different order if, for example,
French messages want modifiers on one side and English on the other.
The code can stay the same, while only the text used to do the
formatting must change.
--Scott David Daniels
scott.
Joel Hedlund wrote:
Scott David Daniels wrote:
Perhaps your hash function could be something like:
I'm not sure I understand what you're suggesting.
/Joel
Sorry, a half-thought out idea based on the fact that you wanted a
consistent hash for a varying dictionary. The given
Tim Rowe wrote:
2008/12/18 Scott David Daniels :
def quadsolve(a, b, c):
try:
discriminant = sqrt(b**2 - 4 * a * c)
The discriminant of a quadratic is more usually just the b**2 - 4 * a
* c part, not the square root of it. Testing that for negative, zero
or positive avoids the need
ow if they cannot get
through in two hours.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
% (
type(self).__name__, len(self))
(3.0):
class HiddenList(list):
def __repr__(self):
return '<{0} object: length={1}>'.format(
type(self).__name__, len(self))
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
.
if discriminant: # two results
return ((-b - discriminant) / (2 * a),
(-b + discriminant) / (2 * a))
else: # a single result (discriminant is zero)
return (-b / (2 * a),)
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo
Li Han wrote:
But what repr() do remain a black hole!
Han
Try: print repr(repr("'"))
that might enlighten you.
--
http://mail.python.org/mailman/listinfo/python-list
_hash
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
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
You might be interested in the "Beautiful Code" book:
http://oreilly.com/catalog/9780596510046/
It has a chapter on Python's dict implementation that is pretty good.
On Tue, Dec 16, 2008 at 10:51 AM, Brigette Hodson
wrote:
> Hello! I am in a beginning algorithms class this semester and I am work
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
clearer code, but by nowhere near as much.
--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.
ed
"Unique Transparency Program Uncovers Problems with Voting Software"
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
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
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
lls like homework without a particular application.
--Scott David Daniels
scott.dani...@acm.org
--
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
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
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
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
"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
"", 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
Damn you, Python, and your loose documentation! It never occurred to
me to actually TRY my pseudocode, since I couldn't find anything on
that type of statement. Anyway, feel free to ignore me from now on.
--
http://mail.python.org/mailman/listinfo/python-list
I've been trying to read up on this, but I'm not sure what the
simplest way to do it is.
I have a list of string. I'd like to check to see if any of the
strings in that list matches another string.
Pseudocode:
if "two" in ["one", "two", "three", "four"]:
return True
Is there any built-in i
nd the recipient decodes the nonsense back into the message.
--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
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
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
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
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
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
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
[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,
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
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
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
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
location without having to cook up a custom
PYTHONPATH.
--Scott David Daniels
[EMAIL PROTECTED]
--
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
[EMAIL PROTECTED] wrote:
...
so, it seems to me that if I would know how to write a file object,
then I could write one that prefixes each line, and that would be
fine, no? I don't see how this would necessitate waiting for p.py's
termination, or matter that it is a different process. I just do
he "sys.stdout" that p.py uses is different from that in the program
calling Popen. In fact, it could be using a different Python. The
situation is really similar to
p = subprocess.Popen([, 'aa'])
in that you have no way to "muck with the guts" of the subproces
way to experiment
with things you think you get; try "corner cases" to make sure you
know what is going on.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
quot;
that don't work that way (setattr knows about checking for the
exceptional cases). The "storage" can be removed with the "del"
statement. Try
del d.non_template
print d.non_template
del e.holder
print e.holder
--Scott David Daniels
[EMAIL PROTE
;t you are setting yourself
up to discover a pile of bugs that you don't understand.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
What size of a project are you looking to work on? I enjoy learning in a
similar way as you it seems. Recently I have been interested in data
visualization problems. Maybe trying to replicate something from a website
like: http://www.visualcomplexity.com/vc/ would interest you?
Scott
On Tue
s you, then MyParseError isn't a
ValueError and you shouldn't inherit from ValueError.
Just from the name, I'd look into making MyParseError inherit from
SyntaxError.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
n write something cool at least once, it will
encourage him to learn more.
Do you know about scratch (http://scratch.mit.edu/)
Actually, my son is 15, so Scratch might be too simplistic. PyGame
looks interesting. I'll play around with it tonight.
Look into VPython -- you can do 3-D _ea
p(sorted(dic1.items()),
sorted(dic2.items()))
if p1 != p2)
>>> differs
{'h': (104, 13), 'e': (101, 12)}
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ding that you should (in such cases) put
a commented-out import at the top level (so you can look at the top of a
module's source and see what other modules it relies upon.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Error
except ValueError:
start = traceback.extract_tb(sys.exc_info()[2])[-1]
Start should show you where the program is being run from.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
901 - 1000 of 2115 matches
Mail list logo