Wednesday, March 31, 2010

comp.lang.python - 25 new messages in 13 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* Fetch files from mail in python - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/ab1e159bcd418ac1?hl=en
* Python + OpenOffice Calc - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/22165c0d3711582a?hl=en
* logging: local functions ==> loss of lineno - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/1282b9ec08adc2a6?hl=en
* "Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS IN
KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT" "ADVERTISED JOBS
ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/871beb7290b8acf1?hl=en
* (a==b) ? 'Yes' : 'No' - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/b985d5727945d2b4?hl=en
* No editbox () functionality in python-dialog module? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5448287bea345935?hl=en
* Sublassing tuple works, subclassing list does not - 7 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/ed8630710a349620?hl=en
* psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with
time zone: - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/7463ded0971425f8?hl=en
* libpst - python bindings - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/e119b6f92648e821?hl=en
* PyDispatcher on sourceforge doesn't play nice with easy_install - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/122bcc79cac930fe?hl=en
* Generating text from a regular expression - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/c16f904e698a42b3?hl=en
* os.walk restart - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/cb80b10e27af49d4?hl=en
* wrapping data from groups - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0410a687755fdf99?hl=en

==============================================================================
TOPIC: Fetch files from mail in python
http://groups.google.com/group/comp.lang.python/t/ab1e159bcd418ac1?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 12:03 am
From: Dennis Lee Bieber


On Wed, 31 Mar 2010 00:47:47 +0000, hidura@gmail.com declaimed the
following in gmane.comp.python.general:

> I did that but i want to know if i have a file inside the mail how could i
> download that file from my mail.

Top posting is undesirable...

As for "downloading"... At least with POP3 (I don't do IMAP), there
is NO "downloading" -- all attachments come down with the message.

What you need to do is parse out the portion of the body that
contains the "attachment".

<html>
<body>
-- <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Wulfraed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dennis Lee Bieber&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AF6VN<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wlfraed@ix.netcom.com&nbsp;&nbsp;&nbsp; <a href="HTTP://wlfraed.home.netcom.com/" eudora="autourl">HTTP://wlfraed.home.netcom.com/<br>
</a></body>
</html>


==============================================================================
TOPIC: Python + OpenOffice Calc
http://groups.google.com/group/comp.lang.python/t/22165c0d3711582a?hl=en
==============================================================================

== 1 of 2 ==
Date: Wed, Mar 31 2010 12:47 am
From: Tracubik


Hi all!
i'm giving away to a friend of mine that have a garage (he repair car) my
old computer. He will use it essentialy to create estimates of the work
via an ods file (i've made a simple ods file to be filled with the cost of
materials and a description of the work).
He's totally new with computer and have difficult to fill the ods file, so
i'ld like to create a simple python program that help him to introduce the
data in to the ods file via a simple gui.
So what i'm looking for is a way in python to insert data in a particular
cell of the ods file and possibly to save it and print it when it's full
filled with data.

the guy is similar to this:

3 fields: quantity - description of the piece bought - price

a way to add a new "line" if needed (for a new piece entry) similar to the
"add rule" in evolution

1 text field for the description of the work + 1 field for the price of
the work

and off course a way to insert this data in to the ods file via python

Any hints/tutorial/info?

thanks
Nico


== 2 of 2 ==
Date: Wed, Mar 31 2010 12:58 am
From: Chris Rebert


On Wed, Mar 31, 2010 at 12:47 AM, Tracubik <affdfsdfdsfsd@b.com> wrote:
> Hi all!
> i'm giving away to a friend of mine that have a garage (he repair car) my
> old computer. He will use it essentialy to create estimates of the work
> via an ods file (i've made a simple ods file to be filled with the cost of
> materials and a description of the work).
> He's totally new with computer and have difficult to fill the ods file, so
> i'ld like to create a simple python program that help him to introduce the
> data in to the ods file via a simple gui.
> So what i'm looking for is a way in python to insert data in a particular
> cell of the ods file and possibly to save it and print it when it's full
> filled with data.
>
> the guy is similar to this:
>
> 3 fields: quantity - description of the piece bought - price
>
> a way to add a new "line" if needed (for a new piece entry) similar to the
> "add rule" in evolution
>
> 1 text field for the description of the work + 1 field for the price of
> the work
>
> and off course a way to insert this data in to the ods file via python
>
> Any hints/tutorial/info?

PyUNO: http://wiki.services.openoffice.org/wiki/PyUNO_bridge

Cheers,
Chris
--
http://blog.rebertia.com

==============================================================================
TOPIC: logging: local functions ==> loss of lineno
http://groups.google.com/group/comp.lang.python/t/1282b9ec08adc2a6?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 12:52 am
From: Peter Otten <__peter__@web.de>


Hellmut Weber wrote:

> Hi Peter and Jean-Michel,
> thanks for all your hints and pieces of code.
>
> It took me a while to play around with what I got from you (and some
> study of Vinay's module documentation.
>
> Now I have come up with a more complete solution I'm quite satisfied
> with. And I would be very glad to receive your comments on my code
> indicating what I could do better, given that I'm still at the very
> beginning with python.

> Here is my module and a corresponding test program:

> # --- color change strings for terminal output ---
> #
> pc_yell = '\033[01;93m'
> pc_purp = '\033[01;33m'
> pc_gren = '\033[01;92m'

Hw lng wld psts + prgrms b wr it nt 4 z art of clvr + ez 2 mmrz
abbreviations ;)

> # --- Class for all logging functionality ---
> #
> class locLogg():
> _logger = None
>

> def debug_log(self, msg, *args, **kwargs):
> def warn_log(self, msg, *args, **kwargs):
> def error_log(self, msg, *args, **kwargs):

It should be easy to factor out most the code in your xxx_log() methods into
a common helper.

> def fatal_log(self, msg, *args, **kwargs):
> previousFrame = inspect.currentframe().f_back
> locLogg._logger.fatal(str(level_color['fatal'])+msg+pc_norm + \
> ' ' + argskw_2_string(*args, **kwargs),
> extra={'custom_lineno':previousFrame.f_lineno,
> 'custom_filename': previousFrame.f_code.co_filename })

I think the formatting belongs into another layer. That's the purpose of the
logging.Formatter class. You could enhance it along those lines:

class Formatter(logging.Formatter):
markers = {
logging.INFO: ("<info>", "</info>"),
logging.WARN: ("<warn>", "</warn>"),
}
def format(self, record):
message = logging.Formatter.format(self, record)
try:
prefix, suffix = self.markers[record.levelno]
except KeyError:
pass
else:
message = prefix + message + suffix
return message

My general impression is that you are fighting the logging library's
structure rather than trying to use it as effectively as possible.

> foo.info_log('another bar info', 1,2,3, a=11, b=22, c=44)

You could achieve something similar with a standard logger by passing your
extra information through the extra parameter, e. g:

def extra(*args, **kw):
return dict(argskw=(args, kw))
foo.info("another...", extra=extra(1, 2, 3, a=11, b=22))

Peter

==============================================================================
TOPIC: "Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT" "ADVERTISED
JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
http://groups.google.com/group/comp.lang.python/t/871beb7290b8acf1?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 12:56 am
From: Naeem


"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
"Jobs in Kuwait" "Kuwait jobs" "accounts jobs in kuwait" "MEDICAL JOBS
IN KUWAIT" "FINANCE JOBS IN KUWAIT" "ENGINEERING JOBS IN KUWAIT"
"ADVERTISED JOBS ION KUWAIT" ON http://jobsinkuwait-net.blogspot.com/
VV

==============================================================================
TOPIC: (a==b) ? 'Yes' : 'No'
http://groups.google.com/group/comp.lang.python/t/b985d5727945d2b4?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 12:57 am
From: Peter Otten <__peter__@web.de>


Pierre Quentel wrote:

> I'm surprised nobody proposed a solution with itertools ;-)

next(itertools.takewhile(lambda _: a == b, ["yes"]), "no")

You spoke to soon :)

Peter

==============================================================================
TOPIC: No editbox () functionality in python-dialog module?
http://groups.google.com/group/comp.lang.python/t/5448287bea345935?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 1:16 am
From: Harishankar


Strange issue, I find that the dialog utility has an editbox function but
the python-dialog module doesn't provide this and there's no mention of
the reason for the omission of this important functionality.

Is there no easy and simple way to create a multi-line input dialog in
ANY of the text mode console libraries? :-(

--
Harishankar (http://harishankar.org http://literaryforums.org)

==============================================================================
TOPIC: Sublassing tuple works, subclassing list does not
http://groups.google.com/group/comp.lang.python/t/ed8630710a349620?hl=en
==============================================================================

== 1 of 7 ==
Date: Wed, Mar 31 2010 1:18 am
From: lbolla


On Mar 31, 7:49 am, "Frank Millman" <fr...@chagford.com> wrote:
> Hi all
>
> I needed something similar to, but not quite the same as,
> collections.namedtuple.
>
> The differences are that namedtuple requires the 'names' to be provided at
> creation time, and then lends itself to creating multiple instances of
> itself. I wanted a more generic class where I could supply the 'names' and
> 'values' at instantiation time.
>
> I came up with a simple solution that seems to work -
>
> >>> class MyTuple(tuple):
>
> ...   def __new__(cls, names, values):
> ...     for name, value in zip(names, values):
> ...       setattr(cls, name, value)
> ...     return tuple.__new__(cls, values)
> ...
>
> >>> names = ['A', 'B', 'C']
> >>> values = ['a', 'b', 'c']
>
> >>> tup = MyTuple(names, values)
>
> >>> print tup
> ('a', 'b', 'c')
>
> >>> print tup[0]
> a
>
> >>> print tup.B
> b
>
> Then I had a need to add elements after the tuple had been created. As
> tuples are immutable, I thought it would be easy to change it to a list.
> However, it does not work -
>
> >>> class MyList(list):
>
> ...   def __new__(cls, names, values):
> ...     for name, value in zip(names, values):
> ...       setattr(cls, name, value)
> ...     return list.__new__(cls, values)
> ...>>> names = ['A', 'B', 'C']
> >>> values = ['a', 'b', 'c']
>
> >>> lst = MyList(names, values)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: list() takes at most 1 argument (2 given)
>
>
>
> I can find a workaround, but I would be interested to know the reason why it
> does not work.
>
> Version is 2.6.2.
>
> Thanks
>
> Frank Millman

When subclassing immutable types, you need to override __new__;
otherwise you need to override __init__.
Here is an in-depth explanation: http://www.python.org/download/releases/2.2/descrintro/#metaclasses

Here is some code:

class MyTuple(tuple):
def __new__(cls, names, values):
for name, value in zip(names, values):
setattr(cls, name, value)
return tuple.__new__(cls, values)

class MyList(list):
def __init__(self, names, values):
list.__init__(self, values)
for name, value in zip(names, values):
setattr(self, name, value)

names = ['A', 'B', 'C']
values = ['a', 'b', 'c']

tup = MyTuple(names, values)
print tup
print tup[0]
print tup.B

lst = MyList(names, values)
print lst
print lst[0]
print lst.B


L.


== 2 of 7 ==
Date: Wed, Mar 31 2010 1:29 am
From: "Frank Millman"

"lbolla" <lbolla@gmail.com> wrote in message
news:f8011c0b-0b1b-4a4f-94ff-304c16ef9a5b@q16g2000yqq.googlegroups.com...
On Mar 31, 7:49 am, "Frank Millman" <fr...@chagford.com> wrote:
>> Hi all
>>

> When subclassing immutable types, you need to override __new__;
> otherwise you need to override __init__.

Perfect. Thanks very much.

Frank


== 3 of 7 ==
Date: Wed, Mar 31 2010 1:58 am
From: Bruno Desthuilliers


lbolla a �crit :
>
> class MyList(list):
> def __init__(self, names, values):
> list.__init__(self, values)
> for name, value in zip(names, values):
> setattr(self, name, value)
>
> names = ['A', 'B', 'C']
> values = ['a', 'b', 'c']
>
> lst = MyList(names, values)
> print lst
> print lst[0]
> print lst.B
>

>>> lst[0] = "foobar"
>>> lst.A
'a'>>> lst.B = 42
>>> lst[1]
'b'
>>> lst.D="duh"
>>> lst[3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range

== 4 of 7 ==
Date: Wed, Mar 31 2010 2:02 am
From: Rob Williscroft


Frank Millman wrote in news:mailman.1360.1270018159.23598.python-
list@python.org in comp.lang.python:

> I came up with a simple solution that seems to work -
>
>>>> class MyTuple(tuple):
> ... def __new__(cls, names, values):
> ... for name, value in zip(names, values):
> ... setattr(cls, name, value)
> ... return tuple.__new__(cls, values)
> ...
>>>> names = ['A', 'B', 'C']
>>>> values = ['a', 'b', 'c']
>>>>
>>>> tup = MyTuple(names, values)
>>>>

Are you aware you are adding attributes to the class here, IOW:

MyTuple.C == 'c'

If you want to add attibutes to the instance:

class MyTuple(tuple):
def __new__(cls, names, values):
r = tuple.__new__(cls, values)
for name, value in zip(names, values):
setattr(r, name, value)
return r

names = ['A', 'B', 'C']
values = ['a', 'b', 'c']

tup = MyTuple(names, values)

assert tup[0] == 'a'
assert tup.B == 'b'

try:
MyTuple.C
except AttributeError:
pass
else:
assert False

== 5 of 7 ==
Date: Wed, Mar 31 2010 2:38 am
From: Carl Banks


On Mar 31, 2:02 am, Rob Williscroft <r...@rtw.me.uk> wrote:
> Frank Millman wrote in news:mailman.1360.1270018159.23598.python-
> l...@python.org in comp.lang.python:
>
> > I came up with a simple solution that seems to work -
>
> >>>> class MyTuple(tuple):
> > ...   def __new__(cls, names, values):
> > ...     for name, value in zip(names, values):
> > ...       setattr(cls, name, value)
> > ...     return tuple.__new__(cls, values)
> > ...
> >>>> names = ['A', 'B', 'C']
> >>>> values = ['a', 'b', 'c']
>
> >>>> tup = MyTuple(names, values)
>
> Are you aware you are adding attributes to the class here, IOW:
>
>         MyTuple.C == 'c'

> If you want to add attibutes to the instance:
>
> class MyTuple(tuple):
>   def __new__(cls, names, values):
>     r =  tuple.__new__(cls, values)
>     for name, value in zip(names, values):
>       setattr(r, name, value)
>     return r
>
> names = ['A', 'B', 'C']
> values = ['a', 'b', 'c']
>
> tup = MyTuple(names, values)
>
> assert tup[0] == 'a'
> assert tup.B == 'b'
>
> try:
>   MyTuple.C
> except AttributeError:
>   pass
> else:
>   assert False

Careful, this adds the new attributes as to the object's __dict__, not
to the tuple item slots. Which works ok if you don't care if that
someone can mutate the attributes, and if they do the attributes no
longer match the items. Personally I do mind.

tup = MyTuple(names,values)
assert tup.A == 'a'
assert tup[0] == 'a'
tup.A = 'd' # doesn't fail but should
assert tup.A == 'd'
assert tup[0] == 'd' # fails but, granted you allow mutabilty,
shouldn't

The best way to do what the OP wanted (originally) is this, no
subclassing necessary:

def my_named_tuple(names,values):
return namedtuple('ad_hoc_named_tuple',names)(*values)


As for the OP's second problem, to append named items, I'd first
consider whether I'm thinking about the problem correctly, and if so,
go with a subclass of list and overriding __getattr__. Probably one
of the rare cases I would override __getattr__ other than a proxy
class.


Carl Banks


== 6 of 7 ==
Date: Wed, Mar 31 2010 4:07 am
From: Hrvoje Niksic


"Frank Millman" <frank@chagford.com> writes:

>>>> class MyList(list):
> ... def __new__(cls, names, values):
> ... for name, value in zip(names, values):
> ... setattr(cls, name, value)
> ... return list.__new__(cls, values)

Did you really mean to setattr the class here? If I'm guessing
your intentions correctly, it should be:

def __new__(cls, names, values):
self = list.__new__(cls, values)
for name, value in zip(names, values):
setattr(self, name, value)
return self

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: list() takes at most 1 argument (2 given)
>>>>
>
> I can find a workaround, but I would be interested to know the reason
> why it does not work.

Because you didn't define __init__, so MyList inherited the one from
list, and it has a different signature to what you're calling it with.
Simply add an __init__ with the proper signature, and the proper upcall
to list.__init__:

def __init__(self, names, values):
list.__init__(self, values)

But if you're doing that, you don't need __new__ at all. Simply
override __init__ and place your setattr loop there:

>>> class MyList(list):
... def __init__(self, names, values):
... for name, value in zip(names, values):
... setattr(self, name, value)
... list.__init__(self, values)
...
>>> MyList(['a'], [1])
[1]
>>> _.a
1


== 7 of 7 ==
Date: Wed, Mar 31 2010 4:51 am
From: "Frank Millman"


On Mar 31, 8:49 am, "Frank Millman" <fr...@chagford.com> wrote:
> Hi all

Thanks to all for the helpful replies.

Rob, you are correct, I had not realised I was adding attributes to the
class instead of the instance. Your alternative does work correctly. Thanks.

Carl, I understand your concern about modifying attributes. In my particular
case, this is not a problem, as the class is under my control, and an
instance will not be modified once it is set up, but I agree one must be
careful not to mis-use it.

My use-case is that I want to create a number of objects, I want to store
them in a tuple/list so that I can retrieve them sequentially, and I also
want to retrieve them individually by name. Normally I would create a tuple
and a dictionary to serve the two purposes, but I thought this might be a
convenient way to get both behaviours from the same structure.

Regarding adding elements after instantiation, I would subclass 'list', as
suggested by others, and then add an 'add' method, like this -

def add(self, name, value):
setattr(self, name, value)
self.append(value)

I tested this and it behaves as I want.

Having said all of this, I have realised that what I probably want is an
ordered dict. I will play with the one in PyPi, hopefully it will render
this entire discussion redundant. It was interesting, though, and I have
learned a lot.

Thanks again

Frank

==============================================================================
TOPIC: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp
with time zone:
http://groups.google.com/group/comp.lang.python/t/7463ded0971425f8?hl=en
==============================================================================

== 1 of 3 ==
Date: Wed, Mar 31 2010 1:29 am
From: Michael Ricordeau


Hi

You cannot add 'NOW() - '29 days'::INTERVAL' as a query because cursor.execute() will try to mogrify it.

You can do :
import datetime
idays = psycopg2.extensions.adapt(datetime.timedelta(days=29))
self.dyndb.orderdb.query('update xxxx set creation_date=(NOW() - %s) where id_order=%s', idays, "123"))

Or:
import datetime
interval = datetime.datetime.now() - datetime.timedelta(days=29)
self.dyndb.orderdb.query('update xxxx set creation_date=%s where id_order=%s', (interval, "123"))
# But in this case current date/time is not evaluated from postgresql server but only from python env ... this may cause some bugs

You may also try to add an interval type with psycopg2.extensions.INTERVAL (I never played with it)

Le Tue, 30 Mar 2010 17:26:51 -0400,
Philip Semanchuk <philip@semanchuk.com> a écrit :

>
> On Mar 30, 2010, at 4:47 PM, ASh wrote:
>
> > Hi, please help me understand why am I getting error with this query
> >
> >
> > new_start_date = "NOW() - '29 days'::INTERVAL"
> > self.dyndb.orderdb.query('''update xxxx set creation_date
> > = %s
> > where id_order = %s''', (new_start_date, "123"))
> >
> >
> >
> > ...
> > psycopg2.DataError: invalid input syntax for type timestamp with time
> > zone: "NOW() - '29 days'::INTERVAL"
>
> Hi Anton,
> It sounds to me like the problem is with your SQL rather than with
> psycopg2 or Python. Try the query directly in Postgres -- does it work
> there? If so, then your next step should be to ask on the psycopg2
> mailing list that Google can find for you.
>
> Good luck
> Philip
>


== 2 of 3 ==
Date: Wed, Mar 31 2010 1:42 am
From: Anton Shishkov


On Mar 31, 3:10 am, "D'Arcy J.M. Cain" <da...@druid.net> wrote:
> On Tue, 30 Mar 2010 15:46:12 -0700 (PDT)
>
> ASh <anton.shish...@gmail.com> wrote:
> > > >             new_start_date = "NOW() - '29 days'::INTERVAL"
> > > >             self.dyndb.orderdb.query('''update xxxx set creation_date
> > > > = %s
> > > >             where id_order = %s''', (new_start_date, "123"))
>
> > > Put single quotes around the first %s in the query.
>
> > Tried like you said, got this error:
>
> > psycopg2.ProgrammingError: syntax error at or near "NOW"
> > LINE 1: update orderdb.orders set creation_date = 'E'NOW() - ''29
> > da...
>
> Right.  I misread it.  Please show us the exact error that you get with
> the original code.
>
> --
> D'Arcy J.M. Cain <da...@druid.net>         |  Democracy is three wolveshttp://www.druid.net/darcy/               |  and a sheep voting on
> +1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.

Error:
cursor.execute(sql, params)
File "/opt/local/lib/python2.5/site-packages/psycopg2/extras.py",
line 118, in execute
return _cursor.execute(self, query, vars, async)
psycopg2.ProgrammingError: syntax error at or near "NOW"
LINE 1: update orderdb.orders set creation_date = 'E'NOW() - ''29
da...
^


== 3 of 3 ==
Date: Wed, Mar 31 2010 3:50 am
From: Anton Shishkov


On Mar 31, 11:29 am, Michael Ricordeau <michael.ricord...@gmail.com>
wrote:
> Hi
>
> You cannot add 'NOW() - '29 days'::INTERVAL' as a query because cursor.execute() will try to mogrify it.
>
> You can do :
>   import datetime
>   idays = psycopg2.extensions.adapt(datetime.timedelta(days=29))
>   self.dyndb.orderdb.query('update xxxx set creation_date=(NOW() - %s) where id_order=%s', idays, "123"))
>
> Or:
>   import datetime
>   interval = datetime.datetime.now() - datetime.timedelta(days=29)
>   self.dyndb.orderdb.query('update xxxx set creation_date=%s where id_order=%s', (interval, "123"))
>   # But in this case current date/time is not evaluated from postgresql server but only from python env ... this may cause some bugs    
>
> You may also try to add an interval type with psycopg2.extensions.INTERVAL (I never played with it)
>
> Le Tue, 30 Mar 2010 17:26:51 -0400,
> Philip Semanchuk <phi...@semanchuk.com> a écrit :
>
>
>
>
>
> > On Mar 30, 2010, at 4:47 PM, ASh wrote:
>
> > > Hi, please help me understand why am I getting error with this query
>
> > >            new_start_date = "NOW() - '29 days'::INTERVAL"
> > >            self.dyndb.orderdb.query('''update xxxx set creation_date
> > > = %s
> > >            where id_order = %s''', (new_start_date, "123"))
>
> > > ...
> > > psycopg2.DataError: invalid input syntax for type timestamp with time
> > > zone: "NOW() - '29 days'::INTERVAL"
>
> > Hi Anton,
> > It sounds to me like the problem is with your SQL rather than with  
> > psycopg2 or Python. Try the query directly in Postgres -- does it work  
> > there? If so, then your next step should be to ask on the psycopg2  
> > mailing list that Google can find for you.
>
> > Good luck
> > Philip

thank you for good examples (bow)

==============================================================================
TOPIC: libpst - python bindings
http://groups.google.com/group/comp.lang.python/t/e119b6f92648e821?hl=en
==============================================================================

== 1 of 2 ==
Date: Wed, Mar 31 2010 1:36 am
From: Richard Lamboj

Hello,

are there any python bindings for libpst?

http://www.five-ten-sg.com/libpst/
https://alioth.debian.org/projects/libpst/

Kind Regards

Richi


== 2 of 2 ==
Date: Wed, Mar 31 2010 6:02 am
From: Jean-Michel Pichavant


Richard Lamboj wrote:
> Hello,
>
> are there any python bindings for libpst?
>
> http://www.five-ten-sg.com/libpst/
> https://alioth.debian.org/projects/libpst/
>
> Kind Regards
>
> Richi
>
http://www.lmgtfy.com/?q=libpst+python

3rd hit

Cheers,

JM

==============================================================================
TOPIC: PyDispatcher on sourceforge doesn't play nice with easy_install
http://groups.google.com/group/comp.lang.python/t/122bcc79cac930fe?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 3:39 am
From: Chris Withers


Mike C. Fletcher wrote:
> Chris Withers wrote:
>> Hi All,
>>
>> Using easy_install to get PyDispatcher results in:
>>
> ...
>> Who's the maintainer of PyDispatcher nowadays? Would be handy if they
>> removed the sourceforge link from pypi.
> ...
>
> Thanks for the report. I've released a 2.0.2 version on PyPI. That
> should now work properly with easy_install.

Great! Thanks Mike!

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

==============================================================================
TOPIC: Generating text from a regular expression
http://groups.google.com/group/comp.lang.python/t/c16f904e698a42b3?hl=en
==============================================================================

== 1 of 3 ==
Date: Wed, Mar 31 2010 3:49 am
From: Nathan Harmston


Hi everyone,

I have a slightly complicated/medium sized regular expression and I
want to generate all possible words that it can match (to compare
performance of regex against an acora based matcher). Using the
regular expression as a grammar to generate all words in its language.
I was wondering if this possible in Python or possible using anything.
Google doesnt seem to give any obvious answers.

Many thanks in advance,

Nathan


== 2 of 3 ==
Date: Wed, Mar 31 2010 4:58 am
From: "Gabriel Genellina"


En Wed, 31 Mar 2010 07:49:14 -0300, Nathan Harmston
<iwanttobeabadger@googlemail.com> escribió:

> I have a slightly complicated/medium sized regular expression and I
> want to generate all possible words that it can match (to compare
> performance of regex against an acora based matcher). Using the
> regular expression as a grammar to generate all words in its language.
> I was wondering if this possible in Python or possible using anything.
> Google doesnt seem to give any obvious answers.

I've done this some time ago.
This recipe
http://code.activestate.com/recipes/577041-merge-multiple-potentially-infinite-sorted-inputs-/
provides an infinite merge operation, required for effectively enumerating
a regular language (with shorter strings first, else 'a*b' would get stuck
repeating "a"s and never yielding any "b").
The example at the end shows the basics of how to use it (by hand) in a
very simple case.
To enumerate all strings matching '(a|bc)*' one should invoke
closure(product(['a'],['b','c'])), which gives:

'', 'a', 'aa', 'bc',
'aaa', 'abc', 'bca',
'aaaa', 'aabc', 'abca', 'bcaa', 'bcbc',
'aaaaa', 'aaabc', 'aabca', 'abcaa', 'abcbc', 'bcaaa', 'bcabc', 'bcbca',
...

Converting the former expression into the later function calls requires a
parser (not shown -- and I won't be able to find it until Friday)

--
Gabriel Genellina

== 3 of 3 ==
Date: Wed, Mar 31 2010 5:01 am
From: Tim Chase


Nathan Harmston wrote:
> I have a slightly complicated/medium sized regular expression
> and I want to generate all possible words that it can match
> (to compare performance of regex against an acora based
> matcher). Using the regular expression as a grammar to
> generate all words in its language. I was wondering if this
> possible in Python or possible using anything. Google doesnt
> seem to give any obvious answers.

Unless you limit your regexp to bounded regular expressions (you
don't use the "*", "+" and unbounded-top-end "{...}" tokens), it
has an infinite number of possible words that can match. As a
simple example, the regexp "a*" matches "" (the empty string),
"a", "aa", "aaa", "aaaa"...and so on up to the limit of a string
length.

There was a discussion on this a while back:

http://mail.python.org/pipermail/python-list/2010-February/1235120.html

so you might chat with the person who started that thread. You
basically have to write a regexp parser that generates code to
generate the expressions, and even simple expressions such as
"[a-z]{1,30}" can create an astronomical number of possible inputs.

-tkc


==============================================================================
TOPIC: os.walk restart
http://groups.google.com/group/comp.lang.python/t/cb80b10e27af49d4?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 5:50 am
From: Piet van Oostrum


You have no guarantee that on the next run the directories will be
visited in the same order as in the first run (this could depend on the
filesystem). So then remembering a last directory won't do it. You could
write each completed directory name to a file, and then on the second
run check whether a directory is in that list and skip the program run
for these.

Something like this (symbolically):

lastrun = map(string.strip, logfile.readlines())
newlog = ... open logfile in append mode ...

for root, dirs, files in os.walk(basedir):
if root not in lastrun:
run program
newlog.write(root)
newlog.flush()

--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
Nu Fair Trade woonwaar op http://www.zylja.com

==============================================================================
TOPIC: wrapping data from groups
http://groups.google.com/group/comp.lang.python/t/0410a687755fdf99?hl=en
==============================================================================

== 1 of 1 ==
Date: Wed, Mar 31 2010 6:01 am
From: azrael


Hi

Could anyone give me a hint about a problem I have. I want to wrap
data from newsgroups like comp.lang.python. Is there anywhere out
some module for this or does google has something for this.


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate