Re: Accessing objects at runtime.

2009-09-10 Thread Jochen Schulz
jacopo:
> 
>> What exactly do you want to know? The names of existing attributes or
>> their content? The latter is probably obvious to you and the former is
>> easy, too. See hasattr, getattr and isinstance.
> 
> I want to know the value of the attributes.
> What you suggest works when the program stops, objects are still in
> memory and I could inspect all I want. BUT I don’t want to stop the
> system. So even the shell would be blocked to type something.

Ah, now I get it: you want to attach to a running process and inspect it
interactively? -Sorry, then I cannot answer you question.

J.
-- 
When I get home from the supermarket I don't know what to do with all the
plastic.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing objects at runtime.

2009-09-10 Thread Jochen Schulz
jacopo:
> 
> I would like to find a way to inspect the objects at run time.  In
> other words I would like to check certain attributes in order to
> understand in which status the object is.

What exactly do you want to know? The names of existing attributes or
their content? The latter is probably obvious to you and the former is
easy, too. See hasattr, getattr and isinstance.

J.
-- 
I lust after strangers but only date people from the office.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for 64bit Linux version

2009-09-03 Thread Jochen Schulz
Bhanu Srinivas Mangipudi:
>
> I just want to that s there a 64 bit Linux version for python ?

Yes.

> if yes can you provide me any links for it.I could find a 64bit
> windows version but could not find Linuux version

I am currently too lazy to look it up for you on python.org (if it is
there), but your AMD64 distribution has most likely packaged it for you
already.

J.
-- 
The houses of parliament make me think of school bullies.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: anyone with genomewide microarray analysis experience ?

2009-08-14 Thread Jochen Schulz
trias:
> 
>  One of the things I would like to do is to fetch all data from a certain
> distance from gene ATGs say 100+/- bp and calculate the bp average over all
> genes over this region. 

I know absolutely nothing about your problem domain, but if your
distance function is metric, you can use this:

http://well-adjusted.de/mspace.py

or that:

http://code.activestate.com/recipes/572156/

The latter (by Baerophile) is fast, the former (by me) has more
features. Baerophile has even faster implementations (non-Python) as
well.

J.
-- 
I am worried that my dreams pale in comparison beside TV docu-soaps.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: iterate lines with regex

2009-08-01 Thread Jochen Schulz
Michael Savarese:
> 
> for line in readThis:
> try:
> thisKey = key.search(line).group(1)
> thisMap = map.search(line).group(1)
> thisParcel = parcel.search(line).group(1)
> except:
> continue

Why do you catch all exceptions in that loop? Remove the try-except
clause including the 'continue' and a stacktrace will probybably tell
you why your loop appears to do nothing.

J.
-- 
A passionate argument means more to me than a blockbuster movie.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Jochen Schulz
Xavier Ho:
>
> Why doesn't the second output print [1, 2, 3,  , 7, 8, 9] ?
-- snip
> print a.n.extend([6, 7, 8, 9])

extend doesn't fail. It just returns None and extends the list in place.

In [1]: l = [1, 2, 3]

In [2]: l.extend([4, 5, 6])

In [3]: l
Out[3]: [1, 2, 3, 4, 5, 6]


J.
-- 
When I get home from the supermarket I don't know what to do with all the
plastic.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regarding Python is scripting language or not

2009-06-18 Thread Jochen Schulz
Terry Reedy:
> Jochen Schulz wrote:
>> 
>> If, by "object-oriented" you mean "everything has to be put into
>> classes", then Python is not object-oriented.
> 
> That depends on what you mean by 'put into classes' (and 'everything').

:) What I meant was that in Python you can write code without defining
your own classes at all. I had Java in mind where you cannot write a
program without using the keyword 'class'. But I think we agree here.

J.
-- 
In idle moments I remember former lovers with sentimental tenderness.
[Agree]   [Disagree]
 <http://www.slowlydownward.com/NODATA/data_enter2.html>


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regarding Python is scripting language or not

2009-06-17 Thread Jochen Schulz
abhishek goswami:
> 
> Can anyone Guide me that Python is Oject oriented programming language
> or Script language

In my opinion, Python is both. But an "objective" answer would require
you to define what you means by these terms.

If, by "object-oriented" you mean "everything has to be put into
classes", then Python is not object-oriented. If, by "scripting
language" you mean Python is an error-prone toy language, unsuitable for
large, serious projects, then Python is not a scripting language either.

J.
-- 
My clothes aren't just fashion. They're a lifestyle.
[Agree]   [Disagree]
 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: similar words index?

2009-01-02 Thread Jochen Schulz
* robert:
> how can one index (text documents) for efficient similar word search?
> existing modules?

I implemented one approach in mspace.py:

http://well-adjusted.de/mspace.py/

But beware that it is pure Python and not optimized for speed. You gain
quite a lot by having Psyco installed, though.

J.
-- 
I count my partner's eyelashes.
[Agree]   [Disagree]
 
--
http://mail.python.org/mailman/listinfo/python-list


Re: maximum recursion depth?

2008-05-29 Thread Jochen Schulz
* Marc 'BlackJack' Rintsch:
> On Wed, 28 May 2008 02:28:54 -0700, bearophileHUGS wrote:
>> Dennis Lee Bieber, the ghost:
>>
>>> I'd have to wonder why so many recursive calls?
>> 
>> Why not?
> 
> Because of the recursion limit of course.  And function call overhead in
> Python is quite high compared to an iterative approach.

One of my pet projects[1, it's about building and searching trees] made
heavy use of recursion in the beginning.  I rewrote parts of it using
iteration because I hit the recursion limit and suspected a performance
hit as well. To my (mild) surprise, the rewrite didn't perform
significantly better. My benchmarks only showed an improvement of a few
percent in runtime. I didn't measure memory usage, though.

J.

[1] http://well-adjusted.de/mspace.py/
(Sorry, baerophile, I'll get back to you about this! My SNV working
copy is currently a mess and I need to clean that up first.)

-- 
I feel yawning hollowness whilst talking to people at parties.
[Agree]   [Disagree]
 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Data structure recommendation?

2008-04-10 Thread Jochen Schulz
* [EMAIL PROTECTED]:
> 
> Please plug such good things. It seems the Python community is an
> endless source of interesting modules I didn't know about. Your
> (single) module looks very nice. I'll take a better look later.

Could you please send me an email with an existing From: address? I
tried to reply to you but apparently your From: is forged.

J.
-- 
I can tell a Whopper[tm] from a BigMac[tm] and Coke[tm] from Pepsi[tm].
[Agree]   [Disagree]
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Data structure recommendation?

2008-04-08 Thread Jochen Schulz
* Steven Clark:
> Hi all-
> 
> I'm looking for a data structure that is a bit like a dictionary or a
> hash map. In particular, I want a mapping of floats to objects.
> However, I want to map a RANGE of floats to an object.

This solution may be more than you actually need, but I implemented two
metric space indexes which would do what you want (and I wanted to plug
it anyway :)):

http://well-adjusted.de/mspace.py/

You can do arbitrary range searches and nearest-neighbour search in
these indexes provided you have a metric distance function for the
objects you want to index. The distance function in your case would
simply be the absolute difference between your floats.

If every log message was contained in objects of this type:

class LogMessage(object)
def __init__(self, timestamp, object):
self.timestamp = timestamp
self.message = message

you could write a distance function for these objects like this:

def log_distance(log1, log2):
return abs(log1.timestamp - log2.timestamp)

and then you would create and search an index like this:

from mspace import VPTree
index = VPTree(all_log_messages, log_distance)
index.search(single_msg, 10)

The last line would yield all log messages within ten seconds (or
whatever the unit of your timestamps is) of the given LogMessage
single_msg. You could also use

index.nn_search(single_msg, 3)

To find the three messages closest to the given single_msg.

Searching should be quite fast (O(log(n)), but indexing might take some
time (O(n*log(n))). The problem is that VPTrees have to be constructed
from the complete data set initially. They cannot grow. The alternative
from mspace.py, BKTrees, may grow over time but they don't work with
non-discrete distances. If you want to use them, you'd have to convert
your timestamps to int/long first.

J.
-- 
In the west we kill people like chickens.
[Agree]   [Disagree]
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Jochen Schulz
* René Fleschenberg:
> Stefan Behnel schrieb:
>> 
>> [...] They are just tools. Even if you do not
>> understand English, they will not get in your way. You just learn them.
> 
> I claim that this is *completely unrealistic*. When learning Python, you
> *do* learn the actual meanings of English terms like "open",
> "exception", "if" and so on if you did not know them before.

This is certainly true for easy words like "open" and "in". But there
are a lot of counterexamples.

When learning something new, you always learn a lot of new concepts and
you get to know how they are called in this specific context. For
example, when you learn to program, you might stumble upon the idea of
"exceptions", which you can raise/throw and except/catch. But even if
you know how to use that concept and understand what it does, you do not
necessarily know the "usual" meaning of the word outside of your domain.

As far as I can tell, quite often these are the terms that even enter
the native language without any translation (even though there are
perfect translations for the words in their original meaning).  German
examples are "exceptions", "client" and "server", "mail", "hub" and
"switch", "web" and many, many more. Nobody who uses these terms has to
know their exact meaning in his native language as long as he speaks to
Germans or stays in the domain where he learned them.

I read a lot of English text every day but I am sometimes still
surprised to learn that a word I already knew has a meaning outside
of computing. "Hub" is a nice example for that. I was very surprised to
learn that even my bike has this. ;-)

J.
-- 
If I was Mark Chapman I would have shot John Lennon with a water pistol.
[Agree]   [Disagree]
 
-- 
http://mail.python.org/mailman/listinfo/python-list