Re: Comparing 2 similar strings?

2005-05-18 Thread Scott David Daniels
William Park wrote: > How do you compare 2 strings, and determine how much they are "close" to > each other? Here's a really weird idea: Measure the size difference between the pair of strings compressed together and compressed separately. --Scott David Daniels [EMAI

Re: Python Polymorphism

2005-05-22 Thread Scott David Daniels
Joal Heagney wrote: > ... "If you're sick of answering newbie questions, and don't > think you can do so politely, for the sake of the community, > DON'T!" You're not that necessary. +1 QOTW (or at least FAQ) --Scott David Daniels [EMAIL PROTECTED] --

Re: python24.zip

2005-05-23 Thread Scott David Daniels
ecked, you might be able to drive this "failed open" time down drastically without seriously affecting those who care. Such an implementation should have a call which allowed you to "clear" the timestamps for the "known bad" entries. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: SQL Query via python

2005-05-23 Thread Scott David Daniels
e DBMS to determine how to best perform the query. This means only data can be parameterized, not table or field names). The query plan includes things like which indexes to use and what tables to access in what order. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: python24.zip

2005-05-25 Thread Scott David Daniels
be an easy test: sys.path.insert(0, 'zope.zip') or whatever. If that works and you want to drop even more, make a copy of zope.zip, update it with python24.zip, and call the result python24.zip. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: os independent way of seeing if an executable is on the path?

2005-05-26 Thread Scott David Daniels
env('PATH').split(os.pathsep): try: files = os.listdir(dirname) except IOError: continue else: for name in files: if name in tests or win32 and name.lower() in tests: yield dirname, name --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: 2D vector graphics Problem

2005-05-29 Thread Scott David Daniels
* cos + yRel self.coords = newx, newy If you define a testcase or two, you can catch things like this early. test = Point(1, 1) test.rotate(math.pi / 2) x, y = test.coords assert (x - -1) ** 2 + (y - 1) ** 2 < .1 --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: 2D vector graphics Problem

2005-05-29 Thread Scott David Daniels
Karl Max wrote: > "Scott David Daniels" <[EMAIL PROTECTED]> ha scritto nel messaggio >>... Your equation for y uses the new x, not the old x > De hi hi ho. I must sleep some more hours at night... ;-) >>Be more free with names. > > Well, I often r

Re: Unhappy with numarray docs

2005-06-01 Thread Scott David Daniels
easier for the next one in line. You don't even need to get it exactly right; the person after you can fix the mistakes you make. This is the process we use for this. See this as an opportunity to contribute, not simply a frustration about how much you overpaid for the product. --S

Re: odbc and python

2005-06-03 Thread Scott David Daniels
of your DB's schema, some other solution may do you as well. I'd be careful you don't spend far more effort getting corner cases to work right with a cobbled-together system than you'll save by using mxODBC. I am not connected to mxODBC other than as a very satisfied customer.

Re: Walking through a mysql db

2005-06-04 Thread Scott David Daniels
yle (in the DB world) to use "SELECT *" above. Name the fields you are grabbing, and your code will survive more schema changes. The contents of the table's key column(s) _is_ the unique identifier of that row, not a "row number" (which may well change on a backup-restore for example). --Scott David [EMAIL PROTECTED] [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest: collecting tests from many modules?

2005-06-12 Thread Scott David Daniels
glbl[modprefix + element] = data if __name__ == "__main__": module = type(unittest) set_globals([mod for name, mod in globals().items() if name.lower().beginswith('test') and isinstance(mod, module)]) unittest.main() --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: checking for when a file or folder exists, typing problems?

2005-06-12 Thread Scott David Daniels
ten as: if exists(r"c:\projects"): or: if exists("c:\\projects"): I suspect you problem has to do with this difference, but perhaps not. Give exact short code that actually demonstrates the problem. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding to Exception.args

2005-06-13 Thread Scott David Daniels
rap" an exception that has its own __str__ method, it may well expect the args tuple to hold a precise number of elements (and therefore fail to convert to a string). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: implicit variable declaration and access

2005-06-14 Thread Scott David Daniels
;, '.join( ['%s=%r' % (name, getattr(self, name)) for name in dir(self) if name[0] != '_'])) When I want to fiddle with named values. el = Data(a=5, b='3') el.c = el.a + float(el.b) setattr(el, 'other

Re: Going crazy...

2005-06-14 Thread Scott David Daniels
quot; without importing anything. set(['apple', 'orange', 5]) - set([5]) --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Scott David Daniels
the particular solution. > Oh well, I guess it's a bit late to try to rename the Computer > Science discipline now. The best I've heard is "Informatics" -- I have a vague impression that this is a more European name for the field. --Scott David Daniels [EMAIL PROTECTE

Re: extending Python base class in C

2005-06-14 Thread Scott David Daniels
problem -- call PyType_Ready _after_ setting up the base class, not before. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Using a base class for a factory function

2005-06-15 Thread Scott David Daniels
ne, *args, **kwargs) def __init__(self, *args, **kwargs): self.xargs = args self.xkwargs = kwargs --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Set of Dictionary

2005-06-16 Thread Scott David Daniels
= 2 What is len(ds)? Making sets of mutable things is pretty useless. You could make sets of tuple(sorted(adict.items())) if the "adict"s don't have mutable values. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Priority Queue with Mutable Elements

2007-06-16 Thread Scott David Daniels
dentical for two nodes when they have edges to each > other and no other nodes. Any suggestions on structures that can > accompany identical priority values? > > Thanks, > Chris > Make the priority value for element: (intended_value, id(element)) always a total order that obeys

Re: Interpolation of a discrete 3D trajectory

2007-06-17 Thread Scott David Daniels
f you know more about what the curve should be like, you can decide among various ways to interpolate (the term for what you want to do). I personally like the cubic B-spline because it is so easy to "understand" it visually. -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: is this a valid import sequence ?

2007-06-23 Thread Scott David Daniels
tever). You only read the global name-to-object mapping (though you may be using methods on the named object to alter the referenced object). You only need "global" when you need to "write" (re-bind) the global name-to-object mapping. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Do eval() and exec not accept a function definition? (like 'def foo: pass) ?

2007-06-23 Thread Scott David Daniels
sh(x):\ny= x * 2\nprint x, y" foolish(2.4) -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: is this a valid import sequence ?

2007-06-24 Thread Scott David Daniels
> > It's never _wrong_ to use the global statement, even if it is strictly > unnecessary for the Python compiler. Your post led a newbie to presume the extra use of global was "good style," while I think you'll find there is no such consensus. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Inferring initial locals()

2007-06-24 Thread Scott David Daniels
written with a fixed idea of what other programmers write. The others don't use introspection, the others don't use higher order functions to build functions, --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: try/except with multiple files

2007-06-24 Thread Scott David Daniels
]: files.append(open(name)) a, b, c = files finally: while files: files.pop().close() --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Portable general timestamp format, not 2038-limited

2007-07-02 Thread Scott David Daniels
noring them leaves you almost 5 digits of accuracy even when you naively ignore them. Disadvantages: time-of-day is not simple (but I maintain it shouldn't be). No external way to know if a stamp is leap-second aware or not; you'll just have to know for a whole group. Once y

Re: Implementaion of random.shuffle

2007-07-16 Thread Scott David Daniels
shabda raaj wrote: > ... Oh, I wasn't aware that I could see the source of all python modules Well, actually not _all_ (or is that __all__), but that is exactly why so many of us love Python -- no magic (or at least as little as needed). --Scott David Daniels [EMAIL PROTECTED]

Re: Relative Imports

2007-07-17 Thread Scott David Daniels
x27;s my problem? This seems like something very trivial, but I've > never had to use python for a project of this size before, so I've never > dealt with this. > > Thanks for your help, > -Pat My guess (without seeing your code or error messages; shame on you) is that yo

Re: Question about Tkinter MenuOption variable

2007-04-19 Thread Scott David Daniels
"10", Nov="11", Dec="12") or OPTIONS = dict((m, n + 1) for n, m in enumerate( 'Jan Feb Mar Apr May June July Aug Sep Oct Nov Dec'.split())) -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: I need a string/list/generator/comprehension incantation.

2007-04-20 Thread Scott David Daniels
in over your head; back up and learn to swim. -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespaces/introspection: collecting sql strings for validation

2007-04-22 Thread Scott David Daniels
modname, name) else: print "Look at %s, class %s, string %s.' % modname, class_, name) if __name__ == '__main__': import sys for modname in sys.argv[1: ]: investigate(modname, sometest) -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: clarification

2007-08-17 Thread Scott David Daniels
data1.add(splitted[1]) > > result = data.intersection(data1) lefts = set() rights = set() with open('sheet1', 'r') as fh: for line in fh: trimmed = line.strip() if trimmed: # Skip blanks (file end often looks like that) left, right = line.strip().split('\t') lefts.add(left) rights.add(right) result = lefts & rights -Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: help on object programing

2007-08-17 Thread Scott David Daniels
emporary namespace that contains Abc is hidden while Small is being defined. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I add methods to built in types with classes?

2007-08-19 Thread Scott David Daniels
CC wrote: > ... But am still a long way from seeing how I can use this OOP stuff. > ... I wrote: > from string import hexdigits > def ishex(word): > for d in word: > if d not in hexdigits: return(False) > else return(True) > Then I can do this to check if a string is

Re: introspection and functions

2007-08-22 Thread Scott David Daniels
yagyala wrote: > Hi. I would like to be able to tell, at run time, how many parameters > a function requires. Ideally I would like to be able to tell which are > optional as well. I've tried looking at the functions attributes, but > haven't found one that helps in this. How can I do this? > > Tha

Re: beginner, idiomatic python

2007-08-23 Thread Scott David Daniels
;port'): yield page ... tempList = ['1','2','3','4','5','6','7','8'] missing = dict((int(v), v) for v in tempList) for page in self.ported_pages(): if page.port in missing: missing.pop(page.port) if not missing: break sampleList = missing.values() ... -Scott David Daniels -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner, idiomatic python

2007-08-25 Thread Scott David Daniels
d algebraic properties analogous to sets. bag([1,2,3,3,4]) == bag([3,1,2,4,3]) != bag([1,2,3,4]) bag([1,2,2,3]) - bag([1,2]) == bag([2,3]) bag([1,2,3]) - bag([3,4]) == bag([1]) >>> Excellent. By symmetry, I see that "list" casts the set back into a list. Some will say 'sorted&

Re: beginner, idiomatic python

2007-08-26 Thread Scott David Daniels
n returning a range taking a parameter, > for i in f(v) > is it defined that the variable is evaluated for every loop? Nope. Take the tutorial. for i in f(v): is the same as: iterator = iter(f(v)) for i in iterator: -Scott David Daniels [EMAIL PRO

Re: Biased random?

2007-08-27 Thread Scott David Daniels
rgs.pop(key) break else: raise ValueError('Too many samples taken from the universe') return result print choose(3, a=1, b=2, c=2, d=1, e=3) -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: "Try:" which only encompasses head of compound statement

2007-08-27 Thread Scott David Daniels
is not defined You'd need to "raise" after the print, but the normal IOError failure to open message already includes the name of the file it tried to get to in an attribute "filename", so just catch it outside this code (as others have already suggested). -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: self extracting zipefile (windows) and (standard module) zipefile

2007-08-29 Thread Scott David Daniels
rather than the _beginning_ of the file. Some random file with a zip file concatenated on the end will have the same contents as the zip file. You can even point Python itself at such files and get data via: import zipfile zf = zipfile.ZipFile('something.exe') ... -Scott Da

Re: Python molecular viewer

2007-08-29 Thread Scott David Daniels
Andy Cheesman wrote: > Dear People, > > I was wondering if people could recommend a simple molecular viewing > package written in python. I'm working in Theoretical chemistry and I'm > not after an all-singing dancing molecular rendering package(pymol does > that rather well) but a program which r

Re: Pivy problem and some other stuff

2007-08-30 Thread Scott David Daniels
Marc 'BlackJack' Rintsch wrote: A fine repy > In [57]: funcs = [a, b] > In [58]: funcs > Out[58]: [, ] > > In [59]: funcs[0]() > Out[59]: 1 > > In [60]: funcs[1]() > Out[60]: 2 and a "list comprehension" allows you to call these things no matter how long the list is. So after the above: >>

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Scott David Daniels
result = 0 for die in range(count): result += random.randint(1, 6) return result -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Modul (%) in python not like in C?

2007-09-10 Thread Scott David Daniels
of code to satisfy the (usually non-existant) corner case. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Enum class with ToString functionality

2007-09-11 Thread Scott David Daniels
if name[0] != '_' and getattr(class_, name) == value: return name raise ValueError('Unknown value %r' % value) Outcome.named(2) -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: TitleCase, camelCase, lowercase

2007-03-08 Thread Scott David Daniels
Ben Finney wrote: > I prefer to use the term "title case" to refer unambiguously to > "NameWithSeveralWords", leaving the term "camel case" to describe the > case with the humps only in the middle :-) The names "TitleCase" and "camelCase&

Re: Dyanmic import of a class

2007-03-08 Thread Scott David Daniels
except (ImportError, AttributeError, SyntaxError), err: print filename, modname, err else: class_().dosomething() -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Signed zeros: is this a bug?

2007-03-11 Thread Scott David Daniels
a subtype of float, and distinguish negative zero from zero that way. Not saying I know how in portable C, but --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem I have with a while loop/boolean/or

2007-03-13 Thread Scott David Daniels
break >else: > print 'Please answer yes or no' And if you really want to see what is going wrong, replace that last by: print 'Please answer yes or no (not %r):' % hint -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: class question

2007-03-17 Thread Scott David Daniels
return '%s(%s)' % (self.name, self.age) guy = Person(age=28, name='George') gal = Person(age=31, name='Martha') kid = Person(age=1, name='Ellen', dad=guy, mom=gal) print '%s of %s and %s.' % (kid, kid.dad, kid.mom) print

Re: where function

2007-03-18 Thread Scott David Daniels
: print 'Nothing found' -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

My MVC critique

2007-03-22 Thread scott . w . white
Looking at different MVC frameworks from many langauges from PHP to Python, I've concluded that the explosion of MVC frameworks is mainly due to undisciplined & unexperienced programmers. Nobody would argue about the separation of the layers because this is not the problem I have with it, if anyth

Re: Creating a new data structure while filtering its data origin.

2007-03-29 Thread Scott David Daniels
>the easier way to get that final output. > > Thanks in advance. > > lista, wanted = ... result = {} for a,b,c in lista: inner = result.setdefault(b, {}).setdefault(c, []) if a not in inner: inner.insert(0, a) # I had used append, but ... print result == wanted --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange Behavior with Old-Style classes and implicit __contains__

2007-04-11 Thread Scott David Daniels
0... > [False, 'KeyError', False, 'KeyError', False, > 'KeyError', False, 'KeyError', False, 'KeyError'] > > > And here are the results under Python 2.4.3: > >>>> tester(10) [works] > > Looks like a bug to me. No problem with 2.5.1c1 here. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Python in a strange land: IronPython and ASP.NET at the next PyGTA

2007-04-13 Thread Scott David Daniels
affe on the wiki: > >http://web.engcorp.com/pygta/wiki/NextMeeting > > Hope to see you all there, > Mike You might mention Toronto, Ontario, Canada in an announcement to a global mailing list. -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: super() doesn't get superclass

2007-09-19 Thread Scott David Daniels
MRO is the superclass", which is what I was responding to. > One thing not pointed out in this thread is that the chain of classes on the MRO starting with super(A, obj) _will_ include all superclasses of A. That is the guarantee of the MRO, and that is why super is an appropriate name. -

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Scott David Daniels
Cristian wrote: > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > >> I think key may be to discuss names and name binding with your friend. Here's an idea: import math def sin_integral(start, finish, dx): total = 0.0 y0 = math.sin(start) for n in range(1, 1 + int((finis

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Scott David Daniels
Ron Adam wrote: > > > Scott David Daniels wrote: >> Cristian wrote: >>> On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >>> >>>> I think key may be to discuss names and name binding with your friend. >> >> Here's

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Scott David Daniels
Ron Adam wrote: > Scott David Daniels wrote: >> Ron Adam wrote: >>> How about this? >>> def integrate(fn, x1, x2, n=100):... >> The point was a pedagogic suggestion, ... > I understood your point. I just found it interesting since I've been > t

Re: Tkinter / Tk 8.5

2007-09-26 Thread Scott David Daniels
This is just a guess, but: The beta: no way for anything. 2.5.x: also very unlikely 2.6: unlikely unless release is _soon_ (first alpha of 2.6 is out) 3.0: much more likely, 3.0 won't be out for some time. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mai

Re: How to create a file on users XP desktop

2007-10-06 Thread Scott David Daniels
goldtech wrote: > ... I want the new file's location to be on the user's desktop in > a Windows XP environment > How about: import os.path handle = open(os.path.expanduser(r'~\DeskTop\somefile.txt'), 'w') ... -Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: function wrappers

2007-10-10 Thread Scott David Daniels
arguments? What is > the flux of the arguments in the program when you pass functions as > arguments? I suspect you don't understand that each time require_int is called a _new_ function named wrapper is created (and then returned). -Scott David Daniels Scott David [EMAIL PROTECTED] --

Re: Version specific or not?

2007-10-10 Thread Scott David Daniels
distinct values of M and/or N. So, if you had a shared directory, not only would your users have to be able to write to the shared directory (when they import mumble, and mumble.pyc or mumble.pyo has been generated by a different version of Python, they will recompile mumble.py and rewrite mumbl

Re: howto add a sub-directory to the searchpath / namespace ?

2007-10-11 Thread Scott David Daniels
is passed to the regular expression functions as a regex pattern parameter. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: remove header line when reading/writing files

2007-10-11 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > ... > for zipfile in filelist: > zfiter = iter(gzip.Gzipfile(zipfile,'r')) > zfiter.next() # ignore header line > for i, line in enumerate(fziter): > outfile.write(line) Or even: writes = outfile.write for zipfile in filelist: zfiter = it

Re: Problem of Readability of Python

2007-10-13 Thread Scott David Daniels
y ... performance tuning without profiling is a > waste of time. And the performance of a programmer both with and without excessive early performance tweaking has been measured time and again (we do that particular experiment _way_ too often). The early performance tweaking version loses

Re: tarfile...bug?

2007-10-13 Thread Scott David Daniels
the zip is separately compressed, so redundancy between files is not compressed out. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Safely dealing with arbitrary file objects

2007-10-14 Thread Scott David Daniels
27;2-': return DontCloseOutput(sys.stderr) else: return open(filename, 'w') # BTW, open is the preferred way # file was for a short time. You of course can do similar things (probably forwarding more message) with readopen. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: where do I need to "tab"?

2007-10-19 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > I'm following the python's translation of SICP: > http://codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages:Python:Chapter_1 > ... OK, you have a mix of Python 3,0 and current (2.5.1) Python. > a = 3 > b = a + 1 Fine in all > print a + b + (a * b) Fine i

Re: where do I need to "tab"?

2007-10-20 Thread Scott David Daniels
Gabriel Genellina wrote: > En Fri, 19 Oct 2007 23:24:30 -0300, Scott David Daniels > ... >> OK, you have a mix of Python 3,0 and current (2.5.1) Python. > > All examples are OK for 2.5 You are absolutely correct. Sorry for the misinformation. I've been working on 2.3, 2

Re: transforming list

2007-10-24 Thread Scott David Daniels
0, 0, 0, 0, 0, 0, 0, 0] else: assert report[code][1] == team if game: report[code][game + 1] = bet reports = report.values() -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Test for a unicode string

2007-10-24 Thread Scott David Daniels
> if a string will throw the error cited above). How about: if ord(max(thestring)) >= 128: print 'whatever you want' -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Parallel insert to postgresql with thread

2007-10-25 Thread Scott David Daniels
that your DB server will have to "serialize" your inserts, so unless there is some other reason for the threads, a single thread through a single connection to the DB is the way to go. Of course it may be clever enough to behave "as if" they are serialized, but mostly of your

Re: Parallel insert to postgresql with thread

2007-10-25 Thread Scott David Daniels
Erik Jones wrote: > > On Oct 25, 2007, at 7:28 AM, Scott David Daniels wrote: >> Diez B. Roggisch wrote: >>> Abandoned wrote: >>>> Hi.. >>>> I use the threading module for the fast operation. But >> [in each thread] >>>>

Re: Tkinter code (with pmw) executing to soon please help

2007-01-13 Thread Scott David Daniels
Otherwise callback returns the spectacularly un-useful value None. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing a matrix (list[][]) ?

2007-01-13 Thread Scott David Daniels
ry with the minimal value. This code raises ValueError if all entries of mat are <= 0. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Maths error

2007-01-15 Thread Scott David Daniels
Tim Peters wrote: > ... Alas, most people wouldn't read that either <0.5 wink>. Oh the loss, you missed the chance for a <0.47684987 wink>. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: A note on heapq module

2007-01-16 Thread Scott David Daniels
27;no ordering relation is defined for %s' % self.__class__.__name__) __gt__ = __le__ = __ge__ = __lt__ --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: A note on heapq module

2007-01-16 Thread Scott David Daniels
Scott David Daniels wrote: Sorry, I blew the __ne__: >> def __ne__(self, other): >> return not isinstance(other, Heap) or self.h != other.h > return not isinstance(other, self.__class__) and sorted( > self.h) != sorted(

Re: Testers please

2007-02-13 Thread Scott David Daniels
mpression, showing a factor of 9 compression -- that is, I was seeing less than a single bit required per byte in the original. -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: What is more efficient?

2007-02-18 Thread Scott David Daniels
e you one reference per object for the __dict__. -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding non ascii characters in a set of files

2007-02-23 Thread Scott David Daniels
import os.path import glob import sys for dirname in sys.path[1:] or ['.']: for name in non_ascii(glob.glob(os.path.join(dirname, '*.py')) + glob.glob(os.path.join(dirname, '*.pyw'))): print name --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists: Converting Double to Single

2007-02-26 Thread Scott David Daniels
just >> [3.5, 4.5, 5.5, 6.5, 7.5]. > > l = l[0] Or, if you want to simultaneously assert there is only one list, use unpacking like: [l] = l Although I'd prefer to use a better name than l; something like: lst = [[3.5, 4.5, 5.5, 6.5, 7.5]] [inner] = lst p

Re: Walk thru each subdirectory from a top directory

2007-02-27 Thread Scott David Daniels
yield os.path.join(root, r) ### possibly also (but I'd only go for files) #for r in dirs: #yield os.path.join(root, r) def findallfiles(base): return list(produce_all_files(base)) -- --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a c array to python list

2007-03-01 Thread Scott David Daniels
in the C array. If you don't want to see your program data as it changes, you could Create a Block and fill it. If you need Python 2.4 or 2.5, you'll need to figure out how to build from sources on Windows (I assume building from sources is otherwise "easy"). -- --Scott

Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-08 Thread Scott David Daniels
xample)? True, but these days I build my data structures first in Python to measure their effectiveness, and (sometimes) cast them into C concrete once I know the winner. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: easy 3D graphics for rendering geometry?

2007-11-08 Thread Scott David Daniels
ere it is not good enough for you, but nowhere will you find so shallow a ramp to getting to competent, relatively fully-featured, 3-D visualizations in simple, direct code. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Scott David Daniels
hat unpythonic? Right now, after: which_corner = {} corner = {} for n, position in enumerate([(1,1), (1,5), (3,5), (3,1)]): corner[n] = position which_corner[position] = n which_corner[1,5] returns 1 I would hate to have to know whether which_corner is a dict

Re: Image treshold

2007-11-10 Thread Scott David Daniels
oint" method. > But how should the 256-item mapping table look like, if the threshold > is 18( found from the histogram) Sounds like homework. You have the tools, and are close to the answer. Experiment and look at the results. -Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: easy 3D graphics for rendering geometry?

2007-11-10 Thread Scott David Daniels
gsal wrote: > By the way, VPython crashes my computer rather easily: > > - launch the editor > - open python file > - press F5 to run > - when the graphical windows appears, attempt to manipulate (drag or > resize) > - the computer looses it... Well, what kind of computer, what version of everyth

Re: easy 3D graphics for rendering geometry?

2007-11-10 Thread Scott David Daniels
gsal wrote: > I actually did look at VPython last weekend. I managed to draw a > soccer field, a few players, move them around and even record/play- > back playsI was very impressed on how easy it was to learn not > only VPython, but Python in the first...I did not know any python, > either. B

Re: security code whit python

2007-11-11 Thread Scott David Daniels
s.html You've given a full traceback, but you have spent no effort describing what your goal is or what different things you've done to solve _your_ problem. -Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: easy 3D graphics for rendering geometry?

2007-11-11 Thread Scott David Daniels
gsal wrote: > On Nov 10, 11:13 am, Scott David Daniels <[EMAIL PROTECTED]> > wrote: >> Well, what kind of computer, what version of everything (OS, Python, >> VPython), what display card, > > Windows XP Professional > Version 2002, Service Pack 2 > 1.4GHz,

Re: easy 3D graphics for rendering geometry?

2007-11-11 Thread Scott David Daniels
Scott David Daniels wrote: > gsal wrote: >> On Nov 10, 11:13 am, Scott David Daniels <[EMAIL PROTECTED]> >> wrote: >>> Well, what kind of computer, what version of everything (OS, Python, >>> VPython), what display card, >> >> Windows XP Pro

Re: Binary search tree

2007-11-13 Thread Scott Sandeman-Allen
On 11/13/07, Terry Reedy ([EMAIL PROTECTED]) wrote: >"Scott SA" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >| On 11/12/07, Scott SA ([EMAIL PROTECTED]) wrote: >| I decided to test the speeds of the four methods: >| >|set_example >|

Re: referencing a subhash for generalized ngram counting

2007-11-13 Thread Scott David Daniels
count = bigrams.setdefault(lag, {}).get(current, 0) bigrams[lag][current] = count + 1 lag = current -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Python To Change The World :)

2007-11-14 Thread Scott David Daniels
y out VPython. More than any other 3-D system I've seen, it allows you to concentrate more on your problem, and let it handle most of the 3-D rendering calculations as you are learning how to use it. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

<    8   9   10   11   12   13   14   15   16   17   >