howto use pylint from Eric IDE?

2008-05-18 Thread dmitrey
Hi all,

I have Eric 4.1.1, pylint and Eric pylint plugin installed, but I
cannot find how to use pylint from Eric IDE GUI.
Does anyone know?

Thank you in advance, D.
--
http://mail.python.org/mailman/listinfo/python-list


Re: morning in Python

2008-05-18 Thread inhahe

What advantages do teams have? in what? over who? when?  If they have
any use at all,
what language is good for them?  How do programming teams interact?
It sounds fun.  I'm not sure I want to get work done so much as talk,
but programming is fun.

-the advantages of teams in general is the organization of effort.
-with 10 people doing 10 things in their own individually chosen
-directions, you get 10 little things done. with 10 people doing 10
-things in a team, you get 1 big thing done that's 10 times as large.
-(some things that can be done can only be done as big things; i.e
-not everything is scalar in a practical sense). and that's not even
-including synergy.  perhaps i should have said, the "coalition
-/coalescence" of effort, as the organization of it is a different
-matter.  that's a harder animal to tackle.  it also applies to
-computing itself.  why is programming useful? because of its
-organization. why is a CPU useful? because of its organization.
-why is an organization useful?  why are systems effective? is the
-universe a system? is it thusly a matter of reciprocality? (as
-affected and affecter are two sub-systems of the universe)
-a team's advantage is in accomplishing a goal that all members
-agree to accomplish.  this may involve compromising on their
-own goals just enough to do something close but similar that can
-actually get done.  but it gets more complex than that as a lot of
-people join programming teams to make money and put bread on
-the table.  the economy becomes the team. and then you get into
-game theory and realize that sometimes just because a system
-falls into a certain order doesn't mean it's the most mutually
-beneficial way of doing things.
-a programming team wouldn't have an advantage "over"
-somebody unless it's a competing company.  but then those
-companies also have teams so it wouldn't be having a team
-per se that gives an advantage "over" them. although teams
-of programmers would have advantage over every would-be
-single programmer that would want to program a competing
-product.  but do those people even count?  they're not in the
-arena.
-even with a programming team, what language to use depends on
-what the goal is.  although it also depends on the preconceptions
-of ill-informed higher-ups.  i'm not prepared to say, though, that
-some programming languages aren't more amenable to
-team-work than others.

I'd start to discuss state property in appertanance to city property.
What are some properties of the state?

-what states have more than cities: power.  universality.  levels of
-beaurocracy.  global relevance. size.  superordination.  time.

You would have to introduce a computer to a (finite?) way of
expressing language, provided it *expresses* at rates over time that
do not exceed its input (impression), and limited by the complexity
bound of the architecture.  Tangent: architecture complexity.

-hmm. expression vs. impression rates represents symmetry in flow.
-conservation of information.  complexity of architecture is static.
-so i wonder what dimension that affects.  the only thing I can think of
-is that regardless of your flow control if your architecture is too
-simple then people will realize that it's not sentient.  they may realize
-that anyway but they'd be less entertained.  basically, your computer
-would be less effective at achieving its goals in a complex arena.  but
-not all arenas are complex. (people are, yes.)

In order to recreate 'propositional knowledge', you have to tell it.
Accumulating could amount to hashing video feed over time.  What do
you know about what's on the screen?  Naturally, as symbols are
logical, the video would have to be of something you want from it,
even if it's high spirits.

-i don't fully understand this logic and i don't fully agree with it so i
-won't comment.

I am less concerned about the audio, but maybe video is just one way
of learning.  What information do the mic inputs convey from a spoken
voice?  (And how do you summarize that?)

-it's probably easier to gather information from audio.  but then you can
-gather more at a time from video (with more holistic requirements).  but
-then if you're measuring how much you can gather per byte of input
-stream (thus putting 'at a time' into the von neuman computing arena or
-perhaps bandwidth allowance) then it's hard to say (as video requires
-more bytes per sense-time).
-to summarize, mic inputs convey a) one's voice (it's part of why people
-fall in love..), b) words and sentences; semantic content; formal
-(or informal) facts (already in propositional form) (depending on the
-the theoretical limits for AI speech recognition), c) intonation and 
emphasis
-of those words (largely requires understanding of the psyche for
-interpretation). but i'm not going to say that a computer can necessarily
-understand psyche (or one's voice); it's cosmic.
-also, words can express facts from anywhere at any time.  video
-expresses an event or a state at on

Re: Python and Flaming Thunder

2008-05-18 Thread Matthieu Brucher
2008/5/15 John Salerno <[EMAIL PROTECTED]>:

> On Tue, 13 May 2008 06:25:27 -0700 (PDT)
> Dave Parker <[EMAIL PROTECTED]> wrote:
>
> > > I'm pretty generally interested, but where can print layout take you?
> >
> > Not far, especially with books disappearing.  Our library says that
> > these days, only 25% of their checkouts are books; the other 75% are
> > DVDs, CDs, etc.
>
> Sorry, but I must point out a logical flaw in this statement. Assuming your
> stats are even true, just because books are now only 25% of checkouts rather
> than, for example, 80%, doesn't necessarily imply that any less books are
> being checked out (i.e. "disappearing"). It can just as easily mean that
> *more* of the other things are being checked out while books remain the
> same.
>
> Example:
>
> Total number of items checked out:100
> Total number of books checked out: 80
> Percentage of books checked out:   80%
>
> Total number of items checked out:320
> Total number of books checked out: 80   # same as above
> Percentage of books checked out:   25%
> --
> http://mail.python.org/mailman/listinfo/python-list
>

In France, the book market is bigger (in terms of money) than the DVD and CD
market IIRC. That's strange, isn't it ?

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
--
http://mail.python.org/mailman/listinfo/python-list

Re: Python library for clustering from distance vector

2008-05-18 Thread Matthieu Brucher
Hi,

You should send your question on the scipy user ML. If you use a distance
between objects, you can try the kmeans (implemented in scipy), if you use
similarities, you can change them to dissimilarities and use the same
function.

Matthieu

2008/5/18 Sengly <[EMAIL PROTECTED]>:

> Dear all,
>
> I am looking for a python library which can cluster similar objects
> into their respective groups given their similarity score of each two
> of them. I have searched the group but I couldn't find any helpful
> information yet.
>
> Any suggestion is appreciated. Also, if you know any specific group
> that I should post this message, please also suggest.
>
> Thank you.
>
> Sengly
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
--
http://mail.python.org/mailman/listinfo/python-list

Re: morning in Python

2008-05-18 Thread inhahe
By the way, "state" as a meronym of "city" and "state" as it applies to 
programming (i.e. stasis) are two unrelated things.

>I'd start to discuss state property in appertanance to city >property.
>What are some properties of the state?


--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for programming algorithms

2008-05-18 Thread Lie
On May 18, 5:32 am, Vicent Giner <[EMAIL PROTECTED]> wrote:
> Hello.
>
> I am new to Python. It seems a very interesting language to me. Its
> simplicity is very attractive.
>
> However, it is usually said that Python is not a compiled but
> interpreted programming language —I mean, it is not like C, in that
> sense.
>
> I am working on my PhD Thesis, which is about Operations Research,
> heuristic algorithms, etc., and I am considering the possibility of
> programming all my algorithms in Python.
>
> The usual alternative is C, but I like Python more.
>
> The main drawbacks I see to using Python are these:
>
> * As far as I understand, the fact that Python is not a compiled
> language makes it slower than C, when performing huge amounts of
> computations within an algorithm or program.

It is slower than a goodly written C code. C codes might be slower
than Python if the writer of C isn't very familiar with C, on the
other hand Python's implementation of things like list, dictionary,
sets, etc are a very optimized piece of code (some says it's the most
fine tuned implementation in the world) and a sloppily written array/
dict/sets implementation in C might be slower than Python.

> * I don't know how likely it is to find libraries in Python related to
> my research field.
>
> * I know Python is a "serious" and mature programming language, of
> course. But I do not know if it is seen as "just funny" in a research
> context. Is Python considered as a good programming language for
> implementing Operations Research algorithms, such as heuristics and
> other soft-computing algorithms?

Why not ask your peers? AFAIK (since I'm not a researcher, just a high-
school student with a "too much time" to program, I'm not even
familiar with Operation Research), in a Operation Research context (as
I understand it from wikipedia) the important thing is the algorithm
instead of pure speed, and codes are written just to describe the
algorithm you're devising. So any programming language that isn't an
esoteric language (like Whitespace or Brainfuck) would not be
considered a "just funny".

> Maybe this is not the right forum, but maybe you can give me some
> hints or tips...
>
> Thank you in advance.


On May 18, 11:37 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sat, 17 May 2008 20:25:18 -0700 (PDT), Henrique Dante de Almeida
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
> >  My opinion: choose compiled or byte compiled languages. Choose the
> > language paradigm that best suit the algorithms.
>
>         Python IS byte compiled -- that's what .pyc and .pyo files contain
> (strangely though, one must specify a command line argument to get the
> "optimized" .pyo, rather than the .pyc with debugging data embedded).

Just to note, currently, "optimized" python code (using -O or -OO)
does very little to make your code goes faster as it doesn't (yet) do
anything but removing docstrings. The -O(ptimized) flags is reserved
to make it possible to add optimizations that might make some features
unavailable or behave differently (such as the docstrings removal that
breaks codes that uses __doc__).
--
http://mail.python.org/mailman/listinfo/python-list


Re: morning in Python

2008-05-18 Thread Gabriel Genellina
En Sun, 18 May 2008 04:42:58 -0300, inhahe <[EMAIL PROTECTED]> escribió:

> To those who don't want me to feed the bot, I'm sorry.  It's not a bot, and
> I don't know the policy on having philosophical conversations.

If you manage to stay on topic...

-- 
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: morning in Python

2008-05-18 Thread Martin v. Löwis
> Full day later, I think it, to emphasize state, would prioritize
> context.  The reason for the huge ramble was, believe it or not,
> namespace conflict... as though any other states around here might
> nose in.

I think the namespace conflict is rather in cities than in states.
For example, there are several cities called "Berlin", but only
one state (that I know of) is called "Mecklenburg-Vorpommern".
In some cases, prefixing helps, e.g. you don't call it "York"
when that already exists, but "New York".

There is also the issue of aliases. Some call it Moscow, some Moskau,
when it is really called Москва. Of course, the same issue exists
for states: some call it Kalifornien, others California.

> And thanks to 'inhahe' for coming back with the
> question.  ...Which would explain next move to 'prioritize context'.
> Context is a high priority for people.

I'd rather say that priority is a high context.

Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list

GOZERBOT 0.8.1-BETA released

2008-05-18 Thread Bart Thate

working to a new 0.8.1 release we make a BETA available to be tested
by interested users.

new features:

* ssl connections are now supported
* third party software included into gozerbot:
  o feedparser (used by RSS) .. makes atom feeds possible
  o simplejson (used by COLLECTIVE)
  o BeautifulSoup (used to parse webpages)
* renewed RSS plugin
* renewed collective plugin
* renewed webserver plugin .. new webserver API
* tcp.py notification plugin as well as a totcp.py client program

if you are using one of these features please test this BETA.

the BETA can be downloaded from http://gozerbot.org and problems with
it can be reported on http://dev.gozerbot.org or email me at
[EMAIL PROTECTED]

about gozerbot:

Requirements

* a shell
* python 2.4 or higher
* if you want to remotely install plugins: the gnupg module
* if you want mysql support: the py-MySQLdb module
* if you want jabber support: the xmpppy module

Why gozerbot?

* provide both IRC and Jabber support
* user management by userhost .. bot will not respond if it
doesn't know you (see /docs/USER/)
* fleet .. use more than one bot in a program (list of bots) (see /
docs/FLEET/)
* use the bot through dcc chat
* fetch rss feeds (see /docs/RSS/)
* remember items
* relaying between bots (see /docs/RELAY/)
* program your own plugins (see /docs/PROGRAMPLUGIN/)
* run the builtin webserver (see /docs/WEBSERVER/)
* query other bots webserver via irc (see /docs/COLLECTIVE/)
* serve as a udp <-> irc or jabber gateway (see /docs/UDP)
* mysql and sqlite support

the gozerbot development team
--
http://mail.python.org/mailman/listinfo/python-list


Re: r' question

2008-05-18 Thread Gabriel Genellina
En Sun, 18 May 2008 02:49:03 -0300, Dick Moores <[EMAIL PROTECTED]> escribió:

> However, (please refer back to my original post)
> I want to keep the fstr, ultimately to be the
> string entered by the user who knows a bit about
> regex, but not how to use r'  ' . Or
> alternatively, not assume any knowledge of regex,
> but build in some options, such as ignoring/not
> ignoring case, searching on just a string, or on
> a word. So I want to know how to build the user's
> fstr into regex. I apologize for not making this clear.

Ok, supose the user enters "joe (home)" and you want to build a regular 
expression to find that words surrounded by space:

fstr = "joe (work)"
regex = r"\s" + fstr + r"\s"

This doesn't work exactly as expected, because "(" and ")" have a special 
meaning in a regular expression; use re.escape:

regex = r"\s" + re.escape(fstr) + r"\s"

You may use "\\s" instead of r"\s", it's the *same* string. The r prefix is 
just a signal, it says how to interpret the source code, not part of the string.

-- 
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: morning in Python

2008-05-18 Thread Marc 'BlackJack' Rintsch
On Sun, 18 May 2008 11:15:06 +0200, Martin v. Löwis wrote:

>> Full day later, I think it, to emphasize state, would prioritize
>> context.  The reason for the huge ramble was, believe it or not,
>> namespace conflict... as though any other states around here might
>> nose in.
> 
> I think the namespace conflict is rather in cities than in states.
> For example, there are several cities called "Berlin", but only
> one state (that I know of) is called "Mecklenburg-Vorpommern".
> In some cases, prefixing helps, e.g. you don't call it "York"
> when that already exists, but "New York".

The state or the city "New York"!?  And wasn't the city object bound to
the name "New Amsterdam" once?  :-)

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list

Re: morning in Python

2008-05-18 Thread Ivan Illarionov
On Sun, 18 May 2008 11:15:06 +0200, Martin v. Löwis wrote:

> There is also the issue of aliases. Some call it Moscow, some Moskau,
> when it is really called Москва. Of course, the same issue exists for
> states: some call it Kalifornien, others California.

I don't see any issues here. Everybody call it "Moscow" when they speak
English and "Москва" when they speak Russian. Calling it "Москва" or
"Moskva" in English would be simply not correct and confusing.

-- Ivan

--
http://mail.python.org/mailman/listinfo/python-list

Re: morning in Python

2008-05-18 Thread inhahe

>It is not clear that the first (cheapest best) human->computer language
>is a computer language, though if two were orthonormal >in comparison
>to life, Python's fine.  Not my first.

The utterly dry, closed, logical, definitive, hierarchical, consistent, 
determinate nature of a computer language is the only thing that will 
facilitate anything useful on something as utterly stupid (and not to 
mention logical, definite and determined) as a computer.

I mean it, computers are /really/ stupid.  They're literally
stupider than a bug.  We just like things we can control.

The requisites I have for a computer language are:

Efficiency (speed)
Elegance of syntax
Powerful (conceptual-wise) abstractions

Python has delicious abstractions that make doing a lot of things really 
easy and fun to think about.
Stackless Python adds even more to that with continuations.
Also Python's dynamic (another aspect of being powerful conceptual-wise)
But most of all, I love its syntax.  Guido is the awesome.
(BTW, I won't even use any language that uses := for assignment.  I just 
refuse.  I don't care what the language has.)

The speed/efficiency issue depends on the task at hand.  For most things I 
use Python.  But assembly isn't out of the question, and it's fun to code 
in.  I also find C/C++ an elegant language.  Most things just don't need 
that speed.   And Python is 50 times easier to code in than C/C++ and 1000 
times easier to debug in.

I also like C#.

My ideal language would be a natively compiling cross between C++ and 
Python.  Objects declared with a type would be statically typed, objects not 
declared with a type would be dynamically typed.  There would also be 
keywords to declare that class names won't be reassigned and class 
attributes won't be deleted.  Those attributes would be referred to by 
offset, not hast table keys.  f





--
http://mail.python.org/mailman/listinfo/python-list


Re: morning in Python

2008-05-18 Thread inhahe

"inhahe" <[EMAIL PROTECTED]> wrote in message news:...
>
>>It is not clear that the first (cheapest best) human->computer language
>>is a computer language, though if two were orthonormal >in comparison
>>to life, Python's fine.  Not my first.
>
> The utterly dry, closed, logical, definitive, hierarchical, consistent, 
> determinate nature of a computer language is the only thing that will 
> facilitate anything useful on something as utterly stupid (and not to 
> mention logical, definite and determined) as a computer.
>
> I mean it, computers are /really/ stupid.  They're literally
> stupider than a bug.  We just like things we can control.
>
> The requisites I have for a computer language are:
>
> Efficiency (speed)
> Elegance of syntax
> Powerful (conceptual-wise) abstractions
>
> Python has delicious abstractions that make doing a lot of things really 
> easy and fun to think about.
> Stackless Python adds even more to that with continuations.
> Also Python's dynamic (another aspect of being powerful conceptual-wise)
> But most of all, I love its syntax.  Guido is the awesome.
> (BTW, I won't even use any language that uses := for assignment.  I just 
> refuse.  I don't care what the language has.)
>
> The speed/efficiency issue depends on the task at hand.  For most things I 
> use Python.  But assembly isn't out of the question, and it's fun to code 
> in.  I also find C/C++ an elegant language.  Most things just don't need 
> that speed.   And Python is 50 times easier to code in than C/C++ and 1000 
> times easier to debug in.
>
> I also like C#.
>
> My ideal language would be a natively compiling cross between C++ and 
> Python.  Objects declared with a type would be statically typed, objects 
> not declared with a type would be dynamically typed.  There would also be 
> keywords to declare that class names won't be reassigned and class 
> attributes won't be deleted.  Those attributes would be referred to by 
> offset, not hast table keys.  f

hast = hash 


--
http://mail.python.org/mailman/listinfo/python-list


Error when calling superclass __init__ method

2008-05-18 Thread Maese Fernando

Hi,

I'm getting an odd error while trying to call the __init__ method of a
super class:

BaseField.__init__(self)
TypeError: unbound method __init__() must be called with BaseField
instance as first argument (got nothing instead)


This is the code:

class BaseField(object):

def _addFieldsToRec(self, rec, *fields):
for field in fields:
self.mfn[field] = rec

def __init__(self):
self._addFieldsToRec(1,1)
self._addFieldsToRec(2, 500,501,502,503,504,505,506,507,508)


class Field(BaseField):
def __init__(self, value):
BaseField.__init__(self)  # this seems to be the offending
line.
self.tag = value


What am I doing wrong?
--
http://mail.python.org/mailman/listinfo/python-list


Re: morning in Python

2008-05-18 Thread inhahe

> My ideal language would be a natively compiling cross between C++ and
> Python.  Objects declared with a type would be statically typed, objects 
> not declared with a type would be dynamically typed.  There would also be 
> keywords to declare that class names won't be reassigned and class 
> attributes won't be deleted.  Those attributes would be referred to by 
> offset, not hash table keys.


But those attributes would also exist in the hash table because the referer 
can also use a dynamically created name.


--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for programming algorithms

2008-05-18 Thread dmitrey
Along with numpy & scipy there is some more Python scientific soft
worse to be mentioned:

http://scipy.org/Topical_Software
http://pypi.python.org/pypi?:action=browse&show=all&c=385

On 18 Тра, 06:25, Henrique Dante de Almeida <[EMAIL PROTECTED]> wrote:
> once I
> looked for linear programming toolkits for python and IIRC, I only
> could find a trivial wrapper for glpk (called pulp).

You could be interested in OpenOpt, it has connections to LP solvers
glpk, cvxopt's one and lp_solve (former & latter allows handling MILP
as well)

http://scipy.org/scipy/scikits/wiki/LP
--
http://mail.python.org/mailman/listinfo/python-list

Write bits in file

2008-05-18 Thread Monica Leko
Hi

I have a specific format and I need binary representation.  Does
Python have some built-in function which will, for instance, represent
number 15 in exactly 10 bits?
--
http://mail.python.org/mailman/listinfo/python-list


Re: how would you...?

2008-05-18 Thread inhahe

"Sanoski" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'm pretty new to programming. I've just been studying a few weeks off
> and on. I know a little, and I'm learning as I go. Programming is so
> much fun! I really wish I would have gotten into it years ago, but
> here's my question. I have a longterm project in mind, and I wont to
> know if it's feasible and how difficult it will be.
>
> There's an XML feed for my school that some other class designed. It's
> just a simple idea that lists all classes, room number, and the person
> with the highest GPA. The feed is set up like this. Each one of the
> following lines would also be a link to more information about the
> class, etc.
>
> Economics, Room 216, James Faker, 3.4
> Social Studies, Room 231, Brain Fictitious, 3.5
>
> etc, etc
>
> The student also has a picture reference that depicts his GPA based on
> the number. The picture is basically just a graph. I just want to
> write a program that uses the information on this feed.
>
> I want it to reach out to this XML feed, record each instance of the
> above format along with the picture reference of the highest GPA
> student, download it locally, and then be able to use that information
> in various was. I figured I'll start by counting each instance. For
> example, the above would be 2 instances.
>
> Eventually, I want it to be able to cross reference data you've
> already downloaded, and be able to compare GPA's, etc. It would have a
> GUI and everything too, but I am trying to keep it simple right now,
> and just build onto it as I learn.
>
> So lets just say this. How do you grab information from the web, in
> this case a feed, and then use that in calculations? How would you
> implement such a project? Would you save the information into a text
> file? Or would you use something else? Should I study up on SQLite?
> Maybe I should study classes. I'm just not sure. What would be the
> most effective technique?


People usually say BeautifulSoup for getting stuff from the web.  I think I 
tried it once and had some problem and gave up.  But since this is XML I 
think all you'd need is an xml.dom.minidom or xml.etree.ElementTree. i'm not 
sure which is easier.  see doc\python.chm in the Python directory to study 
up on those.  To grab the webpage to begin with you'd use urllib2.  That 
takes around one line of code.  I wouldn't save it to a text file, because 
they're not that good for random access.  Or storing images.  I'd save it in 
a database.  There are other database modules than SQLite, but SQLite is a 
good one, for simple projects like that where you're just going to be 
running one instance of the program at a time.  SQLite is fast and it's the 
only one that doesn't require a separate database engine to be installed and 
running.
Classes are just a way of organizing code (and a little more, but they don't 
have a lot to do with saving stuff to file).
I'm not clear on whether the GPA is available as text and an image, or just 
an image.  If it's just available as an image you're going to want to use 
PIL (Python Image Library).  Btw, use float() to convert a textual GPA to a 
number.
You'll have to learn some basics of the SQL language (that applies to any 
database).  Or maybe not with SQLObject or SQLAlchemy, but I don't know how 
easy those are to learn.  Or if you don't want to learn SQL you could use a 
text file with fixed-length fields and perhaps references to individual 
filenames that store the pictures, and I could tell you how to do that.  But 
a database is a lot more flexible, and you wouldn't need to learn much SQL 
for the same purposes.
Btw, I used SQLite version 2 before and it didn't allow me to return query 
results as dictionaries (i.e., indexable by field name), just lists of 
values, except by using some strange code I found somewhere.  But a list is 
also easy to use.  But if version 3 doesn't do it either and you want the 
code I have it.


--
http://mail.python.org/mailman/listinfo/python-list


Re: Psyco alternative

2008-05-18 Thread Jacob Hallen
In article <[EMAIL PROTECTED]>,
sturlamolden  <[EMAIL PROTECTED]> wrote:
>On Mar 27, 4:44 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>
>> PyPy is self-hosted and has been for some time (a year or so?).
>
>This is technically not correct. PyPy is hosted by RPython, which is
>not Python but a different language all together.

This is pure FUD! PyPy is written in RPython, which is a pure subset of Python,
designed for writing interpreters in such a way that they can be translated into
source code for a static language and then compiled to machine code.

The translation toolchain, written in Python is used to create a binary image,
which is a full interpreter for the Python language. This binary image can
run the toolchain to generate another, identical binary image, which of course
also is a a full interpreter for the Python language.

This makes PyPy self hosting in every sense of the word.

The fact that the interpreter is written in RPython and actually runs as an 
interpreted
program under CPyton or a compiled PyPy is a useful implementation detail, 
adding
yet another aspect of self hosting that is not present in other systems that 
claim
to be self hosting.

PyPy btw, is alive and well. Work is progressing along 3 major fronts. One is 
supporting
real world applications, where we recently added support for ctypes and where we
are working on ensuring that a number of popular modules and frameworks run 
under PyPy.
Another major undertaking has been to improve execution speed without the JIT. 
We can
report that we are faster than CPython on some benchmarks, while slower on 
others. On the
average, I'd say that we still have some catching up to do. The third avenue 
that
is being pursued is the JIT. While a huge refactoring has been finished and the
results look very good, there are still many months of work to do before the
JIT can be used in production.

Jacob Hallén

-- 
--
http://mail.python.org/mailman/listinfo/python-list

Re: addendum Re: working with images (PIL ?)

2008-05-18 Thread Ken Starks

Oops. I meant:

WhiteArea=Result.histogram()[255]

of course, not

WhiteArea=Result.histogram()[0]

Ken Starks wrote:
As others have said, PIL has the 'histogram' method to do most of the 
work. However, as histogram works on each band separately, you have

a bit of preliminary programming first to combine them.

The ImageChops darker method is one easy-to-understand way (done twice),
but there are lots of alternatives, I am sure.


# 

import Image
import ImageChops

Im = Image.open("server\\vol\\temp\\image.jpg")
R,G,B = Im.split()

Result=ImageChops.darker(R,G)
Result=ImageChops.darker(Result,B)



 Mistake here:


WhiteArea=Result.histogram()[0]



TotalArea=Im.size[0] * Im.size[1]
PercentageWhite = (WhiteArea * 100.0)/TotalArea





Poppy wrote:
I've put together some code to demonstrate what my goal is though 
looping pixel by pixel it's rather slow.


import Image

def check_whitespace():
im = Image.open("server\\vol\\temp\\image.jpg")

size = im.size

i = 0
whitePixCount = 0
while i in range(size[1]):
j = 0
while j in range(size[0]):
p1 = im.getpixel((j,i))
if p1 == (255, 255, 255):
whitePixCount = whitePixCount + 1
if whitePixCount >= 492804:  ## ((image dimensions 
1404 x 1404) / 4) 25%

return "image no good"
j = j + 1
i = i + 1

print whitePixCount

return "image is good"

print check_whitespace()


"Poppy" <[EMAIL PROTECTED]> wrote in message news:...
I need to write a program to examine images (JPG) and determine how 
much area is whitespace. We need to throw a returned image out if too 
much of it is whitespace from the dataset we're working with. I've 
been examining the Python Image Library and can not determine if it 
offers the needed functionality. Does anyone have suggestions of 
other image libraries I should be looking at it, or if PIL can do 
what I need?






--
http://mail.python.org/mailman/listinfo/python-list


Re: Error when calling superclass __init__ method

2008-05-18 Thread Peter Otten
Maese Fernando wrote:

> I'm getting an odd error while trying to call the __init__ method of a
> super class:
> 
> BaseField.__init__(self)
> TypeError: unbound method __init__() must be called with BaseField
> instance as first argument (got nothing instead)
> 
> 
> This is the code:

No, it isn't. Please provide the actual code or, better, a minimal
example. Don't forget to run it to verify it shows the behaviour described
above before you post it.

> What am I doing wrong?

My bets are on

BaseField.__init__() # no self

Peter
--
http://mail.python.org/mailman/listinfo/python-list


secret code?

2008-05-18 Thread Sanoski
What would you guys says about this secret code? The key was
apparently lost. The guy never sent it, and he was never seen again.
It must stand for letters in the alphabet, but it almost looks like
trajectory tables. I don't know. What do you guys think?

http://i243.photobucket.com/albums/ff273/ezname420/code.jpg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for programming algorithms

2008-05-18 Thread sturlamolden
On May 18, 5:46 am, "inhahe" <[EMAIL PROTECTED]> wrote:

> The numbers I heard are that Python is 10-100 times slower than C.

Only true if you use Python as if it was a dialect of Visual Basic. If
you use the right tool, like NumPy, Python can be fast enough. Also
note that Python is not slower than any other language (including C)
if the code is i/o bound. As it turns out, most code is i/o bound,
even many scientific programs.

In scientific research, CPU time is cheap and time spent programming
is expensive. Instead of optimizing code that runs too slowly, it is
often less expensive to use fancier hardware, like parallell
computers. For Python, we e.g. have mpi4py which gives us access to
MPI. It can be a good advice to write scientific software
parallelizable from the start.

I learned Pascal my first year in college. When I started programming
Matlab, I brought with me every habits of a novice Pascal programmer.
Needless to say, my programs ran excruciatingly slow. I learned C just
to write faster "mex" extensions for Matlab. But eventually, my skills
improved and I found that my Matlab programs did not need C anymore.
It took me almost 3 years to unlearn the bad habits I had acquired
while programming Pascal. It is very easy to blame the language, when
in fact it is the programmer who is not using it properly.
















--
http://mail.python.org/mailman/listinfo/python-list


Re: Write bits in file

2008-05-18 Thread Ken Starks

You want your file considered as a sequence of bits rather
than a sequence of 8-bit bytes, do you? is the 10-bit
bit-pattern to be stored at an arbitrary bit-position in
the file, or is the whole file regularly subdivided
at 10-bit intervals?


Monica Leko wrote:

Hi

I have a specific format and I need binary representation.  Does
Python have some built-in function which will, for instance, represent
number 15 in exactly 10 bits?

--
http://mail.python.org/mailman/listinfo/python-list


Re: multiple databases, what's the best interface ?

2008-05-18 Thread M.-A. Lemburg

On 2008-05-17 20:54, Stef Mientki wrote:

hello,

I need to switch fluently between 2 or 3 types of dbases:
SQLite, Sybase ( and in the future MS SQL-server).

I need both closed application and general purpose database manager,
which should run on different platforms (windows, windows mobile, not 
web based).


I would like to write the applications in Python.
What's the best interface so I can use the same program for all databases,
and just have to change the database name, if I want to use another 
database ?


If you need a common interface on all the platforms, then I'd suggest
you have a look at our mxODBC:

http://www.egenix.com/products/python/mxODBC/

If you also need to support Windows Mobile, then you'll be interested
in our upcoming new product called "mxODBC Connect" which separates
the client from the server.

mxODBC Connect allows using the mxODBC API on platforms which don't
come with ODBC drivers or where getting ODBC drivers is difficult.
Due to it's client-server approach it also simplifies configuration
a lot.

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 18 2008)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
--
http://mail.python.org/mailman/listinfo/python-list


Re: secret code?

2008-05-18 Thread Duncan Booth
Sanoski <[EMAIL PROTECTED]> wrote:

> What would you guys says about this secret code? The key was
> apparently lost. The guy never sent it, and he was never seen again.
> It must stand for letters in the alphabet, but it almost looks like
> trajectory tables. I don't know. What do you guys think?
> 
> http://i243.photobucket.com/albums/ff273/ezname420/code.jpg
> 
Try Googling for 'Beale Cipher'.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to modify meaning of builtin function "not" to "!"?

2008-05-18 Thread Lie
On May 9, 8:41 pm, grbgooglefan <[EMAIL PROTECTED]> wrote:
> I am creating functions, the return result of which I am using to make
> decisions in combined expressions.
> In some expressions, I would like to inverse the return result of
> function.
>
> E.g. function contains(source,search) will return true if "search"
> string is found in source string.
> I want to make reverse of this by putting it as:
> if ( ! contains(s1,s2) ):
>      return 1
>
> I found that "!" is not accepted by Python & compile fails with
> "invalid syntax".
> Corresponding to this Boolean Operator we've "not" in Python.
>
> How can I make "not" as "!"?

Are you trying to make Python a C? Realize that when you work with a
language, you play by that language's rule, not by your rule. This
seems like a troll or something.
--
http://mail.python.org/mailman/listinfo/python-list


Re: explain this function to me, lambda confusion

2008-05-18 Thread Lie
On May 9, 8:57 am, [EMAIL PROTECTED] wrote:
> On May 8, 6:11 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
>
>
>
> > No, no, no, no, no!
>
> Geez.  Go easy.
>
>
>
> > You have got it entirely wrong here. Your XOR function simply returns a
> > function which gives you the result of xoring the parameters AT THE TIME
> > WHEN YOU ORIGINALLY CREATED IT. I'm guessing that you had already set
> > cream and icecream (otherwise the call to XOR would have thrown an
> > exception) and at leas one was true. Try setting them both False at the
> > beginning:
>
> > >>> cream = False
> > >>> icecream = False
> > >>> topping = XOR( cream, icecream)
> > >>> cream = True
> > >>> icecream = False
> > >>> print topping()
>
> > False
>
> Ok. I understand this better now.  I did say I found the documentation
> rather terse on this.
>
> > Using a lambda was a completely pointless exercise here, you could have
> > just returned the result directly:
>
> If I try out a new language, I try to exercise those parts of the
> language that are new to me.  Now I saw lambdas, an interesting
> structure I hadn't seen before. So I tried them out.  I get to learn a
> little at the same time as scripting.  That was the "point".  I only
> get to optimise my use of a language by trying out various corners of
> it.
>
>
>
> > def TFF(x,y,z) :
> >   return x and not y and not z
>
> > AddOnly = TFF( options.AddAction, options.ReplaceAction,
> > options.DeleteAction )
> > DeleteOnly = TFF( options.DeleteAction, options.AddAction,
> > options.ReplaceAction )
> > ReplaceOnly = TFF( options.ReplaceAction, options.AddAction,
> > options.DeleteAction )
>
> > if not (DeleteOnly or AddOnly or ReplaceOnly):
> >   print "Error:  Exactly one of  [ --add | --replace | --delete ]
> > allowed. "
> >   parser.print_help()
> >   exit
>
> > which boils down to:
>
> > if (options.AddAction + options.ReplaceAction +
> >         options.DeleteAction) != 1:
> >     print "Error: ..."
>
> Indeed, there are many ways this could be done.  Some are more
> concise, some are more efficient.  As I said, I did it the way I did
> it to try out lambdas.  Your way achieves the result, rather elegantly
> I think, but teaches me nothing about using lambdas.
>
> Pardon my tetchiness, but it is a little hard to receive such blunt
> and inflexible replies to my posts.
>
> Both the responses offer lambda free alternatives.  That's fine, and
> given the terse documentation and problems that I had understanding
> them, I would agree.  So what applications are lambdas suited to?  I
> think the parameterised function model is one.
> What else?

Lambda can actually be safely removed from python and no other
features would be missing. It is always possible to create a def
version of any lambda, so lambda is useless. It is just a convenience
for the times where we're just too lazy to invent a name and find a
place to place the def, instead just inlining the function.
--
http://mail.python.org/mailman/listinfo/python-list


Re: explain this function to me, lambda confusion

2008-05-18 Thread Lie
On May 9, 12:12 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Thu, 08 May 2008 22:57:03 -0300,  
> <[EMAIL PROTECTED]> escribió:
>
>
>
> > On May 8, 6:11 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
>
> >> No, no, no, no, no!
> > Geez.  Go easy.
> >> You have got it entirely wrong here. Your XOR function simply
> [...]
> > Pardon my tetchiness, but it is a little hard to receive such blunt
> > and inflexible replies to my posts.
>
> Don't take it so seriously. I would have written a reply in the same tone.  
> Weeds must be uprooted early :)
>
> > Both the responses offer lambda free alternatives.  That's fine, and
> > given the terse documentation and problems that I had understanding
> > them, I would agree.  So what applications are lambdas suited to?  I
> > think the parameterised function model is one.
> > What else?
>
> It should be clear now that lambda is just a shortcut for defining a  
> normal function using "def", except it has no name, and it can handle  
> expressions only (no statements).
> So you never *need* a lambda. But in a few cases they're useful:
>
> - Most GUIs are event-driven, and let you bind a function (or any other  
> callable object) to be executed when certain event happens (by example,  
> when certain button is pressed, or a menu item is selected). Usually an  
> instance method is used: Button("Total", onclick=self.calculate_total).  
> Suppose you're developing a calculator; the ten buttons labeled '0' to '9'  
> should inserte the corresponding digit. To do that, you should write ten  
> functions insert_digit_0 to insert_digit_9 (and they would be  
> one-line-functions: insert_digit('0') ... insert_digit('9')). Too boring :(
> The usual idiom is something like this:
>      Button("0", onclick=lambda: self.insert_digit('0'))
>      Button("5", onclick=lambda: self.insert_digit('5'))
>
> - To write an expression that is to be evaluated lazily (perhaps only if  
> certain other conditions are met). Older Python versions didn't have a  
> conditional expression like C's :? ternary operator, and one possible way  
> to emulate it is this:
>
> def iif(cond, if_true, if_false):
>      if cond:
>          return if_true()
>      else:
>          return if_false()
>
> iff(x!=2, lambda: 1/(x-2), lambda: 100)
>
> You can't write iff(x!=2, 1/(x-2), 100) because arguments are evaluated  
> before the function is called, and with x=2 you get an error.
>

Calling iff would give a NameError. I wonder why... perhaps because
iif is so iffy?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Write bits in file

2008-05-18 Thread Monica Leko
On May 18, 2:20 pm, Ken Starks <[EMAIL PROTECTED]> wrote:
> You want your file considered as a sequence of bits rather
> than a sequence of 8-bit bytes, do you?

Yes.

> is the 10-bit
> bit-pattern to be stored at an arbitrary bit-position in
> the file

Yes.  I need arbitrary, 8bits, than 10 bits for something else, than
sequence of bytes, than 10 bits again, etc.


--
http://mail.python.org/mailman/listinfo/python-list


Re: explain this function to me, lambda confusion

2008-05-18 Thread Arnaud Delobelle
Lie <[EMAIL PROTECTED]> writes:

> Lambda can actually be safely removed from python and no other
> features would be missing. It is always possible to create a def
> version of any lambda, so lambda is useless. It is just a convenience
> for the times where we're just too lazy to invent a name and find a
> place to place the def, instead just inlining the function.

Note that the same thing can be said about generator expressions,
which are nothing more than anonymous, non-reusable, generator
functions.  Instead these were _added_ to the language!

-- 
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list


Re: howto use pylint from Eric IDE?

2008-05-18 Thread Detlev Offenbach
dmitrey wrote:

> Hi all,
> 
> I have Eric 4.1.1, pylint and Eric pylint plugin installed, but I
> cannot find how to use pylint from Eric IDE GUI.
> Does anyone know?
> 
> Thank you in advance, D.

Project->Check->Run PyLint

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: "indexed properties"...

2008-05-18 Thread David C. Ullrich
On Sun, 18 May 2008 08:50:23 +0200, pataphor <[EMAIL PROTECTED]>
wrote:

>In article <[EMAIL PROTECTED]>, 
>[EMAIL PROTECTED] says...
>
>> >>   window.pos = (x,y)
>> >>
>> >> seems more natural than
>> >>
>> >>   window.SetPos(x,y);
>
>Yes, and to assign a row in a matrix I'd also like to use either tuples 
>or lists on the right side. 

Heh - in the current (flawed) implementation you can
say m.row[0] = 'Hello'; m.row[1]= 'World!' .Not that I see why 
you'd want to, but that happened in the test code just to
check that things were as general as I wanted - sure enough
m.row[0] + m.row[1] comes out to ['HW', 'eo', 'lr', ''ld', 'o!'].

>>   def __add__(self, other):
>> return Row([x + y for x, y in zip(self, other)])
>> 
>> worked as hoped if self is a Row and other is a
>> Row _or_ a list.)
>> 
>> Anyway, my m.rows[j] can't be a list, because
>> I want to be able to say things like
>> m.rows[0] += c*m.rows[2]. Allowing 
>> m.rows[j] = [1,2,3] seems convenient, while
>> requiring m.rows[j] = Row([1,2,3]) fixes
>> this problem. Hmm.
>
>I'm not sure how far you'd go along with Gabriel's idea of decoupling 
>views from data but I think there isn't even a need for using a matrix 
>as the underlying data type. Why not use a flat list and compute matrix 
>positions according to a row or column adressing scheme on the fly? 

Is there some reason that would be better? It would make a lot
of the code more complicated. Ok, it would require only one
bit of added code, I suppose, but I don't see the plus side.

Hmm. It might actually _reduce_ the total amount of code,
since the code to access columns has to exist anyway and
rows could use the same code as columns with different
"start" and "skip". And come to think of it rows and
columns could be obtained just with a slice of the data.
So column access might even be more efficient. But I
expect that row access will happen a lot more often
than column access.

>P.

David C. Ullrich
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for programming algorithms

2008-05-18 Thread David C. Ullrich
On Sat, 17 May 2008 15:32:29 -0700 (PDT), Vicent Giner
<[EMAIL PROTECTED]> wrote:

>Hello.
>
>I am new to Python. It seems a very interesting language to me. Its
>simplicity is very attractive.
>
>However, it is usually said that Python is not a compiled but
>interpreted programming language —I mean, it is not like C, in that
>sense.
>
>I am working on my PhD Thesis, which is about Operations Research,
>heuristic algorithms, etc., and I am considering the possibility of
>programming all my algorithms in Python.

Other people have said things about how to use Python
effieiently. Something that seems relevant that I don't
see mentioned:

Are you going to be doing research _about_ the
algorithms in question or is it going to be research
_using_ these algorithms to draw conclusions
about other things?

Most of the replies seem to be assuming the latter.
If it's the former then Python seems like definitely
an excellent choice - when you have want to try
something new it will be much faster trying it
out in Python, when you write up the results
there will be no need for pseudo-code as a
guide to the real code because the Python
will be just about as easy to read as the
pseudo code would be, etc.

>The usual alternative is C, but I like Python more.
>
>The main drawbacks I see to using Python are these:
>
>* As far as I understand, the fact that Python is not a compiled
>language makes it slower than C, when performing huge amounts of
>computations within an algorithm or program.
>
>* I don't know how likely it is to find libraries in Python related to
>my research field.
>
>* I know Python is a "serious" and mature programming language, of
>course. But I do not know if it is seen as "just funny" in a research
>context. Is Python considered as a good programming language for
>implementing Operations Research algorithms, such as heuristics and
>other soft-computing algorithms?
>
>Maybe this is not the right forum, but maybe you can give me some
>hints or tips...
>
>Thank you in advance.

David C. Ullrich
--
http://mail.python.org/mailman/listinfo/python-list


Re: python newbie: some surprises

2008-05-18 Thread Lie
On May 8, 2:06 pm, v4vijayakumar <[EMAIL PROTECTED]>
wrote:
> When I started coding in python, these two things surprised me.
>
> 1. my code is inconsistently indented with the combination of tabs and
> spaces. Even lines looked intended, but it is not.

The problem is in tab not Python, there is no convention on how many
spaces should tab be treated, python (by default) assumes a tab to be
equal to 8 spaces, but not everyone thinks the same, some code editor
might consider it as 4 spaces or 2 spaces. In most python-oriented
code editor, a tab might be automatically replaced with four spaces.

> 2. python requires to pass "self" to all instance methods

No, python doesn't requires self to be passed to all instance methods,
python passes the "current instance" of a class to the first argument
of a function inside the class, this first argument can be named
anything, although it is traditionally named as self. In other
programming languages, this current instance is implicitly passed (Me
in VB, this in C/C++).

> and I missed ":" often. :)

Not in your smiley though. :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: writing python extensions in assembly

2008-05-18 Thread Diez B. Roggisch

Also, from the gcc manpage, apparently 387 is the default when
compiling for 32 bit architectures, and using sse instructions is
default on x86-64 architectures, but you can use -march=(some
architecture with simd instructions), -msse, -msse2, -msse3, or
-mfpmath=(one of 387, sse, or sse,387) to get the compiler to use
them.

As long as we're talking about compilers and such... anybody want to
chip in how this works in Python bytecode or what the bytecode
interpreter does?  Okay, wait, before anybody says that's
implementation-dependent: does anybody want to chip in what the
CPython implementation does?  (or any other implementation they're
familiar with, I guess)


There isn't anything in (C)Python aware of these architecture extensions 
- unless 3rd-party-libs utilize it. The bytecode-interpreter is machine 
and os-independent. So it's above that level anyway. And AFAIK all 
mathematical functionality is the one exposed by the OS math-libs.


Having said that, there are of course libs like NumPy that do take 
advantage of these architectures, through the use of e.g. lib atlas.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: Write bits in file

2008-05-18 Thread Gabriel Genellina
En Sun, 18 May 2008 10:36:28 -0300, Monica Leko <[EMAIL PROTECTED]> escribió:

> On May 18, 2:20 pm, Ken Starks <[EMAIL PROTECTED]> wrote:
>> You want your file considered as a sequence of bits rather
>> than a sequence of 8-bit bytes, do you?
>
> Yes.
>
>> is the 10-bit
>> bit-pattern to be stored at an arbitrary bit-position in
>> the file
>
> Yes.  I need arbitrary, 8bits, than 10 bits for something else, than
> sequence of bytes, than 10 bits again, etc.

If you really need arbitrary bit sequences that aren't synchonized into bytes, 
I think there is a BitVector o BitArray package somewhere.
But if you mostly have bytes and sparsely a different size, I think the struct 
module and some gymnastics involving bitwise operations would be enough.

-- 
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: waiting on an event blocks all signals

2008-05-18 Thread Diez B. Roggisch

alan schrieb:

This ignores CTRL-C on every platform I've tested:

python -c "import threading; threading.Event().wait()"
^C^C^C^C

It looks to me like all signals are masked before entering wait(). Can
someone familiar with the internals explain and/or justify this
behavior? Thanks,


They aren't masked. Read the docs:

# Although Python signal handlers are called asynchronously as far as 
the Python user is concerned, they can only occur between the ``atomic'' 
instructions of the Python interpreter. This means that signals arriving 
during long calculations implemented purely in C (such as regular 
expression matches on large bodies of text) may be delayed for an 
arbitrary amount of time.



(http://docs.python.org/lib/module-signal.html)

Which is what is happening here - wait is implemented in C. So the 
arriving signal is stored flagged in the interpreter so that the next 
bytecode would be the signal-handler set - but the interpreter still 
waits for the blocked call.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: Write bits in file

2008-05-18 Thread Ken Starks

I admit that I was mostly just interested in getting your
question clarified, rather than having any great experise.

But a bit of Googling took me to the 'Bit vector' module,
[I googled: 'python ("bit array" OR "bit vector")']
which might be what you are after. I have no experience
with it, myself:

http://cobweb.ecn.purdue.edu/~kak/dist/BitVector-1.4.1.html

Monica Leko wrote:

On May 18, 2:20 pm, Ken Starks <[EMAIL PROTECTED]> wrote:

You want your file considered as a sequence of bits rather
than a sequence of 8-bit bytes, do you?


Yes.


is the 10-bit
bit-pattern to be stored at an arbitrary bit-position in
the file


Yes.  I need arbitrary, 8bits, than 10 bits for something else, than
sequence of bytes, than 10 bits again, etc.



--
http://mail.python.org/mailman/listinfo/python-list


ANN: Pyrex 0.9.8.2

2008-05-18 Thread Greg Ewing

Pyrex 0.9.8.2 is now available:

  http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/

A block of external functions can now be declared nogil at once.

  cdef extern from "somewhere.h" nogil:
...

Also some minor nogil-related bugs have been fixed.


What is Pyrex?
--

Pyrex is a language for writing Python extension modules.
It lets you freely mix operations on Python and C data, with
all Python reference counting and error checking handled
automatically.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Get all the instances of one class

2008-05-18 Thread Terry
On May 17, 8:04 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 16 May 2008 20:44:00 -0300, Terry <[EMAIL PROTECTED]>
> escribió:
>
> > Is there a simple way to get all the instances of one class? I mean
> > without any additional change to the class.
>
> Try with gc.get_referrers()
>
> py> import gc
> py> class A(object): pass
> ...
> py> a,b,c = A(),A(),A()
> py> A
> 
> py> for item in gc.get_referrers(A): print type(item)
> ...
> 
> 
> 
> 
> 
> 
> 
> 
>
> We need to filter that list, keeping only A's instances:
>
> py> [item for item in gc.get_referrers(A) if isinstance(item,A)]
> [<__main__.A object at 0x00A40DC8>, <__main__.A object at 0x00A40DF0>,
> <__main__.A object at 0x00A40E18>]
>
> --
> Gabriel Genellina

Thanks! This is what I'm looking for.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Get all the instances of one class

2008-05-18 Thread Terry
On May 17, 8:04 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 16 May 2008 20:44:00 -0300, Terry <[EMAIL PROTECTED]>
> escribió:
>
> > Is there a simple way to get all the instances of one class? I mean
> > without any additional change to the class.
>
> Try with gc.get_referrers()
>
> py> import gc
> py> class A(object): pass
> ...
> py> a,b,c = A(),A(),A()
> py> A
> 
> py> for item in gc.get_referrers(A): print type(item)
> ...
> 
> 
> 
> 
> 
> 
> 
> 
>
> We need to filter that list, keeping only A's instances:
>
> py> [item for item in gc.get_referrers(A) if isinstance(item,A)]
> [<__main__.A object at 0x00A40DC8>, <__main__.A object at 0x00A40DF0>,
> <__main__.A object at 0x00A40E18>]
>
> --
> Gabriel Genellina

But I saw in the help that we should "Avoid using get_referrers() for
any purpose other than debugging. "
--
http://mail.python.org/mailman/listinfo/python-list


Re: Get all the instances of one class

2008-05-18 Thread Diez B. Roggisch

Terry schrieb:

On May 17, 8:04 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:

En Fri, 16 May 2008 20:44:00 -0300, Terry <[EMAIL PROTECTED]>
escribió:


Is there a simple way to get all the instances of one class? I mean
without any additional change to the class.

Try with gc.get_referrers()

py> import gc
py> class A(object): pass
...
py> a,b,c = A(),A(),A()
py> A

py> for item in gc.get_referrers(A): print type(item)
...









We need to filter that list, keeping only A's instances:

py> [item for item in gc.get_referrers(A) if isinstance(item,A)]
[<__main__.A object at 0x00A40DC8>, <__main__.A object at 0x00A40DF0>,
<__main__.A object at 0x00A40E18>]

--
Gabriel Genellina


But I saw in the help that we should "Avoid using get_referrers() for
any purpose other than debugging. "


Yes, because using it do is very resource-consuming and shouldn't be 
done. Why don't you tell us what you are after here & then we might come 
up with a better solution?


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: explain this function to me, lambda confusion

2008-05-18 Thread inhahe
>
> Both the responses offer lambda free alternatives. That's fine, and
> given the terse documentation and problems that I had understanding
> them, I would agree. So what applications are lambdas suited to? I
> think the parameterised function model is one.
> What else?

i've hardly ever used lambdas since map() and filter() were replaced by list 
comprehension.  two other uses I can think of for it are: using it as a 
sorting key (which takes a function and lambdas are perfect for that when a 
direct function isn't available. for example, lambda x: x.myName), and I 
made an irc bot once that certain events had a list of fuctions that would 
be called after that event.  it was like being able to dynamically add and 
remove event handlers.  for example what if you asked the user a question 
and you wanted to know for the next input whether it was from that user and 
was an answer to that question.  sometimes the function to add would be very 
simple, so writing a def for it would just be ugly. 


--
http://mail.python.org/mailman/listinfo/python-list


Re: Shelve or pickle module

2008-05-18 Thread Ville M. Vainio
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:


> A shelve is just a persistent dictionary that uses pickle to store
> the objects.  If you want to store one or a few objects, using
> pickle directly may be easier.  Any problem you may have with pickle
> (nonpickleable objects, security risks) will happen with shelve too.

Shameless plug warning!

If you want to store pickles "directly" in a directory with
shelve-like dict API, you may also be interested in my "pickleshare"
module:

http://pypi.python.org/pypi/pickleshare/0.3

--
http://mail.python.org/mailman/listinfo/python-list


Re: waiting on an event blocks all signals

2008-05-18 Thread Rhamphoryncus
On May 18, 9:05 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> alan schrieb:
>
> > This ignores CTRL-C on every platform I've tested:
>
> > python -c "import threading; threading.Event().wait()"
> > ^C^C^C^C
>
> > It looks to me like all signals are masked before entering wait(). Can
> > someone familiar with the internals explain and/or justify this
> > behavior? Thanks,
>
> They aren't masked. Read the docs:
>
> # Although Python signal handlers are called asynchronously as far as
> the Python user is concerned, they can only occur between the ``atomic''
> instructions of the Python interpreter. This means that signals arriving
> during long calculations implemented purely in C (such as regular
> expression matches on large bodies of text) may be delayed for an
> arbitrary amount of time.
>
> (http://docs.python.org/lib/module-signal.html)
>
> Which is what is happening here - wait is implemented in C. So the
> arriving signal is stored flagged in the interpreter so that the next
> bytecode would be the signal-handler set - but the interpreter still
> waits for the blocked call.

If a signal arrives while the thread is in a syscall it will usually
interrupt the syscall.  Most code in the interpreter will see the
EINTR error code and check if we have a signal to process, which leads
to raising a KeyboardInterrupt exception.  However, most thread
synchronization functions specified in POSIX are not interrupted by
signals, so the interpreter never has a chance do anything.  Why would
we care anyway, as Python doesn't let you intentionally interrupt a
non-main thread?
--
http://mail.python.org/mailman/listinfo/python-list


Re: "indexed properties"...

2008-05-18 Thread pataphor
In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] says...

> Is there some reason that would be better? It would make a lot
> of the code more complicated. Ok, it would require only one
> bit of added code, I suppose, but I don't see the plus side.

The plus side is you give up an untenable position :-) And to address an 
item in a matrix costs two lookups, row and column, while an array needs 
only one. 

P.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Get all the instances of one class

2008-05-18 Thread Gabriel Genellina
En Sun, 18 May 2008 12:32:28 -0300, Terry <[EMAIL PROTECTED]> escribió:

> On May 17, 8:04 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>> En Fri, 16 May 2008 20:44:00 -0300, Terry <[EMAIL PROTECTED]>
>> escribió:
>>
>> > Is there a simple way to get all the instances of one class? I mean
>> > without any additional change to the class.
>>
>> Try with gc.get_referrers()
>
> But I saw in the help that we should "Avoid using get_referrers() for
> any purpose other than debugging. "

Yes - so what do you want to do actually?

-- 
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: Write bits in file

2008-05-18 Thread John Nagle

Monica Leko wrote:

Hi

I have a specific format and I need binary representation.  Does
Python have some built-in function which will, for instance, represent
number 15 in exactly 10 bits?


   The "struct" module will let you format Python data as a binary
object of specified format.  But it doesn't support arbitrary bit-width
fields; integers can be 1, 2, 4, or 8 bytes.

   If you have a space problem, you might use the "struct" module to
convert to a reasonably concise binary representation, then use the
"gzip" module to compress the file down further.

John Nagle
--
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing applications that use 3rd party modules

2008-05-18 Thread Mike Driscoll
On May 17, 10:13 am, eliben <[EMAIL PROTECTED]> wrote:
> On May 17, 3:23 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > On May 17, 4:42 am, eliben <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > I'm getting into Python now after years of Perl, and as part of my
> > > research I must understand how to do some common tasks I need.
>
> > > I have a bunch of Windows PCs at work to which I want to distribute an
> > > application I've developed on my PC. All these PCs have Python 2.5
> > > installed.
>
> > > If my application contains only code I've developed, I simply zip its
> > > directory with .py files and send it to everyone, who can then use it
> > > by running the entry-point .py file. However, what if I've installed
> > > some 3rd party modules on my PC, and my application uses them (for
> > > example pyparsing, PiYAML and some others) ? I don't want to manually
> > > install all these packages (there may be dozens of them) on all those
> > > PCs (there may be dozens of those too). What is the best method I can
> > > use ? Naturally, I want all the non-standard packages my app uses to
> > > be detected automatically and collected into some kind of convenient
> > > distributable that is easy to pass around and run.
>
> > > I'm aware of py2exe - tried it and it works fine. But it creates huge
> > > executables, and I don't want to distribute those all the time. I much
> > > prefer a zipped directory of .py scripts that takes some 10s of KBs.
>
> > > Thanks in advance,
> > > Eli
>
> > You might want to check out Buildout. It allows you to run all that
> > stuff in it's own virtual world, so to speak. I'm planning on playing
> > with it this week.
>
> I looked at its examples and I'm not sure it's what I need. It seems
> useful for other cases though.
>
> > Also, there's this site which has collected the various means of
> > distributing Python apps:
>
> >http://www.freehackers.org/Packaging_a_python_program
>
> This page only talks about the packagers that create .exe files that
> don't need Python installed.
>
> Is there a simple way to find out which packages are used by my
> script ?
>
> Eli

I'm fairly certain you can use that Freeze application to do the dirty
work for you. Or you can just distribute the pyc files...I've heard
that works somehow too.

Mike
--
http://mail.python.org/mailman/listinfo/python-list


Re: usage of python

2008-05-18 Thread Paddy
On May 13, 6:10 pm, Rajarshi <[EMAIL PROTECTED]> wrote:
> Hi, I teach an introductory programming course in Python. As part of
> the introduction I'd like to highlight theusage of Pythonin
> industry. The idea is to show that there are big players using Python
> for a variety of tasks. Given that the students come from a variety of
> backgrounds and are not necessarily 'hackers', I'm trying to look for
> examples with a bit of wow-factor.
>
> Is there any list with people/groups/companies using Python for
> impressive things?
>
> Any pointers would be appreciated
>
> Thanks,
> Rajarshi

Ciranova uses Python and manages to allow its customers to migrate
their Designs from a proprietary format that dominates the market
using Python: http://www.ciranova.com/index.html

- Paddy.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python library for clustering from distance vector

2008-05-18 Thread jay graves
On May 17, 11:49 pm, Sengly <[EMAIL PROTECTED]> wrote:
> I am looking for a python library which can cluster similar objects
> into their respective groups given their similarity score of each two
> of them. I have searched the group but I couldn't find any helpful
> information yet.

How about google?  Searching for the terms python and cluster gave
some results for me.

http://www.google.com/search?q=python+cluster


> Any suggestion is appreciated. Also, if you know any specific group
> that I should post this message, please also suggest.

The book, "Programming Collective Intelligence" by Toby Segaran is
great and has examples of clustering algorithms written in Python.

http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325/


...
Jay Graves
--
http://mail.python.org/mailman/listinfo/python-list


What's the api tat I should use to connect python to a MS Access Db?

2008-05-18 Thread David Anderson
Please answer me the question of the subject =)
--
http://mail.python.org/mailman/listinfo/python-list

Compress a string

2008-05-18 Thread Matt Porter

Hi guys,

I'm trying to compress a string.
E.g:
 "BBBC" -> "ABC"

The code I have so far feels like it could be made clearer and more  
succinct, but a solution is currently escaping me.



def compress_str(str):
new_str = ""
for i, c in enumerate(str):
try:
if c != str[i+1]:
new_str += c
except IndexError:
new_str += c
return new_str


Cheers
Matt
--
--

--
http://mail.python.org/mailman/listinfo/python-list


[EMAIL PROTECTED]: Re: Compress a string]

2008-05-18 Thread J. Clifford Dyer
On Sun, May 18, 2008 at 07:06:10PM +0100, Matt Porter wrote regarding Compress 
a string:
> 
> Hi guys,
> 
> I'm trying to compress a string.
> E.g:
>  "BBBC" -> "ABC"
> 
> The code I have so far feels like it could be made clearer and more  
> succinct, but a solution is currently escaping me.
> 
> 
> def compress_str(str):
> new_str = ""
> for i, c in enumerate(str):
> try:
> if c != str[i+1]:
> new_str += c
> except IndexError:
> new_str += c
> return new_str
> 
> 
> Cheers
> Matt

def compress_str(s): 
# str is a builtin keyword. Don't overload it.
out = []
for c in s:
if out and c == out[-1]:
out.append(c) # This is faster than new_str += c
return ''.join(out) 


--
http://mail.python.org/mailman/listinfo/python-list


Fwd: Re: [EMAIL PROTECTED]: Re: Compress a string]

2008-05-18 Thread python
> I'm trying to compress a string.
> E.g:
>
>  "BBBC" -> "ABC"

Doesn't preserve order, but insures uniqueness:

line = "BBBC"
print ''.join( set( line ) )

Malcolm
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EMAIL PROTECTED]: Re: Compress a string]

2008-05-18 Thread Matt Porter
On Sun, 18 May 2008 19:13:57 +0100, J. Clifford Dyer  
<[EMAIL PROTECTED]> wrote:


On Sun, May 18, 2008 at 07:06:10PM +0100, Matt Porter wrote regarding  
Compress a string:


Hi guys,

I'm trying to compress a string.
E.g:
 "BBBC" -> "ABC"

The code I have so far feels like it could be made clearer and more
succinct, but a solution is currently escaping me.


def compress_str(str):
new_str = ""
for i, c in enumerate(str):
try:
if c != str[i+1]:
new_str += c
except IndexError:
new_str += c
return new_str


Cheers
Matt


def compress_str(s):
# str is a builtin keyword. Don't overload it.
out = []
for c in s:
if out and c == out[-1]:
out.append(c) # This is faster than new_str += c
return ''.join(out)




Thanks. Had to change a few bits to make it behave as I expected:

def compress_str(s):
# str is a builtin keyword. Don't overload it.
out = [s[0],]
for c in s:
if out and c != out[-1]:
out.append(c) # This is faster than new_str += c
return ''.join(out)

Feels slightly less hacked together



--
http://mail.python.org/mailman/listinfo/python-list





--
--

--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread Salvatore DI DI0
Try this

t = set("bbc")
list(t)

Regards

Salvatore


"Matt Porter" <[EMAIL PROTECTED]> a écrit dans le message de news: 
[EMAIL PROTECTED]
> Hi guys,
>
> I'm trying to compress a string.
> E.g:
>  "BBBC" -> "ABC"
>
> The code I have so far feels like it could be made clearer and more 
> succinct, but a solution is currently escaping me.
>
>
> def compress_str(str):
> new_str = ""
> for i, c in enumerate(str):
> try:
> if c != str[i+1]:
> new_str += c
> except IndexError:
> new_str += c
> return new_str
>
>
> Cheers
> Matt
> -- 
> --
> 


--
http://mail.python.org/mailman/listinfo/python-list

Re: Compress a string

2008-05-18 Thread Arnaud Delobelle
"Matt Porter" <[EMAIL PROTECTED]> writes:

> Hi guys,
>
> I'm trying to compress a string.
> E.g:
>  "BBBC" -> "ABC"
>
> The code I have so far feels like it could be made clearer and more
> succinct, but a solution is currently escaping me.
>
>
> def compress_str(str):
> new_str = ""
> for i, c in enumerate(str):
> try:
> if c != str[i+1]:
> new_str += c
> except IndexError:
> new_str += c
> return new_str
>
>
> Cheers
> Matt
> -- 
> --

>>> string = 'sspppaaam'
>>> ''.join(x for x, y in zip(string, '\0'+string) if x != y)
'spam'

HTH

PS: I keep seeing problems on this list whose solution seems to
involve 'window' iterating over a sequence. E.g.

>>> list(window('eggs', 2))
[('e', 'g'), ('g', 'g'), ('g', 's')]

-- 
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread Gary Herron

Matt Porter wrote:

Hi guys,

I'm trying to compress a string.
E.g:
 "BBBC" -> "ABC"

The code I have so far feels like it could be made clearer and more 
succinct, but a solution is currently escaping me.



def compress_str(str):
new_str = ""
for i, c in enumerate(str):
try:
if c != str[i+1]:
new_str += c
except IndexError:
new_str += c
return new_str


Cheers
Matt


This is shorter and perhaps clearer:

def compress_str(str):
  new_str = ""
  for c in str:
if not new_str  or  c != new_str[-1]:
  new_str += c
  return new_str


However, successive appends to a string is inefficient (whereas 
successive appends to a list are ok), so this is probably more efficient:


def compress_str(str):
  r = []
  for c in str:
if not r  or  c != r[-1]:
  r.append(c) # Build a list of characters
  return ''.join(r)#  Join list into a single string


And then building a list in a loop is usually more efficient (and 
perhaps clearer) if done with a list comprehension:


 new_str = ''.join([c for i,c in enumerate(str)   if not i or str[i-1] 
!= c])


or, maybe clearer as two lines:

 r = [c for i,c in enumerate(str)   if not i or str[i-1] != c]
 new_str = ''.join(r)


Gary Herron






--
http://mail.python.org/mailman/listinfo/python-list


Re: howto use pylint from Eric IDE?

2008-05-18 Thread dmitrey
Since I have no project (and willing to create the one), just several
py-files, the Project->Check button is disabled.
Are there any other methods in v4.1.1 or more recent?
Thx, D.

On 18 Тра, 16:48, Detlev Offenbach <[EMAIL PROTECTED]> wrote:
> dmitrey wrote:
> > Hi all,
>
> > I have Eric 4.1.1, pylint and Eric pylint plugin installed, but I
> > cannot find how to use pylint from Eric IDE GUI.
> > Does anyone know?
>
> > Thank you in advance, D.
>
> Project->Check->Run PyLint
>
> Regards,
> Detlev
> --
> Detlev Offenbach
> [EMAIL PROTECTED]

--
http://mail.python.org/mailman/listinfo/python-list

Re: Get all the instances of one class

2008-05-18 Thread Tommy Nordgren


On 17 maj 2008, at 01.44, Terry wrote:


Hi,

Is there a simple way to get all the instances of one class? I mean
without any additional change to the class.

br, Terry
--
http://mail.python.org/mailman/listinfo/python-list



class MyClass : a_base_class
  memberlist=[]

#  Insert object in memberlist when created;
#  note: objects won't be garbage collected until removed from  
memberlist.

-
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
[EMAIL PROTECTED]




--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread Paul McGuire
On May 18, 1:45 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
> Matt Porter wrote:
> > Hi guys,
>
> > I'm trying to compress a string.
> > E.g:
> >  "BBBC" -> "ABC"
>

I'm partial to using (i)zip when I need to look at two successive
elements of a sequence:

>>> from itertools import izip
>>> instr = "aaabbdaaaddccc"
>>> newstr = "".join( b for a,b in izip(" "+instr,instr) if a!=b )
>>> print newstr
abdadc

-- Paul

--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the api tat I should use to connect python to a MS Access Db?

2008-05-18 Thread Henry Chang
A simple google search:
http://bytes.com/forum/thread637384.html

On Sun, May 18, 2008 at 10:57 AM, David Anderson <[EMAIL PROTECTED]>
wrote:

> Please answer me the question of the subject =)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

python confusion possibly related to pickle

2008-05-18 Thread Dennis


I have a problem that I don't understand at all. I run a python script, 
which uses pickle, and it fails. That alone is, perhaps, no big deal.


The problem that's got me annoyed is that after getting said error I 
close the shell window, open a new one, run the python interpreter and 
type "import pickle" and get the error that the script I'd run earlier 
caused. Why is this ?


To my knowledge, once python stopped running it didn't store anything 
related to the last time it was run.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread Peter Otten
Matt Porter wrote:

> I'm trying to compress a string.
> E.g:
>   "BBBC" -> "ABC"

Two more:

>>> from itertools import groupby
>>> "".join(k for k, g in groupby("aabbcc"))
'abc'

>>> import re
>>> re.compile(r"(.)\1*").sub(r"\1", "aaa")
'abc'

Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: python confusion possibly related to pickle

2008-05-18 Thread Dennis


Never mind. I solved it. I had a file called pickle in the same folder I 
was in when I ran python, and that's the file it was trying to import.


Duh @ me :s


Dennis wrote:


I have a problem that I don't understand at all. I run a python script, 
which uses pickle, and it fails. That alone is, perhaps, no big deal.


The problem that's got me annoyed is that after getting said error I 
close the shell window, open a new one, run the python interpreter and 
type "import pickle" and get the error that the script I'd run earlier 
caused. Why is this ?


To my knowledge, once python stopped running it didn't store anything 
related to the last time it was run.

--
http://mail.python.org/mailman/listinfo/python-list


Re: python confusion possibly related to pickle

2008-05-18 Thread Derek Martin
On Sun, May 18, 2008 at 08:28:34PM +0100, Dennis wrote:
> The problem that's got me annoyed is that after getting said error I
> close the shell window, open a new one, run the python interpreter
> and type "import pickle" and get the error that the script I'd run
> earlier caused. Why is this ?

Well, what's the error?  Sounds like your system could be b0rked (or
at least your python installation)... but depending on the error,
there could be other explanations.  

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D



pgpkARlxW8Y91.pgp
Description: PGP signature
--
http://mail.python.org/mailman/listinfo/python-list

Re: Using Python for programming algorithms

2008-05-18 Thread sturlamolden
On May 18, 4:20 pm, David C. Ullrich <[EMAIL PROTECTED]> wrote:

> Are you going to be doing research _about_ the
> algorithms in question or is it going to be research
> _using_ these algorithms to draw conclusions
> about other things?
>
> Most of the replies seem to be assuming the latter.
> If it's the former then Python seems like definitely
> an excellent choice - when you have want to try
> something new it will be much faster trying it
> out in Python,

I second this. Hence my previous statement that "In scientific
research, CPU time is cheap and time spent programming is expensive."
If it was not clear what I meant, your post can serve as a
clarification. But whether Giner is 'developing' or 'using'
algorithms, he should value his own labour more than the CPU's. CPU
labour (i.e. computation) is very cheap. Manual labour (i.e.
programming) is very expensive. He may in any case benefit from using
Python. Today, the preferred computer language amount scientists is
not Fortran77, but various high-level languages like Matlab, S, IDL,
Perl and Python.

A related question is: How much 'speed' is really needed? If Giner is
analyzing datasets using conventional statistics (ANOVA, multiple
regression, etc.), when will Python (with NumPy) cease to be
sufficient? In my experience, conventional statistics on a dataset of
100,000 or 1,000,000 samples can be regarded child's play on a modern
desktop computer. One really need HUGE amounts of data before it's
worthwhile to use anything else. If one can save a couple of seconds
CPU time by spending several hours programming, then the effort is not
just futile, it's downright wasteful and silly.


Something else that should be mentioned:

The complexity of the algorithm (the big-O notation) is much more
important for runtime performance than the choice of language. If you
can replace a O(N*N) with O(N log N), O(N) or O(1) it is always
adviceable to do so. An O(N*N) algorithm implemented in C is never
preferred over an O(N) algorithm written in Python. The only time when
C is preferred over Python is when N is large, but this is also when
O(N*N) is most painful. Pay attention to the algorithm is things are
running unbearably slow.

Python has highly tuned datatypes like lists, dicts and sets, which a
C programmer will have a hard time duplicating. This also applies to
built-in algorithms like 'timsort'. qsort in the C standard library or
anything a C programmer can whip up within a reasonable amount of time
simply doesn't compare. C vs. Python benchmarks that doesn't take this
into account will falsely put Python in a bad light.











--
http://mail.python.org/mailman/listinfo/python-list


Re: Rpy Module

2008-05-18 Thread Mike P
Superb, thanks

--
http://mail.python.org/mailman/listinfo/python-list


is there a bug in urlunparse/urlunsplit

2008-05-18 Thread Alex
Hi all.

Is there a bug in the urlunparse/urlunsplit functions?
Look at this fragment (I know is quite silly):

urlunparse(urlparse('www.example.org','http'))
---> 'http:///www.example.org'
   ^

There are too many slashes, isn't it? Is it a known bug or maybe I
missed something...

Alex

--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread Marc Christiansen
Matt Porter <[EMAIL PROTECTED]> wrote:
> Hi guys,
> 
> I'm trying to compress a string.
> E.g:
>  "BBBC" -> "ABC"

You mean like this?

 >>> ''.join(c for c, _ in itertools.groupby("BBBCAADCASS"))
 'ABCADCAS'

HTH
  Marc
--
http://mail.python.org/mailman/listinfo/python-list


Showing the method's class in expection's traceback

2008-05-18 Thread Agustin Villena
Hi!

is there anyway to show the class of a method in an exception's
traceback?

For example, the next code

class Some(object):
def foo(self,x):
raise Exception(x)

obj = Some()
obj.foo("some arg")

produces the next traceback

Traceback (most recent call last):
  File "", line 231, in run_nodebug
  File "G:\dev\exceptions\sample.py", line 7, in 
obj.foo("some arg")
  File "G:\dev\exceptions\sample.py", line 3, in foo
raise Exception(x)
Exception: some arg

I want to improve the line
File "G:\dev\exceptions\sample.py", line 3, in foo

to
File "G:\dev\exceptions\sample.py", line 3, in Some.foo

Is this improvement feasible
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for programming algorithms

2008-05-18 Thread Jaap Spies

Vicent Giner wrote:

Hello.

I am new to Python. It seems a very interesting language to me. Its
simplicity is very attractive.

However, it is usually said that Python is not a compiled but
interpreted programming language —I mean, it is not like C, in that
sense.

I am working on my PhD Thesis, which is about Operations Research,
heuristic algorithms, etc., and I am considering the possibility of
programming all my algorithms in Python.

The usual alternative is C, but I like Python more.

The main drawbacks I see to using Python are these:

* As far as I understand, the fact that Python is not a compiled
language makes it slower than C, when performing huge amounts of
computations within an algorithm or program.

* I don't know how likely it is to find libraries in Python related to
my research field.

* I know Python is a "serious" and mature programming language, of
course. But I do not know if it is seen as "just funny" in a research
context. Is Python considered as a good programming language for
implementing Operations Research algorithms, such as heuristics and
other soft-computing algorithms?



You definitely should take a look at Sage: http://www.sagemath.org/

This may offer all you need, based on Python integrating a lot of
other programs!

Jaap
--
http://mail.python.org/mailman/listinfo/python-list


distutils directory problem

2008-05-18 Thread Martin Manns
Hi,

I have the following problem with the distutils package:
(I have now spent hours reading and searching the manuals and tutorials,
and I am still stuck.)

I have a working directory
~/pyspread
in which my libraries are situated and two icons directories
~/pyspread/icons and ~/pyspread/icons/actions

Now I would like to create a setup.py file inside my ~/pyspread
directory that installs my .py modules in .../site-packages/pyspread
and the icons in appropriate sub-folders and adds pyspread.pth to
.../site-packages so that .../site-packages/pyspread is in the
PYTHONPATH.

However, my setup.py puts everything  (including .pyc files) into
site-packages *and* into the sub-folders. What am I doing wrong?

I am looking for a platform-independent solution. Currently, I am using
python 2.5 on Linux.

Here my setup.py

#!/usr/bin/env python

from distutils.core import setup
setup(name='pyspread',
  version='0.0.7',
  description='A spreadsheet that accepts a pure python expression in each 
cell.',
  license='GPL v3 :: GNU General Public License',
  classifiers=[ 'Development Status :: 3 - Alpha',
'Intended Audience :: End Users/Desktop',
  ],
  author='Martin Manns',
  author_email='[EMAIL PROTECTED]',
  url='http://sourceforge.net/projects/pyspread/',
  packages=['pyspread'],
  package_dir={'pyspread': '.'},
  scripts=['pyspread.py'],
  py_modules=['pyspread.mainapp', 'pyspread.pysgrid', 
'pyspread.mygrid','pyspread.icontheme'],
  package_data={'pyspread': ['icons/*.png', 'icons/actions/*.png' ,\
 'test.pys', 'test.csv', 'test2.csv', \
 'README', 'COPYING']},
)


Thanks in advance

Martin


--
http://mail.python.org/mailman/listinfo/python-list


Re: Showing the method's class in expection's traceback

2008-05-18 Thread Diez B. Roggisch

Agustin Villena schrieb:

Hi!

is there anyway to show the class of a method in an exception's
traceback?

For example, the next code

class Some(object):
def foo(self,x):
raise Exception(x)

obj = Some()
obj.foo("some arg")

produces the next traceback

Traceback (most recent call last):
  File "", line 231, in run_nodebug
  File "G:\dev\exceptions\sample.py", line 7, in 
obj.foo("some arg")
  File "G:\dev\exceptions\sample.py", line 3, in foo
raise Exception(x)
Exception: some arg

I want to improve the line
File "G:\dev\exceptions\sample.py", line 3, in foo

to
File "G:\dev\exceptions\sample.py", line 3, in Some.foo

Is this improvement feasible


It should be. You can get a dictionary of the locals of an exception 
stack frame, of which you could extract the self-parameter's class.


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: is there a bug in urlunparse/urlunsplit

2008-05-18 Thread Rob Williscroft
Alex wrote in news:09764c57-03ce-4ccb-a26d-
[EMAIL PROTECTED] in comp.lang.python:

> Hi all.
> 
> Is there a bug in the urlunparse/urlunsplit functions?
> Look at this fragment (I know is quite silly):
> 
> urlunparse(urlparse('www.example.org','http'))
> ---> 'http:///www.example.org'
>^

Try these 3:

  urlparse('www.example.org','http')
  urlparse('http://www.example.org','http')
  urlparse('//www.example.org','http')

The 1st returns www.example.org as the path part
with the other 2 its the location (domain) part.

Although it may not be immediately obvious that the result 
is correct, consider the follwing html fragment:

  
  http://anothersite.com/bbb.gif";>

If you were to use urlparse to parse the src attributes
you would want:

  ( '', '', 'aaa.gif', '','','' )
  ( 'http', 'anothersite.com', '/bbb.gif', '','','' )


Which AIUI is what urlparse does.


Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: multiple databases, what's the best interface ?

2008-05-18 Thread Stef Mientki

thanks guys,
I'll take a look at your suggestions.
cheers,
Stef

M.-A. Lemburg wrote:

On 2008-05-17 20:54, Stef Mientki wrote:

hello,

I need to switch fluently between 2 or 3 types of dbases:
SQLite, Sybase ( and in the future MS SQL-server).

I need both closed application and general purpose database manager,
which should run on different platforms (windows, windows mobile, not 
web based).


I would like to write the applications in Python.
What's the best interface so I can use the same program for all 
databases,
and just have to change the database name, if I want to use another 
database ?


If you need a common interface on all the platforms, then I'd suggest
you have a look at our mxODBC:

http://www.egenix.com/products/python/mxODBC/

If you also need to support Windows Mobile, then you'll be interested
in our upcoming new product called "mxODBC Connect" which separates
the client from the server.

mxODBC Connect allows using the mxODBC API on platforms which don't
come with ODBC drivers or where getting ODBC drivers is difficult.
Due to it's client-server approach it also simplifies configuration
a lot.



--
http://mail.python.org/mailman/listinfo/python-list


Re: about python

2008-05-18 Thread Fuzzyman
On Apr 23, 3:50 am, [EMAIL PROTECTED] wrote:
> How can python execute in browser?
>
> Mukul

The best way of running Python code in the browser is with the
Silverlight browser plugin. Silverlight 2 (currently working with IE,
Safari and Firefoxon Windows and Mac OS X - but Silveright 2 for
Linux, called Moonlight, made major steps in the last few days).

You can run IronPython code inside Silverlight, with the choice of the
WPF based user interface or interacting with the browser DOM and
Javascript.

See the following for more details:

http://www.voidspace.org.uk/ironpython/silverlight/

Michael Foord
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread Matt Porter

On Sun, 18 May 2008 20:30:57 +0100, Peter Otten <[EMAIL PROTECTED]> wrote:


Matt Porter wrote:


I'm trying to compress a string.
E.g:
  "BBBC" -> "ABC"


Two more:


from itertools import groupby
"".join(k for k, g in groupby("aabbcc"))

'abc'


import re
re.compile(r"(.)\1*").sub(r"\1", "aaa")

'abc'



Brilliant - I was trying to figure out how to do this with the re  
capabilities.


Thanks to everyone


Peter
--
http://mail.python.org/mailman/listinfo/python-list





--
--

--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread inhahe
i see lots of neat one-liner solutions but just for the sake of argument:

def compress_str(str):
 new_str = ""
 lc = ""
 for c in str:
if c != lc: new_str.append(c)
 return new_str


"Matt Porter" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi guys,
>
> I'm trying to compress a string.
> E.g:
>  "BBBC" -> "ABC"
>
> The code I have so far feels like it could be made clearer and more 
> succinct, but a solution is currently escaping me.
>
>
>
>
> Cheers
> Matt
> -- 
> --
> 


--
http://mail.python.org/mailman/listinfo/python-list


Re: Compress a string

2008-05-18 Thread inhahe
I forgot a line that says, "lc = c"
i should really test my stuff.

"inhahe" <[EMAIL PROTECTED]> wrote in message news:...
>i see lots of neat one-liner solutions but just for the sake of argument:
>
> def compress_str(str):
> new_str = ""
> lc = ""
> for c in str:
>if c != lc: new_str.append(c)
> return new_str
>
>
> "Matt Porter" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Hi guys,
>>
>> I'm trying to compress a string.
>> E.g:
>>  "BBBC" -> "ABC"
>>
>> The code I have so far feels like it could be made clearer and more 
>> succinct, but a solution is currently escaping me.
>>
>>
>>
>>
>> Cheers
>> Matt
>> -- 
>> --
>>
>
> 


--
http://mail.python.org/mailman/listinfo/python-list


How do *you* use Python in non-GUI work?

2008-05-18 Thread John Salerno
Hey all. Just thought I'd ask a general question for my own interest. Every 
time I think of something I might do in Python, it usually involves creating a 
GUI interface, so I was wondering what kind of work you all do with Python that 
does *not* involve any GUI work. This could be any little scripts you write for 
your own benefit, or what you do at work, if you feel like talking about that! 
:)

Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Daniel Fetchinson
> Hey all. Just thought I'd ask a general question for my own interest. Every
> time I think of something I might do in Python, it usually involves creating
> a GUI interface, so I was wondering what kind of work you all do with Python
> that does *not* involve any GUI work. This could be any little scripts you
> write for your own benefit, or what you do at work, if you feel like talking
> about that! :)

web apps
manage/format/write cv
convert jpg to gif
start/stop/manage parallel runs on a PC cluster
etc :)

Actually, I've never written anything with a GUI (unless you count web apps).

Cheers,
Daniel
-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Mensanator
On May 18, 5:20�pm, John Salerno <[EMAIL PROTECTED]> wrote:
> Hey all. Just thought I'd ask a general question for my own interest. Every 
> time I think of something I might do in Python, it usually involves creating 
> a GUI interface, so I was wondering what kind of work you all do with Python 
> that does *not* involve any GUI work. This could be any little scripts you 
> write for your own benefit, or what you do at work, if you feel like talking 
> about that! :)
>
> Thanks.

Odd, I've been using Python since ver 2.2 and I've
NEVER needed a GUI. I do things like (looking at the
last 6 months of my Python directory):

- how to scrape movie receipt data from IMDB
  and insert them into an MS-Access database

- how to scrape .jpgs from a web page (simple
  file transfer, no display needed)

- how to do a Cartesian Product in SQLlite3

- how to creat a polynomial from a sequence of
  numbers using Newton's Forward Differences method

- how to calculate the date of Easter

- how to construct arbitrary length cycles in the
  Collatz Conjecture

- how to find the Ultimate Cycle (also in Collatz
  Conjecture)

- efficient cycle detection comparing Brent's and
  Sedgewick's cycle detection algorithms

- finding the cycles of 3n+C systems

- partioning W marbles into D ordered bins with
  the constraint that each bin contain a minimum of 1

- partioning W marbles into D ordered bins with
  the constraint that each bin contain a minimum of 1
  and that no bin exceeds M

- a Python Cartesian Product that in addition to
  Permutaions with Replacement, also gives the subsets
  Permutations without Replacement, Combinations with
  Replacement and Combinations without Replacement

- demonstrating the fallacy of Peter Scorer's "proof"
  of the Collatz Conjecture

- demonstrating the fallacy of Alan Tyte's "proof" of
  the Collatz Conjecture

- demonstrating the fallacy of Ken Conrow's "proof" of
  the Collatz Conjecture

- how to identify which members of the infinite solutions
  to a given Sequnce Vector of a 3n+C system are located
  on the trivial graph component

- developing a novel factoring algorithm based on the
  Collatz Conjecture

I see no need for GUI in any of these applications.


--
http://mail.python.org/mailman/listinfo/python-list

Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread sturlamolden
On May 19, 12:20 am, John Salerno <[EMAIL PROTECTED]> wrote:

> Hey all. Just thought I'd ask a general question for my own interest. Every 
> time I think of something I might do in Python, it usually involves creating 
> a GUI interface, so I was wondering what kind of work you all do with Python 
> that does *not* involve any GUI work. This could be any little scripts you 
> write for your own benefit, or what you do at work, if you feel like talking 
> about that! :)


Back in the 'old days' of Unix, programs tended not to be small, could
only do one thing, and did it well. They had  no gui, and all
interaction came from command line options. The programs were invoked
from the command line, and input and output were piped from one
program to another (input on stdin, output on stdout).

Today, it is expected that programs should have a GUI. The majority do
not even know how to use a program that does not have one. As a
result, programs have become poorer at interacting with other, and
become bloated and grown monolithic. Today's programs are monolithic
beasts spanning tens or hundreds of megabytes, where the bulk of the
code duplicates functionality found in every other program.

I prefer that a program has no GUI if it does not need user
interaction beyond what can be easily accomplished from the command
line. Sometimes I think gui becomes overwhelming, and obfuscates the
real functionality in the program. When I write program's for others
people, a GUI is usually expected. But when I get requests for adding
new functionality to such a program, it tends to be for unimportant
GUI stuff rather than real functionality to the program.

To answer your question: I only add GUIs when I have to. But because
it seems that people are becoming computer illiterate, incapable of
using a keyboard, and only comfortable with a certain point-and-click
input device, it tends to be most of the time now.






--
http://mail.python.org/mailman/listinfo/python-list


Re: Get all the instances of one class

2008-05-18 Thread Terry
On May 18, 11:35 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Terry schrieb:
>
>
>
> > On May 17, 8:04 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
> > wrote:
> >> En Fri, 16 May 2008 20:44:00 -0300, Terry <[EMAIL PROTECTED]>
> >> escribió:
>
> >>> Is there a simple way to get all the instances of one class? I mean
> >>> without any additional change to the class.
> >> Try with gc.get_referrers()
>
> >> py> import gc
> >> py> class A(object): pass
> >> ...
> >> py> a,b,c = A(),A(),A()
> >> py> A
> >> 
> >> py> for item in gc.get_referrers(A): print type(item)
> >> ...
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
>
> >> We need to filter that list, keeping only A's instances:
>
> >> py> [item for item in gc.get_referrers(A) if isinstance(item,A)]
> >> [<__main__.A object at 0x00A40DC8>, <__main__.A object at 0x00A40DF0>,
> >> <__main__.A object at 0x00A40E18>]
>
> >> --
> >> Gabriel Genellina
>
> > But I saw in the help that we should "Avoid using get_referrers() for
> > any purpose other than debugging. "
>
> Yes, because using it do is very resource-consuming and shouldn't be
> done. Why don't you tell us what you are after here & then we might come
> up with a better solution?
>
> Diez

I'm developing a message/state_machine based python program (I'm not
using stackless, plan to move to it later).
I want to collect all the state_machines (threads) and send them
'tick' message or 'quit' message.

Now I'm using a static member to collect the machines, just wonderring
if python already provide something like this.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread John Salerno
On Sun, 18 May 2008 16:17:55 -0700 (PDT)
Mensanator <[EMAIL PROTECTED]> wrote:


> I see no need for GUI in any of these applications.

Yeah, I try to find little projects to write in Python that don't involve a 
GUI. It's quicker, for one thing, and I also find that there is much more of a 
focus on the actual problem rather than wasting time trying to get a button 
positioned just right. :)

Even back when I was using Windows 3.1 and 95, I enjoyed doing stuff in DOS 
because it made me feel like I was actually getting work done. :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Mensanator
On May 18, 7:25�pm, John Salerno <[EMAIL PROTECTED]> wrote:
> On Sun, 18 May 2008 16:17:55 -0700 (PDT)
>
> Mensanator <[EMAIL PROTECTED]> wrote:
> > I see no need for GUI in any of these applications.
>
> Yeah, I try to find little projects to write in Python that don't involve a 
> GUI. It's quicker, for one thing, and I also find that there is much more of 
> a focus on the actual problem rather than wasting time trying to get a button 
> positioned just right. :)
>
> Even back when I was using Windows 3.1 and 95, I enjoyed doing stuff in DOS 
> because it made me feel like I was actually getting work done. :)

I see Python as the successor to Turbo Pascal - the DOS
version before Borland fucked it up by making it a GUI IDE.
--
http://mail.python.org/mailman/listinfo/python-list

New to Python, Discussion Groups.

2008-05-18 Thread cmoller
Hi,

I am new to Python and the use of discussion groups. Is there a FAQ
for basic information so certain questions are not repeated?

I am NOT an experienced programmer, but have decided to write a data
logger for sensors sending data via an internal ethernet work to
machines running OS X (Intel). The program should store data and allow
real time plotting. It does not need a beautiful GUI, but I may want
to share the program with others, so it should be somewhat intuitive.
It looks like I could use Python to access MS Excel, which would
significantly reduce the effort, but I am not sure if this is
practical. I am not in a hurry and would approach the problem as a way
to learn.

The data I am processing is readily seen via telnet so I know it's
there.

Is Python a good choice or should I invest in learning a language well
known to be best for applications like this? Are there other key
topics in addition to network programing that I should be focusing on?


Thanks,

Chris
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread timh
On May 19, 6:20 am, John Salerno <[EMAIL PROTECTED]> wrote:
> Hey all. Just thought I'd ask a general question for my own interest. Every 
> time I think of something I might do in Python, it usually involves creating 
> a GUI interface, so I was wondering what kind of work you all do with Python 
> that does *not* involve any GUI work. This could be any little scripts you 
> write for your own benefit, or what you do at work, if you feel like talking 
> about that! :)
>
> Thanks.

Hi

I work fulltime developing in python and have done so for more than 5
years now, and I would say 99.8% of the time I have not
built anything with a GUI (Unless you consider a web page as a GUI ;-)

Much of my work is web based (zope backend stuff), test frameworks for
windows build environments that need to compare the output of 1000's
of images from rendering pipelines. Lots of data integration and
manipulation utilities as part of processing pipelines. All sorts of
stuff that just doesn't use
a GUI.

T

--
http://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Discussion Groups.

2008-05-18 Thread Mensanator
On May 18, 7:34�pm, cmoller <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am new to Python and the use of discussion groups. Is there a FAQ
> for basic information so certain questions are not repeated?
>
> I am NOT an experienced programmer, but have decided to write a data
> logger for sensors sending data via an internal ethernet work to
> machines running OS X (Intel). The program should store data and allow
> real time plotting. It does not need a beautiful GUI, but I may want
> to share the program with others, so it should be somewhat intuitive.
> It looks like I could use Python to access MS Excel, which would
> significantly reduce the effort, but I am not sure if this is
> practical.

It ought to be as long as you have the modules to
interface with Excel and know how to use them.

Although MS-Access might be a better choice than Excel
as both products have the same graphing capabilities
but Access might be a better choice for capturing data.

And Python can easily insert data into Access.

> I am not in a hurry and would approach the problem as a way
> to learn.
>
> The data I am processing is readily seen via telnet so I know it's
> there.
>
> Is Python a good choice or should I invest in learning a language well
> known to be best for applications like this? Are there other key
> topics in addition to network programing that I should be focusing on?
>
> Thanks,
>
> Chris

--
http://mail.python.org/mailman/listinfo/python-list

Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Irmen de Jong


John Salerno wrote:

Hey all. Just thought I'd ask a general question for my own interest. Every 
time I
think of something I might do in Python, it usually involves creating a GUI
interface, so I was wondering what kind of work you all do with Python that does
*not* involve any GUI work. This could be any little scripts you write for your 
own
benefit, or what you do at work, if you feel like talking about that! :)

Thanks.


- web server/blog/wiki. This doesn't have a gui if you don't consider HTML 
pages a gui
- various scripts to help me during software deployment and testing
  (for instance log file analyzers, automated web clients)
- network communications library that tries hard to just get out of your way ;-)
- file processing scripts to do more sophisticated stuff than basic 
search/replace
- most recent script is a little tool that downloads the latest version of some 
World-Of-Warcraft addon, extracts it to the game folder after deleting the old one 
first, and then copies a backup to a network drive. I just doubleclick the .py file and 
it dumps the results in a console window that closes after a few seconds. Who needs a 
gui for that?


Also, I often find myself opening a Python prompt to just execute simple tasks that I 
see other people needing big tools or even online services for:

- base-64 encoding/decoding
- md5/sha hashing
- simple string or regular expression operations
- simple math
- unicode decoding/encoding
- etc etc.


--irmen de jong
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Brian

John Salerno wrote:

Hey all. Just thought I'd ask a general question for my own interest. Every 
time I think of something I might do in Python, it usually involves creating a 
GUI interface, so I was wondering what kind of work you all do with Python that 
does *not* involve any GUI work. This could be any little scripts you write for 
your own benefit, or what you do at work, if you feel like talking about that! 
:)

Thanks.


here is some non-text stuff that I have done within the 
 last two or three years


1. controlling and parsing thousands of label files 
several times per day, that are used by the factory to 
drive the printers that make product safety labels - 
code was easily approved by UL and CSA.
2. real-time control of platform in EMC lab for 
radiated emissions testing.
3. hi-speed data acquisition of 3 to 20 parameters 
during simulated abnormal operating conditions to 
demonstrate product compliance with product safety 
standards.
4. monitoring of several server logs, also sends email 
to me if it finds something it does not like.
5. parallel monitor/control systems for several 
greenhouses.

--
http://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Discussion Groups.

2008-05-18 Thread Ben Finney
cmoller <[EMAIL PROTECTED]> writes:

> I am new to Python and the use of discussion groups.

Welcome to both.

> Is there a FAQ for basic information so certain questions are not
> repeated?

Congratulations on asking this question; it puts you ahead of many
other first-time posters.

Python's official FAQ documents are on the Python site
http://www.python.org/doc/faq/>.

Despite its arrogant tone, the document "How to Ask Questions the
Smart Way" http://www.catb.org/~esr/faqs/smart-questions.html> is
a good guide for interacting well with technical discussion forums.

-- 
 \   "I bet one legend that keeps recurring throughout history, in |
  `\   every culture, is the story of Popeye."  -- Jack Handey |
_o__)  |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Kam-Hung Soh
On Mon, 19 May 2008 08:20:22 +1000, John Salerno  
<[EMAIL PROTECTED]> wrote:


Hey all. Just thought I'd ask a general question for my own interest.  
Every time I think of something I might do in Python, it usually  
involves creating a GUI interface, so I was wondering what kind of work  
you all do with Python that does *not* involve any GUI work. This could  
be any little scripts you write for your own benefit, or what you do at  
work, if you feel like talking about that! :)


Thanks.
--
http://mail.python.org/mailman/listinfo/python-list



- Enhancing existing products by scripting new features.
- Interface between databases, Excel and text files.
- Convert data between flat files and XML.
- Manage files for build processes.
- Automating processes (e.g. checkout, builds, FTP).

Wish I had some reasons to make a GUI application in Python.

--
Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman

--
http://mail.python.org/mailman/listinfo/python-list


handling xml embedded within xml

2008-05-18 Thread Avowkind
I have a log file within which is contained a dump of an xml message

... rubbish
///asd laksj aslf



content


.. more junk
... then more xml
""")
This example is of course a summary.

I want to write a streaming filter which will throw out all the junk
and just return a series of nice strings of each complete xml
message.  Ideally I also want to filter which messages I am interested
in.

e.g. the output from the above would be


content


Two problems.
1. clearing away junk that is nothing like XML.
2. handling the http://mail.python.org/mailman/listinfo/python-list


Re: Get all the instances of one class

2008-05-18 Thread Matt Nordhoff
Tommy Nordgren wrote:
> class MyClass : a_base_class
>   memberlist=[]
> 
> #  Insert object in memberlist when created;
> #  note: objects won't be garbage collected until removed from memberlist.

Just to say, if you wanted to go about it that way, you could avoid the
garbage collection problem by using weakrefs:


-- 
--
http://mail.python.org/mailman/listinfo/python-list


FREE Tutorials on HTML XHTML CSS JavaScript XML XSL ASP SQL ADO VBScript, SAP - ABAP

2008-05-18 Thread univbgp100
##FREE Tutorials on HTML XHTML CSS JavaScript XML XSL ASP SQL ADO
VBScript, SAP - ABAP

FREE Tutorials on HTML XHTML CSS JavaScript XML XSL ASP SQL ADO
VBScript, SAP - ABAP visit ebooks.univdatabase.com
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >