Re: binascii.a2b_binary

2006-04-03 Thread Scott David Daniels
quot;); What, you mean like: int('0011001100110101', 2) Which you could show as: hex(int('0011001100110101', 2)) I guess because Python is not so wonderful as Perl. Apparently Python stupidly forgot to follow Perl's great naming conventions. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Oserror: [Errno 20]

2006-04-03 Thread Scott David Daniels
s' in files: file = FITS.Read(os.path.join(root, 'flux.fits')) if root != DATADIR: del dirs[:] # Stop recursing after the first descent) depending on whether you know 'flux.fits' should be there or you only want to work on subdirs where it is in the directory. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: can I get the index number in for x in y loop?

2006-04-03 Thread Scott David Daniels
ex number with b format..:( Well, that's true, but it is a bit like saying: I cannot find the distance in meters between Paris and London with: for i in range(10): print i --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] markup.py - 1.2 - an HTML/XML generator

2006-04-03 Thread Scott David Daniels
ng underscore rather than use an abbreviation or spelling corruption. Thus "print_" is better than "prnt". (Perhaps better is to avoid such clashes by using a synonym.) Reference: http://www.python.org/dev/peps/pep-0008/ --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: how to convert string

2006-04-05 Thread Scott David Daniels
print >>dest print repr(dest.getvalue()) prints: '0 1 2 3 4 5 6 7 8 9\n' -- -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: how relevant is C today?

2006-04-09 Thread Scott David Daniels
a "big" language, while C is a "small" one; it will take much longer to "know" C++ even though C++ started with the goal of being "C with objects." If you are interested in languages, reading "the Design and Evolution of C++" is a great base; it explains

Re: More pythonic circle?

2006-04-09 Thread Scott David Daniels
][max(0, x + dx)] = entry field[max(0, y + dx)][x] = entry return field There is still overlap done at x = y and x = -y; you could squeeze that out as well by changing wedge_nz not to put it out, and making circle2 do diagonal diameters as well (leaving the center the sole overwrite). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Characters contain themselves?

2006-04-10 Thread Scott David Daniels
and somehow you couldn't have an issue with characters in strings, you would have to deal with this: simple_list = [3.1415] container = [simple_list] simple_list.append(container) Your function (and mine) assumes the argument is a DAG (Directed Acyclic Graph), but there is no such guarantee about data structures in python. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: how relevant is C today?

2006-04-10 Thread Scott David Daniels
finition was completely machine-independent). > 3) C - The "Latin" of modern programming languages. Used in low level > tasks (e.g. - hardware drivers) as well as larger projects (e.g. - > operating systems and other programming languages). Logcal, explicit > flow albe

Re: import help

2006-04-10 Thread Scott David Daniels
t; > > Does anyone know what the problem is here? I have trouble believing you. I suspect you are telling us what you think is happening, and leaving something vital out. In particular, cut and paste the traceback. Here's another experiment, interactively do: import node pri

Re: Sorting a list of objects by multiple attributes

2006-04-11 Thread Scott David Daniels
Kent Johnson wrote: > In Python 2.5 you can do this with operator.attrgetter(): > L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey')) Note: this is also available in Python 2.4 --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting a list of objects by multiple attributes

2006-04-11 Thread Scott David Daniels
Kent Johnson wrote: > Scott David Daniels wrote: >> Kent Johnson wrote: >>> In Python 2.5 you can do this with operator.attrgetter(): >>> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey')) >> >> Note: this

Re: requestion regarding regular expression

2006-04-14 Thread Scott David Daniels
: yield number else: yield prelude prelude = None path = "d:/emacs files/emacsinit.txt" source = open(path) try: for line in starts(source): print line, # could ju

Re: Help for a complete newbie

2006-04-15 Thread Scott David Daniels
Steve Bergman wrote: > One of these days Alex will come out with a 2nd Edition of Nutshell and > there will be much rejoicing. ;-) > Rumor has it he is trying to hit print for OSCON (so soon, soon). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: keyboard command to break out of infinite loop?

2006-04-16 Thread Scott David Daniels
yboardInterrupt has a reasonable repr (the result of the %r translation), but its str conversion (the result of the %s translation) is a zero length string (which is kind of hard to see in a print). So, avoid "except:" when catching exceptions, and your life will be happier. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting changes to a dict

2009-09-28 Thread Scott David Daniels
etdefault = mutating(dict.setdefault) update = mutating(dict.update) d = SerializedDictionary(whatever) Then just use dict.serial to see if there has been a change. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Want to call a method only once for unittest.TestCase--but not sure how?

2009-09-28 Thread Scott David Daniels
class__.needs_initial = False def setUp(self): if self.needs_initial: self.initialize() And write your test classes like: class Bump(FunkyTestCase): def initialize(self): super(Bump, self).initialize() print 'One time

Re: Idiom for "last word in a string"

2009-09-29 Thread Scott David Daniels
d out the efficiency reason (asking the machine to do a pile of work that you intend to throw away). But nobody warned you: s.rsplit(None, 1)[-1] would be better in the case of 'single_word'.rsplit(None, 1) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/

Re: Restarting IDLE without closing it

2009-09-29 Thread Scott David Daniels
candide wrote: Hi I was wondering if there exists somme way to clear memory of all objects created during a current IDLE session (with the same effect as if one starts an IDLE session). Thanks. Different than "Shell / Restart Shell (Ctrl+F6)" ? Of course this doesn't work if you started Idle i

Re: Q: sort's key and cmp parameters

2009-10-02 Thread Scott David Daniels
make the easy path the fast path, and more will use it; provide two ways, and the first that springs to mind is the one used. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: 'Once' properties.

2009-10-05 Thread Scott David Daniels
tialized.a, Initialized.b --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: 'Once' properties.

2009-10-06 Thread Scott David Daniels
Scott David Daniels wrote: ... Look into metaclasses: ... class Initialized(ClassBase): @classmethod def _init_class(class_): class_.a, class_.b = 1, 2 super(Initialized, class_)._init_class() Mea culpa: Here super is _not_ a good idea, and I had

Re: PIL : How to write array to image ???

2009-10-06 Thread Scott David Daniels
her than looping in the way you might in C for example, the numpy where might be quicker if you have a big image. Just a thought... And a good thought too... I think what Martin is telling you is: Look to numpy to continue working on the array first. byte_store = imgL.astype(np.uint8) I

Re: When ‘super’ is not a good idea

2009-10-07 Thread Scott David Daniels
Ben Finney wrote: Scott David Daniels wrote: ... class Initialized(ClassBase): @classmethod def _init_class(class_): class_.a, class_.b = 1, 2 super(Initialized, class_)._init_class() Mea culpa: Here super is _not_ a good idea, […] Why is ‘super

Re: Rules regarding a post about a commercial product

2009-10-07 Thread Scott David Daniels
art making real money from it, like ActiveState you'll help out the community that is giving you its support. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: No module named os

2009-10-10 Thread Scott David Daniels
l you what locations are being checked for files. Normally you should: 1) tell us python version and which OS (and OS version) you are using. 2) include a pasted copy of exactly what did not work, along with the resulting output, and why you did not expect the output you got. --

Re: a simple unicode question

2009-10-20 Thread Scott David Daniels
gt;>> q = s.decode('utf-8') >>> degrees, rest = q.split(u'\N{DEGREE SIGN}') >>> print degrees 48 >>> print rest 13' 16.80" N And if you are unsure of the name to use: >>> import unicodedata >>> unicodedata.name(u'\xb0') 'DEGREE SIGN' --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: a simple unicode question

2009-10-21 Thread Scott David Daniels
George Trojan wrote: Scott David Daniels wrote: ... And if you are unsure of the name to use: >>> import unicodedata >>> unicodedata.name(u'\xb0') 'DEGREE SIGN' > Thanks for all suggestions. It took me a while to find out how to > configure my ke

Re: [ANN] Python(x,y) 2.6.3.0 released

2009-10-22 Thread Scott David Daniels
ion _very_ soon) -- get to python dev immediately if you have problems with the release candidate. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: IDLE python shell freezes after running show() of matplotlib

2009-10-24 Thread Scott David Daniels
aqs/smart-questions.html Hint: I don't know your CPU, python version, IDLE version, matplotlib version, nor do you provide a small code example that allows me to easily reproduce your problem (or not). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda forms within a loop

2009-10-25 Thread Scott David Daniels
these are numbers: a, b = [x.__add__ for x in [1, 2]] print a(10) print b(10) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Another (simple) unicode question

2009-10-29 Thread Scott David Daniels
.6.4? Does your test work in 2.6? Also consider how 2to3 translates the problem section(s). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension problem

2009-11-03 Thread Scott David Daniels
in order to make equal immutable values identical, you'd have to end each operation producing an immutable result with a search of all appropriately typed values for one that was equal. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Serious Privileges Problem: Please Help

2009-11-10 Thread Scott David Daniels
e I don't think control characters are likely in the interpreter file name. You could work around this by creating a symlink (or even hard link to the python executable named "python\r" --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: overriding __getitem__ for a subclass of dict

2009-11-17 Thread Scott David Daniels
jects Since nobody else has mentioned it, I'd point you at Mock objects: http://python-mock.sourceforge.net/ for another way to skin the cat that it sounds like has been biting you. They are surprisingly useful for exploratory and regression testing. --Scott David Daniels scott.dani...@acm.o

Re: python gui builders

2009-11-17 Thread Scott David Daniels
. Maybe your groundwork can help me out with that. I must be in a really cranky mood today. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: ZipFile - file adding API incomplete?

2009-11-17 Thread Scott David Daniels
bzip compression as well, and about the "find which bits means what" was where my process broke down. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: TODO and FIXME tags

2009-11-17 Thread Scott David Daniels
ments, which appears to be the biggest convention :-) Perhaps: "The comments are a directive to delete the comment if you happen do this." --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: FYI: ConfigParser, ordered options, PEP 372 and OrderedDict + big thank you

2009-11-20 Thread Scott David Daniels
waiting for me when I move to Python3. So a big thank you is in order. And thank you for, having done that, not simply smiling because your work was lighter. Instead you described a great work path and handed an attaboy to a pair of people that richly deserve attaboys. --Scott David Daniels

Re: Writing a Carriage Return in Unicode

2009-11-20 Thread Scott David Daniels
s" as if Microsoft got it wrong; it did not -- Unix made up a convenient fiction and people went along with it. (And, yes, if Unix had been there first, their convention was, in fact, better). So, sorry for venting, but I have bee wanting to say this in public for years. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Messing up with classes and their namespace

2009-06-05 Thread Scott David Daniels
nside) And here is a fix foo.py: if __name__ == '__main__': import sys sys.modules['foo'] = sys.modules['__main__'] class Foo: inside = __name__ import foo if __name__ == '__main__': print(Foo is foo.Foo) print(Foo.inside, foo.Foo.inside) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Winter Madness - Passing Python objects as Strings

2009-06-05 Thread Scott David Daniels
the dictionary becomes that holding point. The counter-as-key idea allows you to keep separate references to the same thing, so the reference is held for precisely as long as needed. It (counter-as-key) beats the str(id(obj)) of can because it tracks the actual object, not simply the id that can

Re: fastest way to test file for string?

2009-06-05 Thread Scott David Daniels
dirs[:] = sorted([d for d in dirs if d[0] != '.' and d not in ('RCS', 'CVS')]) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: MD6 in Python

2009-06-05 Thread Scott David Daniels
Christian Heimes wrote: ... 2.7rc1 is already out. There is no way a new piece of code will land in the 2.7 release. Christian 3.1rc1 is out, but 2.7 is not even in alpha. See pep 373 for the 2.7 schedule; 3.1's schedule is on pep 375. --Scott David Daniels scott.dani...@acm.org --

Re: openhook

2009-06-06 Thread Scott David Daniels
Gaudha wrote: Can anybody tell me what is meant by 'openhook' ? Certainly someone can. -- http://mail.python.org/mailman/listinfo/python-list

Re: can it be shorter?

2009-06-06 Thread Scott David Daniels
al semantics, you might prefer either: if s[-1:] != '/': s = (s or '.') + '/' or: if s and s[-1] != '/': s += '/' --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: multi-core software

2009-06-07 Thread Scott David Daniels
he cost of that speed is that timing is a black art. Perhaps modern operating systems need the syyem call that was implemented in the Stanfor AI Lab's operating system -- phase of the moon. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Is reduce() foldl() or foldr()?

2009-06-07 Thread Scott David Daniels
ist). Foldl is the eager-beaver's dream; foldr is the procrastinator's dream. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Keeping console window open

2009-06-07 Thread Scott David Daniels
print 'Failed:', why import sys, traceback traceback.print_tb(sys.exc_info()[2]) raw_input('Leaving: ') Note that building your script like this also allows you to open the interpretter, and type: import mymodule mymodule.main() in order to exa

Re: Properties for several keywords

2009-06-07 Thread Scott David Daniels
red = mangled('red', "their side") white = mangled('white', "the poor civilians") def _mangle(self, text): print text return text.join('<>') --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: spammers on pypi

2009-06-07 Thread Scott David Daniels
from selling it. (3) You'll probably advertize your new solution via bulk e-mail to all e-mail addresses you know of that might be interested in learning of your great discovery. :-) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: multi-core software

2009-06-07 Thread Scott David Daniels
Lew wrote: Scott David Daniels wrote: the nub of the problem is not on the benchmarks. There is something to be said for the good old daays when you looked up the instruction timings that you used in a little document for your machine, and could know the cost of any loop. We are faster now

Re: Extract value and average

2009-06-08 Thread Scott David Daniels
e) # break the post-DIHED part into '=', , words = parts[1].split(None, 2) values.append(float(tokens[1])) mean = sum(values) / len(values) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: preferring [] or () in list of error codes?

2009-06-08 Thread Scott David Daniels
r brackets, if I were you I'd go with the list form. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Unbound Method Error

2009-06-09 Thread Scott David Daniels
CifradorDeCesar(class_, mensagem, chave, funcao): ... --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: easiest way to check python version?

2009-06-10 Thread Scott David Daniels
_info < (2, 3): ... elif (2, 5) <= sys.version_info <= (2, 6, 2, 'final'): ... else: print('Untested') --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: retrieve bitwise float representation

2009-06-10 Thread Scott David Daniels
into writing from the array directly -- using cStringIO if you need to get to the result within Python, rather than as an I/O format. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: xml application advice

2009-06-10 Thread Scott David Daniels
'-') print node.tag, ', '.join(sorted('%s=%r' % pair for pair in node.items())) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: xml application advice

2009-06-10 Thread Scott David Daniels
William Purcell wrote: Scott David Daniels wrote: William Purcell wrote: I am writing a application to calculate pressure drop for a piping network. Namely a building sprinkler system. This will be a command line program at first with the system described in xml If you are going to be

Re: Changing Hash Values Across Versions

2009-06-11 Thread Scott David Daniels
not be surprised to see a non-CPython implementation use a different hash. Generally it is a good idea to keep the result of hash computations inside the program, and off the persistant store, so I'd want a good excuse to use the hash "outside." --Scott David Daniels scott.dani..

Re: Unhandled exception in thread

2009-06-11 Thread Scott David Daniels
shutdown, but it sounds like you have a thread shutdown issue. --Scott David Daniels Scott.Daniels#Acm.Org -- http://mail.python.org/mailman/listinfo/python-list

Re: uncompress base64-gzipped string

2009-06-13 Thread Scott David Daniels
handful. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about None

2009-06-14 Thread Scott David Daniels
Steven D'Aprano wrote: ... or {1}∩0. (If that character between the set and zero ends up missing, it's meant to be INTERSECTION u'\u2229'.) Note that you can write this in a quite readable way in ASCII: "it's meant to be the character u'\N{INTERSECTION}&#

Re: shoehorn c-structured data into Numpy

2009-06-14 Thread Scott David Daniels
C1 = np.fromfile(data, count=ncells, dtype=float) # and again, possibly: TC1.byteswap(True) # True to byteswap in place. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: ImageEnhance.Contrast - is this fishy or what?

2009-06-15 Thread Scott David Daniels
center. I'm not quite sure which one is more properly called "contrast," as I can see wanting either one. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Input problem

2009-06-16 Thread Scott David Daniels
#2) a, b = (int(t) for t in input('Numbers: ').split()) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to know if a file as only ASCII charaters

2009-06-16 Thread Scott David Daniels
n(ctrls) and '~' >= max(chars ) and min(chars - ctrls) > ' ' For potentially more performance (at least on 2.X), you could do min and max on the data read, and only do the set(data) if the min and max are OK. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: doctests and decorators

2009-06-16 Thread Scott David Daniels
decorator(function): @functools.wraps(function) def new_function(*args, **kwargs): return function(*args, **kwargs) return new_function --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to know if a file as only ASCII charaters

2009-06-16 Thread Scott David Daniels
norseman wrote: Scott David Daniels wrote: Dave Angel wrote: Jorge wrote: ... I'm making a application that reads 3 party generated ASCII files, but some times the files are corrupted totally or partiality and I need to know if it's a ASCII file with *nix line terminators. In l

Re: doctests and decorators

2009-06-16 Thread Scott David Daniels
@indexed def first_function(...): ... @indexed def second_function(...): ... --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: strptime issue in multi-threaded application

2009-06-16 Thread Scott David Daniels
o sleep a short time and then retry. Can you just import and use time.strptime once before you start the threads? --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: mac text files & for line

2009-06-16 Thread Scott David Daniels
\n'). A good guess of what might be going wrong. Another could be using read. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: ImageEnhance.Contrast - is this fishy or what?

2009-06-16 Thread Scott David Daniels
Scott David Daniels wrote: roop wrote: I was browsing ImageEnhace.py, and found something that I thought was odd in class Contrast: class Contrast(_Enhance): "Adjust image contrast" ... Good catch [I'll send a copy to the imaging sig]. If you replace class ... Ov

Re: Guidance on initialization code in a module

2009-06-16 Thread Scott David Daniels
() === EOF === Is the 'something()' line at the end in an ok location? I just put it at the end. Seems fine there. I'd add a comment like: something() #initialize the frambus so the whatzies are set up. Perhaps I'd choose better names :-) --Scott David Daniels scott.dan

Re: walking a directory with very many files

2009-06-17 Thread Scott David Daniels
ion files in /path or /path/f/9/e/95ea with only hundred of them in each path. Probably better to use: /path/f9/e9/5ea4926a4 If you want to talk hundreds per layer. Branching 16 ways seems silly. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-17 Thread Scott David Daniels
k in a numpy world long enough, you'll forget that not everyone uses numpy. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about method options

2009-06-17 Thread Scott David Daniels
your operation to everything with that tag. operations include such things as color manipulation, delete, clone, and move. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: UDP queue size

2009-06-17 Thread Scott David Daniels
perhaps augmented by dynamic scaling. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance and forward references (prototypes)

2009-06-21 Thread Scott David Daniels
ject): _default = None def __init__(self, test=None): if test is None: test = self._default if test is None: B._default = test = A() ... --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: class or instance method

2009-06-21 Thread Scott David Daniels
(functools.partial(self._function, cls if obj is None else obj)) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Good books in computer science?

2009-06-22 Thread Scott David Daniels
host of experiences to our writing, and we should similarly bring that to the programs we write. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: fastest native python database?

2009-06-22 Thread Scott David Daniels
Lawrence D'Oliveiro wrote: ... Use Python mapping objects. Most real-world databases will fit in memory anyway. Interesting theory. Certainly true for some definitions of "most" and "real-world" (and "databases" for that matter). --Scott David Dan

Re: Converting Python code to C/C++

2009-06-24 Thread Scott David Daniels
language in addition to learning the rest of the coursework. The first course is now in Python, since at the end of the two-semester sequence they know two languages and apparently suffer no compensating loss. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary self lookup

2009-06-24 Thread Scott David Daniels
ot;python-dev" : home + "/py-dev"} or even (if the list gets much longer): home = "/home/test" config = {"home" : "", "user1" : "/user1", "user2" : "/user2", "python-dev" : "/py-dev"} for key, entry in config.iteritems(): config[key] = home + entry --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: fileinput.input, readlines and ...

2009-06-24 Thread Scott David Daniels
with open(filename) as instream: gen = (line.strip() for line in instream) for key in gen: lookup[key] = next(gen) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading then sending new parts of a log file

2009-06-24 Thread Scott David Daniels
sh in the right direction. Thanks! What OS and version, what Python and version. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: fileinput.input, readlines and ...

2009-06-24 Thread Scott David Daniels
Peter Otten wrote: Scott David Daniels wrote: Peter Otten wrote: with open(filename) as instream: lines = (line.strip() for line in lines) lookup = dict(zip(lines, lines)) Little bit of a fluff-up here. Sorry, it should have been with open(filename) as instream: lines

Re: It's ...

2009-06-24 Thread Scott David Daniels
g my feet wet, and I'll try not to ask too many silly questions! First impressions are: (1) Python seems both elegant and practical; and (2) Beazley seems a pleasantly unfussy introduction for someone with at least a little programming experience in other languages. Both 1 an

Re: fileinput.input, readlines and ...

2009-06-24 Thread Scott David Daniels
p(), "-->", next(lines).strip() NameError: global name 'next' is not defined Sorry, I am running 2.6 Try: print line.strip(), "-->", lines.next().strip() --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-24 Thread Scott David Daniels
Scott David Daniels wrote: Angus Rodgers wrote: ... my first ... question is how best to find out what's changed from version 2.1 > to version 2.5. (I've recently installed 2.5.4) Consecutively read: http://docs.python.org/whatsnew/2.2.html As someone else pointed ou

Re: Problem with multithreading

2009-06-24 Thread Scott David Daniels
going on related to multithreading at this point in the code. Why else might the program freeze at a try statement? Or a print statement or ... We need more clues than three lines of source. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: 3.2*2 is 9.6 ... or maybe it isn't?

2009-06-25 Thread Scott David Daniels
arbitrary-precision, huge exponent version of binary floating point. In that sense the Decimal floating point beats it. Not that it would be too hard to have such a floating point in Python (long for mantissa, int for exponent, ...), but we don't in fact have such a module in place. --Scott

Re: Tkinter - non-ASCII characters in text widgets problem

2009-06-25 Thread Scott David Daniels
TE 261 105 ą LATIN SMALL LETTER A WITH OGONEK 347 15b ś LATIN SMALL LETTER S WITH ACUTE 322 142 ł LATIN SMALL LETTER L WITH STROKE 380 17c ż LATIN SMALL LETTER Z WITH DOT ABOVE 378 17a ź LATIN SMALL LETTER Z WITH ACUTE 263 107 ć LATIN SMALL LETTER C WITH ACUTE 324 144 ń LATIN SMALL LETTE

Re: 3.2*2 is 9.6 ... or maybe it isn't?

2009-06-26 Thread Scott David Daniels
the obvious choice, digits and letters, and 1/N works for n in range(1, 7) + range(8, 11). Gödel numbers, anyone? :-) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: change the first character of the line to uppercase in a text file

2009-06-26 Thread Scott David Daniels
e attempting to work it out alone. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter - non-ASCII characters in text widgets problem

2009-06-26 Thread Scott David Daniels
norseman wrote: Scott David Daniels wrote: norseman wrote: ... A note here: In reading the original posting I get ... then an e with a goatee Here's something to try in any future circumstances: Good thought, good idea, useful tool. BUT - compare your output to what I

Re: Fast Dictionary Access

2009-06-27 Thread Scott David Daniels
= data[key] The form: try: value = data[key] except KeyError: pass works, but is not terribly efficient unless failures are rare. And this is a micro-optimization, measure before changing your program structure away from the clearest code you can write. --Scott David

Re: Python Imaging Library download link broken?

2009-06-27 Thread Scott David Daniels
olivergeorge wrote: Ditto. Anyone know what's happening with pythonware? (and why PIL is such a pain to install for that matter.) (1) It is usually there; be patient. (2) I suggest you demand a refund. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/lis

Re: [RELEASED] Python 3.1 final

2009-06-28 Thread Scott David Daniels
e the world from our 'bot overlords. Congratulations on another release from the hydra-like world of multi-head development. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list

Re: problems with mysql db

2009-06-29 Thread Scott David Daniels
golu wrote: here i have posted my code...plz tell why am i getting the error "int argument required" on the hash marked line(see below) although i am giving an int value ... url_count += 1 curse.execute("INSERT INTO URL_TABLE VALUES(%d,%s)", (url_count,file_path)

<    15   16   17   18   19   20   21   22   >