Re: type(foo) == function ?

2006-11-29 Thread Erik Max Francis
in general, explicit typechecks are not a good idea, since they often preclude user-defined objects from being used. Instead, try performing the call and catch the resulting TypeError: >>> f = 'asdf' >>> try: ... f() ... except TypeError: ... print "oops, f is

Re: How to test if two strings point to the same file or directory?

2006-12-16 Thread Erik Max Francis
x27;. That's what os.path.expanduser is for. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis It is much safer to obey than to rule. -- Thomas a Kempis -- http://mail.python.org/mailman/listinfo/python-list

Re: python , Boost and straight (but complex) C code

2006-12-30 Thread Erik Max Francis
> > namespace { // Avoid cluttering the global namespace. iostream and namespaces are both most definitely C++ features, not C. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfranc

Re: python , Boost and straight (but complex) C code

2006-12-30 Thread Erik Max Francis
s that you're dealing with C++ code throughout, not C, contrary to what you had claimed. C and C++ are not the same language. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M e

Re: Some thougts on cartesian products

2006-01-23 Thread Erik Max Francis
a set, then it should either be a generator or a set. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Nothing is potent against love save impotence. -- Samuel Butler -- http://mail.python.org/mailman/listinfo/python-list

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Erik Max Francis
e as "temp_buf.write(v)". > So the suggestion is to add a __iadd__ method to StringIO and cStringIO. > > Any thoughts? Why? StringIO/cStringIO have file-like interfaces, not sequences. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/

Re: Why checksum? [was Re: Fuzzy Lookups]

2006-02-01 Thread Erik Max Francis
Are there any other reasons? Because if you store a hash, then you can keep that around even when the original file is archived, moved elsewhere, or deleted. It's awfully helpful for building databases of files you've seen before. -- Erik Max Francis && [EMAIL PROTECTED] &&

Re: A problem with some OO code.

2006-02-04 Thread Erik Max Francis
to get help will usually allow _you_ to see where the problem was in the process. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis God said: "Let Newton be"; and all w

Re: how do you pronounce 'tuple'?

2006-02-12 Thread Erik Max Francis
nced the latter if you list out the various pronounciations for large n, seems me the _uhs_ outweigh the _oos_. (There's quadruple on one side, but then quintuple, sextuple, septuple, heptuple, octuple, etc., etc., etc.) -- Erik Max Francis && [EMAIL PROTECTED] && http://w

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Erik Max Francis
in its history when every post had to be accompanied by a Monty Python gag ... -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Whatever it is you came to teach me / I am here

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Erik Max Francis
s a 1-tuple would be a single. Granted that's not nearly as gruesome enough a name to go with the special lopsided Pythonic creature mentioned above. I suggest we name it a hurgledink. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Whatever it is you came to teach me / I am here to learn it -- India Arie -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Erik Max Francis
but there's already plenty of existing English usage such that 3-tuple : triple :: 2-tuple : pair. (A 2-tuple is an "ordered pair" in mathematics.) If a 2-tuple is a pair, then it would seem to follow that a 1-tuple is a single. -- Erik Max Francis && [EMAIL PROTECTED

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Erik Max Francis
nipple? We don't talk about that anymore since the Incident. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Society attacks early when the individual is helpless. -- B.F. Skinner -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Erik Max Francis
I don't think it's something we need to worry about. I'm sure you'd just call them "empty tuples" or "0-tuples" and move on :-). -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 5

Re: how do you pronounce 'tuple'?

2006-02-14 Thread Erik Max Francis
It's a "trip-you-uple", which you can pronounce anyway you like ;-) All I hear there is "triple you up," which is good if you're in a poker tournament, which I suppose tells you where my mind has been lately. -- Erik Max Francis && [EMAIL PROTECTED] &&

Re: aborting without killing the python interpreter

2006-02-18 Thread Erik Max Francis
tring (the help for sys.exit shows that if a string is passed in, it will be printed before the process exits with failure -- something I wasn't aware of actually). -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 2

Re: number ranges (was Re: Matlab page on scipy wiki)

2006-02-19 Thread Erik Max Francis
typically use a normal ellipsis "..." to indicate any sort of repeated pattern. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis To know oneself, one should assert oneself

Re: Mutable numbers

2006-02-20 Thread Erik Max Francis
cs doesn't change that fact. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis I will always remember / This moment -- Sade -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening files without closing them

2006-03-05 Thread Erik Max Francis
> Just keep doing what you are doing, please. Note quite. The assignment of the resources to its variable needs to be done before the try: f = open(file) try: contents = f.read() finally: f.close() -- Erik Max Francis && [EMAIL PROTECTED] &

Re: Static Methods in Python

2005-05-01 Thread Erik Max Francis
aticMethod(x, y, z): ... aStaticMethod = staticmethod(aStaticMethod) -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Wyrd has swept all my kin / all the brave chiefs away

Re: How to detect a double's significant digits

2005-05-05 Thread Erik Max Francis
d not only is that a major PITA, you almost never get it > bug-for-bug right... Especially since all of his examples have the same number of significant digits (3), as the term is usually meant. Zeroes to the right are significant, not zeroes to the left. -- Erik Max Francis && [

Re: F.readline

2005-05-05 Thread Erik Max Francis
Robert Kern wrote: > There is no such command built in. You will have to build it yourself > out of the components that are available. linecache is probably what he's looking for. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose,

Re: How to detect a double's significant digits

2005-05-05 Thread Erik Max Francis
ly wanted to get the number of digits involved, then that's fine, but that's not what significance is. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Eternity is very long, especially near the end. -- Woody Allen -- http://mail.python.org/mailman/listinfo/python-list

Re: Fredrik Lundh

2005-05-08 Thread Erik Max Francis
D H wrote: > Yet again someone bitches about a thread right after they hypocritically > throw their own little darts into the mix. No one cares. Please take it elsewhere. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA &

Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Erik Max Francis
Jonathan Bartlett wrote: > I think you're misreading some of what is being said. I think you're giving the author too much credit. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AI

Re: The need to put "self" in every method

2005-05-31 Thread Erik Max Francis
this way? Because it's not always needed. See staticmethod or classmethod. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis The basis of optimism is sheer terror. -- Oscar Wilde -- http://mail.python.org/mailman/listinfo/python-list

Re: method = Klass.othermethod considered PITA

2005-06-04 Thread Erik Max Francis
lias_, which acts as a verb, but won't be automatically scanned as a verb when help is finding the list of valid verbs: alias_hi = verb_hello ... That way, you get maximum effectiveness for minimum clutter. -- Erik Max Francis && [EMAIL PROTECTED] && http:

Re: method = Klass.othermethod considered PITA

2005-06-05 Thread Erik Max Francis
uestion was asked before he went on to show what wasn't working for him.) -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis To understand is to forgive, even oneself. -

Re: Creating file of size x

2005-06-06 Thread Erik Max Francis
Jan Danielsson wrote: >Is there any way to create a file with a specified size? What do you want to put in the file? Once you've answered that question, the solution should present itself. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ Sa

Re: poker card game revisited (code included)

2005-06-07 Thread Erik Max Francis
hen will all this information you can easily arrange the code to select the best existing hand. Note that these all use well-established techniques and reveal nothing secret. > 3. x wild. > For games like "deuces wild", what would be the best way to manage > those? I tought

Re: poker card game revisited (code included)

2005-06-08 Thread Erik Max Francis
he same as the straight set, then it's a straight. (Do this by reverse order of the relative values of the straights, and stop when you find the first one, to get the highest straight.) The most efficient way to do this is with a bitmask, so that's how it's usually done. --

Re: poker card game revisited (code included)

2005-06-08 Thread Erik Max Francis
s > ... You can also deal with them as a mask of card indexes. So the deuce of clubs is bit 0, the three of clubs is bit 1, all the way up to the ace of spades, which is bit 51. (That obviously won't fit in an int; you'll need a long.) -- Erik Max Francis && [EMAIL PR

Re: Python documentation problem

2005-06-18 Thread Erik Max Francis
Xah Lee wrote: > Fuck the python doc wasted my time. Fuck python coders. Use your words! -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis The mind is not a vessel to

Re: c[:]()

2007-05-31 Thread Erik Max Francis
d changes to the language and its conventions. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis The quality, not the longevity, of one's life is what is important. -- Dr. Martin Luther King, Jr. -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-05-31 Thread Erik Max Francis
ast): File "", line 1, in ? TypeError: 'str' object is not callable You also seem to be under the impression that `x[:]()` is somehow special syntax that is treated differently than `y = x[:]; y()`. It is not. Besides, _ambiguity_ was never the problem. _Functionality_ is the p

Re: c[:]()

2007-05-31 Thread Erik Max Francis
either learning Python, or suggesting useful improvements. That's just the way the ball bounces, unfortunately. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis To endure what is unendurable is true endurance. -- (a Japanese proverb) -- http://mail.python.org/mailman/listinfo/python-list

Re: subexpressions (OT: math)

2007-06-03 Thread Erik Max Francis
efined as the length of the subtended arc divided by the length of the radius, which is a length divided by a length, and thus dimensionless. (Like in a lot of dimensional analysis, you write "rad" when desired to give a helpful hint, not because it's necessary; the radian has the s

Re: subexpressions (OT: math)

2007-06-03 Thread Erik Max Francis
ret sin(1.2) as sine of an angle measured in > degrees or radians (or whatever else). The problem with this reasoning is when angular-dimensioned quantities pop out of trigonometric functions, which happens routinely in the world of calculus. When that happens, you use radians (or steradians) o

Re: subexpressions (OT: math)

2007-06-04 Thread Erik Max Francis
for the original function. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis The time to repair the roof is when the sun is shining. -- John F. Kennedy -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-04 Thread Erik Max Francis
ere proposing this whole time. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Get there first with the most men. -- Gen. Nathan Bedford Forrest, 1821-1877 -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-05 Thread Erik Max Francis
ed to iterate over the first 2**22 items in a list of 2**22+1 > items, making a copy of the sub-list first would probably be a bad idea :) Then again, in that case, so would making a list of the indices with `range`, which is what the original poster was suggesting. -- Erik Max Francis &&am

Re: urllib2 - iteration over non-sequence

2007-06-09 Thread Erik Max Francis
, as there's no point in reading in the whole file before iterating over it. To get the same effect as file iteration in later versions, use the .xreadlines method:: for line in aFile.xreadlines(): ... -- Erik Max Francis && [EMAIL PROTECTED] &&

Re: urllib2 - iteration over non-sequence

2007-06-09 Thread Erik Max Francis
ay to do it -- and it isn't to read the whole thing in first for no reason whatsoever other than to avoid an `x`. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis

Re: urllib2 - iteration over non-sequence

2007-06-09 Thread Erik Max Francis
ess waste. This falls in the latter category. Besides, someone was asking for/needing an older equivalent to iterating over a file. That's obviously .xreadlines, not .readlines. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA &

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Erik Max Francis
which defaults to identity), and only support comparisons when the user defines what it is he wants them to mean. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Water whic

Re: unicode

2007-06-30 Thread Erik Max Francis
it in hex string escape notation. > Then if I try this: > > --- > u_str = u"abc\u" > reg_str = u_str.encode("utf-8") > print reg_str > --- > > I get the output: > > abc > > Here it looks like python isn't using the asci

Re: Proposal: s1.intersects(s2)

2007-07-04 Thread Erik Max Francis
onundrum of not understanding how the null set relates to intersections. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Perfect girl / She was never me -- Lamya -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode problem

2007-07-07 Thread Erik Max Francis
7 ( as > defined in iso-8859-15 ) U+2019 is RIGHT SINGLE QUOTATION MARK. The APOSTROPHE (U+0027) is a cross-reference as a similar code point, but they're not the same thing. Your problem is that ISO-8859-15 doesn't have the RIGHT SINGLE QUOTATION MARK, so you'll have to do the

Re: 2**2**2**2**2 wrong? Bug?

2007-07-10 Thread Erik Max Francis
**c), or they would have written it more efficiently and clearly. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Men with empires in their purpose / And new eras in their b

Re: Pass by reference or by value?

2007-07-13 Thread Erik Max Francis
ith ints! But that's because ints are immutable, not because there is an explicit copy of anything being made. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Ip

Re: Sorting dict keys

2007-07-20 Thread Erik Max Francis
ld really like it if I could somehow do it in one > line. Why is doing it in one line a priority? Clarity is more important than brevity. Regardless, you can do it in one line with the sorted builtin: >>> sorted(a.keys()) [1, 2, 3] -- Erik Max Francis && [EMAIL PROTECT

Re: Vector classes

2007-04-22 Thread Erik Max Francis
g 1 forces me to do). > > Is there any way to combine the two? The ultimate would be if I > somehow could take vector2 and hook the member self.vals[0] to self.x > or something. There are also full-featured Vector and Matrix classes in the la.py module of ZOE: http://www.alcyon

Re: Bug in select

2007-04-22 Thread Erik Max Francis
Ron Garret wrote: > So this is clearly a bug, but surely I'm not the first person to have > encountered this? Is there a known workaround? It's hard to see how this demonstrates a bug in anything, since you're telnetting to the wrong port in your example. -- Erik

Re: Bug in select

2007-04-22 Thread Erik Max Francis
cent call last): > File "", line 1, in > File "", line 1, in bind > socket.error: (48, 'Address already in use') >>>> s.bind(('',8081)) >>>> s.listen(5) >>>> f = s.accept()[0].makefile() >>>> f.re

Re: Asyncore Help?

2007-05-13 Thread Erik Max Francis
more general name for asyncore/asynchat is Medusa, and there are some resources with more examples available here: http://www.nightmare.com/medusa/ http://www.amk.ca/python/code/medusa.html -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/

Re: 0 == False but [] != False?

2007-05-23 Thread Erik Max Francis
thing. if x: ... is not the same thing as if x == True: ... it's the same as if bool(x): ... So a more meaningful comparison of your two tests are: >>> bool(0) == bool(False) True >>> bool([]) == bool(Fal

Re: 0 == False but [] != False?

2007-05-24 Thread Erik Max Francis
the end. Yes, it's the Laura Creighton > article again: > > http://groups.google.com/group/comp.lang.python/msg/2de5e1c8384c0360 If so, be sure to click "More options," then "View thread," and then read the responses. There were many reasonable objections to

Re: 0 == False but [] != False?

2007-05-24 Thread Erik Max Francis
g. Really. He's not. That's a perfect example of a style guideline that not only wastes energy, misses the point, but is totally wrong. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W &&

Re: 0 == False but [] != False?

2007-05-29 Thread Erik Max Francis
since it was not widely granted as true. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Fear is an emotion indispensible for survival. -- Hannah Arendt -- http://mail.python.org/mailman/listinfo/python-list

Re: 0 == False but [] != False?

2007-05-29 Thread Erik Max Francis
Donn Cave wrote: > "Not that it is of no historical interest" may have been too > hard to follow, my apologies. Yeah, my reading comprehension wasn't up to snuff that night. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jos

Re: "is" and ==

2007-05-29 Thread Erik Max Francis
ng "PING" then you do not want to do so by identity, but rather value, so you use the `==` operator, not `is`. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis You could have another fate / You could be in another place -- Anggun -- http://mail.python.org/mailman/listinfo/python-list

Re: [2.5] Reading a two-column file into an array?

2007-07-30 Thread Erik Max Francis
Gilles Ganault wrote: > I'm sure there's a much easier way to read a two-column, CSV file into > an array, but I haven't found it in Google. > > Should I use the Array module instead? The csv module? Or just .rstrip and .split? -- Erik Max Francis &

Re: Question -- Running Programming Python Examples

2007-08-04 Thread Erik Max Francis
ady bound to it; probably you have an HTTP server already running as part of your default software installation and don't realize it. Choose another port. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W &

Re: Puzzled by "is"

2007-08-09 Thread Erik Max Francis
ntinel object (e.g., `mySentinel = object()`), because that is the only time you actually _are_ interested in identity. All other times you are not really interested in identity. Sample code as above is essentially showing unimportant implementation details that should never concern you.

Re: Puzzled by "is"

2007-08-09 Thread Erik Max Francis
of large tuples can be expensive). Admittedly the empty > tuple is a special case but then 'Special cases aren't special enough to > break the rules'. > > A bit odd. It doesn't save time if you have to check through all the existing tuples for matches ... -- Erik Max

Re: Puzzled by "is"

2007-08-09 Thread Erik Max Francis
e user (that's you and > I) should *not* expect any particular behaviour to hold between > different implementations. Right. In the terminology of language standards, it is implementation defined. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/

Fatest standard way to sum bytes (and their squares)?

2007-08-12 Thread Erik Max Francis
loop, but since it's going to be processing massive amounts of data, the faster the better. Are there any tricks I'm not thinking of, or perhaps helper functions in other modules that I'm not thinking of? -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcy

Re: Fastest standard way to sum bytes (and their squares)?

2007-08-12 Thread Erik Max Francis
And of course I meant fastest, not "fatest." Fattest wouldn't be good, either. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Whoever named it necking w

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-12 Thread Erik Max Francis
the sums as ints/longs to avoid losing precision, so converting to floating point isn't an optional. (The sums are normalized by the sizes of the files and expanded to 32 bits in order to maximize precision.) -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.co

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-12 Thread Erik Max Francis
appear to work quite as dramatically well for me with strings instead of lists, but it certainly is an improvement. > Of course, that optimization doesn't work for the squared sum; using a > lambda only pessimizes it. Right. -- Erik Max Francis && [EMAIL PROTECTED] &

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-12 Thread Erik Max Francis
unt) > ordinalSumSquared = sum(ord(c)**2 * count[c] for c in count) This approach is definitely faster than using a generator in my tests, and was second fastest overall. I'm actually a bit surprised that it's as fast as it is; it never would have occurred to me to try it this wa

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-12 Thread Erik Max Francis
l the next day, but got a factor of two speedup within half an hour! -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis It is morale that wins the victory. -- Gen. George C. Marshall -- http://mail.python.org/mailman/listinfo/python-list

Re: negative polar axis

2007-08-13 Thread Erik Max Francis
negative. The usual translation from polar to Cartesian coordinates makes this meaningful, albeit weird, so in effect the resulting positions are just reflections around the origin. Which I suppose is what the original poster was asking about, but it's still not clear. -- Erik Max Fra

Re: about negative polar plots

2007-08-14 Thread Erik Max Francis
u're going to have to give more information about what you're doing, what you're using to do it, and where it's giving you unexpected or undesired results if you want help solving your problem. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/ma

Re: Retry: Question about FutureWarning

2007-08-14 Thread Erik Max Francis
6, 17:16:11) [GCC 3.2.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 0x 4294967295L -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis Black vinyl man with black plasticized imagination -- Nik Kershaw -- http://mail.python.org/mailman/listinfo/python-list

Re: Python question (PyNoob)

2007-08-19 Thread Erik Max Francis
uch tasks would be your ability to manipulate them and write your own. If tools already exist that do what you need, which languages they were written in would be completely irrelevant. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA &

Re: beginner, idiomatic python

2007-08-23 Thread Erik Max Francis
ith a list, then the sets-difference-and-then-make-a-list mechanism is appropriate. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis It [freedom] must be demanded by the oppressed. -- Dr. Martin Luther King, Jr. -- http://mail.python.org/mailman/listinfo/python-list

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Erik Max Francis
assigning mutates the sequence. Slicing alone returns a copy. >>> L = ['one', 'two', 'three', 'four', 'five'] >>> x = L[1:] # grab a slice >>> x[:] = [] # mutate it >>> x [] >>> L # original li

Re: list index()

2007-08-31 Thread Erik Max Francis
t; towards the back of my mouth. Native English accents vary as well, but _roll_ rhymes with _troll_, not _trawl_. _Trawl_ would rhyme with _fall_, and _fall_ definitely doesn't rhyme with _roll_. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San

Re: list index()

2007-08-31 Thread Erik Max Francis
t; sound in any accent I've ever heard of. Which you pronounce _boat_ and _bot_ the same way, too? -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis There are no dul

Re: How best to dynamically define methods (and functions)?

2007-09-01 Thread Erik Max Francis
;, ...] for method in methods: setattr(MyClass, method, lambda *x: Node(method, *x)) The first argument here will be the implicit self, if you don't want that, strip off the first argument (or use lambda self, *x: ...). -- Erik Max Francis && [EMAIL PROTECTED] &

Re: How best to dynamically define methods (and functions)?

2007-09-01 Thread Erik Max Francis
Erik Max Francis wrote: > Something like:: > > method = ['fun', ...] > for method in methods: > setattr(MyClass, method, lambda *x: Node(method, *x)) Err, that first line was supposed to be methods = ... -- Erik Max Francis && [EMAIL PROTECT

Re: Python is overtaking Perl

2007-09-03 Thread Erik Max Francis
Asun Friere wrote: > How do you figure that? Isn't the chart showing the frequency of > those particular terms combined as a fraction of the total search > volume on Google? Who knows? The graph has no labeling or calibration for the y-axis, so it's meaningless. -

Re: why brackets & commas in func calls can't be ommited? (maybe it could be PEP?)

2007-03-21 Thread Erik Max Francis
programming language design. Excessive and needless verbosity is one thing; but saving keystrokes for its own sake is not a priority and never should be. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis I am not afraid / To be a lone Bohemian -- Lamya -- http://mail.python.org/mailman/listinfo/python-list

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

2007-09-22 Thread Erik Max Francis
since Io makes no such requirements. The attribute and method (not made distinct in Io; they're called "slots") is much the same as with Python; the current instance is checked for the object, then its parents, then _its_ parents, and so on. -- Erik Max Francis && [EMA

Re: Order of tuples in dict.items()

2007-10-14 Thread Erik Max Francis
hat), but I wouldn't take the chance and rely on such an implementation detail. If you want to keep track of the order in which objects were added to a dictionary, you'll need to keep a separate list of (sorted) keys, which is easy enough. If you're lazy there are plenty of

Re: if..else stmt

2007-10-22 Thread Erik Max Francis
g wrong. Without seeing actual code, it's impossible to say what. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis So little time, so little to do. -- Oscar Lev

Re: Overloading assignment operator

2007-01-23 Thread Erik Max Francis
elf, x): ... self.x = x ... def __mul__(self, other): ... return C(self.x*other.x) ... >>> result = C(2)*C(3) >>> print result <__main__.C instance at 0x402e13ec> >>> result.x 6 -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.

Re: how to "free" an object/var ?

2007-02-01 Thread Erik Max Francis
our M's and a silent Q like the famous > author Farles Wickens *wink* "I knew a guy whose first name was Ed. He was so cool, he spelled it with a hyphen." -- George Carlin -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA,

Re: Running long script in the background

2007-02-06 Thread Erik Max Francis
ees if the job has completed -- showing the results if it has -- or refreshes periodically if it hasn't yet. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis You coul

Re: Running long script in the background

2007-02-06 Thread Erik Max Francis
7;t show anything until the entire process > is complete and it's just a bunch of echo statements in a for loop, > I'm not sure why they behave differently. In a word: buffering. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA

Re: eval('000052') = 42?

2007-02-20 Thread Erik Max Francis
unwise. Instead use int: >>> int('00052') 52 -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis God grant me to contend with those that understand me

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Erik Max Francis
when it reaches the surface of Mars. It was units of momentum that were inappropriately compared, actually. (And it broke up before hitting the ground, but that's a minor quibble.) -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, US

Re: md5 wrongness?

2007-11-23 Thread Erik Max Francis
;credits" or "license" for more information. >>>> import md5 >>>> s = md5.new() >>>> s.update('snagglefrob') >>>> s.hexdigest() > '9eb2459fcdd9f9b8a9fef7348bcac933' echo inserts a newline, your Python snippet doesn

Re: Disk Space Script

2007-11-24 Thread Erik Max Francis
popen, or one of the more involved popen... modules, and then parse it however you like. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis Who'd ever think it / Such

Re: Why does __builtins__ mean different things...

2007-12-21 Thread Erik Max Francis
et unpredictable behavior, you just get different behavior you didn't expect, which is not the same thing. Python is a programming language, like any other; randomly dropping letters in names is going to result in bad behavior, so be more careful about it. -- Erik Max Francis && [EMAI

Re: test for None

2006-04-18 Thread Erik Max Francis
ne" > ... else: > ... print "X is not None" > ... No, because you're iterating over an empty list, which does nothing: >>> for x in []: print 'hi' ... >>> -- Erik Max Francis && [EMAIL PROTECTED] &&a

Re: Non-web-based templating system

2006-04-28 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > Thanks, it looks like empy is what I need. :-) -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis The object of war is not to die for your country b

Re: Non-web-based templating system

2006-04-28 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > Actually, that looks even better that EmPy for what I need. :-( -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis All bad poetry springs from

Re: Python "member of" function

2006-04-29 Thread Erik Max Francis
ng pages for "python in" does not reveal very many relevant > sources. Yes, `in` is the relevant operator. It's quite simple to use: >>> a = [1, 4, 9, 16, 25] >>> 2 in a False >>> 4 in a True If you're having problems using it in some circumstan

<    1   2   3   4   5   6   7   >