Re: how to use "heapq" module as a max-heap?

2009-03-29 Thread Paddy3118
On Mar 29, 8:36 am, "Apollo"  wrote:
> as we all known, in the standard module 'heapq',  we can easily get the 
> smallest item from the heap. i.e. it's an implementation of min-heap.
>
>  my question is how to use 'heapq' to extract the biggest item from the heap? 
>  is it possible?
>
>  thanks  in advance.:)

If heapifying something that will be compared by number, then use the
negative of the number in the object to be heapified. You can then
negate it when popped.

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


Re: Does Python have certificate?

2009-03-24 Thread Paddy3118
On Mar 24, 1:50 am, Johannes Bauer  wrote:
> Sebastian Bassi schrieb:
>
> > No, there is no certification for Python. Maybe in the future...
>
> I'll hand out the "Johannes Bauer Python Certificate of Total
> Awesomeness" for anyone who can write a hello world in python and hands
> me $25000 in cash.
>
> This whole "certified foobar programmer" is complete crap IMHO.
>
> The above offer stands nontheless.
>
> Kind regards,
> Johannes
>
> --
> "Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
> verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
>          -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
>                          <48d8bf1d$0$7510$54022...@news.sunrise.ch>

The Academy of Research into Science Education being a true leader in
the field offers acclaimed accreditation for Python programmers. Those
who pass our strict exams and pay our modest fees will earn our
prestigious certification.

Those who show promise can advance to our Winter Improve Python to
Expert program, for an additional fee, and, be given expert tutoring
to help you gain our exemplary A.R.S.E./W.I.P.E certification which is
guaranteed to attract certain types of employers by its name alone.

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


Re: equivalent of source command in tcl for python

2009-03-18 Thread Paddy3118
On Mar 19, 4:42 am, Ralf Schoenian  wrote:
> mark.coll...@csiro.au wrote:
> > Many times I am developing a code in a file and I want to, for
> > example, exit at a specific line so that I can test something. In tcl
> > you can just put an exit command in and source the file. Is there an
> > equivalent for python? Thanks,
>
> Hi Mark,
>
> there is:
>
> import sys
> sys.exit()
>
> Ralf Schoenian

...Which is what I would use instead of typing 0/0 at a convenient
point, if I could fight my laziness :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: datetime.time and midnight

2009-02-21 Thread Paddy3118
On Feb 21, 10:44 pm, Ethan Furman  wrote:
> Greetings, List!
>
> I was curious if anyone knew the rationale behind making midnight False?
>
> --> import datetime
> --> midnight = datetime.time(0,0,0)
> --> bool(midnight)
> False
>
> To my way of thinking, midnight does actually exist so it should be
> true.  If datetime.time was measuring an *amount* of time, rather than a
> certain point during the day, then a time of 0:0:0 should certainly be
> False as it would mean no time had passed.  However, since midnight does
> indeed exist (as many programmers have observed when deadlines approach
> ;) I would think it should be true.
> --
> ~Ethan~

Ethan,
Knights are true and seek the light. Evil trolls seek the night and so
their hour is false.

;-)

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


Re: VIM: Python type indented-block command equivalent to % for C?

2007-03-08 Thread Paddy3118
On Mar 8, 5:02 am, "Paddy3118" <[EMAIL PROTECTED]> wrote:
>   Not python:
> but python type
> indented text
>
> Notice the blank line above.
> It could have several
> spaces or tabs, and still
> be a part of the block
> beginning 'Not python:':
>   The block ends at the
>   first non-blank line
>   with less indent.
>
> Assuming that only space characters are allowed
> for indenting, is their a way to yank a Python
> block like y% works for C , or a way to move to
> the end of a block defined by indentation?
>
> I have tried help indent but could not find
> anything.
>
> Thanks, Paddy.

I have installed the following plugins for my Python work:
taglist
  http://vim-taglist.sourceforge.net/images/taglist_python.gif
python.vim
  http://vim.sourceforge.net/scripts/script.php?script_id=30
and Bicycle Repair Man
   http://bicyclerepair.sourceforge.net/

- Paddy

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


VIM: Python type indented-block command equivalent to % for C?

2007-03-07 Thread Paddy3118

  Not python:
but python type
indented text

Notice the blank line above.
It could have several
spaces or tabs, and still
be a part of the block
beginning 'Not python:':
  The block ends at the
  first non-blank line
  with less indent.

Assuming that only space characters are allowed
for indenting, is their a way to yank a Python
block like y% works for C , or a way to move to
the end of a block defined by indentation?

I have tried help indent but could not find
anything.

Thanks, Paddy.

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


Anyone persuaded by "merits of Lisp vs Python"?

2006-12-28 Thread Paddy3118
This month there was/is a 1000+ long thread called:
 "merits of Lisp vs Python"
In comp.lang.lisp.

If you followed even parts of the thread, AND previously
used only one of the languages AND (and this is the
crucial bit), were persuaded to have a more positive view
of the other language; (deep breath, this is a long, as
well as grammatically incorrect sentence), THEN WHY NOT
POST ON WHAT ARGUMENTS PERSUADED YOU.

OTHERWISE LET THIS POST WITHER AND DIE ALONE.

(I suspect this thread to be very short - even the
original poster seems to have given up on the day he
started the thread).

- Paddy.

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


Lisp additions to Docstring Wikipedia entry?

2006-11-11 Thread paddy3118
Hello,
I have just expanded the Wikipedia stub article on docstrings at
http://en.wikipedia.org/wiki/Docstring.
Unfortunately I do not know about Lisp, but took the time to google and
found a link to the GNU Emacs Lisp entry: documentation at:
http://ftp.gnu.org/gnu/Manuals/elisp-manual-20-2.5/html_chapter/elisp_24.html#SEC361
.

If someone, more knowledgeable about Lisp, and interested in Wikipedia
could flesh out the Lisp part...

Thanks for your time.

- Paddy.

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


Re: combining several lambda equations

2005-02-18 Thread paddy3118
Fredrik Lundh wrote:
> Paddy McCarthy wrote:
>
> > #If given:two or more lambda equations
> > x=lambda : A < B
> > y=lambda : C+6 >= 7
> >
> > How do I create another lambda expression Z equivalent to
> >
> > Z=lambda : (A=7)
> >
> > # i.e. the anding together of the originals, but without
referencing
> > # globals x and y as they are artificial in that I will start of
with
> > # probably a list of lambda equations.
>
> x=lambda : A < B
> y=lambda : C+6 >= 7
> Z=lambda x=x, y=y: x() and y()
> del x, y
>
> 

Thanks Frederik.

I actually have a set of lambdas so my use will be more like:


>>> s = set([lambda : A < B, lambda : C+6 >= 7])
>>> x=s.pop(); y=s.pop()
>>> Z=lambda x=x, y=y: x() and y()
>>> del x,y
>>> A,B,C = [2,3,1]
>>> Z()
True
>>> A,B,C = [2,3,0]
>>> Z()
False
>>> A,B,C = [3,3,1]
>>> Z()
False
>>> 

- Gosh, isn't life fun!

- Pad.

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