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: 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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: [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: 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: 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: 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: 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
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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: how to get the thighest bit position in big integers?

2008-10-05 Thread Scott David Daniels
gh_bit((1<<587)-1) 587 By the way, I wrote my response before any replies had happened; it was not a correction to your post. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Array of dict or lists or ....?

2008-10-08 Thread Scott David Daniels
'] = 20 >>> base['Nebraska']['Wabash']['Newville']['Math']['curr'] += 1 >>> base['Nebraska']['Wabash']['Newville']['Math']['curr'] 1 >>> base['Nebraska']['Wabash']['Newville']['English']['curr'] 0 --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: docpicture

2008-10-14 Thread Scott David Daniels
=== end docpicture === Or similar. I'm sure people will cope, especially since it should be relatively rare. or you could even use: ''' 1234567890ABCDEF... ''' A comment _not_ a docstring (only found by scanning the source). which is ea

Re: Implementing my own Python interpreter

2008-10-14 Thread Scott David Daniels
Stefan Behnel wrote: You should take a look at Cython, which translates Python code to C. Also take a gander at RPython in the PyPy project. It is a restricted subset of Python on top of which they implement Python. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman

Re: Distributing compiled (swig) python modules

2008-10-15 Thread Scott David Daniels
miss it. Each major version change (2.3.X -> 2.4.X, 2.4.X -> 2.5.X, ...) changes the Python VM and internals. There is no way below Python source (.pyc, .pyo, or .pyd) to stay compatible. That is why Python projects offer code in Python version-specific packages. --Scott David Dan

Re: algorizm to merge nodes

2008-10-18 Thread Scott David Daniels
in do_nets([['a', 'b'], ['c', 'd'], ['e', 'f'], ['a', 'g'], ['e', 'k'], ['c', 'u'], ['b', 'p']]): print group --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: better scheduler with correct sleep times

2008-10-19 Thread Scott David Daniels
: break heapq.heappush(pending, command) queue = Queue.Queue() thread.thread.start_new_thread(queue) queue.put((time.time() + dt, callable, args, {})) ... --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: better scheduler with correct sleep times

2008-10-19 Thread Scott David Daniels
Scott David Daniels wrote: def time_server(commands): '''Process all scheduled operations that arrive on queue commands''' ... queue = Queue.Queue() thread.thread.start_new_thread(queue) > queue.put((time.time() + dt, callable, args, {})) > ... A

Re: better scheduler with correct sleep times

2008-10-19 Thread Scott David Daniels
oing after, and I just had the None in there so my tests could stop gracefully (in fact I printed the leftover queue when I was testing). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Exclude Directories from os.walk

2008-10-21 Thread Scott David Daniels
D wrote: Hello, How can one exclude a directory (and all its subdirectories) when running os.walk()? Thanks, Doug for base, dirs, files in os.walk('wherever'): if 'RCS' in dirs: dirs.remove('RCS') As described in the os.walk docs. --Scott

Re: Exclude Directories from os.walk

2008-10-21 Thread Scott David Daniels
#x27; home, final = os.path.split(canonical(forbidden)) for base, dirs, files in os.walk('wherever'): if final in dirs and home == canonical(base): dirs.remove(final) --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Resizing Tif's to smaller gifs adds pixels

2008-10-21 Thread Scott David Daniels
tif") w, h = im.size im.thumbnail((600, h * 600 // w), Image.ANTIALIAS).save("tmp/sho20080901.png") --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Type feedback tool?

2008-10-26 Thread Scott David Daniels
with: @watch def somefun(arg, defarg=1): ... ... Finally record_* could write to a data structure (using bits like function.__name__, and f.__module__, and possibly goodies from inspect). Then you wrap your actual code start with something like: try: main(...) finally: --

Re: dictionary

2008-10-27 Thread Scott David Daniels
oscilloscope traces shifting up and down. If there wasn't a metal mask over the oscilloscope with marks where the bits were, we'd have been in a world of hurt. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: using modules in destructors

2008-10-27 Thread Scott David Daniels
of what happens after SystemExit leaves the __main__ module. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a time string to a more readable date, time

2008-10-27 Thread Scott David Daniels
from.] (2) give system name and version and python version info. And finally (hoping it doesn't reward you too much for skipping steps): Look in the time module documents for localtime, gmtime, and strftime. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/lis

Re: Unpacking byte strings from a file of unknown size

2008-10-28 Thread Scott David Daniels
Mark wrote: Thanks I tested your solution and that works. One of the things that didn't work was for chunk in myfile.read(10): info1, info2, info3 = struct.unpack(' this code python interprets as: data = myfile.read(10) for chunk in data: . --Scott David Dani

Re: Need advice/suggestion for small project

2008-10-28 Thread Scott David Daniels
AEB wrote: Hello, my supervisor has requested that I write a program to display 2D waves in 3D using Python. Basically I have a time series file that has the heights of the wave over time steps, and I want to extrude these waves lengthwise so that they appear in a 3D manor. I am not very famili

Re: list versions of all installed modules

2008-10-28 Thread Scott David Daniels
ou may get more. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: split() and string.whitespace

2008-11-03 Thread Scott David Daniels
ster per-repetition (blending in to your use-case): import string SEP = string.maketrans('abc \t', ' ') ... parts = 'whatever, abalone dudes'.translate(SEP).split() print parts ['wh', 'tever,', 'lone', 'dudes'] --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Scott David Daniels
g in enumerate(args): ... print i, arg ... >>> foo(1,2) 0 1 1 2 >>> foo((1,2)) # these parens are pretty important :) 0 (1, 2) pedantically-grinning-ducktyping-and-running-ly yers, I'll see your pedantry and raise you one: >>> foo() >>> foo

Re: How do I find the memory used by a python process

2008-11-03 Thread Scott David Daniels
d live on in a cache. For this (and similar caching reasons), what you want to see is that memory doesn't grow in an unbounded way. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python 2.6 on Vista

2008-11-12 Thread Scott David Daniels
dle's improper use of the format_warning and show_warning stuff turns the waning into an error. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple question about Python lists

2008-11-12 Thread Scott David Daniels
nse, but in this case MATLAB seems easier and no less readable. That said, I know better than for a newbie like me to question syntax issues. If you are using numpy, you may find found the following link useful: http://www.scipy.org/NumPy_for_Matlab_Users --Scott David Daniels [EMAIL PR

Re: Using the result of type() in a boolean statement?

2008-11-12 Thread Scott David Daniels
elif issubclass(type(value), str): # do the string logic --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

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: 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: 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: 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: 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: 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-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: 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: 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: Python Imaging Library (PIL): create PDF from scratch

2009-02-23 Thread Scott David Daniels
. I'm not even sure that PIL is the right library for that. Any help/informations will be appreciate Use PIL to fiddle the individual images, and reportlab to build a pdf from the (now tweaked) images. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: coding style - try, except

2009-02-25 Thread Scott David Daniels
tributeError, ValueError), why: # Don't use bare except print "Oops something didn't work: %s" % why else: do something 3 do something 4 ... do something 25 --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Using xreadlines

2009-02-27 Thread Scott David Daniels
y this: The simplest way to solve this for the moment is (re)defining xreadlines: def xreadlines(source): for line in iter(src.readline, ''): yield line --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How best to test functions which use date.today

2009-02-28 Thread Scott David Daniels
sut.date = temp Note: each test should test 1 thing. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeErrors

2009-03-01 Thread Scott David Daniels
(needle) * [needle] depending on the needed result (until values starts returning an iterator). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: qt, gtk, wx for py3 ?

2009-03-03 Thread Scott David Daniels
le in a "grab and modify" way. Qt: simplest model, well-documented, until very recently not available on Windows w/o a restrictive license or substantial cost. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about binary file reading

2009-03-04 Thread Scott David Daniels
t something like this: import binascii fd = open(filename, 'rb') fd.seek(0x80) x = fd.read(8) print binascii.hexlify(x) fd.close() --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Roulette wheel

2009-03-05 Thread Scott David Daniels
first yield second def random_crossing(population, probability=0.6): '''This chooses random pairs from the population. ''' shuffled = list(population) # make a copy random.shuffle(shuffled) # mix it up return list

Re: Is there a better way of doing this?

2009-03-06 Thread Scott David Daniels
e, choice) yield candidates[first], candidates[second] --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: create boolean

2009-03-07 Thread Scott David Daniels
and more readable than short-circuited operations. How about: b = None is not n != [] It is amazing to think about how rarely we consider is / is not as a comparison operator. Also, and more reasonably, we often don't consider "chaining" comparisons that are intransitive.

Re: Help cleaning up some code

2009-03-07 Thread Scott David Daniels
d] is None: ad[field] = 'None' if ni != ad['ni']: if ni is UNSET: ni = ad['ni'] else: break stack.append(ad) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 3.1 alpha 1

2009-03-07 Thread Scott David Daniels
Benjamin Peterson wrote: On behalf of the Python development team and the Python community, I'm happy to announce the first alpha release of Python 3.1. Congratulations on the release. I know 3.0 didn't have installers built for the alphas, will that be the case for 3.1? --Scott Dav

Re: Windows install to custom location after building from source

2009-03-08 Thread Scott David Daniels
those of us not on the MS compiler upgrade train to do a little alpha (and/or beta) testing as well. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython fast and slow

2009-03-08 Thread Scott David Daniels
iu2 wrote: Here is the timer version. It works even more slowly, even with PyScripter active: ... I actually tried this one first. Due to the slow speed I changed to looping inside the event. I don't understand why it takes so long to move that square with wx.Timer set to 1 ms interval. Perhaps

Re: Guidance - Professional Python Development

2009-03-08 Thread Scott David Daniels
ion without trying will have you skipping too many good ideas. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: [JOB] Short-term python programming consultant - funds expire soon!

2009-03-10 Thread Scott David Daniels
post this most effectively. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: "Byte" type?

2009-03-12 Thread Scott David Daniels
ms to check out their behavior. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: "import" not working?

2009-03-12 Thread Scott David Daniels
s, I prefer single quotes unless doubles are needed). I solve the trailing backslash problem as so: sys.path.append(r'C:\DataFileTypes' '\\') --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.7 MSI / pywin32 snapshots [was: Windows install to custom location ...]

2009-03-12 Thread Scott David Daniels
Tim Golden wrote: Scott David Daniels wrote: Tim Golden wrote: ... Anyhow, at the end I have a working Python 2.7a0 running under Windows. Do you mean 3.1a0? As far as I know, 2.7a0 requires the use of the time machine, as it is expected to be 3 months out. If you do get an installer built

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Scott David Daniels
t easily usable thing, and provide a way to swap the commas and periods. The rest can be ponied in by string processing. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: loop performance in global namespace (python-2.6.1)

2009-03-12 Thread Scott David Daniels
while True: time.sleep(.1) counter *= 2 For that matter, it could do ... del counter ... and force a NameError in your second loop. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: converting a string to a function parameter

2009-03-13 Thread Scott David Daniels
ll parameters from a call''' return _nargs, _kwargs ... nargs, kwargs = eval('_args(%s)' % arglist ... test(*nargs, **kwargs) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Special keyword argument lambda syntax

2009-03-13 Thread Scott David Daniels
ably a mistake: somefun(something, key(x)==5) somefun(something, key(x)=5) Right now a syntax error makes you look there, after your extension, only test cases will show these problems. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: [ActivePython 2.5.1.1] Why does Python not return first line?

2009-03-16 Thread Scott David Daniels
e you had to print a printing character, we used ASCII NULs (though I have seen rub-out used as well) to finish the time delay needed. Since we needed eight (or was it twelve) chars of delay, this driver substantially improved the print speed for our listings. --Scott David Daniels scott.dan

More copyright briefs

2009-03-16 Thread Scott David Daniels
ticle.php?story=20090310172906129 -Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-16 Thread Scott David Daniels
higher priority than the other operators. > print(" %d, " " %d, buckle my shoe" % (1,2)) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to add months to a date?

2009-03-16 Thread Scott David Daniels
So, I see nobody has seen fit to make the obvious joke. I will demonstrate my lack of restraint, by answering: The way to add months to a date is to begin by asking about your date's early childhood. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/lis

Re: error writing str to binary stream - fails in Python 3.0.1, works in 2.x

2009-03-16 Thread Scott David Daniels
R. David Murray wrote: ... Here is some example code that works: out=open('temp', "wb") out.write(b"BM") def write_int(out, n): bytesout=bytes(([n&255), (n>>8)&255, (n>>16)&255, (n>>24)&255]) out.write(bytesout) write_int(out, 125) or even: import struct

Re: Style formating of multiline query, advise

2009-03-18 Thread Scott David Daniels
sier, not a durable way to write queries. query = """SELECT a.columna, a.columnb, a.iso, b.id, ... FROM all AS a, other as b WHERE a.name = LOWER(%s) AND a.gid = b.id AND b.class = 'A' ORDER BY population DESC LIMIT %s;""" --Scot

Re: Tuple passed to function recognised as string

2009-03-18 Thread Scott David Daniels
is the same as X (parentheses are for grouping), to get a singleton, you need (X,). 3 is just a 3 with a bunch of meaningless parens around it. So, you want: test_func(val=('val1',)) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in Python? - A "gotcha"

2009-03-19 Thread Scott David Daniels
True u'' == '' True Ah, you misunderstand the short-term expedient that 2.6 took. Effectively, it simply said, bytes = str. In 2.6: >>> str is bytes True in 3.X: >>> str is bytes False >>> b'' == '' False >>> type(b''), type('') (, ) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Preferred syntax for the docstrings

2009-03-19 Thread Scott David Daniels
g): '''A trap: never use 'def' as an arg name. In which Doris gets her oats. ''' return 3 >>> f( And at this point pause a second, the hint will appear. I use both this and "print(a.b.__doc__)" regularly for reminders of what I have once read. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple question about yyyy/mm/dd

2009-03-19 Thread Scott David Daniels
Look into time.strptime --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

<    11   12   13   14   15   16   17   18   19   20   >