comp.lang.python - 25 new messages in 14 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* libpst - python bindings - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e119b6f92648e821?hl=en
* wrapping data from groups - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/0410a687755fdf99?hl=en
* Generating text from a regular expression - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/c16f904e698a42b3?hl=en
* associative array - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/2cba5368a4df0374?hl=en
* sorting ascending/descending with operator.attrgetter - 4 messages, 4
authors
http://groups.google.com/group/comp.lang.python/t/95c91eb2efe1bcc7?hl=en
* (a==b) ? 'Yes' : 'No' - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/b985d5727945d2b4?hl=en
* Video is very funny..hhhhhhhhhhhh - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/8a3aca32f5591a55?hl=en
* "Usability, the Soul of Python" - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e70d8f60e4ec72cc?hl=en
* ANN: Intro+Intermediate Python course, SF, May 10-12 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/fcdbd2fb036a7717?hl=en
* sort array, apply rearrangement to second - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/e282242a44ded215?hl=en
* Want / Need Genuine Google Adsense Account for Rs.300/- - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/bf235c7802c99e28?hl=en
* Python + OpenOffice Calc - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/22165c0d3711582a?hl=en
* Question about list comprehension/standard "for" disparities - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/db3158b760f2803a?hl=en
* decorators only when __debug__ == True - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5da23b4a51e9a19e?hl=en
==============================================================================
TOPIC: libpst - python bindings
http://groups.google.com/group/comp.lang.python/t/e119b6f92648e821?hl=en
==============================================================================
== 1 of 1 ==
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: wrapping data from groups
http://groups.google.com/group/comp.lang.python/t/0410a687755fdf99?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Mar 31 2010 6:28 am
From: Steve Holden
azrael wrote:
> 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.
nntplib would be the normal starting point. I've used it, and it works
reasonably well.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 2 of 2 ==
Date: Wed, Mar 31 2010 9:58 am
From: azrael
I tried to use some servers I know but they have a limited amount of
stored threads. not like google that has every thread ever opened. so
I tried to wrap google's html but I get a 403 error. any sugesstions?
On Mar 31, 3:28 pm, Steve Holden <st...@holdenweb.com> wrote:
> azrael wrote:
> > 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.
>
> nntplib would be the normal starting point. I've used it, and it works
> reasonably well.
>
> regards
> Steve
> --
> Steve Holden +1 571 484 6266 +1 800 494 3119
> See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
> Holden Web LLC http://www.holdenweb.com/
> UPCOMING EVENTS: http://holdenweb.eventbrite.com/
==============================================================================
TOPIC: Generating text from a regular expression
http://groups.google.com/group/comp.lang.python/t/c16f904e698a42b3?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Mar 31 2010 7:13 am
From: Grant Edwards
On 2010-03-31, Nathan Harmston <iwanttobeabadger@googlemail.com> wrote:
> I have a slightly complicated/medium sized regular expression and I
> want to generate all possible words that it can match
>
> I was wondering if this possible in Python or possible using
> anything. Google doesnt seem to give any obvious answers.
We did this one a couple weeks ago.
It's not possible in the general case (there are an infinite number of
matching words for many/most regular expressions).
--
Grant Edwards grant.b.edwards Yow! ... the MYSTERIANS are
at in here with my CORDUROY
gmail.com SOAP DISH!!
== 2 of 2 ==
Date: Wed, Mar 31 2010 8:23 am
From: Paul McGuire
On Mar 31, 5:49 am, Nathan Harmston <iwanttobeabad...@googlemail.com>
wrote:
> 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).
The pyparsing wiki Examples page includes this regex inverter:
http://pyparsing.wikispaces.com/file/view/invRegex.py
From the module header:
# Supports:
# - {n} and {m,n} repetition, but not unbounded + or * repetition
# - ? optional elements
# - [] character ranges
# - () grouping
# - | alternation
-- Paul
==============================================================================
TOPIC: associative array
http://groups.google.com/group/comp.lang.python/t/2cba5368a4df0374?hl=en
==============================================================================
== 1 of 3 ==
Date: Wed, Mar 31 2010 9:40 am
From: Javier Montoya
Dear all,
I'm a newbie in python and would be acknowledge if somebody could shed
some light on associative arrays.
More precisely, I would like to create a multi-dimensional associative
array. I have for example a list of students which are identified
uniquely by their student IDs. Additionally, for each student I have
some information: FirstName, LastName, etc.
The array would have then the following form:
[StudentID] => [FirstName][LastName][Telephone]...[ ... ]
I would like to be able to access a field directly by using a
StudentID
[StudentID][FirstName]
[StudentID][LastName]
How could I manipulate such an array (create the array, add elements,
access data)?
Best wishes
== 2 of 3 ==
Date: Wed, Mar 31 2010 9:52 am
From: Kushal Kumaran
On Wed, Mar 31, 2010 at 10:10 PM, Javier Montoya <jmontoyaz@gmail.com> wrote:
> Dear all,
>
> I'm a newbie in python and would be acknowledge if somebody could shed
> some light on associative arrays.
> More precisely, I would like to create a multi-dimensional associative
> array. I have for example a list of students which are identified
> uniquely by their student IDs. Additionally, for each student I have
> some information: FirstName, LastName, etc.
>
> The array would have then the following form:
> [StudentID] => [FirstName][LastName][Telephone]...[ ... ]
>
> I would like to be able to access a field directly by using a
> StudentID
> [StudentID][FirstName]
> [StudentID][LastName]
>
> How could I manipulate such an array (create the array, add elements,
> access data)?
>
Did you try the python tutorial? Dictionaries might be what you are
looking for.
http://docs.python.org/tutorial/datastructures.html#dictionaries
--
regards,
kushal
== 3 of 3 ==
Date: Wed, Mar 31 2010 10:36 am
From: Gary Herron
Javier Montoya wrote:
> Dear all,
>
> I'm a newbie in python and would be acknowledge if somebody could shed
> some light on associative arrays.
> More precisely, I would like to create a multi-dimensional associative
> array. I have for example a list of students which are identified
> uniquely by their student IDs. Additionally, for each student I have
> some information: FirstName, LastName, etc.
>
> The array would have then the following form:
> [StudentID] => [FirstName][LastName][Telephone]...[ ... ]
>
> I would like to be able to access a field directly by using a
> StudentID
> [StudentID][FirstName]
> [StudentID][LastName]
>
> How could I manipulate such an array (create the array, add elements,
> access data)?
>
> Best wishes
>
>
>
Create a class for student with attributes for ID, FirstName, LastName, etc.
class Student:
def __init__(self, id, FirstName, ...):
self.id = id
self.FirstName = FirstName
...
then whenever you create a student object, use a dictionary to associate
the object with its is
AA = {} # An empty dictionary
s = Student(...)
AA[s.id] = s
... and repeat for many students...
Then to access a student's object given an id:
s = AA[id]
print s.id, s.FirstName, s.LastName, ...
I'd *not* call this a multi-dimension association, but rather just an
association between student objects and their ids.
Hope that helps,
Gary Herron
--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
==============================================================================
TOPIC: sorting ascending/descending with operator.attrgetter
http://groups.google.com/group/comp.lang.python/t/95c91eb2efe1bcc7?hl=en
==============================================================================
== 1 of 4 ==
Date: Wed, Mar 31 2010 10:08 am
From: Chris Curvey
I must be having a brain cramp. Given a list of objects, how can I
sort the list on one attribute in descending order, then sort within
each group in ascending order on another attribute.
For example:
class Foo:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
I can do "allmyfoos.sort(operator.attrgetter('a','b'))" to sort
ascending on both attributes, but how could i sort by "a, descending,
then b, ascending)?"
== 2 of 4 ==
Date: Wed, Mar 31 2010 10:35 am
From: Tim Golden
On 31/03/2010 18:08, Chris Curvey wrote:
> I must be having a brain cramp. Given a list of objects, how can I
> sort the list on one attribute in descending order, then sort within
> each group in ascending order on another attribute.
>
> For example:
>
> class Foo:
> def __init__(self, a, b, c):
> self.a = a
> self.b = b
> self.c = c
I think this is the kind of thing you're after...
http://ramblings.timgolden.me.uk/2009/10/15/reverse-sorting-on-arbitrary-key-segments/
... at least the link to the Wiki should help:
http://wiki.python.org/moin/HowTo/Sorting
TJG
== 3 of 4 ==
Date: Wed, Mar 31 2010 10:49 am
From: Peter Otten <__peter__@web.de>
Chris Curvey wrote:
> I must be having a brain cramp. Given a list of objects, how can I
> sort the list on one attribute in descending order, then sort within
> each group in ascending order on another attribute.
>
> For example:
>
> class Foo:
> def __init__(self, a, b, c):
> self.a = a
> self.b = b
> self.c = c
>
>
> I can do "allmyfoos.sort(operator.attrgetter('a','b'))" to sort
> ascending on both attributes, but how could i sort by "a, descending,
> then b, ascending)?"
In the general case you have to sort twice:
>>> from collections import namedtuple
>>> Foo = namedtuple("Foo", "a b")
>>> items = [Foo(x, y) for x in range(3) for y in range(3)]
>>> def show(items):
... for item in items: print item
...
>>> show(items)
Foo(a=0, b=0)
Foo(a=0, b=1)
Foo(a=0, b=2)
Foo(a=1, b=0)
Foo(a=1, b=1)
Foo(a=1, b=2)
Foo(a=2, b=0)
Foo(a=2, b=1)
Foo(a=2, b=2)
>>> from operator import attrgetter
>>> items.sort(key=attrgetter("b"))
>>> items.sort(key=attrgetter("a"), reverse=True)
>>> show(items)
Foo(a=2, b=0)
Foo(a=2, b=1)
Foo(a=2, b=2)
Foo(a=1, b=0)
Foo(a=1, b=1)
Foo(a=1, b=2)
Foo(a=0, b=0)
Foo(a=0, b=1)
Foo(a=0, b=2)
This is guaranteed to work because list.sort() is "stable", i. e. it doesn't
alter the order of items with equal keys.
Peter
== 4 of 4 ==
Date: Wed, Mar 31 2010 12:05 pm
From: Patrick Maupin
On Mar 31, 12:08 pm, Chris Curvey <ccur...@gmail.com> wrote:
> I must be having a brain cramp. Given a list of objects, how can I
> sort the list on one attribute in descending order, then sort within
> each group in ascending order on another attribute.
>
> For example:
>
> class Foo:
> def __init__(self, a, b, c):
> self.a = a
> self.b = b
> self.c = c
>
> I can do "allmyfoos.sort(operator.attrgetter('a','b'))" to sort
> ascending on both attributes, but how could i sort by "a, descending,
> then b, ascending)?"
You can provide a cmp function to the string sort method, e.g. cmp =
lambda x,y: -cmp(x.a, y.a) or cmp(x.b, y.b)
You can also possibly gain some efficiency by using key instead of
cmp.
For example, if one of the objects is numeric, you can call sort()
with something like key = lambda x:(-x.a, x.b)
Or if b is numeric but a is a string, you could use lambda x:(x.a, -
x.b) and then use list.reverse() afterward.
HTH,
Pat
==============================================================================
TOPIC: (a==b) ? 'Yes' : 'No'
http://groups.google.com/group/comp.lang.python/t/b985d5727945d2b4?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Mar 31 2010 10:21 am
From: TomF
On 2010-03-31 00:57:51 -0700, Peter Otten <__peter__@web.de> said:
> Pierre Quentel wrote:
>
>> I'm surprised nobody proposed a solution with itertools ;-)
>
> next(itertools.takewhile(lambda _: a == b, ["yes"]), "no")
>
> You spoke to soon :)
I salute you, sir, for upholding the standards of this group.
-Tom
== 2 of 2 ==
Date: Wed, Mar 31 2010 12:11 pm
From: Joaquin Abian
On Mar 31, 1:18 am, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message <7316f3d2-bcc9-4a1a-8598-
>
> cdd5d41fd...@k17g2000yqb.googlegroups.com>, Joaquin Abian wrote:
> > (a==b) and 'YES' or 'NO'
>
> > Yes, ugly
>
> Why would you say that's ugly?
>
> By the way, you don't need the parentheses.
Lawrence,
maybe it was not the perfect adjective. I meant 'not beautiful'
because for me it is not an expression I can easily read. It is not
internalized in my brain. I know how to use it because I learnt how to
do it time ago(in Learning Python) but always I have to think how it
works (like a mental translation). For me the other alternative
expresion is more readable:
take_it if you_have_it else search_for_it
this was already in my brain before I started writing python code.
Thus, I prefer this option for my code. On the other hand, in my post,
I proposed the and/or style because I found interesting how
symmetrical it was with the one the OP was refering:
(a==b) ? 'Yes' : 'No'
(a==b) and 'Yes' or 'No'
I know, I could write it without parenthesis but it seems more
naturally organized with it and I read it faster and clearly. I dont
know exactly why but it seems also safer to me.
Joaquin
==============================================================================
TOPIC: Video is very funny..hhhhhhhhhhhh
http://groups.google.com/group/comp.lang.python/t/8a3aca32f5591a55?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 10:30 am
From: safwan alahmadi
hhhhhhhhhhhh
Video is very funny
http://www.youtube.com/watch?v=-cKvPp71QFY
==============================================================================
TOPIC: "Usability, the Soul of Python"
http://groups.google.com/group/comp.lang.python/t/e70d8f60e4ec72cc?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 11:05 am
From: John Nagle
Alf P. Steinbach wrote:
> * Jean-Michel Pichavant:
>> John Nagle wrote:
>>> Jonathan Hayward wrote:
>>>> I've posted "Usability, the Soul of Python: An Introduction to the
>>>> Python Programming Language Through the Eyes of Usability", at:
>>>>
>>>> http://JonathansCorner.com/python/
>>>
>>> No, it's just a rather verbose introduction to Python, in dark brown
>>> type on a light brown background. One could write a good paper on this
>>> topic, but this isn't it.
>>>
>>>
>>> John Nagle
>> Why is it bad ?
>
> Consider
>
>
> <quote>
> From a usability standpoint, the braces go with the lines to print out
> the stanza rather than the for statement or the code after, so the
> following is best:
The last time I ran a C++ project, I just had everyone run their
code through Artistic Style ("http://astyle.sourceforge.net") with
"--style=ansi". No more inconsistencies.
John Nagle
==============================================================================
TOPIC: ANN: Intro+Intermediate Python course, SF, May 10-12
http://groups.google.com/group/comp.lang.python/t/fcdbd2fb036a7717?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 11:01 am
From: wesley chun
Need to get up-to-speed with Python as quickly as possible? Come join
me, Wesley Chun, author of Prentice-Hall's bestseller "Core Python
Programming," for a comprehensive intro course coming up this May in
beautiful Northern California! Please pass on this note to whomever
you think may be interested. I look forward to meeting you and your
colleagues! feel free to pass around the PDF flyer linked down below.
(Comprehensive) Introduction to Python
Mon-Wed, 2010 May 10-12, 9am-5pm
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(COMPREHENSIVE) INTRO+INTERMEDIATE PYTHON
Although this course may appear to those new to Python, it is also
perfect for those who have tinkered with it and want to "fill in the
gaps" and/or want to get more in-depth formal training. It combines
the best of both an introduction to the language as well as a "Python
Internals" training course.
We will immerse you in the world of Python in only a few days, showing
you more than just its syntax (which you don't really need a book to
learn, right?). Knowing more about how Python works under the covers,
including the relationship between data objects and memory management,
will make you a much more effective Python programmer coming out of
the gate. 3 hands-on labs each day will help hammer the concepts home.
Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware,
NASA, Ubuntu, YouTube, and Red Hat all use Python. Users supporting
or jumping to Plone, Zope, TurboGears, Pylons, Django, Google App
Engine, Jython, IronPython, and Mailman will also benefit!
PREVIEW 1: you will find (and can download) a video clip of a
class session recorded live to get an idea of my lecture style and
the interactive classroom environment at:
PREVIEW 2: Partnering with O'Reilly and Pearson, Safari Books
Online has asked me to deliver a 1-hour webcast last Spring called
"What is Python?". This was an online seminar based on a session
that I've delivered at numerous conferences in the past. It will give
you an idea of lecture style as well as an overview of the material
covered in the course.
info:http://www.safaribooksonline.com/events/WhatIsPython.html
download (reg req'd):
http://www.safaribooksonline.com/Corporate/DownloadAndResources/webcastInfo.php?page=WhatIsPython
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA
WEB: http://cyberwebconsulting.com
FLYER: http://starship.python.net/crew/wesc/flyerPP1may10.pdf
LOCALS: easy freeway (101/280/380) with lots of parking plus public
transit (BART and CalTrain) access via the San Bruno stations, easily
accessible from all parts of the Bay Area
VISITORS: free shuttle to/from the airport, free high-speed internet,
free breakfast and regular evening receptions; fully-equipped suites
See website for costs, venue info, and registration. There is a significant
discounts available for full-time students, secondary teachers, and others.
Hope to see you there!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
==============================================================================
TOPIC: sort array, apply rearrangement to second
http://groups.google.com/group/comp.lang.python/t/e282242a44ded215?hl=en
==============================================================================
== 1 of 4 ==
Date: Wed, Mar 31 2010 11:58 am
From: see@sig.for.address (Victor Eijkhout)
Robert Kern <robert.kern@gmail.com> wrote:
> second[first.argsort()]
Really cool. Thanks.
> Ask numpy questions on the numpy mailing list.
I will. I thought that this question would have an answer in a generic
python idiom.
Victor.
--
Victor Eijkhout -- eijkhout at tacc utexas edu
== 2 of 4 ==
Date: Wed, Mar 31 2010 12:13 pm
From: Robert Kern
On 2010-03-31 13:58 PM, Victor Eijkhout wrote:
> Robert Kern<robert.kern@gmail.com> wrote:
>
>> second[first.argsort()]
>
> Really cool. Thanks.
>
>> Ask numpy questions on the numpy mailing list.
>
> I will. I thought that this question would have an answer in a generic
> python idiom.
When dealing with numpy arrays, the generic Python idiom is often much slower.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
== 3 of 4 ==
Date: Wed, Mar 31 2010 12:22 pm
From: Steve Holden
Victor Eijkhout wrote:
> Robert Kern <robert.kern@gmail.com> wrote:
>
>> second[first.argsort()]
>
> Really cool. Thanks.
>
>> Ask numpy questions on the numpy mailing list.
>
> I will. I thought that this question would have an answer in a generic
> python idiom.
>
> Victor.
Not an unreasonable assumption, but it turns out that for most Python
users (estimate PFTA: 97%) numpy/scipt is esoteric knowledge.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 4 of 4 ==
Date: Wed, Mar 31 2010 1:09 pm
From: Raymond Hettinger
On Mar 30, 4:25 pm, s...@sig.for.address (Victor Eijkhout) wrote:
> I have two arrays, made with numpy. The first one has values that I want
> to use as sorting keys; the second one needs to be sorted by those keys.
> Obviously I could turn them into a dictionary of pairs and sort by the
> first member, but I think that's not very efficient, at least in space,
> and this needs to be done as efficiently as possible.
Alf's recommendation is clean and correct. Just make a list of
tuples.
FWIW, here's a little hack that does the work for you:
>>> values = ['A', 'B', 'C', 'D', 'E']
>>> keys = [50, 20, 40, 10, 30]
>>> keyiter = iter(keys)
>>> sorted(values, key=lambda k: next(keyiter))
['D', 'B', 'E', 'C', 'A']
Raymond
==============================================================================
TOPIC: Want / Need Genuine Google Adsense Account for Rs.300/-
http://groups.google.com/group/comp.lang.python/t/bf235c7802c99e28?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 1:18 pm
From: SWETHA
Genuine Google Adsense Account for Rs.300/-
We will approve your google adsense approval.
We will help you till you get the first adsense check.
Please send your mobile number to pramesh0538@gmail.com , i will call
you with in 15 minutes and give you the google adsense account.
High Price Reduction for multiple adsense accounts.
==============================================================================
TOPIC: Python + OpenOffice Calc
http://groups.google.com/group/comp.lang.python/t/22165c0d3711582a?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 1:21 pm
From: bobicanprogram
On Mar 31, 2:47 am, Tracubik <affdfsdfds...@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?
>
> thanks
> Nico
OOcalc supports a little known feature whereby data can be
automatically sync'd between the spreadsheet and an HTML table. A
few years ago I did up a demo of this in action using Tcl/Tk (http://
www.icanprogram.com/hosug). It should not be too hard to port this
idea to Python.
bob
==============================================================================
TOPIC: Question about list comprehension/standard "for" disparities
http://groups.google.com/group/comp.lang.python/t/db3158b760f2803a?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 1:21 pm
From: Steve Holden
Nathan Rice wrote:
> I was just wondering, why the list/generator and standard "for" have
> disparities?
>
> It would be really nice to be able to do:
>
> for x in y if foo:
> ...
>
> rather than:
>
> for x in (x for x in y if foo):
> ...
>
But it's not much of an issue when you can easily write
for x in y:
if foo:
...
is it? What's the advantage of your preferred format that overrides its
reduced readability?
> Also, from a style standpoint, I prefer to extract the loop logic into a
> function if it's more than a few lines long. As a result, most of my
> loops are of the form:
>
> for x in y:
> bar(x)
>
> So I frequently end up using map. As I understand it, there is some
> discussion of removing map() in favor of comprehensions. Is there any
> reason why the for syntax could not be expanded to accommodate
> statements of the form:
>
> bar(x) for x in y
>
> ?
>
Put parentheses around it and you have a generator expression, which
sounds like it's exactly what you want: a lazy way of producing a
sequence of values:
>>> y = ["this", "that", "and", "the", "other"]
>>> def bar(x):
... return 2*x
...
>>> ge = (bar(x) for x in y)
>>> ge
<generator object at 0x7ff28f2c>
>>> for x in ge:
... print x
...
thisthis
thatthat
andand
thethe
otherother
>>>
If you need to use the sequence repeatedly then a list comprehension is
clearly better, since you don't exhaust it by iterating over it.
I doubt map's going to disappear, but neither are comprehensions or
generator expressions.
> This inconsistency really bothered me when I started playing with
> python, and it seems kind of at-odds with the "one right way to do
> things" mentality.
>
That's the Platonic ideal, but the real world is a dirty place and
Python lives firmly in the real world!
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
==============================================================================
TOPIC: decorators only when __debug__ == True
http://groups.google.com/group/comp.lang.python/t/5da23b4a51e9a19e?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Mar 31 2010 1:59 pm
From: LX
On Mar 30, 2:41 pm, MRAB <pyt...@mrabarnett.plus.com> wrote:
> LX wrote:
> > On Mar 29, 6:34 pm, MRAB <pyt...@mrabarnett.plus.com> wrote:
> >> LX wrote:
> >>> Hi all, I have a question about decorators. I would like to use them
> >>> for argument checking, and pre/post conditions. However, I don't want
> >>> the additional overhead when I run in non-debug mode. I could do
> >>> something like this, using a simple trace example.
> >>> @decorator
> >>> def pass_decorator(f, *args, **kw): # what about the slow-down that
> >>> incurs when using pass_decorator?
> >>> return f(*args, **kw)
> >>> @decorator
> >>> def trace_decorator(f, *args, **kw):
> >>> print "calling %s with args %s, %s" % (f.func_name, args, kw)
> >>> return f(*args, **kw)
> >>> trace_enable_flag = False #__debug__
> >>> trace = trace_decorator if trace_enable_flag else pass_decorator
> >>> Trouble is, there is still an additional encapsulating function call.
> >>> Is there any way to eliminate the extra function call altogether?
> >>> Thanks in advance!
> >> I think you have misunderstood certain details about decorators.
>
> >> This code with adecorator:
>
> >> @decorator
> >> def hello():
> >> print "hello world"
>
> >> basically does this:
>
> >> def hello():
> >> print "hello world"
> >> hello =decorator(hello)
>
> >> so your non-decoratorjust needs to return the function it was passed:
>
> >> def pass_decorator(func):
> >> return func
>
> >> and your tracedecoratorwould be something like this:
>
> >> def trace_decorator(func):
> >> def show(*args, **kwargs):
> >> print "calling %s with args %s, %s" % (func.func_name,
> >> args, kwargs)
> >> result = func(*args, **kwargs)
> >> print "returning %s from %s" % (result, func.func_name)
> >> return result
> >> return show
>
> > Sure, but during runtime, pass_decorator will still be called, even
> > though it doesn't do anything. I am wondering if I can disable this
> > additional function call at non-debug runtime. In other words, I want
> > the calling stack to contain nodecoratorat all, not even
> > pass_decorator.
>
> > I should mention that, in my code, the symbol "decorator" is imported
> > from Michele Simionato'sdecorator.py file.
>
> pass_decorator will be called when the decorated function is _defined_,
> but not when the decorated function is _called_.
Why is it then that during runtime, with a breakpoint in some
arbitrary main() in main.py, I get something similar to the following
call stack:
main.py, line xxx, in <module>
main()
<string>, line 2, in main
decorator.py, line 261, in pass_decorator
return f(*args, **kw)
main.py, line yyy, in main()
* breakpoint line here *
It looks to me the call stack still includes the additional level of
the decorator... what am I missing? Thank you for your time.
==============================================================================
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