Re: is this pythonic?

2009-01-21 Thread Scott David Daniels
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

Re: English-like Python

2009-01-21 Thread Scott David Daniels
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

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Scott David Daniels
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

Re: How to write a simple shell loop in python?

2009-01-21 Thread Scott David Daniels
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

Re: what's the point of rpython?

2009-01-21 Thread Scott David Daniels
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

Re: function to find the modification date of the project

2009-01-19 Thread Scott David Daniels
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

Re: Python and threads

2009-01-19 Thread Scott David Daniels
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

Re: uninstall before upgrade?

2009-01-19 Thread Scott David Daniels
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

Re: import urllib2 fails with Python 2.6.1 on Vista

2009-01-19 Thread Scott MacDonald
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

Re: import urllib2 fails with Python 2.6.1 on Vista

2009-01-18 Thread Scott MacDonald
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

Re: import urllib2 fails with Python 2.6.1 on Vista

2009-01-18 Thread Scott MacDonald
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

import urllib2 fails with Python 2.6.1 on Vista

2009-01-17 Thread Scott MacDonald
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

Re: *Advanced* Python book?

2009-01-16 Thread Scott David Daniels
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'

Re: lazy evaluation is sometimes too lazy... help please.

2009-01-16 Thread Scott David Daniels
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

Re: optimizing large dictionaries

2009-01-15 Thread Scott David Daniels
= 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

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Scott David Daniels
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

Re: can someone tell me why this doesn't work please python 3

2009-01-14 Thread Scott David Daniels
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

Re: exec in a nested function yields an error

2009-01-13 Thread Scott David Daniels
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

Re: Problems in Using C-API for Unicode handling

2009-01-13 Thread Scott David Daniels
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

Re: Ternary operator and tuple unpacking -- What am I missing ?

2009-01-13 Thread Scott David Daniels
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

Re: efficient interval containment lookup

2009-01-12 Thread Scott David Daniels
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

Re: Python tricks

2009-01-12 Thread Scott David Daniels
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. --

Re: Python logging rollover

2009-01-12 Thread Scott David Daniels
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

Re: if-else statement

2009-01-10 Thread Scott David Daniels
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

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread Scott David Daniels
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

Re: Is it ok to type check a boolean argument?

2009-01-07 Thread Scott David Daniels
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

Re: Is it ok to type check a boolean argument?

2009-01-07 Thread Scott David Daniels
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

Re: How do you write to the printer ?

2009-01-07 Thread Scott David Daniels
. (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

Re: formatted 'time' data in calculations

2009-01-07 Thread Scott David Daniels
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

Re: formatted 'time' data in calculations

2009-01-07 Thread Scott David Daniels
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

Re: How to get millisec/fractional seconds out of a time object ?

2009-01-06 Thread Scott David Daniels
_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

Re: Reverse order of bit in repeating seqence of byte string

2009-01-04 Thread Scott David Daniels
;> 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

Re: How to initialize an array with a large number of members ?

2008-12-31 Thread Scott David Daniels
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

Re: select.select and socket.setblocking

2008-12-31 Thread Scott David Daniels
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

Re: get method

2008-12-29 Thread Scott David Daniels
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

Re: why cannot assign to function call

2008-12-29 Thread Scott David Daniels
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

Re: C API: array of floats/ints from python to C and back

2008-12-27 Thread Scott David Daniels
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

Re: C API: array of floats/ints from python to C and back

2008-12-27 Thread Scott David Daniels
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

Re: C API: array of floats/ints from python to C and back

2008-12-27 Thread Scott David Daniels
y([1, 2, 3]) + numpy.array([2, 3, 4]) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3 and my Mac (Leopard)

2008-12-27 Thread scott
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

Re: multiply each element of a list by a number

2008-12-26 Thread Scott David Daniels
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

Re: strange behavior of math.sqrt() in new 3.0 version

2008-12-26 Thread Scott David Daniels
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

Re: [SQL] Right way to set a variable to NULL?

2008-12-26 Thread Scott David Daniels
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

Re: python interpreter black window

2008-12-25 Thread Scott David Daniels
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

Re: New Python 3.0 string formatting - really necessary?

2008-12-24 Thread Scott David Daniels
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

Re: Doing set operation on non-hashable objects

2008-12-24 Thread Scott David Daniels
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

Re: Iterating over objects of a class

2008-12-24 Thread Scott David Daniels
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

Re: Strategy for determing difference between 2 very large dictionaries

2008-12-24 Thread Scott David Daniels
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

Re: IDLE doesn't show stderr output from extension modules

2008-12-19 Thread Scott David Daniels
ode solves your problems. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-19 Thread Scott David Daniels
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.

Re: weird dict problem, how can this even happen?

2008-12-19 Thread Scott David Daniels
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

Re: Factoring Polynomials

2008-12-19 Thread Scott David Daniels
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

Re: Factoring Polynomials

2008-12-18 Thread Scott David Daniels
ow if they cannot get through in two hours. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Scott David Daniels
% ( 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

Re: Factoring Polynomials

2008-12-18 Thread Scott David Daniels
. 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

Re: The rule of literal string

2008-12-17 Thread Scott David Daniels
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

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Scott David Daniels
_hash --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help improving number guessing game

2008-12-16 Thread Scott David Daniels
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

Re: Python Dictionary Algorithm Question

2008-12-16 Thread Scott MacDonald
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

Re: tricky nested list unpacking problem

2008-12-15 Thread Scott David Daniels
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

Re: Removing None objects from a sequence

2008-12-15 Thread Scott David Daniels
clearer code, but by nowhere near as much. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Rename of .mdb file -- lock

2008-12-15 Thread Scott David Daniels
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.

Python shows up checking votes

2008-12-14 Thread Scott David Daniels
ed "Unique Transparency Program Uncovers Problems with Voting Software" --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Output to file gets lost - don't know where to look ...

2008-12-14 Thread Scott David Daniels
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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Scott David Daniels
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

Re: dictionary idiom needed

2008-12-11 Thread Scott David Daniels
lls like homework without a particular application. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, threading

2008-12-11 Thread Scott David Daniels
for results in iter(combined_results.get, None): --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Determining whether a variable is less/greater than a range.

2008-12-08 Thread Scott David Daniels
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

Re: ANN: Shed Skin 0.0.30, an experimental (restricted-)Python-to-C++ Compiler

2008-12-05 Thread Scott David Daniels
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

Re: pretty strange behavior of "strip" FORGET THE LAST ONE

2008-12-05 Thread Scott David Daniels
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

Re: Good introductory book?

2008-12-04 Thread Scott David Daniels
"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

Re: unicode and hashlib

2008-12-01 Thread Scott David Daniels
"", 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

Re: Checking a string against multiple matches

2008-12-01 Thread Aaron Scott
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

Checking a string against multiple matches

2008-12-01 Thread Aaron Scott
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

Re: unicode and hashlib

2008-11-30 Thread Scott David Daniels
nd the recipient decodes the nonsense back into the message. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Debugging in Python

2008-11-29 Thread Scott David Daniels
it on, as I remember. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: end of print = lower productivity ?

2008-11-29 Thread Scott David Daniels
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

Re: Version upgrade blocked mentally

2008-11-29 Thread Scott David Daniels
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

Re: Debugging in Python

2008-11-29 Thread Scott David Daniels
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

Re: unicode and hashlib

2008-11-29 Thread Scott David Daniels
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

Re: 'new' module deprecation in python2.6

2008-11-29 Thread Scott David Daniels
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

Re: Debugging in Python

2008-11-29 Thread Scott David Daniels
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

Re: newbie question: if var1 == var2:

2008-11-29 Thread Scott David Daniels
[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,

Re: unicode and hashlib

2008-11-29 Thread Scott David Daniels
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

Re: Installing NumPy and SciPy in Python 2.6

2008-11-28 Thread Scott David Daniels
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

Re: unicode and hashlib

2008-11-28 Thread Scott David Daniels
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

Re: max(), sum(), next()

2008-11-24 Thread Scott David Daniels
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

Re: Install modules with no root privilegies

2008-11-24 Thread Scott David Daniels
location without having to cook up a custom PYTHONPATH. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't find Python Library packages in Ubuntu (Debian)

2008-11-24 Thread Scott David Daniels
y about affecting the standard environment. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Custom Formatting The Output Of subprocess.Popen

2008-11-21 Thread Scott David Daniels
[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

Re: Custom Formatting The Output Of subprocess.Popen

2008-11-21 Thread Scott David Daniels
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

Re: Using eval, or something like it...

2008-11-21 Thread Scott David Daniels
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

Re: Using eval, or something like it...

2008-11-20 Thread Scott David Daniels
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

Re: Using eval, or something like it...

2008-11-20 Thread Scott David Daniels
;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

Re: Programming exercises/challenges

2008-11-18 Thread Scott MacDonald
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

Re: Best practise hierarchy for user-defined exceptions

2008-11-18 Thread Scott David Daniels
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

Re: Suggestions for an education programming project

2008-11-18 Thread Scott David Daniels
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

Re: Comparing value in two dictionaries?

2008-11-15 Thread Scott David Daniels
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

Re: Good practice when writing modules...

2008-11-15 Thread Scott David Daniels
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

Re: Can I check if I'm running from the interpreter prompt?

2008-11-14 Thread Scott David Daniels
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

<    5   6   7   8   9   10   11   12   13   14   >