Re: GUI Frames and classmethod

2004-12-06 Thread Scott David Daniels
Zak Arntson wrote: On Mon, 06 Dec 2004 13:08:15 -0800, Scott David Daniels <[EMAIL PROTECTED]> wrote: Zak Arntson wrote: On Fri, 03 Dec 2004 14:48:30 -0800, Scott David Daniels wrote: ...The real advantage is clarity: the inner dictionaries in a dict-of-dict implementation have no real &q

Re: Sorting in huge files

2004-12-07 Thread Scott David Daniels
, so I will have to sort 12 times. Well, good sorting is O(N * log(N)), so you should be able to calculate from a sample timing (once you get out of cache effects). If you use a variant of the above, simply time a few of the intervals you've chosen and do a nice linear extrapolation. --Scott David D

Re: Directory structure inside a ZipFile object

2004-12-09 Thread Scott David Daniels
= zipfile.ZipFile('box.zip', 'w', zipfile.ZIP_DEFLATED) archive.write('source/somewhere/one.txt', 'name.txt') archive.write('two.txt', 'another.txt') archive.close() --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Inheritance

2004-12-09 Thread Scott David Daniels
mastervar be contained within the scope of the inheriting classes? Why is it being treated like a global variable and being modified by the other instances? By over-riding mastervar in class c, I hope I've shown that a class variable is shared by all of its instances, but can be over-ri

Re: Questions about file object and close()

2004-12-09 Thread Scott David Daniels
like: def contents(filename): source = open(filename) try: return source.read() finally: source.close() and then you can make your small uses clear. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: from string to raw string

2004-12-15 Thread Scott David Daniels
b_\t_here' len(s.split()) == 1 len(s.decode('string_escape').split()) == 2 s = 'tab_\t_here' len(s.split()) == 2 len(s.encode('string_escape').split()) == 1 -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I convert characters into integers?

2004-12-15 Thread Scott David Daniels
a.fromstring(message) for i in range(len(a)): a[i] += 1 return a.tostring() print mangle('Hello, Harry') -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: NO REALLY

2004-12-16 Thread Scott David Daniels
Martijn Faassen wrote: It's slow and no scientific research exists in its favor! Also it doesn't work. Why would I need polymorphism? Lisp had all of this 50 years ago anyway. But functional programming by the way SUX TOO! So does procedural programming! And structured programming SUX, GOTO all

Re: why not arrays?

2004-12-16 Thread Scott David Daniels
odule, the "numpy" implementation, and the "numarray" implementation. Clearly there are some trade offs here with no clear winner. Until there is a clear favorite, it would be a bad idea to choose a winner. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Best book on Python?

2004-12-16 Thread Scott David Daniels
l Reference for that kind of book -- no fat, lotsa goodies. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: decorator peculiarity

2004-12-17 Thread Scott David Daniels
are better off returning a function which can take the remaining arguments, and controlling when the final function is called by returning a function that can take all the remaining arguments at once. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i send 8-bit data or binary data with pyserial?

2004-12-15 Thread Scott David Daniels
hine words). the strings you pass to pyserial are treated as byte sequences Just one other bit (byte?) of data that wasn't mentioned here: the array module also provides handy conversions. array.array('B', [1,2,3,4]).tostring() == '\1\2\3\4' This may prove useful as you cre

Re: Unpacking Binary Data - not using struct module

2004-12-16 Thread Scott David Daniels
int. If you can encode numbers like 11300, that might help (also throw in some negative numbers and some small numbers). I'd like 0 and +/- versions of 2**n for n in range(16) and +/- versions of 10**n for n in range(1,7). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: How about "pure virtual methods"?

2004-12-19 Thread Scott David Daniels
: u = UsesMissing() except NotImplementedError, e: print 'Got expected exception:', e else: raise ValueError, 'Did not get expected exception' --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy "here documents" ??

2004-12-19 Thread Scott David Daniels
d)) for expr in source[1::2]) return ''.join(source) amount = 1 cost = 2.0 what = 'potato' print fix("""I'll have "amount" "what"s for "'$%.2f' % cost"s please""", locals()) --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread Scott David Daniels
M.E.Farmer wrote: I dont have itertools yet. That module looks like it rocks. thanks for the pointers, M.E.Farmer If you have python 2.3 or 2.4, you have itertools. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: input record seperator (equivalent of "$|" of perl)

2004-12-20 Thread Scott David Daniels
Gábor Farkas wrote: Scott David Daniels wrote: If you have python 2.3 or 2.4, you have itertools. for me it seems that 2.3 does not have itertools.groupby. it has itertools, but not itertools.groupby. True. The 2.4 document says that itertools.groupby() is equivalent to: class groupby(object

Re: Recursive structures

2004-12-20 Thread Scott David Daniels
s def isrecursive(obj): try: walks(obj, set()) except RecursionFoundError, err: return True# err.args[0] is the looping object return False --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: extending python with a C-written dll

2004-12-20 Thread Scott David Daniels
ns. I don't know if anyone has a tested way of using lcc. With MinGW32, your build step will be the delightfully easy: python setup.py build --compiler=mingw32 --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

2004-12-20 Thread Scott David Daniels
Bengt Richter wrote: Not true on NT4 at least: Alt-Spacebar gets you the system menu paste into the dos window with Alt-spacebar e p Thanks immensely for this -- I love it. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy "here documents" ??

2004-12-20 Thread Scott David Daniels
Jim Hill wrote: Fredrik Lundh wrote: Scott David Daniels wrote: And if you enjoy building insecure stuff, try: def fix(text, globals_=None, locals=None, quote='"'): d = (globals_ or locals or globals()).copy() source = text.split(quote) source[1::2] = (s

Re: extending python with a C-written dll

2004-12-21 Thread Scott David Daniels
o write for windows with a GNU compiler; you'll be swimming upstream a bit less. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: word to digit module

2004-12-22 Thread Scott David Daniels
valid element %r in string %r" % ( e.args[0], text) stack = [0] for num in numbers: if num >= 100: stack[-1] *= num if num >= 1000: stack.append(0) else:

Re: wxPython help

2004-12-22 Thread Scott David Daniels
y" (run.py from the same directory where demo.py or demo.pyw lives) to your local directory where you are playing. --Scott David [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with msvcrt60 vs. msvcr71 vs. strdup/free

2004-12-22 Thread Scott David Daniels
ell, and (once we've done that) we can pass the lessons on for other compiler is desired. --Scott David Daniels [EMAIL PROTECTED] p.s. I am able (and willing) to use the MS free compiler, but I have sympathy for those who aren't. I'd like to see it possible to use _lots_ of differ

Re: Python, unix and mssql

2004-12-23 Thread Scott David Daniels
francisl wrote: Can we, directly from unix select and insert data in a remote mssql database? In some sense you can. I used python and mxODBC to talk ODBC protocol to DB2 / MS SqlServer / Access. It was quite a while ago, and I may have had to use an odbc-on-linux piece I don't know about. But

Re: Why are tuples immutable?

2004-12-23 Thread Scott David Daniels
es two different lists. This is half the problem. In the period where an element is in the wrong hash bucket, a new entry for the same value can be created in the proper hash bucket. Then the code will have to determine how to merge two entries at rehash time. --Scott David Daniels [EMAIL PROTE

Re: Koolaid (was Re: Optional Static Typing)

2004-12-24 Thread Scott David Daniels
d I knew a number of people who hung out at Keysey's place and a few "on the bus" types -- none of them ever used the "drank the Kool- Aid" phrase before Jonestown to my knowledge. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: feature suggestion

2004-12-24 Thread Scott David Daniels
statement. "a = 6 5" _is_ a syntax error; there is no way to interpret "6 6" as an expression, and there is no way to interpret " 6" as a statement. So, even if your proposal were to be implemented, it would probably be an "access to undeclared identifier"

Re: Optional Static Typing

2004-12-24 Thread Scott David Daniels
omething. Only that type should not be enforced and 'expects' makes this clear. You need to explain why anyone would want to write expects at all. If you are expecting the code generation to change, you'd better enforce, rather than advise, unless you are defining points at which to do code

Re: Clearing the screen

2004-12-25 Thread Scott David Daniels
this command -d enable debugger -e edit mode; arguments are files to be edited -s run $IDLESTARTUP or $PYTHONSTARTUP first -t titleset title of shell window On Windows, it is likely to be idle.pyw. So, add a -s to the command line used in the shortcut t

Re: sql server support from linux

2004-12-26 Thread Scott David Daniels
early if the larger transaction has not in fact "read" the data they will right. Also, in some cases, the smaller ones may be allowed to proceed and force the larger one to abort if it attempts to acquire locks on the data they write. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.pyth

Re: program in interactive mode

2004-12-26 Thread Scott David Daniels
B.G.R. wrote: numline=0 for line in sys.stdin: numline+=1 workwithline(line) I'd use: for numline, line in enumerate(sys.stdin): workwithline(line) Note: The line numbers start at 0, but that is often acceptable. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.pytho

Re: list IndexError

2004-12-26 Thread Scott David Daniels
re, and "deepcopy" needn't copy such objects. The only way to safely do deepcopy is to copy down to immutables, but usually there is a shallower and faster implementation that depends on application semantics. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Optional Static Typing - Haskell?

2004-12-27 Thread Scott David Daniels
Michael Hobbs wrote: I've always found that with Haskell, if I can get my program to compile without error, it usually runs flawlessly. (Except for the occasional off-by-one error. :-) Then you need "Scott and Dave's Programming Language" -- SAD/PL. By providing separate dat

Re: Q: Scheduling in scipy.cow

2004-12-28 Thread Scott David Daniels
em, a standard line of attack is a queue of work-to-do tasklets, with each worker going back for more when he finishes. The slowest running worker should then only be finished after the fastest worker by at most the longest-running tasklet's time. --Scott David Daniels [EMAIL PROTECTE

Re: what would you like to see in a 2nd edition Nutshell?

2004-12-29 Thread Scott David Daniels
t), B(A), C(A), D(B,C) hierarchy, but they should match. * implementing types/classes in C -- a checklist w/ advice on testing. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-29 Thread Scott David Daniels
Antoon Pardon wrote: Op 2004-12-23, Scott David Daniels schreef <[EMAIL PROTECTED]>: This is half the problem. In the period where an element is in the wrong hash bucket, a new entry for the same value can be created in the proper hash bucket. Then the code will have to determine how to

Re: More baby squeaking - iterators in a class

2004-12-30 Thread Scott David Daniels
's another way: # (Return something with __iter__ and next methods) Py> class R2(object): def __init__(self, data): self.d = data self.i = len(data) def __iter__(self): return iter(self.d) Py> s = R2('spam') Py> list(s) ['s', 'p', 'a', 'm'] Py> list(s) ['s', 'p', 'a', 'm'] --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Python limericks (was Re: Text-to-speech)

2005-03-21 Thread Scott David Daniels
, prophetic, invented a language, herpetic. decidedly brilliant, syntacticly elegant, Made ideas far less hypothetic. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting a dictionary?

2005-03-21 Thread Scott David Daniels
eq in sorted(mydict.items(), key=sortkey): print '%-6s %s' % word_freq --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting a dictionary?

2005-03-21 Thread Scott David Daniels
Anthony Liu wrote: --- Scott David Daniels <[EMAIL PROTECTED]> wrote: def sortkey((word, frequency)): return -frequency, word for word_freq in sorted(mydict.items(), key=sortkey): print '%-6s %s' % word_freq Thank you scott, but 'sorted' itse

Re: (noob alert) why doesn't this work?

2005-03-22 Thread Scott David Daniels
Bouke Woudstra wrote: It turned out that some flac files have tags like Artist=artistname and others have artist=artistname. Therefore it couldn't find the artist! So now I just look for 'rtist=' which works great. You might want try using something like this: wanted = set('artist album date

Re: typo in the library reference?

2005-03-22 Thread Scott David Daniels
more likely to help you out. This is a _collective_ effort. You spotted a problem; submit at least a bug report if not a fix. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: typo in the library reference?

2005-03-23 Thread Scott David Daniels
nicke wrote: Peter Hansen <[EMAIL PROTECTED]> wrote: Scott David Daniels wrote: nicke wrote: If it really is like this it is uncoherent and quite stupid :P Name-calling won't make anyone more likely to help you out. This is a _collective_ effort. You spotted a problem; submit at

Re: Read from the last line of a file?

2005-03-23 Thread Scott David Daniels
"reversed" generator to avoid a copy. for line in reversed(readlines()): .... --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: cross platform use of set locale

2005-03-23 Thread Scott David Daniels
ntrol yourself). Just write a function "commad" and use it. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest help

2005-03-24 Thread Scott David Daniels
uot;module switch" must happen very early (probably at the top of the main program). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: escape single and double quotes

2005-03-24 Thread Scott David Daniels
d" and do a commit after each distinct name_id is finished. This strategy would keep data for individuals coherent. 4) In fact, I'd leave the data in the database. Perhaps more like a set of queries like: UPDATE names SET names.prefix = name_parts.name

Re: Python for a 10-14 years old?

2005-03-24 Thread Scott David Daniels
"secret register" for the moving data, and a "first part done" part of executing the opcode. Modern RISC-structured machines have at most one memory operation, so the instruction is simply completed or not, and can safely be re-executed if it is not complete. --Scott David Dani

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Scott David Daniels
Michael Spencer wrote: itertools.groupby enables you to do this, you just need to define a suitable grouping function, that stores its state: Michael, this would make a great Python Cookbook Recipe. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Scott David Daniels
n(sys.argv[1 :]) else: output = open(sys.argv[-1], 'w') try: main(sys.argv[1 : -1], output) finally: output.close() --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Scott David Daniels
Michael Spencer wrote: Scott David Daniels wrote: Michael Spencer wrote: OK, will do. What would you call it? Something like: "Stateful grouping of iterable items" How about "Using groupby to fill lines"? --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mai

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Scott David Daniels
Qertoip wrote: Dnia Fri, 25 Mar 2005 12:51:59 -0800, Scott David Daniels napisał(a): > ... for word in line.split(): try: corpus[word] += 1 except KeyError: corpus[word] = 1 Above is (probably) not efficient when exception is thr

Re: DBAPI Paramstyle

2005-03-26 Thread Scott David Daniels
our code). You could also be changing the format used to send the data to the database (of that I'm not quite as sure). --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-27 Thread Scott David Daniels
earth would want that? ;) Reinhold You certainly do get lots of adding/subtracting even if they start at 1. For example the length of lst[a : b] would be (a - b + 1). I certainly had my share of fencepost problems in Fortran I, II, IV, V ... --Scott David Daniels [EMAIL PROTECTED] -- http://mail

More decorator rumination

2005-03-30 Thread Scott David Daniels
e boilerplate to me. I'm wondering whether others think this is an interesting insight into what decorators are "for," or they think I'm working on "the moral equivalent of a macro." --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: More decorator rumination

2005-03-30 Thread Scott David Daniels
Jack Diederich wrote: On Wed, Mar 30, 2005 at 02:48:51PM -0800, Scott David Daniels wrote: In particular, I thought about something like: @mousexy def OnRightClick(self, x, y): ... so all event-responding methods tend to look like: def OnRightClick(self, event): x

Re: Newbie Shell Editor Question

2005-03-31 Thread Scott David Daniels
tly open file. Or, if you like to click: File -> Open (choose file) Run -> Run Module --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary Operator in Python

2005-04-01 Thread Scott David Daniels
dea. You probably don't see it since you aren't doing much engineering work. --Scott David Daniels [EMAIL PROTECTED] -- No truth has been harmed by this April Fool's post. :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__ method and raising exceptions

2005-04-01 Thread Scott David Daniels
ways expect certain kinds of errors) lest you accidentally capture an real attempt to stop the program such as the exception a Control-C causes. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-02 Thread Scott David Daniels
Python is not for poetry. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary Operator in Python

2005-04-02 Thread Scott David Daniels
Roy Smith wrote: ... How our tools warp our thinking. That is what it means to be human. I can think of no better reason for a programmer to regularly learn languages: "our tools warp our thinking." A programmer is a professionally warped thinker. --Scott David Daniels [EMAIL PROTECTE

Can I play too?

2005-04-02 Thread Scott David Daniels
Thomas Rast wrote: Tom Carrick <[EMAIL PROTECTED]> writes: In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. Indeed, your program can be improved to run about ten ti

Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-02 Thread Scott David Daniels
Donn Cave wrote: Quoth Scott David Daniels <[EMAIL PROTECTED]>: | Sunnan wrote: | > ...Because what is "boring"? The opposite of dense, tense, intense. Utterly | > predictable; it's like the combination of all my prejudices. Even before | > I knew, I thought "B

Re: unittest vs py.test?

2005-04-03 Thread Scott David Daniels
ur tests cannot be run on a non-debug version. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator Base Class: Needs improvement.

2005-04-05 Thread Scott David Daniels
u write is that you are referring to tweakdoc as a decorator, when it is a function returning a decorator. and not: @decorator(x)(y) This is only prevented by syntax (probably a good idea, otherwise we would see some very complicated expressions before function declarations). --Scott David

Re: Does IronPython indicate MS interest in dynamic languages?

2005-04-06 Thread Scott David Daniels
Bengt Richter wrote: If there is to be an MSPython, how long 'til Mozilla FirePython? ;-) Mexico has already designed the flag for that, I think. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Lambda: the Ultimate Design Flaw

2005-04-06 Thread Scott David Daniels
Aahz wrote: You just can't have your cake and eat it, too. I've always wondered about this turn of phrase. I seldom eat a cake at one sitting. -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator Base Class: Needs improvement.

2005-04-06 Thread Scott David Daniels
function), and if it needs more clarity, of your non-oderiferous proposals, I'd take: Decorator expression for short? --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator Base Class: Needs improvement.

2005-04-06 Thread Scott David Daniels
Guess I am listening to language funny today. Steve Holden wrote: By the way, we pass *parameters* to functions, *perimeters* surround things. But we do pass parameters *around*, which may be the source of the confusion. :-) -Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman

Re: curious problem with large numbers

2005-04-07 Thread Scott David Daniels
not necessarily a bug in the sense of a fixable bug; floating point has vagaries that are not necessarily easily controllable from the C source side. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: curious problem with large numbers

2005-04-08 Thread Scott David Daniels
Steve Holden wrote: Scott David Daniels wrote: Terry Reedy wrote: On my Windows machine with 2.2.1, I get exactly what you expected: 1e1 1.#INF ... If you get wrong behavior on a later version, then a bug has been introduced somewhere, even perhaps in VC 7, used for 2.4. Nope, it is also

Re: How to name Exceptions that aren't Errors

2005-04-08 Thread Scott David Daniels
ed(b, c, a) except Success, instance: result, = instance.args return result else: raise ValueError, 'Nothing found' --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Can dictionary values access their keys?

2005-04-08 Thread Scott David Daniels
objects, but in Python objects refer to each other. How about this: class Holder(object): pass v = [1 + 11 * 2] w = [1, v, 3] d = {1: v} o = Holder() o.x = v What is the parent of v? Or even worse: v = [1] v[0] = v What is the parent of v now? --Scott David Daniels [EMAIL

Re: curious problem with large numbers

2005-04-08 Thread Scott David Daniels
g is length 7 vs 8) In the first one, the final byte is '?' (I made the same mistake myself when I first read it). Also note: float('1e1') is 1.#INF both in Idle and from the command line. I suspect an Idle bug. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: curious problem with large numbers

2005-04-08 Thread Scott David Daniels
Scott David Daniels wrote: Bengt Richter wrote: Aha! Same version (2.3.4): Idle: >>> 1e1 1.0 >>> import struct; struct.pack('d', 1e1) '\x00\x00\x00\x00\x00\x00\xf0?' (which is actually 1.0) python via command line (readline support):

Re: Can dictionary values access their keys?

2005-04-08 Thread Scott David Daniels
Matthew Thorley wrote: Scott David Daniels wrote: ...(explaining Python has no "the" parent) I see what your saying, but I my situation the values of the dictionary are unique objects created by a parent object. But that is your convention, not Python's. Some good general rules:

Re: curious problem with large numbers - Due to subprocess

2005-04-08 Thread Scott David Daniels
alue get converted to text -- the subprocess or the parent? --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: some sort of permutations...

2005-04-12 Thread Scott David Daniels
a time, but it is chock-a-block with great stuff. I paid about twenty bucks a fascicle. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with the logic of read files

2005-04-12 Thread Scott David Daniels
be: ... from progadn import * def checkDNA(seq): ... def main(): ... for x in extseq: f = open(x, "r") try: print checkDNA(f.read()) finally: f.close() if __name__ = '__ma

Re: variables exist

2005-04-12 Thread Scott David Daniels
and use better algorithms. Only in the core of a frequently used inner loop should you even care about the cost of exceptions. Even then, you can often lift the exception handler around the loop and recover the most necessary performance. --Scott David Daniels [EMAIL PROTECTED] -- http

Re: Compute pi to base 12 using Python?

2005-04-13 Thread Scott David Daniels
ut are negative bases. For example, 3(10) = 111(-2). That's 1*(-2)^2 + 1*(-2)^1 + 1*(-2)^0 = 4 - 2 + 1. I can't think of any use for negative bases, but they are a fun game to play with (if you're into that sort of stuff). Non-integer bases are fun too. If you think those are fu

Re: sort of a beginner question about globals

2005-04-15 Thread Scott David Daniels
bclasses of unittest.TestCase. To run all of these the tests, at a command prompt type: python test_prog.py To run them all and see which are being run, python test_prog.py -v You can run individual tests with: python test_prog.py TestCase.test_second TestCase here is the name of the class

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 11)

2005-04-15 Thread Scott David Daniels
ttribute it? ;-) Clearly to Greg. --Scott David Daniels [EMAIL PROTECTED] (who should have said something as soon as he saw the mis-attribution) -- http://mail.python.org/mailman/listinfo/python-list

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 18)

2005-04-19 Thread Scott David Daniels
Simon Brunning wrote: "Get real. I can't imagine using anything so complex." -- Scott David Daniels, in response to a suggestion to try (1j-1) as a counting base Oops -- once again I get credit for someone's response to my post. (I was the "try (1j-1)" poster).

Re: Array of Chars to String

2005-04-20 Thread Scott David Daniels
2 bits per character). I suppose it could be done, but a naïve program might be in for a big shock about memory consumption. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: pythonic use of properties?

2005-04-20 Thread Scott David Daniels
used long after storing is a candidate for more validation. This rule applies "in spades" for persistent data (stored in any form of database). The rule is to catch issues where you can figure them out. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib,winzip barfs on Python-2.4.1.tar, cannot download bzip2

2005-04-20 Thread Scott David Daniels
t "-v" as in: python -v prog.py -args ... --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib,winzip barfs on Python-2.4.1.tar, cannot download bzip2

2005-04-21 Thread Scott David Daniels
Bill Davy wrote: Hi Scott, Nice idea. Tried that but no more information about where the file was (not) found (see below). But many thanks for a useful flag. I did not see them in the documentation. What should I be lkooking for? [StopPres: Ah ha -h why did I not think of that?] ... import

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-23 Thread Scott David Daniels
Mage wrote: Scott David Daniels wrote: See, the body of your anonymous function just looks for "the current value of n" when it is _invoked_, not when it is _defined_. The "lambda functions" was an unclear part of the tutorial I read. Should I use them? Are they pythonic? A

Re: How to "generalize" a function?

2005-04-24 Thread Scott David Daniels
'mask') result = list(part2) input.close() output = open(networkConf, 'w') try: output.writelines(result) finally: output.close() --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading csv file

2013-12-19 Thread Scott Jewloszewicz-Clarke
You didn't pass in self as the first arg to open. This is necessary. S On 19 December 2013 09:22, Igor Korot wrote: > Hi, Peter, > Thank you for the great suggestion. > > I tried to implement you code but failed. > > Here's what I have: > > class FileReader: > def __init__(self, filena

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
So, this is what I came up with. It works, which is good but it’s a little different from a few things you guys had mentioned. For one, I got the correct time by calculating the number of time run and converting that into seconds then back out to hr:mn:sc. I didn’t calculate from midnight. T

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
You guys are awesome! I think I was over complicating things for one. Plus I was looking at some code I wrote for another problem that asked to put in the number of seconds to calculate the problem and I didn’t need some of the things I added to this problem. Anyways, you guys have given me a

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Also, can any of you reccommend sites that may have little “projects” that I could work on to help me learn python better? On Jan 31, 2014, at 1:30 AM, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing > wrote: >> sjud9227 wrote: >>> >>> Doesn't >>> assigning seconds/(

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Also, any help on how to get the hours and seconds into double digits that would be cool too. 00:00:00 On Jan 31, 2014, at 1:30 AM, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing > wrote: >> sjud9227 wrote: >>> >>> Doesn't >>> assigning seconds/(60*60) mean that calcu

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
, Scott W Dunning wrote: > Any chance you guys could help with another question I have? Below is a code > to a different problem. The only thing I don’t understand is why when > calculating the 'discounted price’ you have to subtract 1? Thanks again > guys! > >

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
uot;:", seconds,”am" On Jan 31, 2014, at 5:57 PM, Chris Angelico wrote: > On Sat, Feb 1, 2014 at 11:42 AM, Scott W Dunning wrote: >> Also, any help on how to get the hours and seconds into double digits that >> would be cool too. 00:00:00 > > Once you can divide

Re: Help with some python homework...

2014-01-31 Thread Scott W Dunning
Ok cool, thanks Denis! On Jan 31, 2014, at 8:02 PM, Denis McMahon wrote: > On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote: > >> Here is the question that was asked and below that I'll paste the code I >> have so far. > > The following is a reasonably but not highly obfuscated short solut

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