How to determine which method was used in an inheritance heirarchy?

2007-07-15 Thread Erik Jones
Say you're given a call event frame for a method call. How can you tell if the code being executed came from a super class of the object or class the method was called on? Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma

Re: How to determine which method was used in an inheritance heirarchy?

2007-07-15 Thread Erik Jones
On Jul 15, 2007, at 11:23 PM, Michele Simionato wrote: > On Jul 16, 5:51 am, Erik Jones <[EMAIL PROTECTED]> wrote: >> Say you're given a call event frame for a method call. How can you >> tell if the code being executed came from a super class of the object >> o

Re: How to determine which method was used in an inheritance heirarchy?

2007-07-15 Thread Erik Jones
On Jul 16, 2007, at 1:31 AM, Erik Jones wrote: > On Jul 16, 2007, at 12:53 AM, Michele Simionato wrote: > >> On Jul 16, 7:18 am, Erik Jones <[EMAIL PROTECTED]> wrote: >>> On Jul 15, 2007, at 11:23 PM, Michele Simionato wrote: >>> >>>> On Jul 1

Re: How to determine which method was used in an inheritance heirarchy?

2007-07-16 Thread Erik Jones
On Jul 16, 2007, at 12:53 AM, Michele Simionato wrote: > On Jul 16, 7:18 am, Erik Jones <[EMAIL PROTECTED]> wrote: >> On Jul 15, 2007, at 11:23 PM, Michele Simionato wrote: >> >>> On Jul 16, 5:51 am, Erik Jones <[EMAIL PROTECTED]> wrote: >>>> Say y

Re: How to determine which method was used in an inheritance heirarchy?

2007-07-16 Thread Erik Jones
On Jul 16, 2007, at 3:37 AM, Gabriel Genellina wrote: > En Mon, 16 Jul 2007 03:56:18 -0300, Erik Jones <[EMAIL PROTECTED]> > escribió: > >> Perhaps an even better example of what I'm trying to do would be in >> order (this is minus any exception handling): &g

Re: How to determine which method was used in an inheritance heirarchy?

2007-07-16 Thread Erik Jones
On Jul 16, 2007, at 10:35 AM, Chris Mellon wrote: > On 7/16/07, Erik Jones <[EMAIL PROTECTED]> wrote: >> On Jul 16, 2007, at 3:37 AM, Gabriel Genellina wrote: >> >>> En Mon, 16 Jul 2007 03:56:18 -0300, Erik Jones <[EMAIL PROTECTED]> >>> escribió: &g

Re: How to organize control access to source code ?

2007-07-16 Thread Erik Jones
to read up on filesystem level permissions. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailm

Re: Python in Nashville

2007-07-21 Thread Erik Jones
Me! Did you just move here? On Jul 20, 2007, at 10:22 PM, Patrick Altman wrote: > Anyone on this group writing Python code in Nashville, TN? > > -- > http://mail.python.org/mailman/listinfo/python-list Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or

Re: yield keyword usage

2007-07-30 Thread Erik Jones
nother yield statement or ends. In this case, since the yield occured in a loop, it will be the same yield statement at which point it will "yield" the new value of a. It should be obvious now that this whole process will repeat until the condition a < max is not longer

Re: Database intensive application

2007-08-13 Thread Erik Jones
On Aug 12, 2007, at 7:44 AM, Viewer T. wrote: > and Yes, Python > has awesome database support and can satisfy almost all database > needs. Wow. Nobody ever told me Python was *that* kind of language :) Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615

Re: comparing two lists

2007-08-23 Thread Erik Jones
urthermore, I can have the opposite situation. > This time I need to remove from memlist a host which is not in dblist. > How would you do this? Similarly, if you add an toHash() method to you object class you could do something like (using the reverse iteration solution mentioned in another

Re: Python Classes

2007-08-28 Thread Erik Jones
ot;by default". That's what programmers are for. There may be application domains where *some* defaulting behavior makes sense, but that's what frameworks and DSLs are for. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Em

Re: Haskell like (c:cs) syntax

2007-08-28 Thread Erik Jones
merits of one language over the other, to the OP: no, Python doesn't have any pattern matching facilities. Binding statements must be explicit, so you could do something along the lines of (using parallel assignment): head, tail = l[0], l[1:] or, front, last = l[:len(l) - 1], l[len

Re: Python 3K or Python 2.9?

2007-09-15 Thread Erik Jones
r box, you'll realize that it really is a pointless one. Saying, "because that's how Python does it" may be the only valid reason, but that argument is about on par with a six year old's "just because...". Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list

Re: how to join array of integers?

2007-09-15 Thread Erik Jones
On Sep 15, 2007, at 8:56 AM, Arnau Sanchez wrote: > js escribió: > >>> On 9/15/07, Summercool <[EMAIL PROTECTED]> wrote: > >>> in Python... is the method to use ",".join() ? but then it must >>> take >>> a list of strings... not integers... >>> >>> any fast method? > >> print ''.join([str(i)

Re: how to join array of integers?

2007-09-15 Thread Erik Jones
itertools modules: >> >> from itertools import imap >> ",".join(imap(str, [1, 2, 3])) > > It's nice people have invented so many ways to spell the > builting "map" ;) > >>>> ",".join(map(str,[1,2,3])) > '1,2,3' IIR

Re: Google and Python

2007-09-19 Thread Erik Jones
any of the three listed languages. So, yes, in this case it is what is often Apache in other installations. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Google and Python

2007-09-19 Thread Erik Jones
On Sep 19, 2007, at 4:01 PM, TheFlyingDutchman wrote: > On Sep 19, 1:02 pm, Erik Jones <[EMAIL PROTECTED]> wrote: >> is usually Apache at most sites? >> >> No an http server and application server are two different things. >> An http server services requests o

Re: newb: Simple regex problem headache

2007-09-21 Thread Erik Jones
esn't work for whole numbers. I'm not sure what you just said makes a lot of sense, but if all your looking for is a regex that will match number strings with or without a decimal point, try '\d*\.?\d*' Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.59

Re: Confused about 'positive lookbehind assertion'

2007-09-25 Thread Erik Jones
r = re.compile(r'(?<=abc)def') >>> m1 = r.search('bcde') >>> m1.group()'def' 'def' >>> m2 = r.search('bcdefff') >>> m2 == None True So, it matches 'def' but only if it is immediately p

Re: A question on python performance.

2007-09-26 Thread Erik Jones
per) What you're describing is a case of mulitple dispatch. See http:// www.artima.com/weblogs/viewpost.jsp?thread=101605 for a short description and (as short) example by Guido. You can probably fill that out and adapt it to your needs. Alternatively, you could look into the mult

Re: Delete values from a string using the index

2007-09-26 Thread Erik Jones
n/listinfo/python-list >>> l = [1, 2, 3] >>> del l[1] >>> l [1, 3] Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http:/

Re: True of False

2007-09-27 Thread Erik Jones
t; In [268]: 'c' in a == True > Out[268]: False > > In [269]: ('c' in a) == True > Out[269]: True > > In [270]: 'c' in (a == True) > -- > - > Traceback (most rec

Re: True of False

2007-09-27 Thread Erik Jones
On Sep 27, 2007, at 12:29 PM, Erik Jones wrote: > > On Sep 27, 2007, at 11:47 AM, Marc 'BlackJack' Rintsch wrote: > >> On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote: >> >>> I tried writing a true and false If statement and didn't get >>>

Re: Python 3.0 migration plans?

2007-09-28 Thread Erik Jones
So what we need is a poll on what the questions should be. I *love* > c.l.py. Does professional vs. personal use matter here? What if I plan to switch in the morning or at midnight on the first solstice after the second alpha release? Is Mercury or Venus in retrograde? These thin

Re: Python 3.0 migration plans?

2007-09-28 Thread Erik Jones
stead, decided to actually, actively get along with the others here. I think some of the question you've begun threads with have been both good and valid. It's just that you need some work on your e-people skills, man. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 8

Re: global variables

2007-10-02 Thread Erik Jones
owfoo UnboundLocalError: local variable 'f' referenced before assignment The difference in the last one is that when showfoo() is compiled the assignment to f without any global statement makes f a local variable and a method is called on it before it is bound which results in the

Re: migrating to packages

2007-10-03 Thread Erik Jones
read about that kind > of package 'migration' situation? > > Because i *really* want to keep the FROM PACKAGE import B syntax. http://www.python.org/doc/current/tut/ node8.html#SECTION00840 Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595

Re: The fundamental concept of continuations

2007-10-09 Thread Erik Jones
g. > > I note that I'm being mocked for not using my real name by someone not > using his/her real name. Thank you, no-name gnuist006, you make me > laugh. Relax, ., I hardly think he was mocking you. He probably assumed that using a . in a sentence as a form of address woul

Re: storing meta data on dictionary keys

2007-10-09 Thread Erik Jones
t;>> graph = {} >>> >>> n = Node('foo') >>> m = Node('blah', baz=5) >>> >>> nodes[n.name] = n >>> nodes[m.name] = m >>> >>> for name, node in nodes.items(): ... graph[node] = "whatever for

Re: mutable objects as dictionary keys

2007-10-09 Thread Erik Jones
be done for each mutable > type and rule function separately), especially since I read that > future versions of python (2.6 ?, 3.0 ?) will contain class > decorators and allow syntax like class A(*bases): pass > > Is there a better approach? Any comments are appreciated. > >

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Erik Jones
t; and > x >8] big_evens = range(10, 100, 2) > > low_evens = [2,4,6,8] > # make a list containing 11 - 99 odds only > big_odds = [x for x in list(xrange(100)) if x % 2 != 0 and x >9] big_odds = range(11, 100, 2) Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Erik Jones
range (optionally with a step) while range returns a list of numbers over a range (optionally with a step). >>> l = xrange(99) >>> m = range(99) >>> type(l) >>> type(m) Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list

Re: storing meta data on dictionary keys

2007-10-10 Thread Erik Jones
On Oct 10, 2007, at 6:40 PM, Andreas Kraemer wrote: > On Oct 9, 9:18 pm, Erik Jones <[EMAIL PROTECTED]> wrote: >> So, do you not keep references to your nodes anywhere but the actual >> graph dict? I kind of agree with Chris here in that two dicts will >> work. On

Re: Keeping track of subclasses and instances?

2007-10-11 Thread Erik Jones
an imagine different use cases for this, (though they certainly are > non-standard :-)). I once contemplated the (toy-) implementation of a > frame-based knowledge representation system using Python's object > model, where one definitely needs classes to keep track of their > instanc

Re: storing meta data on dictionary keys

2007-10-11 Thread Erik Jones
On Oct 11, 2007, at 1:36 AM, Andreas Kraemer wrote: > On Oct 10, 9:00 pm, Erik Jones <[EMAIL PROTECTED]> wrote: >> If you're sure that 1. this use case won't grow and 2. that you'll >> only be the only person ever using code, then it's your choice of

Re: storing meta data on dictionary keys

2007-10-11 Thread Erik Jones
On Oct 11, 2007, at 2:25 PM, Andreas Kraemer wrote: > On Oct 11, 10:17 am, Erik Jones <[EMAIL PROTECTED]> wrote: > >> No, duck typing and inheritance are two different things. Duck >> typing is when you implement the same operations as another object or >> class, wh

Re: PEP idea: Instrumented Python

2007-10-12 Thread Erik Jones
On Oct 12, 2007, at 12:10 PM, Jean-Paul Calderone wrote: > On Fri, 12 Oct 2007 11:33:11 -0500, Erik Jones <[EMAIL PROTECTED]> > wrote: >> [snip] >> >> This got me thinking about building a module that could be included >> by projects that creates a soc

Re: PEP idea: Instrumented Python

2007-10-12 Thread Erik Jones
t and responds to messages on that socket in a separate thread from the main app so that you can connect to the app and explore its current state. Take a look at the evalexception module in Paste to see what he does. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401

stderr is a lame hack?

2007-10-12 Thread Erik Jones
f the failure(s) are printed to stdout (why not stderr? because stderr is a lame hack <0.2 wink>), and the final line of output is "Test failed.". What does he mean by stderr being a lame hack? Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5

Re: Python on imac

2007-10-14 Thread Erik Jones
est 2.5 release (and future versions). > > If you're using PyGTK, you will need to install Apple X11 (can't > remember if it's installed by default yet), since OS X's window > manager is not X11-based. Fink can also install GTK+, etc. for you. > Other than that, most

Re: Order of tuples in dict.items()

2007-10-15 Thread Erik Jones
g of a dict the result of Python's hash function for any given newly inserted key is extremely likely to be different than it would have been before the resizing, i.e. the method may be the same, but the result is different. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.

Re: Order of tuples in dict.items()

2007-10-15 Thread Erik Jones
On Oct 15, 2007, at 6:07 PM, Steven D'Aprano wrote: > On Mon, 15 Oct 2007 14:11:27 -0700, John Machin wrote: > >> On Oct 16, 12:47 am, Erik Jones <[EMAIL PROTECTED]> wrote: >> >>> Not between two consecutive reads, no. However, after any >>> res

Re: web.py & postgresql error

2007-10-22 Thread Erik Jones
No module named pgdb > > any thoughts would be greatly appreciated. > thanks, > doug Apparently you don't have pgdb installed or it's path isn't in your PYTHONPATH environment variable. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't Write to PostGIS PostGreSQL database via psycopg2

2007-10-22 Thread Erik Jones
x27;re not seeing the results when you look at the database after the script has run it's probably because you need to call conn.commit() after your execute statements in order to commit your transaction as psycopg does not, by default, run in "autocommit" mode. The update&#

Re: greatest and least of these...

2007-10-23 Thread Erik Jones
print > > Also, if they quit the program with choice #2 and entered numbers, it > should display the greatest and least of them. If they just > started and > didn't enter anything and want to quit, I get an error message saying > UnboundLocalError: local variable '

Re: Parallel insert to postgresql with thread

2007-10-25 Thread Erik Jones
separate connections unless there is something like and ALTER TABLE or REINDEX concurrently happening on the table. The whole serialized inserts thing is strictly something popularized by MySQL and is by no means necessary or standard (as with a lot of MySQL). Erik Jones Software Developer | Em

Re: Parallel insert to postgresql with thread

2007-10-25 Thread Erik Jones
On Oct 25, 2007, at 10:12 AM, Jean-Paul Calderone wrote: > On Thu, 25 Oct 2007 09:46:54 -0500, Erik Jones <[EMAIL PROTECTED]> > wrote: >> >> [snip] >> >> Fortunately, in his case, that's not necessarily true. If they do >> all their work wi

OT Re: Parallel insert to postgresql with thread

2007-10-25 Thread Erik Jones
If you're not Scott Daniels, beware that this conversation has gone horribly off topic and, unless you have an interest in PostreSQL, you may not want to bother reading on... On Oct 25, 2007, at 9:46 PM, Scott David Daniels wrote: > Erik Jones wrote: >> >> On Oct 25, 200

Re: Copy database with python..

2007-11-03 Thread Erik Jones
you can just do a manual copy (using cp, rsync, or whatever) of the entire pg data directory but that will require the same amount of space as the original database. If you're goal is to make a backup, pg_dump is the way to go. Make note, though, pg_dump will only dump one database

Re: Can local function access local variables in main program?

2007-11-03 Thread Erik Jones
al for x? Something like that: >>>> x = 12345 >>>> def foo(): > ... global x > ... print x > ... noglobal(x) # ??? > ... x = 0# now this is local x >>>> foo() > 12345 >>>> print x > 12345 Why would you need

Re: pygresql

2007-11-04 Thread Erik Jones
you think this is the > problem or am I going astray somewhere else? > > Thank you very much in advance for any assistance, > James. You shouldn't be using psycopg, it's not supported anymore. Use psycopg2 which is in active development and has no dependecies on any of the

Re: a simple tcp server sample

2007-11-07 Thread Erik Jones
n how to do that and be glad to get a > hint. > > Thanks in advance That's when it stops being simple. You'll need to spawn threads or fork off separate processes to do that. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fa

Re: basic if stuff- testing ranges

2007-11-26 Thread Erik Jones
quot; looks possible, and > Thanks again. I find the reference is laid-out in a way that I > don't find > intuitive and every time I look for something I fail. I even grep > through > the folder to get a clue, which shows how poor the index is (to me)! Then use one of the quic

Re: basic if stuff- testing ranges

2007-11-26 Thread Erik Jones
he params. So, saying x in range(1,20) is not asking if x is between 1 and 20 but, rather, if x is a member of the values genereated by the range function with params 1 and 20. So, yes, using range() Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.29

Re: fork/exec with input redirection

2007-11-26 Thread Erik Jones
--quiet", "--mode", "gtp", "<", "13x13.tst"]) > > but this apparently doesn't work. Is there some other way to > accomplish what I'm going for? Read up on the docs for the subprocess module. Erik Jones Software Developer | Emma

Re: Handling test data that depends on temporal data (that might change while the test runs)

2008-05-15 Thread Erik Jones
r, with a default, to the method's interface: def test_generate_chat_dir_string(self, now=None): if not now: import datetime now = datetime.datetime.now() . That way you can feed it values when testing to validate the calculations but leave it up to the datetime module to fill in the used value in production. -- Erik Jones [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list