Re: import and package confusion

2009-04-29 Thread Scott David Daniels
you should investigate __import__. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacing files in a zip archive

2009-04-30 Thread Scott David Daniels
your zip grows with every change. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: string processing question

2009-04-30 Thread Scott David Daniels
To discover what is happening, try something like: python -c 'for a in "ä", unicode("ä"): print len(a), a' I suspect that in your encoding, "ä" is two bytes long, and in unicode it is converted to to a single character. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: using zip() and dictionaries

2009-04-30 Thread Scott David Daniels
rint [id(x) for x in [[] for x in header]] So, I think you should use: columnMap = dict(zip(header, ([] for x in header))) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Tools for web applications

2009-04-30 Thread Scott David Daniels
e IPython shell, and I would suffer if I didn't have it in postgres, but not while editing python. You'd be amazed at how much ActiveState's Python _can_ and _does_ guess/infer about available methods. It is pretty fancy (even for an old stick-in-the-mud "Lave my keyboard alone&q

Re: Replacing files in a zip archive

2009-04-30 Thread Scott David Daniels
#x27;two.xml', "I don't give a damn.") nz.writestr('one.xml', 'Frankly, Scarlett, ') nz.close() Which will produce the same output as the original, confounding your user. You could just write the new values out, since .read picks the last entry (as I

Re: string processing question

2009-05-01 Thread Scott David Daniels
Kurt Mueller wrote: Scott David Daniels schrieb: To discover what is happening, try something like: python -c 'for a in "ä", unicode("ä"): print len(a), a' I suspect that in your encoding, "ä" is two bytes long, and in unicode it is converted to to a

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Scott David Daniels
well past the time SomeClass is fully built. Typically, classmethod is used to provide alternate constructors for a class, though it does have other uses. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: object query assigned variable name?

2009-05-01 Thread Scott David Daniels
ollowing code to print?: print 'NoneUnique:', Spam() is Spam() Objects are created and then used somehow (including being put somewhere), not created int a "variable." --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] .pth files are evil

2009-05-01 Thread Scott David Daniels
convenience tools (dinky little functions and classes that I would otherwise waste time scratching together each time I needed them). They obviate the need to fiddle with site.py. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension question

2009-05-01 Thread Scott David Daniels
tree abstraction should be responsible for producing its leaves, rather than a blunderbus that doesn't know where one container abstraction ends, and its contents begin. In other words, I'd like to see thigs like "flatten one layer." --Scott David Daniels scott.dani...@acm.org

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Scott David Daniels
am return "spam is a tasty %s-like food product" % func(self) TypeError: ham() takes exactly 1 argument (2 given) Now it is tough to use obj. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: AutoComplete in C++ Editor for Python

2009-05-04 Thread Scott David Daniels
a has the type of its current value. any kind of object can be stored in any variable. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Self function

2009-05-04 Thread Scott David Daniels
node = node.right Not so hard, really. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Scott David Daniels
ed it for assignment statements, causing much consternation when our source code displayed funny on new-fangled terminals. So, just an unfortunate setting on the time machine is the basic flaw. --Scott David Daniels @Acm.Org -- http://mail.python.org/mailman/listinfo/python-list

Re: exit a program gracefully

2009-05-05 Thread Scott David Daniels
here ... What's wrong with: for _ in (None,): ... do stuff ... if (check1_failed) break; ... do even more stuff ... ... cleanup ... --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with case insensitive volumes

2009-05-05 Thread Scott David Daniels
base, dirs, files = next(os.walk(dirn)) # older: os.walk(dirn).next() current = dict((name.upper() for name in dirs + files) ... changed = some_name == current[some_name.upper()] ... --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: pyc files problem

2009-05-06 Thread Scott David Daniels
ces and re-isolate until you have a small bit of code with the issue. This is why we point people to smart-questions(*) so often. (*) http://www.catb.org/~esr/faqs/smart-questions.html --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Separate Windows versions of Python

2009-05-06 Thread Scott David Daniels
ages directory, Python 2.6 and later will use it to find .pth, .py, .pyw, and .pyd files (as well as .pyc and .pyo files). You may find changing your personal site-packages directory (and/or a .pth therein that you manipulate) will address the issues that you are planning to solve with virtualenv.

Re: Parsing text

2009-05-06 Thread Scott David Daniels
ning the sample code with the sample data. For extra points, identify the Python version you are using. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Copy & Paste in a Dos box

2009-05-06 Thread Scott David Daniels
is rather literal, so be careful if copy/pasting more than one line, or a line that was wrapped. Also, you can type into the cmd window: Alt-Space E P Alt-Space E P --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python

Re: [Python-Dev] [RELEASED] Python 3.1 beta 1

2009-05-07 Thread Scott David Daniels
ng as fidgety as multiprocessing. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: [RELEASED] Python 3.1 beta 1

2009-05-07 Thread Scott David Daniels
CTO wrote: ... If OrderedDict winds up being backported, will you include it in 2.x? I see it in the 2.7 sources. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Scott David Daniels
octets if you prefer), and not use it if what you expect is "text." Your code becomes less confusing by using 'b' properly, even if you see no particular difference. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Compiling snippets of python code

2009-05-08 Thread Scott David Daniels
x27;t borrow trouble you don't need. Rethink your problem and write it in Python. Don't try to do a line-by-line translation, you'll just have a slow awkward Python program with a Java heart. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Tutorial or example use for python-graph library

2009-05-08 Thread Scott David Daniels
n real- world code, using this package? My google-fu wasn't strong enough to find anything directly :-( Try writing one yourself, as you are learning the interface. The package authors will love it, and will probably be overjoyed to help you as you stumble. --Scott David Daniels

Re: unicode bit me

2009-05-08 Thread Scott David Daniels
d unicode to that destination. If you are running under IDLE, print goes to the output window, and if you are running from the command line, it is going elsewhere. the encoding that is being used for output is sys.stdout.encoding. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Path difficulties with Python 2.5 running on Cygwin

2009-05-08 Thread Scott David Daniels
esn't match the corresponding .py file, the .py (or .pyw) file is "compiled into either a .pyc or .pyo, and the contents of that .pyc or .pyo are used to build the module. So, importing a module will write a .pyc or .pyo file unless an appropriate .pyc or .pyo file is found. --Scott David Dani

Re: How to debug this import problem?

2009-05-08 Thread Scott David Daniels
iles are getting imported from the file system and when. "-v" iswhat it got, "-vv" is everywhere it tries. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Complete frustration

2009-05-08 Thread Scott David Daniels
pyw=Python.NoConFile C:\Projects> ftype Python.NoConFile Python.NoConFile="C:\Python31\pythonw.exe" "%1" %* It is possible you installed something that switched those settings. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Complete frustration

2009-05-08 Thread Scott David Daniels
way, it is safe to simply uninstall-reinstall a python .msi in order to make that version of python be the default. uninstalling only removes that which it installs, so after a reinstall, your other libraries are still safely there. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: slice iterator?

2009-05-08 Thread Scott David Daniels
oblem were to be split into groups of 3, I've tried something like: ... Ideally, my outcome would be [1,2,3] [4,5,6] [7,8,9] [10,11,12] for i in range(0, len(a), 3): segment = a[i : i +3] print segment --Scott David Daniels scott.dani...@acm.org -- http://mail.python.o

Re: need help with properties

2009-05-09 Thread Scott David Daniels
print r.size print '-' r.size = -3,7 print r.size --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: heapq.merge with key=

2009-05-09 Thread Scott David Daniels
for stream in streams] for element in heapq.merge(*keyed_streams): yield element.obj --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-09 Thread Scott David Daniels
return 'two' def __str__(self): return 'three' b = B() print b, unicode(b), [b] By the way, pasting code with non-ASCII characters does not mean your recipient will get the characters you pasted. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: need help with properties

2009-05-09 Thread Scott David Daniels
fraught with traps for newbies, who might want to ask for, for example: def setter(self, (height=4, width=3)): the Python 3.X world is wisely losing the unpacking in parameter passing trick. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrapping comments

2009-05-09 Thread Scott David Daniels
nk of your reader, not just your operational environment, unless you are programming on your own and don't care to share. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Get multiprocessing.Queue to do priorities

2009-05-09 Thread Scott David Daniels
uuid wrote: Any recommendation on an alternate way to build a priority queue to use with a "one producer, many consumers" type multiprocessing setup would be welcomed! ? "one producer, many consumers" ? What would the priority queue do? Choose a consumer? --Scott Davi

Re: Get multiprocessing.Queue to do priorities

2009-05-09 Thread Scott David Daniels
uuid wrote: Scott David Daniels wrote: ? "one producer, many consumers" ? What would the priority queue do? Choose a consumer? Sorry, I should have provided a little more detail. There is one producer thread, reading urls from multiple files and external input. These urls have

Re: Wrapping comments

2009-05-09 Thread Scott David Daniels
ct? At least vim and emacs can do so. Some other editors redefine standards in order to make their work easier. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: import overwrites __name__

2009-05-09 Thread Scott David Daniels
re[0] - post[0]) print 'Globals added: %s, removed: %s' % ( post[1] - pre[1], pre[1] - post[1]) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-09 Thread Scott David Daniels
()]) '[repr]' Now if you ask _why_ call repr on its elements, the answer is, "so that the following is not deceptive: >>> repr(["a, b", "c"]) "['a, b', 'c']" which does not look like a 3-element list. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: import overwrites __name__

2009-05-10 Thread Scott David Daniels
, 'size', len(dir()) from x import y as z print __name__, 'size', len(dir()), 'completed import of', z try: print my_name except NameError, e: print '%s found unhandled NameError: "%s"' % (__name__, e) sys.exit() produces: __main__ __main__ size 8 x x size 6 x size 7 completed import of 42 x found unhandled NameError: "name 'my_name' is not defined" --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrapping comments

2009-05-10 Thread Scott David Daniels
e in Portland, where you'd better recycle it. ;) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Q's on my first python script

2009-05-10 Thread Scott David Daniels
starting with a lowercase g is removed :) You (the OP) don't seem to know about PEP 8, which advises 4-space indents, all-caps constants, and many more style specifics. http://www.python.org/dev/peps/pep-0008/ --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: help with recursive whitespace filter in

2009-05-10 Thread Scott David Daniels
ild(c) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the use of the else in try/except/else?

2009-05-10 Thread Scott David Daniels
y there?') as opposed to: try: v = mumble.field sys.warning('field was actually there?') except AttributeError: pass The idea is to make it clear what you expect might go wrong that you are prepared to handle. --Scott David Daniels scott.dani...@a

Re: Can I get a value's name

2009-05-11 Thread Scott David Daniels
: def find_names(value, dictionary): for name, val in dictionary.items(): if val is value: # note: "is", not "==" yield name x = 123456 y = 123456 * 3 // 3 z = 123456.0 q = y print list(find_names(y, locals())) --Scott Davi

Re: What's the use of the else in try/except/else?

2009-05-13 Thread Scott David Daniels
ibuteError: pass Then you could easily fail to notice that you had written 'warming' instead of 'warning'. Well, if you look, you'll discover that warning is not in the sys module at all, but in the logging module. So the original example already demonstrated t

Re: putting date strings in order

2009-05-14 Thread Scott David Daniels
precip_feb', 'precip_mar', 'precip_apr', 'precip_may', 'precip_jun', 'precip_jul', 'precip_aug', 'precip_sep', 'precip_oct', 'precip_nov', 'precip_dec'] * 2 start = 2 ordered_raster_list = multi_months[start - 1: start + 11] --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: C API: how to replace python number object in place?

2009-05-14 Thread Scott David Daniels
_foot = %s' % ( month, inches_per_foot)) might print: Month is now: 11, inches_per_foot = 11 --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the formal args of a function object?

2009-05-14 Thread Scott David Daniels
=> 0.49998662654663256 What would your missing something be for tracer(math.sin)? --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the formal args of a function object?

2009-05-14 Thread Scott David Daniels
norseman wrote: Scott David Daniels wrote: kj wrote: Suppose that f is an object whose type is 'function'. Is there a way to find out f's list of formal arguments?... I can write a wrapper now: def tracer(function): def internal(*args, **kwargs): print

Re: PYTHONPATH on Windows XP module load problem

2009-05-19 Thread Scott David Daniels
(writing a setup.py, using "python setup.py build"; "python setup.py install", you would discover, by what I would guess to be your astonishment, that a .pyd file got put in site-packages or wherever. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: PYTHONPATH on Windows XP module load problem

2009-05-20 Thread Scott David Daniels
ld with mingw32, not the full-blown gcc environment when working on Windows at home. When at work, it is my employer's choice what tools I use (Visual C/C++, Intel C/C++ on Windows usually; more varied on *ix). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Overlapping region resolution

2009-05-21 Thread Scott David Daniels
is: (start, -end) Maybe it will prove helpful to you as well. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for module for shrinking a list with n-point means

2009-05-22 Thread Scott David Daniels
) v.shape = (16, 8) sum(v.transpose()) / 8. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: package questions

2009-05-22 Thread Scott David Daniels
hing like: C:\sound\effects> cd C:\ C:\> python -m sound.effects.surround (2) you can run python -v surround.py or python -vv surround.py To see files opened (or attempted and opened for -vv) in order to discover what exactly is tried and in what order on imports. Warning: the o

Re: package questions

2009-05-22 Thread Scott David Daniels
at least identified. I expect nobody wants to crawl into that code to make your case work, especially since you can switch to 2.6 and have it work. The import code is said to be quite nasty and being rewritten/redocumented. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: package questions

2009-05-22 Thread Scott David Daniels
Daniel wrote: Thanks for doing the experiment. I'll begin to consider testing with python 2.6 for a possible upgrade. I hope you know you can have different minor versions installed simultaneously. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/p

Re: How does Python's OOP feel?

2009-05-24 Thread Scott David Daniels
fining and declaring types on creating test cases. Then you have nicely unit-tested code for only a bit more effort than you had to spend on gettting a program to run before. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: 4 hundred quadrillonth?

2009-05-25 Thread Scott David Daniels
I'd call it F_3, but using a Germanic F (Farey sequence limit 3). Do I get a banana or one with a few more ans? --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Regarding sort()

2009-05-26 Thread Scott David Daniels
ndidate is coming 30-May, with final release on 27-June: http://python.org/dev/peps/pep-0375 --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create a list of functions depending on a parameter?

2009-05-26 Thread Scott David Daniels
f = [functools.partial(add, n) for n in range(0)] --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: replacement for execfile

2009-05-26 Thread Scott David Daniels
to ask them to define a particular module and go names inside that module. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I sample randomly based on some probability(wightage)?

2009-05-27 Thread Scott David Daniels
#x27; % ( sum(1 for w in weights if w > 0))) for n in range(10): gen = sample_without_replacement('abcdef', [32,16,8,4,2,1]) print gen.next(), gen.next(), gen.next() --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Building mySQL-python with python 2.6

2009-05-27 Thread Scott David Daniels
Christian Heimes wrote: abolotnov schrieb: Hi, I am trying to build mySQL-python with python 2.6 on windows and can't figure what's wrong with it. ... You need Visual Studio 2008. Other versions of VS aren't supported by Python 2.6. You might be able to use mingw32 as well.

Re: download all mib files from a web page

2009-05-27 Thread Scott David Daniels
p=u.read() open(filename,"w").write(p) with this: try: u = urllib2.urlopen(link) p = u.read() except urllib2.HTTPError: pass else: dest = open(filename, "w") dest.write(p) dest.close() --Scott

Re: Inheritance and Design Question

2009-05-27 Thread Scott David Daniels
2, 123, 1234, 12345, 123456, 1234567: print '%s\t%s=%r\t%s=%r' % (n, GroupedInt(n), GroupedInt(n), GroupedInt(-n), GroupedInt(-n)) 1 1=1 -1=-1 12 12=12 -12=-12 123 123=123 -123=-123 12341_234=1234 -1_234=-1234 12345 12_345=12345-

Re: What is the purpose of "struct" and "array" modules

2009-05-28 Thread Scott David Daniels
-file and file-to-Python, where the other user of the file may be a completely different program. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: [JOB] Plone Developer, Washington, D.C. - Relo OK | 55-75k

2009-05-29 Thread Scott David Daniels
OSS wrote: Plone Developer, Washington, D.C. - Relo OK | 55-75k You should post this to the Python Jobs board, and not here. http://www.python.org/community/jobs/ --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I sample randomly based on some probability(wightage)?

2009-05-31 Thread Scott David Daniels
Sumitava Mukherjee wrote: On May 27, 8:08 pm, Scott David Daniels wrote: Sumitava Mukherjee wrote: I need to randomly sample from a list where all choices have weights attached to them. The probability of them being choosen is dependent on the weights. I am not sure why everybody is

Re: hash and __eq__

2009-05-31 Thread Scott David Daniels
n a worst-case analysis. I suspect the default is shifting towards average case (although it may already be there). Certainly best practice for the next couple of decades would be to be explicit about the meaning --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I sample randomly based on some probability(wightage)?

2009-05-31 Thread Scott David Daniels
Peter Otten wrote: Scott David Daniels wrote: [a real correction and a bogus one] raise ValueError('Samplng more than %d without replacement?' % ( sum(1 for w in weights))) That would be len(weights) Yup, probably I should have just saved len(combined). but I think your first v

Re: Generating all combinations

2009-05-31 Thread Scott David Daniels
.html#itertools.product (new in 2.6, but code works in lower versions). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating all combinations

2009-05-31 Thread Scott David Daniels
member thudfoo wrote: On 5/31/09, Scott David Daniels wrote: Johannes Bauer wrote: I'm trying to write a function in Python which ... Look here: http://docs.python.org/library/itertools.html#itertools.product (new in 2.6, but code works in lower versions). How would one go

Re: BMP32 for linux

2009-06-01 Thread Scott David Daniels
Djames Suhanko wrote: Hello, all! Did you know the bmp32 module for linux? This module can to load bmp image with alpha channel where is not supported others images formats. Hmmm, why do you think PNG and TGA do not support alpha? --Scott David Daniels scott.dani...@acm.org -- http

Re: BMP32 for linux

2009-06-01 Thread Scott David Daniels
buntu. Sounds like this might be a capability problem on your embedded system. Look for and install PIL (the Python Imaging Library). It might help if you are not simply running up against hardware issues. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Challenge supporting custom deepcopy with inheritance

2009-06-01 Thread Scott David Daniels
re, but one of intent. A true deepcopy could survive making a copy of the number 23, but might fail as it makes a copy of None, True, or False. Certainly a dictionary might or might not be copied, depending on how the dictionary is used. --Scott David Daniels scott.dani...@acm.org -- http://mail.py

Re: Challenge supporting custom deepcopy with inheritance

2009-06-02 Thread Scott David Daniels
Michael H. Goldwasser wrote: On Monday June 1, 2009, Scott David Daniels wrote: Michael H. Goldwasser wrote: > I'll accept the "small price for flexibility" that you > note, if necessary. However, I still desire a cleaner solution. You seem to thi

Re: do replacement evenly

2009-06-02 Thread Scott David Daniels
(with smooth left and right margins) works well for proportional fonts, but decreases readability for fixed pitch fonts, where ragged right (or ragged left) works better. Sadly, I have no idea where I read that as it is only in the recesses of my somewhat addled brain. --Scott David Daniels scott.dani

Re: easiest way to plot x,y graphically during run-time?

2009-06-03 Thread Scott David Daniels
et an idle window with the -n switch on (so you are using the idle "in-process") to see the effects of each Tkinter operation as you go. You can then run these operations in place, seeing results and effects. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: easiest way to plot x,y graphically during run-time?

2009-06-04 Thread Scott David Daniels
Esmail wrote: Scott David Daniels wrote: Esmail wrote: ... Tk seems a bit more complex .. but I really don't know much about it and its interface with Python to make any sort of judgments as to which option would be better. This should look pretty easy: Thanks Scott for taking the ti

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Scott David Daniels
accessing them. Requiring that the C++ compiler used to make the dll's/so's to be the same one Python is compiled with wouldn't be too burdensome would it? And what gave you then impression that Python is compiled with a C++ compiler? --Scott David Daniels scott.dani...@

Re: Odd closure issue for generators

2009-06-04 Thread Scott David Daniels
t;>> i = 'Surprise!' >>> print([f() for f in c]) [11, 12, 13, 14, 15] When you evaluate a lambda expression, the default args are evaluated, but the expression inside the lambda body is not. When you apply that evaluated lambda expression, the expression inside the lambda body is is evaluated and returned. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: anonymous assignment

2008-05-12 Thread Scott David Daniels
Yves Dorfsman wrote: ... Sorry this was a typo (again :-), I meant: d = time.local() y = d[0] d = d[2] Then: y, d = list(time.localtime())[:4:2] --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: working with images (PIL ?)

2008-05-17 Thread Scott David Daniels
it offers the needed functionality. Does anyone have suggestions of other image libraries I should be looking at it, or if PIL can do what I need? If PIL's "histogram" method doesn't give you a clue how you might do this, hire someone to do it. --Scott David Dan

Re: can't delete from a dictionary in a loop

2008-05-17 Thread Scott David Daniels
in list(procs_dict): ... --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Write bits in file

2008-05-19 Thread Scott David Daniels
e than the "byte sex" issue (go ahead, look it up). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: test mult vars to same value, how to shorten expr?

2008-05-19 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: if i want o test: if a == 5 and b ==5 and c==5 ... z==5 is there some synctactic suagr for this? rather than maiking one of my own i mean, something built-in like: if a,b,c... z == 5: How about: if 5 == a == b == c == ... z: ... --Scott David Daniels

Re: Removing Space and "-" from a string

2008-05-20 Thread Scott David Daniels
27;.join( [ c for c in input if c not in ' -' ] ) output '858215558' If you are planning to do a lot of strings: identity_trans = ''.join(chr(x) for x in range(256)) Then you can do simply: input = '8 58-2155-58' output = input.translate(identity_trans,

Re: iterate start at second row in file not first

2008-05-20 Thread Scott David Daniels
Mark d. wrote: How about: mov = open(afile) line = mov.readline() ...(process your ':' line) for line in mov.readlines(): ... The problem here is that you read the entire file in in the call to readlines. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailma

Re: about python modules

2008-05-21 Thread Scott David Daniels
s). Put this file in your site-packages file (for windows in your case, that is C:\Python25\Lib\site-packages --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Unhandled exceptions checking

2008-05-24 Thread Scott David Daniels
t;thinko"s, embrace what they tell you, and don't look for mechanical ways to avoid them; test them out. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Code correctness, and testing strategies

2008-05-24 Thread Scott David Daniels
e untested code, because there was no test that made you write it. If you want to do code coverage, find a code coverage tool and count your code while runnign your unit tests. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

QOTW

2008-05-25 Thread Scott David Daniels
D'Arcy J.M. Cain wrote: Yes! One of the biggest advantages to unit testing is that you never ever deliver the same bug to the client twice. Delivering software with a bug is bad but delivering it with the same bug after it was reported and fixed is calamitous. QOTW for sure. --Scott

Re: Code correctness, and testing strategies

2008-05-25 Thread Scott David Daniels
y times you repeat the same "hand-test" of some code on a subsequent version. Think of how much time that can add up to if you no longer do that; you had-tesing time is subtracting from the time you have to do unit tests. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/ma

Re: raising an exception when multiple inheritance involves same baseThank

2008-05-25 Thread Scott David Daniels
forbidden multi-roots, you could # test if set(trouble) & forbidden_multi_parents: ... if object in trouble: trouble.pop(object) # Avoid simply new-style classes for common_ancestor, progeny in trouble.items(): print common_ancestor.__n

Re: Code correctness, and testing strategies

2008-05-25 Thread Scott David Daniels
ck event system that connects to your code and provides specific event chains and "expects" certain responses. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting a set of lambda functions

2008-05-25 Thread Scott David Daniels
t;lambda i=i: i)", but if you don't know the idiom, I find the "i=i" part confuses people. (2) Use something like functools.partial. if you are simply binding different args to the "same" function: import functools def thefunction(x): return

<    13   14   15   16   17   18   19   20   21   22   >