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
ents, then that is trivially easy to do by creating such an object and overriding its `__call__` method. If you're not willing to do that, but still insisting that `c[:]()` makes sense, then perhaps it would be more advisable to learn more about Python rather than try to suggest profoun

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
window of opportunity for profound changes. Soon isn't all that soon. Furthermore, it is very unlikely that someone is going to be able to suggest profound and useful changes to Python without first being familiar with it. So stabbing in the dark is not going to be very constructive for

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
nd, now. > It sounds like list comprehension may be slower because it builds a list > that never gets used. I'm curious if eval statements are faster than def > statements? Any bytecode experts? Are you serious? Something that builds a list that never gets used is exactly what you w

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. -

The reverse of encode('...', 'backslashreplace')

2007-09-03 Thread Tor Erik Sønvisen
Hi, How can I transform b so that the assertion holds? I.e., how can I reverse the backslash-replaced encoding, while retaining the str-type? >>> a = u'æ' >>> b = a.encode('ascii', 'backslashreplace') >>> b '\\xe6' >>> assert isinstance(b, str) and b == 'æ' Traceback (most recent call last): F

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: Just bought Python in a Nutshell

2007-09-15 Thread Tor Erik Sønvisen
etter programmer, not just a better Python programmer. I only wish I'd read through it earlier, which would have saved me a lot of agony:) -Tor Erik -- http://mail.python.org/mailman/listinfo/python-list

Tapping into the access of an int instance

2007-09-20 Thread Tor Erik Sønvisen
def __init__(self, *a, **k): super(Int, self).__init__(self, *a, **k) >>> i = Int(1) >>> i 1 Regards, Tor Erik -- 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

Convert obejct string repr to actual object

2007-10-08 Thread Tor Erik Sønvisen
t the source sending the object I'm sure someone must have had the same need and created code for it... Maybe Pypy has what I need??? Haven't looked though... Regards, Tor Erik PS: The string repr is created by a server outside of my control... -- http://mail.python.org/mailman/listinfo/python-list

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.

str and __setitem__

2007-01-25 Thread Tor Erik Soenvisen
Hi, What do I need to do to make the code below work as expected: class str2(str): def __setitem__(self, i, y): assert type(y) is str assert type(i) is int assert i < len(self) self = self[:i] + y + self[1+i:] a = str2('1

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

python shelve on win vs unix

2007-02-09 Thread Tor Erik Soenvisen
ppreciated. regards, Tor Erik -- http://mail.python.org/mailman/listinfo/python-list

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

Simple eval

2007-11-18 Thread Tor Erik Sønvisen
eral, etc are appreciated. As this is a contribution to the community I suggest that any improvements are posted in this thread... -Tor Erik Code (tested on 2.5, but should work for versions >= 2.3): ''' Recursive evaluation of: tuples, lists, dicts, strings, unicode strings,

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

Keyword passing to superclass written in C

2007-11-27 Thread Sven Erik Knop
pass the keywords no bother. But if I call Bar with keywords, it calls the C++ version of Foo with all arguments bunched together in "args" and not separated in args and keywords. What am doing wrong? This is Python 2.5.1 - on Ubuntu 7.0.4 if that makes any difference. Thanks

Re: Keyword passing to superclass written in C

2007-11-27 Thread Sven Erik Knop
Duh of course. Not sure what I had done in Python/Python. Now it works. Thanks a lot. Sven Erik Chris Mellon wrote: On Nov 27, 2007 6:47 AM, Sven Erik Knop <[EMAIL PROTECTED]> wrote: Hi I am getting slightly frustrated and wonder if you can help me. Consider a Python cla

Re: "do" as a keyword

2007-12-11 Thread Tor Erik Sønvisen
5) >>> b = range(5, 8) >>> min(a) if sum(a) < sum(b) else min(b) 0 In prior versions, you can use the and/or trick: >>> (sum(a) < sum(b) and [min(a)] or [min(b)])[0] 0 -Tor Erik -- http://mail.python.org/mailman/listinfo/python-list

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

Re: Tuple assignment and generators?

2006-05-05 Thread Erik Max Francis
vdrab wrote: > what the...? > does anybody else get mighty uncomfortable about this? No. Why should you ever care about whether two integers representing values are the same object? Your tests should be with `==`, not `is`. -- Erik Max Francis && [EMAIL PROT

Re: python rounding problem.

2006-05-07 Thread Erik Max Francis
do that? Floating point arithmetic is inherently imprecise. This is not a Python problem. If you want to print it to only three digits, then use something like:: >>> '%.3f' % 2.9954254 '2.995' -- Erik Max Francis && [EMAIL PROTECTED] && http

Re: Why list.sort() don't return the list reference instead of None?

2006-05-07 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > L = [4,3,2,1] > L=L.sort() > L will refer to None, why L.sort() don't return the L? > I want to ask why the designer of Python do so? Because that's the convention that signifies that a Python method mutates the object rather than returns a

Re: Question about exausted iterators

2006-05-18 Thread Erik Max Francis
y choosing to ask in such a way that guarantees practically no one will take your suggestion seriously. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Chance favo

Re: Why does the _winreg module start with an underscore

2006-05-19 Thread Erik Max Francis
as such you probably shouldn't use it or rely on it, unless you know the internal details very well. An identifier starting with _two_ underscores is automatically mangled in a way that makes it more difficult (but not impossible) for external clients to accidentally use them. -- Erik Max

Re: Includeing Python in text files

2006-05-22 Thread Erik Max Francis
like php or > embedded perl. > > So my little toy works not bad, but I was wondering if such a feature > already existed, if yes, can you point me out some links? Another standalone templating system is EmPy: http://www.alcyone.com/software/empy/ -- Erik Max Francis &&

Re: John Bokma harassment

2006-05-24 Thread Erik Max Francis
y were cutting you off unfairly? The alternative is that you're not surprised by this action and are simply trying to spin things in your favor. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W

<    3   4   5   6   7   8   9   10   >