DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Jeff Rush
This Saturday we'll be holding our 4th Saturday meeting of the DFW Pythoneers,
at the usual location of Nerdbooks.com bookstore in Richardson.  For
directions, visit the Nerdbooks.com website.  We start at 2pm and run until
5pm, and then go out for a group dinner.

At this meeting one of our local members, Jeremy Dunck, will be giving us a
preview of a 60-minute advanced Django tutorial he is helping to give at OSCON
next month.  The advanced material will cover the unicode branch, signals and
either stateful views or gis branch.

Since many of our members are not experienced with Django, Jeremy will present
a 45-minute introduction to Django first, which will cover URLConf, views,
models and perhaps middleware.

---

By the way, I've been contacted by a developer at the Travelocity Dallas
office, who is looking for local Python developers with experience in Django
or Genshi.  If you're interested, let me know and I can put you in touch.

---

And just to give a heads-up for July, our own Patrick R. Michaud has agreed to
give our group a presentation on the status of support for Python in the
virtual machine, Parrot, underlying Perl 6 and many other languages.  For more
info, check out:

  http://www.parrotcode.org

Patrick will present to us on the 2nd Saturday of July, the 14th.  Patrick is
the author of PGE, the parrot/Perl6 Grammar engine and is also the Perl 6
compiler pumpking.

See you there!

Jeff Rush
DFW Pythoneers Organizer
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Python-URL! - weekly Python news and links (Jun 19)

2007-06-20 Thread Gabriel Genellina
QOTW:  Regarding a Java programmer moving to Python, a lot of the mindset
change is about the abundant use of built in data types of Python. So a Java
programmer, when confronted with a problem, should think 'how can I solve
this using lists, dicts and tuples?' (and perhaps also my new favourite,
sets).  Class-based solution should be chosen only after seeing that the
problem can't be trivially solved with built-in types. - Ville Vainio 

The remainder of the unittest docs are somewhat obtuse and
uninspiring. - Raymond Hettinger


How to generate HTML page thumbnails: John J Lee enumerates
several alternatives, using MSIE, Firefox, Konqueror and others.

http://groups.google.com/group/comp.lang.python/browse_thread/thread/2185ad4e31c9320b/

Concatenating strings may be painfully slow in some
circumstances if not done the right way:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/3999b83838787fa1/

Initializing class members only when needed, using a
LazyClassAttribute decorator:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/18f8b54cb15f922f/

Postpone attribute creation: similar to thread above,
but more from a design perspective:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/393d2ac620716d90/

Simple Programs: the search for small, complete,
useful examples of Python code still continues:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ec8184ca4ed7e3e6/
See the resulting programs at
http://wiki.python.org/moin/SimplePrograms

A simple question: How many list items comply with
this condition?, and many answers:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/6d488fb624fbb6a7/

Continuing from last week: only one way to do it, now discussing
tail call optimization, generic programming, Scheme and macros...

http://groups.google.com/group/comp.lang.python/browse_thread/thread/e587471d08dbfcbb/



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

The Python Papers aims to publish the efforts of Python enthusiats.
http://pythonpapers.org/

Readers have recommended the Planet sites:
http://planetpython.org
http://planet.python.org

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Python411 indexes podcasts ... to help people learn Python ...
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python 

Re: The Modernization of Emacs

2007-06-20 Thread [EMAIL PROTECTED]
On Jun 19, 9:21 pm, Ed [EMAIL PROTECTED] wrote:

 Have you ever seen an, Extractmethod, function for emacs? Whereby
 you highlight some lines of code, press a key, and the code is whisked
 into its ownmethod, with the appropriatemethodinvocation left in
 its place. If you could post a link, that'd be just champion.

xrefactory does this. I tried it once. It's a bit pricey , though.

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


Re: Q: listsort and dictsort - official equivalents?

2007-06-20 Thread Steven D'Aprano
On Wed, 20 Jun 2007 02:57:30 +0200, BJörn Lindqvist
wrote:

 It's not true that the sort must complete (or that the whole file must
 be read for that matter)

That would be a really good trick. How are you supposed to know which 
item comes first until you've seen them all?


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

Re: Python's only one way to do it philosophy isn't good?

2007-06-20 Thread Michele Simionato

Douglas Alan wrote:
 I think that most people who program in Scheme these days don't do it
 to write practical software.  They either do it to have fun, or for
 academic purposes.  On the other hand, most people who program in
 Python are trying to get real work done.  Which is precisely why I
 program a lot in Python and very little in Scheme these days.  It's
 nice to have the batteries included.

 |oug

A few years ago, tired by the endless threads on comp.lang.python
asking from the inclusion of macros in Python, I decided to
learn Scheme and to understand what the fuss was about.

Learning Scheme coming from Python was not difficult for
what concerned the language features properly, but it was
extremely difficult for what concerned the philosophy behind
the language. I remember that I was expecially angry when I
discovered that the famous Sussman's quotation Programming
languages should be designed not by piling feature on top
of feature, but by removing the weaknesses and restrictions
that make additional features appear necessary was
just a bunch of nice words.

In practice Scheme follows exactly the opposite route: there are
dozens of different and redundant object systems, module systems,
even record systems, built just by piling up feature over feature.
So the minimalism of the core language is just a lie or at best
a red herring (the core language can be minimalistic, but the core
language is basically useless for any real life job).

I was angry for months, until I finally understood that I had to
look at the language in a different way. I thought Scheme was a
language to build applications, but I was wrong:
Scheme is a language intended for language design experimentations.

So if you have an idea for a new and cool object system,
Scheme would be a good tool for prototyping/implementing it without
going at the Assembler or C level. OTOH, if you have an idea
for a new Web framework, Python would be a much better tool
to implement it (but please, don't publish it! ;)


So I basically view Scheme as a tool for
language designers only, or with people with interest in
language design and I don't use it for anything else.

I see Python or C as much better practical implementations
of Sussman's quote about minimalism than real Scheme (for
an example of real Scheme, I refer for instance to the PLT
implementation).


 Michele Simionato

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


Re: Python's only one way to do it philosophy isn't good?

2007-06-20 Thread Paul Rubin
Michele Simionato [EMAIL PROTECTED] writes:
 I see Python or C as much better practical implementations
 of Sussman's quote about minimalism than real Scheme (for
 an example of real Scheme, I refer for instance to the PLT
 implementation).

Python and C as programming languages are like democracy as a system
of government--absolutely terrible, but everything else seems to be
even worse.

The real answer (to programming languages, not governments) seems
tantalizingly close, but not here yet.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTMLParser.HTMLParseError: EOF in middle of construct

2007-06-20 Thread Rob Wolfe

Sérgio Monteiro Basto wrote:
 Stefan Behnel wrote:

  Sérgio Monteiro Basto wrote:
  but is one single error that blocks this.
  Finally I found it , it is :
  td colspan=2align=center
  if I put :
  td colspan=2 align=center
 
  p = re.compile('align')
  content = p.sub(' align', content)
 
  I can parse the html
  I don't know if it a bug of HTMLParser
 
  Sure, and next time your key doesn't open your neighbours house, please
  report to the building company to have them fix the door.
 

 The question, here, is if
 td colspan=2align=center
 is valid HTML or not ?
 I think is valid , if so it's a bug on HTMLParser

According to the HTML 4.01 specification this is *not valid* HTML.


Elements may have associated properties, called attributes, which may
have values
(by default, or set by authors or scripts). Attribute/value pairs
appear before the final
 of an element's start tag. Any number of (legal) attribute value
pairs, separated
by spaces, may appear in an element's start tag.


 if not, we still have a very bad message error (EOF in middle of
 construct !?)

HTMLParser can deal with some errors e.g. lack of ending tags,
but it can't handle many other problems.

 I have to use HTMLParser because I want use only python 2.4 standard , I
 have to install the scripts in many machines.
 And I have to parse many different sites, I just want extract the links, so
 with a clean up before parse solve very quickly my problem.

In Python 2.4 you have to use some third party module. There is no
other option for _invalid_ HTML. IMHO BeautifulSoup is the best among
them.

--
HTH,
Rob

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


Re: caseless dictionary howto ?

2007-06-20 Thread Steven Bethard
Gabriel Genellina wrote:
 En Tue, 19 Jun 2007 19:40:10 -0300, Steven Bethard 
 [EMAIL PROTECTED] escribió:
 
 Stef Mientki wrote:
 Evan Klitzke wrote:
 On 6/19/07, Stef Mientki [EMAIL PROTECTED] wrote:

 I need to search a piece of text and make all words that are equal
 (except their case) also equal in their case, based on the first
 occurrence.
 
 ... def __setitem__(self, key, value):
 ... self._dict[key.lower()] = value
 ... if key not in self._original_keys:
 ... self._original_keys[key.lower()] = key
 ...

 Note that because I store the first form encountered for every key, I
 can always use the lower-case version to retrieve the original string.
 
 As written, it stores the last used spelling; a small change is required 
 to get the intended behavior:
 
 ... def __setitem__(self, key, value):
 ... self._dict[key.lower()] = value
 ... if key.lower() not in self._original_keys:
 ... self._original_keys[key.lower()] = key

Good catch.  Thanks!

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


Re: Windows XMLRPC Service

2007-06-20 Thread half . italian
On Jun 19, 12:32 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Tue, 19 Jun 2007 14:57:10 -0300, [EMAIL PROTECTED] escribió:

   #win32event.WAIT_TIMEOUT = 2 --- This just makes the loop
   never execute because
   # the WaitFor... part always returns 258

  WAIT_TIMEOUT is 258. How do you see it is 2?
  py import win32event
  py win32event.WAIT_TIMEOUT
  258

  I meant here that *if* I set the WAIT_TIMEOUT to 2, then I see that
  behavior.

 Ah, ok! I should have stated clearly that WAIT_TIMEOUT is a Windows  
 predefined constant, not your desired timeout value.

  Thank you again Gabriel.  I'll post back with something complete.

 Yes, please, a working example would be nice for future readers...

 --
 Gabriel Genellina

For posterity...

import sys
import win32serviceutil
import win32service
import win32event
import win32evtlogutil
import servicemanager

import SocketServer, socket
from SimpleXMLRPCServer import
SimpleXMLRPCServer,SimpleXMLRPCRequestHandler

# Threaded mix-in
class
AsyncXMLRPCServer(SocketServer.ThreadingMixIn,SimpleXMLRPCServer):
pass

import XMLRPC_funcs # module containing the functions wrapped in a
class

class XMLRPCservice(win32serviceutil.ServiceFramework):
_svc_name_ = PythonXMLRPC
_svc_display_name_ = PythonXMLRPC
_svc_description_ = Multi-threaded Python XMLRPC Server

def __init__(self, args):
# set the timeout so the service can stop...Otherwise it hangs
forever
socket.setdefaulttimeout(15)

win32evtlogutil.AddSourceToRegistry(self._svc_display_name_,
sys.executable, Application)
win32serviceutil.ServiceFramework.__init__(self, args)

# Create an event which we will use to wait on.
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
localhost = socket.gethostbyname(socket.gethostname())
self.server = AsyncXMLRPCServer((localhost, 8000),
SimpleXMLRPCRequestHandler)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
#send the stop event
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self):
# log a start msg
 
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
  servicemanager.PYS_SERVICE_STARTED,
  (self._svc_name_, ' (%s)' %
self._svc_name_))

self.server.register_instance(XMLRPC_funcs.XMLRPC_funcs())

# handle requests until the stop event is received
while win32event.WaitForSingleObject(self.hWaitStop, 0) ==
win32event.WAIT_TIMEOUT:
self.server.handle_request()

# log a stopped msg
win32evtlogutil.ReportEvent(self._svc_name_,
servicemanager.PYS_SERVICE_STOPPED,
0,
 
servicemanager.EVENTLOG_INFORMATION_TYPE,
(self._svc_name_,))

if __name__ == '__main__':
win32serviceutil.HandleCommandLine(XMLRPCservice)

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

Re: caseless dictionary howto ?

2007-06-20 Thread stef
Gabriel Genellina wrote:
 En Tue, 19 Jun 2007 19:40:10 -0300, Steven Bethard 
 [EMAIL PROTECTED] escribió:

 Stef Mientki wrote:
 Evan Klitzke wrote:
 On 6/19/07, Stef Mientki [EMAIL PROTECTED] wrote:

 I need to search a piece of text and make all words that are equal
 (except their case) also equal in their case, based on the first
 occurrence.

 ... def __setitem__(self, key, value):
 ... self._dict[key.lower()] = value
 ... if key not in self._original_keys:
 ... self._original_keys[key.lower()] = key
 ...

 Note that because I store the first form encountered for every key, I
 can always use the lower-case version to retrieve the original string.

 As written, it stores the last used spelling; a small change is 
 required to get the intended behavior:

 ... def __setitem__(self, key, value):
 ... self._dict[key.lower()] = value
 ... if key.lower() not in self._original_keys:
 ... self._original_keys[key.lower()] = key

 --Gabriel Genellina

thanks guys,
I'll think a while which solution I'll choose.

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Execute script on remote computer

2007-06-20 Thread Laurent Pointal
Evan Klitzke a écrit :
 On 6/19/07, Vikas Saini [EMAIL PROTECTED] wrote:
 I am trying to run the agent on one machine that will execute the 
 script of
 a remote machine.
 
 It's not clear what OS you're using. But if you're running a
 Unix/Linux system and it's a relatively simple script that you want to
 run, you should just use the ssh command coupled with the name of the
 command you want to run (you don't even need the agent to use python,
 necessarily). For example,
 
 ssh [EMAIL PROTECTED] bar
 
 Will ssh to machine 'foo' as user 'user' and execute command 'bar' on
 that machine (rather than launching a shell, which is what ssh will do
 if no command is specified). When the command exits, ssh will exit as
 well.
 
 

Note: You can use an ssh server on Windows too, see CopSSH for a free, 
relatively easy to install solution.

So unix solution for running Python script can be used uder Xindows Xp 
too - at least if you dont want to have a GUI [*].


See
http://www.itefix.no/phpws/index.php?module=pagemasterPAGE_user_op=view_pagePAGE_id=12


[*] You can do remote display of Windows screen via an encrypted VNC 
using ssh port redirection - if you read french (or like screen 
capture), see http://www.limsi.fr/Individu/pointal/winremote/
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: static python classes ?

2007-06-20 Thread Bruno Desthuilliers
Tom Gur a écrit :
 Look for @staticmethod inhttp://docs.python.org/lib/built-in-funcs.html

 Example:
 class C:
 @staticmethod
 def f(arg1, arg2, ...): ...
 
 
 Oops, sorry for the confusion - I've actually meant a static method,
 and Gerald's answer works fine.

FWIW, staticmethods in Python are of very restricted use - we have 
modules and functions for this. And you may be interested in 
classmethods (methods that takes the class object instead of the 
instance as first argument).

As a last word : trying to write Java in Python wis certainly not the 
best option. Better to learn to write Python.

http://dirtsimple.org/2004/12/python-is-not-java.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread peter
Just a tad arrogant, don't you think, to put a notice of some local
event on an international forum without saying where it is?



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


Re: Help With Better Design

2007-06-20 Thread Steve Howell

--- [EMAIL PROTECTED] wrote:
 
 ON  = ON
 OFF = OFF
 
 class LightBulb:
 def __init__(self, initial_state):
 self.state = initial_state
 
 def TurnOn(self):
 if self.state == OFF:
 self.state = ON
 else:
 print The Bulb Is Already ON!
 
 def TurnOff(self):
 if self.state == ON:
 self.state = OFF
 else:
 print The Bulb Is Aleady OFF!
 

I've written code that looks a lot like that, and it's
a perfectly acceptable pattern IMHO.  I don't bother
with the variables ON and OFF, though, as they add no
clarity to simply using 'ON' and 'OFF' for the states.


 [...]
 The test portion of the code is actually longer than
 the class
 itself :-) 

That's usually a good thing!  It means your code is
concise, and your tests are exhaustive.  (But that
doesn't mean you can't also refactor your tests.)



   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=listsid=396545469
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and (n)curses

2007-06-20 Thread peter

  For me, introducing similar commands in Python would be by far  the biggest 
  single improvement that could be made to the language.

 If it should be done, it should be done as a compatible subset of
 curses, IMHO. It has such a long history as the standard GUI toolkit

But curses doesn't run under Windows - thats the whole point!

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


Re: Python IDE

2007-06-20 Thread Evan Klitzke
On 6/19/07, Evan Klitzke [EMAIL PROTECTED] wrote:
 On 6/19/07, Bjoern Schliessmann
 [EMAIL PROTECTED] wrote:
  BartlebyScrivener wrote:
   VIM
 
  *clap-clap*
 
  BTW, are there tutorials on the more arcane vim functions that come
  in handy with Python?

 I don't know of any vim functions that are python specific, but to me
 the two somewhat arcane things that are really important to using vim
 efficiently in programming in general are window splitting and
 folding.  Folding can be immensely useful for moving through files and
 keeping important information visible.  Ctags is also useful -- it
 lets you jump to where the class/function under the cursor is defined.
 Window tabbing is also new as of vim 7, but I prefer window splits.
 You'll probably want to write some vim macros to help you use the
 window splits more efficiently (e.g. to to move up a split and
 maximize it in one key stroke).

 There's a script on vim.org for using the unittest module with the
 :make command, which is also useful if you use that module a lot. And
 of course if you build vim with python support, you can script vim
 using python!

 Another thing I've noticed is that there are a couple of different
 work flows that people have for testing code they're writing in vim.
 The simplest way to run a script is with :!python % (sans quotes),
 which runs the script with the output going to vim which pretends to
 be a terminal.  I think this is sort of suboptimal because vim isn't a
 real terminal so some programs will act strangely this way. The
 workflow I have is a screen session with vim in one (or more)
 windows and another window that is just a shell, which I run my
 scripts in. Another method that I've seen is to just background vim
 with Ctrl-Z, run the program, and then foreground the vim session to
 go back to the code. Either way, I think running your session in
 screen is really, really useful because you can do a search through
 the screen buffer for occurrences of certain words (I tend to do a
 backwards search, with Ctrl-a [ ?search_term), which can help you
 search through the output of your program quickly when things go awry.
 IF you're a fan of screen (or want to use it), I have a pretty nifty
 .screenrc that I use that shows the screen windows on a status line
 at the bottom with some other nifty information (the hostname of the
 machine screen is running on, the load information, and the time) as
 well, plus support for 256 colors, which lets you use those nice 256
 color vim colorschemes. If you're interested you can grab it at
 http://eklitzke.org/files/.screenrc

Oh, one more that I forgot is Bicycle Repair Man. I haven't used it a
lot, but it looks really interesting -- it's a tool designed to
facilitate refactoring Python code. You can use it with vi or emacs.
For those that are interested, you can read more about it at
http://bicyclerepair.sourceforge.net/


-- 
Evan Klitzke [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and (n)curses

2007-06-20 Thread Evan Klitzke
On 6/20/07, peter [EMAIL PROTECTED] wrote:

   For me, introducing similar commands in Python would be by far  the 
   biggest single improvement that could be made to the language.

  If it should be done, it should be done as a compatible subset of
  curses, IMHO. It has such a long history as the standard GUI toolkit

 But curses doesn't run under Windows - thats the whole point!

I know of at least one curses implementation that runs on Windows --
PDCurses. You can find its home page at
http://pdcurses.sourceforge.net/. I have the fortune not to have a
need to do Windows curses programming ;-) so I'm not sure how good the
Python support is, but a quick Google search showed a number of ad hoc
Python wrappers for it.

-- 
Evan Klitzke [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: caseless dictionary howto ?

2007-06-20 Thread Stefan Behnel
Stef Mientki wrote:
 I need to search a piece of text and make all words that are equal
 (except their case) also equal in their case, based on the first
 occurrence.
 So I'm using a dictionary to store names and attributes of objects.
 As as I need to search on the caseless name (so I've choosen lowercase),
 My dictionairy looks like this:
 
 self.procs [ serial_hw_read  ] = ( Serial_HW_Read, F, ++, T)

I have no idea what the F, ++, T means at the end (if it's some kind of
flags or attributes, maybe a class to hold them would look better), but that's
a good solution to the problem IMHO.

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


Re: Using a switch-like if/else construct versus a dictionary?

2007-06-20 Thread Duncan Booth
asincero [EMAIL PROTECTED] wrote:

handle_case = {}
handle_case[1] = doCase1()
handle_case[2] = doCase2()
handle_case[3] = doCase3()
handle_case[4] = doCase4()
handle_case[5] = doCase5()
handle_case[c]()
 
If the switch values are simple integers then a list would be a more 
obvious choice:

  handle_case = [ doCase1, doCase2, doCase3, doCase4, doCase5 ]
  handle_case[c-1]()

 Note that in this situation using OO polymorphism instead of a switch-
 like construct wouldn't be applicable, or at least I can't see how it
 could be.

That is often the case when you reduce your question to a mickeymouse do 
nothing example.

There are many ways to write code that could be written using a switch 
statement. If you took a few real use-cases then you would probably each 
one needs a different technique for best effect depending on the number 
of different cases, the values which must be accessed within each case, 
the side-effects (if any) expected from handling the case etc.

The obvious options include: if/elif chain; a list or dictionary 
containing data values (not functions); a list or dict containing 
functions; command pattern (i.e. a class with a dispatch method); a 
class hierarchy and polymorphism; visitor pattern.

For an example of the last of these see 
http://www.chris-lamb.co.uk/blog/2006/12/08/visitor-pattern-in-python/
which uses decorators to produce a very clean implementation using (I 
think) PyProtocols dispatch.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: static python classes ?

2007-06-20 Thread Diez B. Roggisch
Bjoern Schliessmann wrote:

 Diez B. Roggisch wrote:
 
 With other OOP languages you mean Java. Which does have static
 methods because they lack the notion of a function by its own, so
 the shoehorned them into their everything is inside a
 class-paradigm.
 
 ACK, but doesn't C++ have static methods too?

Might be, I'm a bit rusty on C++. But they do have normal functions as
well - so I figured the OP wouldn't have troubles then.

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


Re: Python IDE

2007-06-20 Thread Roland Puntaier
Hi,

With a python-enabled VIM it's possible to execute and thus test the 
python code. I have the following lines in my vimrc.
F2 prints the result of a line evaluation on the bottom or in a window 
named pyout if there. I open pyout with :vert rightb new pyout mapped to 
F1.
F4 does the same on the selected part of a line
F3 evaluates without printing


py import vim

py  EOL
def PyOutput(): 
  iPy=-1
  for i in range(len(vim.buffers)):
if vim.buffers[i].name and vim.buffers[i].name.find(pyout)!=-1:
  iPy=i
  return iPy
EOL

pyout if present must be right below
r replaces, p prints, symb sets the start
py  EOL 
def PrintCurrentLine(*args): 
  cur_str = vim.current.line 
  action, symb = None, None 
  for i in args: 
if i in [r,p]: action = i 
else:  symb   = i 
  try:start = cur_str.rindex(symb)+len(symb) 
  except: start = 0 
  eval(compile(pyoutres=+cur_str[start:],'string','exec'),globals()) 
  result = eval(pyoutres,globals()) 
  if action == r: 
vim.current.line = cur_str[:start]+str(result) 
  else: 
iPy=PyOutput()
if iPy != -1:
  resS= +cur_str+:+'\n'+str(result)+'\n'
  resL=resS.split('\n')
  vim.buffers[iPy].range(0,0).append(resL)
  vim.command(wincmd b)
  vim.command(normal gg)
  vim.command(wincmd p)
  vim.command(wincmd j)
else:
  print result
EOL 
command -narg=* Pyl python PrintCurrentLine(f-args) 

map F2 :py PrintCurrentLine()CR

this evaluates selected region with F2
map F4 tyo^[tpF2u
map F1 :vert rightb new pyout


python  EOL 
def EvaluateCurrentRange(): 
  c_r=vim.current.range
  i=0
  while c_r[0].startswith(' '*(i+1)):
i+=1
  rngstr='\n'.join([ln[i:] for ln in c_r])
  eval(compile(rngstr,'string','exec'),globals()) 
EOL 
map F3 :py EvaluateCurrentRange()CR




[EMAIL PROTECTED] schrieb 
am 19.06.2007 17:20:08:

 Bjoern Schliessmann wrote:
  BartlebyScrivener wrote:
  VIM
  
  *clap-clap*
  
  BTW, are there tutorials on the more arcane vim functions that come
  in handy with Python?
  
  Regards,
  
  
  Bj?rn
  
 Not a tutorial, but I found this little snippet:
 
 http://www.ibiblio.org/obp/pyBiblio/tips/elkner/vim4python.php
 
 I thought the last line was especially neat.
 
 Will
 -- 
 http://mail.python.org/mailman/listinfo/python-list

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


Re: The Modernization of Emacs

2007-06-20 Thread Giorgos Keramidas
On Tue, 19 Jun 2007 15:53:21 +0200, David Kastrup [EMAIL PROTECTED] wrote:
Harry George [EMAIL PROTECTED] writes:
 I don't mind folks using any editor they want, as long as they are
 proficient.  In those cases, I have no problem doing Extreme
 Programming with them -- code a bit, save, the other guy codes a bit.
 But when someone uses vi and then forgets how to do block moves, or
 uses eclipse and bogs down the session, or uses MS Notepad and can't
 enforce language-specific indents, I get frustrated.

 My favorite killing offence is /* vi:set ts=4: */.

Apparently, we share at least part of that.  My own favorite killing
offense is '/* vi:set ts=anything: */' :)

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-20 Thread Giorgos Keramidas
On Tue, 19 Jun 2007 10:01:35 -0700, Xah Lee [EMAIL PROTECTED] wrote:
 Here are some Frequently Asked Questions about The Modernization of
 Emacs.

 They are slightly lengthy, so i've separated each item per post. The
 whole article can be found at

 http://xahlee.org/emacs/modernization.html
 

 Q: The Terminology “buffer” and “keybinding” is good as they are.

 A: The terminology “buffer” or “keybinding”, are technical terms
 having to do with software programing. The term “keybinding” refers to
 the association of a keystroke with a command in a technical, software
 application programing context. That is to say, a programer “bind” a
 keystroke to a command in a software application. The term “buffer”
 refers to a abstract, temporary area for storing data, in the context
 of programing or computer science.

 These terms are irrelevant to the users of a software application.

 As a user of a text editor, he works with files. The terms “opened
 file” or “untitled file” are more appropriate than “buffer”.

No they are not.  See you may have a real *file* on a disk somewhere,
which is called 'opened file' or even 'untitled file'.  Now isn't it
confusing to think in terms of made-up descriptiors, just because the
term 'buffer' seems alien?

Educating the user to avoid confusion in this and other cases of made
up, 'user-friendly' descriptions is not a good enough answer.  If you
can educate the user about this sort of fine distinction between files
stored on a disk somewhere and files which are figments of the
imagination of Emacs, then I can educate them about 'buffer' too and be
done with it all.

The main difference is that I get to do it today, without the need for
multi-thousand-line changes in the source and documentation of Emacs and
its thousands of plugins.

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

Re: Splitting SAX results

2007-06-20 Thread Stefan Behnel
Gabriel Genellina wrote:
 Forget about SAX. Use ElementTree instead
 ElementTree is infinitely more flexible and easier to use.
 See http://effbot.org/zone/element-index.htm

That's what I told him/her already :)

Rephrasing a famous word:

Being faced with an XML problem, you might think Ok, I'll just use SAX. And
now you have two problems.

SAX is a great way to hide your real problems behind a wall of unreadable
code. If you want my opinion, lxml is currently the straightest way to get XML
work done in Python.

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


Re: Python/C API bug (multithreading)

2007-06-20 Thread Nick Craig-Wood
Krzysztof W³odarczyk [EMAIL PROTECTED] wrote:
  I think I've found a bug in Python/C API and multithreading.

You don't state your python version.

There is an old bug about a similar issue :-

  http://mail.python.org/pipermail/python-dev/2005-May/053840.html
  
http://sourceforge.net/tracker/index.php?func=detailaid=1163563group_id=5470atid=105470

  Is there any simple way to fix this damned bug??

Locking, locking and more locking ;-)

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Invisible processes in Win2K

2007-06-20 Thread henrik.garbergs
Hi!

I'm running a Python program on M$ Windows 2000 as a test monitor. The program 
should close various processes, mostly Application error-windows, as they are 
created. This works fine until the screensaver gets active or until I press 
Ctrl-Alt-Del and choose Lock my computer. At that point, my Python program 
cannot see any change when a Application error pops up. Without locked 
computer, it can identify these windows and close them, but I want it to do 
this with the computer locked as well. (My company has a policy that says you 
have to lock the computer or activate a password protected screensaver when you 
leave your desk)

The code I'm using to list processes looks like this:

# 
def process_callback_function(hwnd, resultdict):
# Callback-function for win32gui.EnumWindows
wtext = win32gui.GetWindowText(hwnd)
if wtext != '' and wtext != 'Default IME':
resultdict.update( {wtext:hwnd} )
# 
def getProcessDictionary(w):
try:
win32gui.EnumWindows(process_callback_function, w)
except Exception, message:
logAndPrint('Error in getProcessDictionary: ' + str(message))
# 
def getProcessList():
# Flush old cache
win32pdh.EnumObjects(None, None, 0, 1)
# Get a list of processes running on the system:
try:
junk, instances = win32pdh.EnumObjectItems(None,None,'Process', 
win32pdh.PERF_DETAIL_WIZARD)
except win32api.error, message:
logAndPrint('Error in getProcessList(): ' + str(message))
return []
else:
return instances
# 

# Code in main loop:
topWindows = {}  
getProcessDictionary(topWindows)
for w in topWindows.iteritems():
...if 'Application Error' in w[0]:
...closeProcess(w[1])


I'm using two functions to receive process info: getProcessList and 
getProcessDictionary. I have tried to save the result of these, compare them at 
different times in the main loop and print newly started processes. This works 
great outside locked computer-mode where it prints all new processes found, 
including Application errors. But when the computer is locked and Application 
errors pops up, the Python program shows no new processes. It's not hanged or 
freezed, since it can identify the screensaver and also keep doing other work. 
So what is so special about the error windows?

Any help with this is greatly appreciated!

Best regards,
/Henrik

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


Re: caseless dictionary howto ?

2007-06-20 Thread stef
Stefan Behnel wrote:
 Stef Mientki wrote:
   
 I need to search a piece of text and make all words that are equal
 (except their case) also equal in their case, based on the first
 occurrence.
 So I'm using a dictionary to store names and attributes of objects.
 As as I need to search on the caseless name (so I've choosen lowercase),
 My dictionairy looks like this:

 self.procs [ serial_hw_read  ] = ( Serial_HW_Read, F, ++, T)
 

 I have no idea what the F, ++, T means at the end (if it's some kind of
 flags or attributes,
This makes part of a simulation of a JAL (a Pascal like language for 
micros),
and this dictionary builds up the namespace,
used in translation JAL to pure Python.

Serial_HW_Read = the name of a function
F = the type of that function (procedure / function / pseudo variable 
/ interrupt /..)
++ = the direction of each parameters, (input / output / input+output )
T = a tupple, containing the type of each of the parameters (bit / byte/ 
sbyte / word / ...)
  maybe a class to hold them would look better),
maybe, but no human is looking at it ;-)
  but that's
 a good solution to the problem IMHO.
   
Seeing the other solution,
I indeed tend to stick to this solution,
because it's the most simple one
(certainly if you realize that the dictionary is generated by the 
program itself)

cheers,
Stef Mientki
 Stefan
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Michael Hoffman
peter wrote:
 Just a tad arrogant, don't you think, to put a notice of some local
 event on an international forum without saying where it is?

It says right in the subject line! DFW. If you don't know what DFW 
means, then it's probably not your local area.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


something similar to shutil.copytree that can overwrite?

2007-06-20 Thread Ben Sizer
I need to copy directories from one place to another, but it needs to
overwrite individual files and directories rather than just exiting if
a destination file already exists. Previous suggestions have focused
on looking at the source for copytree, but it has several places where
exceptions can be raised, and the documentation for the shutil
functions that copytree is implemented in terms of isn't exactly clear
about which exceptions get raised and when. This makes duplicating a
one-line shell operation a non-trivial task.

Has anybody got any pre-written code that does what I'm looking for?

--
Ben Sizer

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


Re: The Modernization of Emacs

2007-06-20 Thread Gabor Urban

Hi guys...

This topic is not relevant in this mailing list.

Though some info from an other mailing list. Emacs (and xemacs) runs
perfectly well on non-gui environments as well. So keyboard commands are the
only efficient way to work with. It is true,  Emacs may be a bit antiquated,
but it honed to an edge GUI tools are very far from. It is like a Formule-1
race car. You do not need automatic gears to drive it faster, do you?

Learning Emacs is not easy but you can start with amazingly little
knowledge. Skills come with usage. I know, I started it 10 years ago, well
in the GUI era.

Yes, vim. Very fine and powerfull tool, as good as Emacs. It is a quiestion
of taste. I use both these times
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: poplib.retr doens't flag message as read

2007-06-20 Thread EuGeNe Van den Bulke
Gabriel Genellina wrote:
 The POP protocol has no concept of read or unread messages; the LIST 
 command simply shows all existing messages. 

My mistake, I guess I was confused by the documentation

retr( which) Retrieve whole message number which, and set its seen flag. 
Result is in form (response, ['line', ...], octets).

What is the seen flag? Nothing it seems 
http://mail.python.org/pipermail/python-list/2005-July/329888.html

Thanks for your help,

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
André [EMAIL PROTECTED] writes:

  Ok, doctest-based version of the Unit test example added; so much
  more Pythonic ;-)

Sorry for being a bit picky but there are a number of things that I'm
unhappy with in that example.

1) It's the second example with 13 lines.  Though I suppose that the
   pragmatism of pairing the examples overriding an implicit goal of
   the page is itself Pythonic.

2) assert is not the simplest example of doctest.  The style should be

 add_money([0.13, 0.02])
0.15
 add_money([100.01, 99.99])
200.0
 add_money([0, -13.00, 13.00])
0.0

3) which fails :-(  So both the unittest and doctest examples ought to
   be redone to emphasize what they are doing without getting bogged
   down by issues of floating point representations.

http://wiki.python.org/moin/SimplePrograms

-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE

2007-06-20 Thread xhm
On Jun 19, 1:39 pm, Tom Gur [EMAIL PROTECTED] wrote:
 Hi,
 which IDE would you recommend for a python ?

pydev (http://pydev.sourceforge.net) for Eclipse is Ok and has
everything you will expect in  a commercial IDE, including code
refactoring, code intelligence, and a Python debugger. Being a Java
SWT application it maybe slow, and make take a long time to start.

Nowadays, when I need a quick and dirty solution, or when I need to
test some code snippets interactively WITH _code completion_ I
typically use PyScripter http://mmm-experts.com/Downloads.aspx?ProductId=4

JEdit (www.jedit.org) is another free and robust alternative with
support for Python, if you install all the necessary plugins. I could
not get the jPyDebug plugin to work, yet it is the only IDE that I
know of which has support and syntax highlighting for PSP (Python
Server Pages).

To sum it up, here are some Python IDEs in my order of preference:

PyScripter http://mmm-experts.com/Downloads.aspx?ProductId=4
JEdit (www.jedit.org) + jPyDebug plugin
pydev (http://pydev.sourceforge.net) requires Eclipse
WingIDE http://www.wingware.com/wingide
ActiveState Komodo IDE (commercial) http://www.activestate.com/Products/Komodo/
ActiveState Komodo Edit (freeware, no debugger)
http://www.activestate.com/Products/komodo_edit/
DrPython http://drpython.sourceforge.net/
PyPE http://pype.sourceforge.net/
BOA Constructor http://boa-constructor.sourceforge.net/


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


Non-blocking keyboard read

2007-06-20 Thread [EMAIL PROTECTED]
I am writing a curses application, but the getch() does not seem to
give me all I want. Of course, if I press d, it returns an ord(d)
and so on. But I want to be able to detect whether alt, shift or ctrl
has been pressed also. Shift is normally covered by returning an
uppercase character instead and ctrl seems to return control codes (as
is normal, I guess), but alt I can't detect with getch, it seems.

Preferably, I would  like one of two things:

1) Having a getch() (or other function) that returns a code like now,
but with different codes depending on the status of the ctrl, alt or
shift keys, for instance by setting higher bits or something. Just as
long as I can differentiate between d, D, ctrl+d, alt+d, shift
+d and maybe ctrl+alt+d and ctrl+shift+d etc.

2) Having a way to read the keyboard status at any given time, for
instance just reading a dictionary (or whatever) of bool for each key.
So that key[KEY_D] == true when d is being pressed, and key[LEFT_ALT]
== true when left alt is being pressed etc.

1) can of course be created from 2) which is lower level, so I would
prefer 1) to save me some work.

Also, are there problems with using a non-curses method of reading
keyboard input, within a curses application?

/David

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


Re: Python's only one way to do it philosophy isn't good?

2007-06-20 Thread Steven D'Aprano
On Tue, 19 Jun 2007 19:22:33 -0700, Paul Rubin wrote:

 Steven D'Aprano [EMAIL PROTECTED] writes:
 So, once you've succeeded in your campaign to make Python more like
 Scheme, what language will you use for getting real work done?
 
 And how long will it take before Schemers start agitating for it to
 become more like Scheme?
 
 While you've dutifully searched the horizon for such intrusion, the rot
 has been quietly happening from within ;-).  Nested scopes, first-class
 functions and closures, internal lambdas, and lazy evaluation streams
 (iterators) are all Schemish incursions into Python.  List
 comprehensions and genexps come from even further in the
 functional-programming beyond.  Soon Python will implement a type
 system based on the Lambda Cube, well maybe not. :)


All of which makes Douglas Alan's accusations of Not Invented Here 
syndrome about Python seem rather silly. If there was ever a language 
that cherry-picked the best features of other languages, it was Python. 
If macros have been left out, it isn't because Guido has an irrational 
attitude of NIH.

The point I was making isn't that Scheme/Lisp features are bad, but 
that there is no reason to slavishly follow Scheme just because it is(?) 
technically the most pure programming language.

Well, obscurity might be a little harsh. Perhaps a lot harsh. I think so 
long as there are programmers who want to play with programming, there 
will be a place for Scheme, and that place will continue to be sneered at 
by the sort of people who just want the job done, never mind whether it 
is the purest, most lambda-calculus-esque way of doing it or not.

I'm glad somebody understands lambda calculus and closures and meta-
classes, and that those people have created Python so I don't have to. 
And I suspect that for every Douglas Alan enamored with Scheme, there are 
ten thousand programmers who just want to use a handful of pre-built 
tools to get the work done, never mind using macros to create the tools 
they need before they can even start.

It sounds all fine and dandy to talk about creating your own control 
structures with macros. Been there, done that: when I was programming in 
Forth, I was so excited about the ability to define my own control 
structures. Great! Why be limited to boring old IF and WHILE and all the 
others, when I can create my own?

But that quickly passed, because, let's be honest, there really aren't 
that many useful control structures. There is a reason that most 
languages offer the same old boring IFs and WHILEs and FORs, instead of 
exciting new ones. 

As a Python programmer, maybe I'd like to see a CASE statement, but I 
don't _really_ need it. That's just an optimization. Same for REPEAT 
UNTIL: it would be a nice to have, not a must have.

Same for macros -- if there is a sufficiently compelling use case for 
macros, one which won't end up with Python code turning into a billion 
different mini-languages, then I have trust that the Python-dev folk will 
eventually add it into the language. But Scheme has macros isn't a 
justification for why Python should have them.



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


Re: something similar to shutil.copytree that can overwrite?

2007-06-20 Thread Justin Ezequiel
On Jun 20, 5:30 pm, Ben Sizer [EMAIL PROTECTED] wrote:
 I need to copy directories from one place to another, but it needs to
 overwrite individual files and directories rather than just exiting if
 a destination file already exists.

What version of Python do you have?
Nothing in the source would make it exit if a target file exists.
(Unless perhaps you have sym-links or the like.)

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]

copytree calls copy2 which calls copyfile

from shutil.py:
#
def _samefile(src, dst):
# Macintosh, Unix.
if hasattr(os.path,'samefile'):
try:
return os.path.samefile(src, dst)
except OSError:
return False

# All other platforms: check for same pathname.
return (os.path.normcase(os.path.abspath(src)) ==
os.path.normcase(os.path.abspath(dst)))

def copyfile(src, dst):
Copy data from src to dst
if _samefile(src, dst):
raise Error, `%s` and `%s` are the same file % (src, dst)

fsrc = None
fdst = None
try:
fsrc = open(src, 'rb')
fdst = open(dst, 'wb')
copyfileobj(fsrc, fdst)
finally:
if fdst:
fdst.close()
if fsrc:
fsrc.close()
#


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


Re: Python/C API bug (multithreading)

2007-06-20 Thread Krzysztof Włodarczyk
Nick Craig-Wood pisze:
 Krzysztof W³odarczyk [EMAIL PROTECTED] wrote:
   
  I think I've found a bug in Python/C API and multithreading.
 

 You don't state your python version.

 There is an old bug about a similar issue :-

   http://mail.python.org/pipermail/python-dev/2005-May/053840.html
   
 http://sourceforge.net/tracker/index.php?func=detailaid=1163563group_id=5470atid=105470

   
 
 This is apparantly fixed in 2.4.2 despite the absence of anentry in 
the NEWS for that release.
 

Python 2.4.1 and 2.4.4 - the same problem exists :(

  Is there any simple way to fix this damned bug??
 

 Locking, locking and more locking ;-)

   
damn true brother, thx

-- 

Krzysztof Włodarczyk
Centrum Technologii Mobilnych Mobiltek S.A.
e-mail: [EMAIL PROTECTED]
mobile: 502-525-035


This email is confidential and is intended for receipt solely by the individual 
or entity to which it is addressed. Any review, use, retention, distribution or 
disclosure by others is strictly prohibited. If you are not the intended 
recipient (or authorized to receive for the recipient), please contact the 
sender by reply email and delete all copies of this message.
Thank you. 

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

Re: Python's only one way to do it philosophy isn't good?

2007-06-20 Thread Steven D'Aprano
On Tue, 19 Jun 2007 20:16:28 -0400, Douglas Alan wrote:

 Steven D'Aprano [EMAIL PROTECTED] writes:
 
 On Tue, 19 Jun 2007 17:46:35 -0400, Douglas Alan wrote:
 
 I think that most people who program in Scheme these days don't do it
 to write practical software.  They either do it to have fun, or for
 academic purposes.  On the other hand, most people who program in
 Python are trying to get real work done.  Which is precisely why I
 program a lot in Python and very little in Scheme these days.  It's
 nice to have the batteries included.
 
 So, once you've succeeded in your campaign to make Python more like
 Scheme, what language will you use for getting real work done?
 
 The problem with using Scheme for real work is that it doesn't come with
 enough batteries included and there isn't a big enough of a community
 behind it that uses it for real work.

And yet there have been so many millions of dollars put into developing 
Lisp... 

I guess this is another example of perfection being the enemy of the 
good. All that development into Lisp/Scheme to make it the best, purest, 
most ideal programming language, with such flexibility and extensibility. 
that nobody wants to use it. You can write any library and macro system 
you need, but nobody has.

I don't mean literally nobody, of course. Its a figure of speech. But it 
seems that people tend to program in Scheme for fun, or to stretch the 
boundaries of what's possible, and not to Get The Job Done.



 And how long will it take before Schemers start agitating for it to
 become more like Scheme?
 
 There is a huge gulf between the claim that Python needs to be more
 Scheme-like, and the fact that by your own admission you use Python,
 not Scheme, for real work. What benefit will be gained? The ability to
 directly explore some pretty mind-bending stuff ... in a hackerly,
 brain-expanding/brain-teaser kind of way?
 
 Well, go to MIT and take SICP and then the graduate-level sequel to the
 class, Adventures in Advanced Symbolic Programming, and then you'll see
 what some of the advantages would be.

Are you suggesting that the only way to see the advantages of Scheme is 
to do a university course?


 A good multimethod system, e.g., would make Python a significantly nicer
 language for my purposes, for instance.

http://en.wikipedia.org/wiki/Multimethod#Python


 For the record, I have a huge problem with NIH-syndrome, and think that
 every programming language in the world could learn a thing or two from
 what other languages have gotten right.


Of course. And Python, more than most, has shamelessly copied features 
from other languages. So the question is, are Scheme macros one of those 
things that other languages have gotten right? Could they be a case of 
over-generalization? Or somewhere in between?



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


Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread peter

 It says right in the subject line! DFW. If you don't know what DFW
 means, then it's probably not your local area.

Precisely


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


Internationalised email subjects

2007-06-20 Thread bugmagnet
I am writing a simple email program in Python that will send out
emails containing Chinese characters in the message subject and body.
I am not having any trouble getting the email body displayed correctly
in Chinese inside the email client, however the email subject and
sender name (which are also in Chinese) are garbled and are not
displayed correctly in the email client.

Here is the code snippet:

writer = MimeWriter.MimeWriter(out)
headers = {From: senderName + ' ' + senderName + '', To:
recipientEmail, Reply-to: senderEmail}

writer.addheader(Subject, subject)
writer.addheader(MIME-Version, 1.0)
writer.addheader('From', headers['From'])
writer.addheader('To', headers['To'])
writer.addheader('Reply-to', headers['Reply-to'])

I'm quite new to Python (and programming in general) and am having a
hard time wrapping my head around the internationalization functions
of Python, so was hoping someone could point me in the right
direction.  Is there a different method I need to use in order for
the  sender name and subject to be displayed correctly?  Is there an
extra step I am missing?  Some sample code would be very helpful.

Thanks!

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


Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Jonathan Fine
Hello

I want to serialise a dictionary, whose keys and values are ordinary strings
(i.e. a sequence of bytes).

I can of course use pickle, but it has two big faults for me.
1.  It should not be used with untrusted data.
2.  I want non-Python programs to be able to read and write these
dictionaries.

I don't want to use XML because:
1.  It is verbose.
2.  It forces other applications to load an XML parser.

I've written, in about 80 lines, Python code that will pack and unpack (to
use the language of the struct module) such a dictionary.  And then I
thought I might be reinventing the wheel.  But so far I've not found
anything much like this out there.  (The closest is work related to 'binary
XML' - http://en.wikipedia.org/wiki/Binary_XML.)

So, what I'm looking for is something like and extension of struct that
allows dictionaries to be stored.  Does anyone know of any related work?

-- 
Jonathan Fine


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


Re: Q: listsort and dictsort - official equivalents?

2007-06-20 Thread BJörn Lindqvist
On 6/20/07, Gabriel Genellina [EMAIL PROTECTED] wrote:
  It's not true that the sort must complete (or that the whole file must
  be read for that matter), Python has cool generators which makes the
  above possible.

 That's not possible, the input must be read completely before sorted() can
 output anything. Suppose the minimum element is at the end - until you
 read it, you can't output the very first sorted element.

Doh! Yes of course. I always thought that sorted() returned a
generator. Since Python's sort is based on merge sort, using a
generator approach it should at least be theoretically possible to
begin emitting the items before the sort operation completes.

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs

2007-06-20 Thread Bjorn Borud
[Xah Lee [EMAIL PROTECTED]]
| 
| 
| SIMPLE CHANGES

if I were to suggest improvements to Emacs, the things you mention are
probably among the last things I'd even consider.  the problem with
Emacs is not really the nomenclature or the keybindings.  the problem
is that it needs to do what it already does better.

My frustration with Emacs has mostly been that Emacs-Lisp is a bit too
limiting.  It is too slow and the codebase is a bit messy.  or at
least it was the last time I tried to do something in Emacs-Lisp a
couple of years ago.  it would also be beneficial if there was a more
proper and well-organized standard library for Emacs to make
developing Emacs applications easier.

for programmers, Emacs is a pretty good editor already, but there is a
bit of a threshold for extending Emacs.

-Bjørn

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


Re: Internationalised email subjects

2007-06-20 Thread Martin Skou
From:
http://docs.python.org/lib/module-email.header.html

  from email.message import Message
  from email.header import Header
  msg = Message()
  h = Header('p\xf6stal', 'iso-8859-1')
  msg['Subject'] = h
  print msg.as_string()
Subject: =?iso-8859-1?q?p=F6stal?=

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


Re: SimplePrograms challenge

2007-06-20 Thread Steve Howell

--- Pete Forman [EMAIL PROTECTED] wrote:

 André [EMAIL PROTECTED] writes:
 
   Ok, doctest-based version of the Unit test
 example added; so much
   more Pythonic ;-)
 
 Sorry for being a bit picky but there are a number
 of things that I'm
 unhappy with in that example.
 

Your pickiness is appreciated. :)

 1) It's the second example with 13 lines.  Though I
 suppose that the
pragmatism of pairing the examples overriding an
 implicit goal of
the page is itself Pythonic.


Since you looked at the page, I have corrected that by
making the example above it 12 lines, so that's no
longer an issue.
 
 2) assert is not the simplest example of doctest. 
 The style should be
 
  add_money([0.13, 0.02])
 0.15
  add_money([100.01, 99.99])
 200.0
  add_money([0, -13.00, 13.00])
 0.0
 

That's not clear cut to me.  I think vertical
conciseness has an advantage for readability, as it
means you get to keep more real code on the screen.

 3) which fails :-(  So both the unittest and doctest
 examples ought to
be redone to emphasize what they are doing
 without getting bogged
down by issues of floating point representations.
 

I was the one who originally posted the floating point
example (with yet another style of unit testing, BTW),
and I agree that the subtleties of floating point do
kind of cloud the issue.  I welcome a better example. 
What I didn't realize is that there's an actual error.
 Are you saying the program fails?  On which test?






  
___
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Q: listsort and dictsort - official equivalents?

2007-06-20 Thread Steve Howell

--- BJörn Lindqvist [EMAIL PROTECTED] wrote:

 On 6/20/07, Gabriel Genellina
 [EMAIL PROTECTED] wrote:
   It's not true that the sort must complete (or
 that the whole file must
   be read for that matter), Python has cool
 generators which makes the
   above possible.
 
  That's not possible, the input must be read
 completely before sorted() can
  output anything. Suppose the minimum element is at
 the end - until you
  read it, you can't output the very first sorted
 element.
 
 Doh! Yes of course. I always thought that sorted()
 returned a
 generator. Since Python's sort is based on merge
 sort, using a
 generator approach it should at least be
 theoretically possible to
 begin emitting the items before the sort operation
 completes.
 

I think Gabriel was making the point that the *input*
to sorted() cannot be a generator, even thought
sorted() itself could in theory be a generator with
the right underlying implementation (e.g. heapsort).  

It's not unrealistic at all to have an indeterminate
sequence of events that you occasionally want to pop
results off of in sorted order, with the obvious
limitation that you haven't yet seen future inputs
from the input iteration.  The way to express that is
by using some kind of heap, though.  I don't really
see how you'd use the heap as a generator in that
case, though.




   

Building a website is a piece of cake. Yahoo! Small Business gives you all the 
tools to get online.
http://smallbusiness.yahoo.com/webhosting 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Jonathan Fine wrote:

 I want to serialise a dictionary, whose keys and values are ordinary strings
 (i.e. a sequence of bytes).

Maybe you can use ConfigObj_ or JSON_ to store that data.  Another format
mentioned in the binary XML article you've linked in your post is
`ASN.1`_. And there's a secure alternative to `pickle` called cerealizer_.

.. _`ASN.1`: http://pyasn1.sourceforge.net/
.. _cerealizer: http://home.gna.org/oomadness/en/cerealizer/
.. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html
.. _JSON: http://www.json.org/

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


Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Sridhar Ratna
On 6/20/07, Jonathan Fine [EMAIL PROTECTED] wrote:
 Hello

 I want to serialise a dictionary, whose keys and values are ordinary strings
 (i.e. a sequence of bytes).

 I can of course use pickle, but it has two big faults for me.
 1.  It should not be used with untrusted data.
 2.  I want non-Python programs to be able to read and write these
 dictionaries.

 I don't want to use XML because:
 1.  It is verbose.
 2.  It forces other applications to load an XML parser.

 I've written, in about 80 lines, Python code that will pack and unpack (to
 use the language of the struct module) such a dictionary.  And then I
 thought I might be reinventing the wheel.  But so far I've not found
 anything much like this out there.  (The closest is work related to 'binary
 XML' - http://en.wikipedia.org/wiki/Binary_XML.)

 So, what I'm looking for is something like and extension of struct that
 allows dictionaries to be stored.  Does anyone know of any related work?


What about JSON? You can serialize your dictionary, for example, in
JSON format and then unserialize it in any language that has a JSON
parser (unless it is Javascript).

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


Re: Help With Better Design

2007-06-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 Greetings,
 
 I have been working on a little project today to help me better
 understand classes in Python (I really like Python). I am a self
 taught programmer and consider myself to fall in the beginner
 category for sure. It was initially sparked by reading about state
 machines. This was my attempt at it however I feel it is not quite
 where it should be:
 

First, a few general comments

 ON  = ON
 OFF = OFF
 
 class LightBulb:

Better to use newstyle classes:
  class LightBulb(object):

 def __init__(self, initial_state):
 self.state = initial_state
 
 def TurnOn(self):

Pep-08 (naming conventions):
   def turn_on(self):

 if self.state == OFF:
 self.state = ON
 else:
 print The Bulb Is Already ON!
 
 def TurnOff(self):
 if self.state == ON:
 self.state = OFF
 else:
 print The Bulb Is Aleady OFF!


What about:

class LightBulb(object):
   def __init__(self, state):
 self.state = state

   def switch(self):
 self.state = not self.state

(snip)

 I would like to be able to get a good hold of the concept

state machines ?

 with this example before I try to model a more complex problem. Would
 someone be willing to give me some feedback on this class and whether
 I am on the right track or how I might better go about it?

There is a lot to say about OO and state machines. Someone once defined 
the use of OO in simulations as building an big unpredictable state 
machine from small predictable state machines. As a matter of fact, 
objects are (most of the time) informal state machines (they have state, 
and they have behaviour depending on state). Now there are much more 
formal state machines (google for FSM or finite state machine) - 
which can be implemented in a lot of ways - including the State design 
pattern.

Before jumping to implementation, you should probably try to model the 
more complex problem with something like UML state diagram (one of the 
few usable things in UML).

My 2 cents
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does altering a private member decouple the property's value?

2007-06-20 Thread Bruno Desthuilliers
Ben Finney a écrit :
 Ethan Kennerly [EMAIL PROTECTED] writes:
 
 I really like properties for readonly attributes,
 
 Python doesn't have readonly attributes,

Err... Ever tried to set a class mro ?-)

 and to attempt to use
 properties for that purpose will only lead to confusion.

read-only attributes actually are one of the common use-case for properties.

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


Re: Using a switch-like if/else construct versus a dictionary?

2007-06-20 Thread asincero
Ahh .. yes of course, you are right.  I mis-typed.  I like how you
defined the dictionary all in one statement, though.  I didn't think
of doing it that way.

-- Arcadio


On Jun 19, 4:11 pm, heltena [EMAIL PROTECTED] wrote:
 asincero ha escrit:



  def foo():
 def doCase1():
pass
 def doCase2():
pass
 def doCase3():
pass
 def doCase4():
pass
 def doCase5():
pass

 handle_case = {}
 handle_case[1] = doCase1()
 handle_case[2] = doCase2()
 handle_case[3] = doCase3()
 handle_case[4] = doCase4()
 handle_case[5] = doCase5()

 Sorry, but I think this is not correct. Now, you put the result of the
 function call into the dictionary, but you want the function address.

 The correct code is:
 handle_case = {}
 handle_case[1] = doCase1
 handle_case[2] = doCase2
 handle_case[3] = doCase3
 handle_case[4] = doCase4
 handle_case[5] = doCase5

 Or:
 handle_case = { 1: doCase1, 2: doCase2, 3: doCase3, 4: doCase4, 5:
 doCase 5 }

 Or:
try:
   { 1: doCase1, 2: doCase2, 3: doCase3, 4: doCase4, 5: doCase 5 }
 [c]()
except:
   print Catch the correct exception

 But this solutions only works fine if the params of the functions are
 the same for all calls (in if/else construct you don't need it).

 Bye!

 --
 Helio Tejedor


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


Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Diez B. Roggisch
 What about JSON? You can serialize your dictionary, for example, in
 JSON format and then unserialize it in any language that has a JSON
 parser (unless it is Javascript).

There is an implementation available for python called simplejson, available
through easy_install.

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


Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Michael Hoffman
peter wrote:
 It says right in the subject line! DFW. If you don't know what DFW
 means, then it's probably not your local area.
 
 Precisely

Precisely what? You complained that the OP didn't provide the location 
of the event, which he did.

You also resorted to needless name-calling as a result of your mistake, 
which I don't think enhances the usefulness of this forum. What exactly 
are you trying to achieve?
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-20 Thread Bjorn Borud
[Xah Lee [EMAIL PROTECTED]]

to be quite honest, your proposal seems to largely be based on
ignorance.

| A: The terminology “buffer” or “keybinding”, are technical terms
| having to do with software programing. The term “keybinding” refers to
| the association of a keystroke with a command in a technical, software
| application programing context. That is to say, a programer “bind” a
| keystroke to a command in a software application. The term “buffer”
| refers to a abstract, temporary area for storing data, in the context
| of programing or computer science.

the term buffer is used extensively outside the computer science
domain, so it is not a CS only term.  in an editor it is actually a
quite sensible name since it abstracts things a bit.  for instance a
buffer need not be associated with a file.  nor does it make any
assumptions about the way it is displayed (as opposed to window or
tab).  

| These terms are irrelevant to the users of a software application.

they are very relevant to me, and I am very much a user of Emacs.  and
again, they provide good abstractions.

| As a user of a text editor, he works with files.

learn Emacs before you criticize it.  your assumption is wrong.  in
emacs you work on _buffers_.  buffers often do not have files
associated with them.

| The terms “opened file” or “untitled file” are more appropriate than
| “buffer”. Since emacs is also used for many things beside reading
| files or writing to files, for example, file management, ftp/sftp,
| shell, email, irc etc., the proper term can be “panel”, “window”, or
| “work area”.

panel and window refer to UI-elements.  the buffer concept does
not map 1:1 to any of these.  substituting work area for buffer
doesn't seem like a better abstraction.  especially not if you see it
in the context of how Emacs relates to buffer contents.

| And, the term “keyboard shortcut” refers to typing of a key-
| combination to activate a command. It is also more appropriate than
| “binding” or “keybinding”.

why?  if anything the term shortcut seems to imply that there is a
primary route to executing the function in question -- which more
often than not isn't the case. keybinding is a more precise term.

| Although concepts like “buffer” and “keybinding” are seemingly
| interchangeable with “panel” or “keyboard shortcut”, but their
| contexts set them apart.

they are interchangeable only if you have no idea what you are talking
about.  you obviously have not bothered to have a proper look at Emacs
and think these things through properly.

| This is why in all modern software application's user
| documentations, terms like “buffer” or “keybinding” are not to be
| seen but “windows, panes, and keyboard shortcuts”.

most modern editors are built on different premises than Emacs and
many have a far simpler view of the world.  extremely few of them even
come close to Emacs in defining what is in practice an operating
environment for applications.  it makes sense to refer to windows
when in fact you are referring to windows.  it doesn't make sense to
call buffers windows in Emacs; because they are not.

| The reason emacs uses the technical terminologies throughout is
| because when emacs started in the 1970s, there really isn't any other
| text editors or even software applications.

the abstractions you mention are sensible ones independently of when
they were concieved.  just because other people came along later and
used different abstractions, doesn't mean that the ones used in Emacs
are wrong, inferior or inappropriate.  if you had bothered to
understand Emacs properly, you would have found that some of the
abstractions used make a lot of sense in an editor.

| Changes in society are always resisted by old timers, but it is also a
| main element behind progress.

I've been in the computer industry long enough to have seen quite a
few cycles of re-invention.  each cycle you learn something about
which inventions were good and which were bad.  a common thread if you
look at the survival rate of products and ideas is that it isn't
always the best product or idea that wins.

often something new comes along to replace something old.  sometimes
it is better than what you had before, but often it is not really
better, just different.  

a good example is the web and the applications we implement in terms
of the web.  take forums for instance.  in a strict technical sense,
web-based forums are inferior to NNTP-based forums. (I am sure you can
make the comparison yourself).  yet NNTP-based discussion is not
growing at the same rate as web forums.  the net has chosen its
preferred technology, and it wasn't because the web-based discussion
forums were so much more technically refined that the majority chose
them. 

for my uses, web forums are a huge step back from NNTP.

| This terminology issue may seem trivial, but its importance lies in
| making emacs palpable to the vast number of people who ever need to
| use a computer to write.

why?  Emacs 

Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Joe Riopel
 Precisely what? You complained that the OP didn't provide the location
 of the event, which he did.

Well, where is DFW?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does altering a private member decouple the property's value?

2007-06-20 Thread Bruno Desthuilliers
Ethan Kennerly a écrit :
 Hello,
 
 There are a lot of Python mailing lists.  I hope this is an appropriate one
 for a question on properties.

It is.

 I am relatively inexperienced user of Python.  I came to it to prototype
 concepts for videogames.   Having programmed in C, scripted in Unix shells,
 and scripted in a number of proprietary game scripting languages, I'm
 impressed at how well Python meets my needs.  In almost all respects, it
 does what I've been wishing a language would do.

So welcome onboard !-)

 One example is properties.  I really like properties for readonly
 attributes, and their ability to make the interface more elegant, by hiding
 uninteresting methods (like dumb get/set accessors).

FWIW, since Python has properties, you often just don't need the 
getter/setter pairs. Start with a plain publi attribute, then switch to 
a computed one (using property or a custom descriptor) if and when needed.

 
 But a gotcha bit me in the behavior of properties that I didn't expect.  
 If another function accesses an underlying data member of a property, then 
 the data member returned by the property is no longer valid.
 
 Here is a session example.
 

 class a_class:

oops ! properties don't work properly with old-style classes. Use a 
new-style class instead:

class AClass(object):

 ...   def __init__( self ):  self.__p = None
 ...   def __set_p( self, new_p ):  self.__p = new_p

Take care, the name mangling invoked by the '__name' scheme may lead to 
undesired results. This feature should only be used when you want to 
make sure an attribute will not be accidentally used in a derived class. 
The idiomatic way to mark an attribute as implementation is a single 
leading underscore, ie: '_name'.

 ...   def reset( self ):  self.__p = None
 ...   p = property( lambda self:  self.__p, __set_p )
 ... 

(snip)

 
 I had wanted to access the private data member in the class to avoid
 side-effects of the set method.
 
 Can someone show me how to reference the data member underlying a property
 and update the property without calling the property set method?

cf above.

While we're at it, everything in Python being an object - yes, functions 
and methods too -, and there's nothing like a private modifier in 
Python. So s/private data member/implementation attribute/ !-)


 By the way, I thought maybe that a variable outside of an __init__ method
 would be static, 

An attribute defined in the class body (ie not in a method) becomes a 
class attribute (shared by all instances).

 but as far as I can tell, it is dynamic.  For example, the
 following class appeared equivalent to the above for tests.   
 
 class a_class:
 ...   __p = None # No __init__

here, you create a class attribute

 ...   def __set_p( self, new_p ):  self.__p = new_p

And here, you create an instance attribute that will shadow the class 
attribute.

 
 I preferred not having the __init__ for this example and my prototype,
 because I wasn't doing anything fancy, and it meant one less method that the
 programmer needed to see.

There are other ways to obtain the same result. Like defining the 
__new__ method (the proper constructor).

(snip the rest)

I think you should take some time to learn the Python object model - 
trying to apply C++/Java concepts to Python won't do it. Articles about 
new-style classes and descriptors on python.org should be a good 
starting point.

My 2 cents...
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Execute script on remote computer

2007-06-20 Thread Vikas Saini
Thanx for your reply,

I have successfully executed the script on a remote machine and store
the log file on the local as well as on the remote machine.

But one problem what I am facing is

How to run 2 or more scripts on remote machine (agent will run on my
local machine) and then saving the SINGLE copy of log files of all the
scripts on my local machine.

 

All machine are operating on window XP

 

ThanksRegards,

Vikas Saini

 

 

   Do or do not. There is no try.   

 



From: rishi pathak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 20, 2007 10:09 AM
To: Vikas Saini
Cc: python-list@python.org
Subject: Re: Execute script on remote computer

 

Does the script resides on the remote machine or do we have to transfer
the script to the remote machine.If remote and agent machine are linux
then you can use rsh/ssh to do so.

On 6/19/07, Vikas Saini [EMAIL PROTECTED] wrote:

I am trying to run the agent on one machine that will execute the script
of a remote machine.

Could you please help me in this regards.

 

vikas

 

Legal Disclaimer: This electronic message and all contents contain
information from Cybage Software Private Limited which may be
privileged, confidential, or otherwise protected from disclosure. The
information is intended to be for the addressee(s) only. If you are not
an addressee, any disclosure, copy, distribution, or use of the contents
of this message is strictly prohibited. If you have received this
electronic message in error please notify the sender by reply e-mail to
and destroy the original message and all copies. Cybage has taken every
reasonable precaution to minimize the risk of malicious content in the
mail, but is not liable for any damage you may sustain as a result of
any malicious content in this e-mail. You should carry out your own
malicious content checks before opening the e-mail or attachment.
www.cybage.com http://www.cybage.com  
--
http://mail.python.org/mailman/listinfo/python-list




-- 
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra 

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

Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread John Machin
On Jun 20, 9:19 pm, Jonathan Fine [EMAIL PROTECTED] wrote:
 Hello

 I want to serialise a dictionary, whose keys and values are ordinary strings
 (i.e. a sequence of bytes).

 I can of course use pickle, but it has two big faults for me.
 1.  It should not be used with untrusted data.
 2.  I want non-Python programs to be able to read and write these
 dictionaries.

 I don't want to use XML because:
 1.  It is verbose.
 2.  It forces other applications to load an XML parser.

 I've written, in about 80 lines, Python code that will pack and unpack (to
 use the language of the struct module) such a dictionary.  And then I
 thought I might be reinventing the wheel.  But so far I've not found
 anything much like this out there.  (The closest is work related to 'binary
 XML' -http://en.wikipedia.org/wiki/Binary_XML.)

 So, what I'm looking for is something like and extension of struct that
 allows dictionaries to be stored.  Does anyone know of any related work?


C:\junkcopy con adict.csv
k1,v1
k2,v2
k3,v3
^Z
1 file(s) copied.

C:\junk\python25\python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
Type help, copyright, credits or license for more information.
 import csv
 adict = dict(csv.reader(open('adict.csv', 'rb')))
 adict
{'k3': 'v3', 'k2': 'v2', 'k1': 'v1'}
 csv.writer(open('bdict.csv', 'wb')).writerows(adict.iteritems())
 ^Z

C:\junktype bdict.csv
k3,v3
k2,v2
k1,v1

C:\junk

Easy enough?
HTH,
John

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-20 Thread Bjorn Borud
[Giorgos Keramidas [EMAIL PROTECTED]]
| 
| Educating the user to avoid confusion in this and other cases of made
| up, 'user-friendly' descriptions is not a good enough answer.

there are two types of user friendly.  there's user friendly and
then there is beginner friendly which is often mislabeled.  the
latter is more important for applications which are to be used
casually.  like utilities you only use once or twice per year -- those
need to be beginner friendly.

for applications you are likely to use for prolonged periods of time
(like programming, video editing, music production etc), it does not
make sense to optimize for beginner friendly.  at least not at the
cost of making the application less user friendly.

applications you spend a lot of time using are worth an investment in
learning how to use them.  what creates friction in an application you
know reasonably well is when common tasks are fiddly.  for instance,
while menus are often good for casual use and lower the initial
threshold for absolute beginners, depending heavily on menu navigation
becomes too fiddly if you are performing a certain task 2-3 times per
minute.  it is not _user_ friendly.


Emacs is rather user friendly, but not very beginner friendly.
when I was first confronted with it, the sort of text editors I was
used to were Wordstar and derivatives of it.  I was rather annoyed
that it didn't do what I expected, so I just used a different editor.

a few years later I bemoaned the fact that Emacs was so hard to use
during a conversation with a friend.  he asked me if I had actually
made an effort to learn Emacs, which of course I hadn't.  so I figured
I might as well give it a shot.

following the tutorial that comes with Emacs (and which is referred to
in the startup message) I spent a couple of hours one afternoon
learning the basics.  already the next day I started using Emacs for
programming.  the week after I had progressed to using it as my
newsreader (which I still do to this day) and eventually I started
reading my email in Emacs.  perhaps two months after I had sat down to
learn Emacs I wrote my first Emacs extensions in Emacs Lisp.  mostly
simple stuff to make common programming tasks easier.

I found Emacs to be user friendly, but in a different sense than the,
IMHO faulty definition, beginner friendly.  Emacs let me, as a user,
do more with less effort and provides a lot less friction than many
other developer tools I've used.  at work I use it extensively, and we
have lots of neat extensions that really save a lot of time.

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
Steve Howell [EMAIL PROTECTED] writes:

 2) assert is not the simplest example of doctest. 
 The style should be
 
  add_money([0.13, 0.02])
 0.15
  add_money([100.01, 99.99])
 200.0
  add_money([0, -13.00, 13.00])
 0.0
 

  That's not clear cut to me.  I think vertical
  conciseness has an advantage for readability, as it
  means you get to keep more real code on the screen.

What I meant was that doctest should be type this into the
interpreter and you should see that.  A doctest is not a unit test,
though it may form a subset of the tests.  There should only be enough
doctests to enclue a human reader.  Comprehensive testing should use a
larger framework.  Doctests in separate files can do this but I would
use py.test, or alternatives like nose or Testoob.

 2 + 2
4

assert 2 + 2 == 4 is a concise way of writing a unit test but it is
not the best way to use doctest IMHO.

 3) which fails :-(  So both the unittest and doctest
 examples ought to
be redone to emphasize what they are doing
 without getting bogged
down by issues of floating point representations.
 

  I was the one who originally posted the floating point
  example (with yet another style of unit testing, BTW),
  and I agree that the subtleties of floating point do
  kind of cloud the issue.  I welcome a better example. 
  What I didn't realize is that there's an actual error.
   Are you saying the program fails?  On which test?

Python 2.5.1 on XP:

Failed example:
add_money([0.13, 0.02])
Expected:
0.15
Got:
0.14999


-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Diez B. Roggisch
Joe Riopel wrote:

 Precisely what? You complained that the OP didn't provide the location
 of the event, which he did.
 
 Well, where is DFW?

Google, first hit:

The Dallas Ft. Worth Pythoneers

They even have their own website. So - what's the fuss about? The BayPIGgies
also announce their meetings here. I don't mind, even though Berlin is
about 10-12 hours away on a jet-plane.

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


Re: caseless dictionary howto ?

2007-06-20 Thread Carsten Haese
On Wed, 2007-06-20 at 11:14 +0200, stef wrote:
 Stefan Behnel wrote:
 Serial_HW_Read = the name of a function
 F = the type of that function (procedure / function / pseudo variable 
 / interrupt /..)
 ++ = the direction of each parameters, (input / output / input+output )
 T = a tupple, containing the type of each of the parameters (bit / byte/ 
 sbyte / word / ...)
   maybe a class to hold them would look better),
 maybe, but no human is looking at it ;-)

But humans might look at the code that looks at the thing.
thing.func_type is self-documenting, thing[0] is not.

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: The Modernization of Emacs

2007-06-20 Thread Kaldrenon
Just so everyone's clear:

Nothing he has said makes much sense, if any.

He's talking about advocacy of something unique and powerful by -
making it less unique and powerful-. Not merely catering to the lowest
common denominator, but promoting something as better -by making it
worse-. Who does that?

Imagine that a man invents a vehicle that's far safer and more
maneuverable than any existing vehicle. Imagine that the increased
safety comes from the fact that it has five wheels. How incredibly
stupid would it be for that inventor to then say, I'm going to
convince people to buy my new vehicle, which is safer thanks to this
fifth wheel. But in order to market it, I'll take the fifth wheel off,
so it's more familiar and comfortable for them.

I'm very, very new to emacs. I used it a little this past year in
college, but I didn't try at all to delve into its features. I'm
starting that process now, and frankly, the thought of it changing -
already- upsets me. I don't feel like the program ought to change in
order to accommodate me. I'm excited about the prospect of mastering
something new and different. The fewer resemblances to the common-
denominator, extra-friendly stuff I've worked with in the past, the
better.

Emacs' uniqueness may hurt its adoption rate, but it still has plenty
of users, who are all perfectly happy with how things are done.

-Andrew

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


Re: SimplePrograms challenge

2007-06-20 Thread Steve Howell

--- Pete Forman [EMAIL PROTECTED] wrote:

 Steve Howell [EMAIL PROTECTED] writes:
 
  2) assert is not the simplest example of doctest.
 
  The style should be
  
   add_money([0.13, 0.02])
  0.15
   add_money([100.01, 99.99])
  200.0
   add_money([0, -13.00, 13.00])
  0.0
  
 
   That's not clear cut to me.  I think vertical
   conciseness has an advantage for readability, as
 it
   means you get to keep more real code on the
 screen.
 
 What I meant was that doctest should be type this
 into the
 interpreter and you should see that.  A doctest is
 not a unit test,
 though it may form a subset of the tests.  There
 should only be enough
 doctests to enclue a human reader.  Comprehensive
 testing should use a
 larger framework.  Doctests in separate files can do
 this but I would
 use py.test, or alternatives like nose or Testoob.
 
  2 + 2
 4
 
 assert 2 + 2 == 4 is a concise way of writing a
 unit test but it is
 not the best way to use doctest IMHO.
 
  3) which fails :-(  So both the unittest and
 doctest
  examples ought to
 be redone to emphasize what they are doing
  without getting bogged
 down by issues of floating point
 representations.
  
 
   I was the one who originally posted the floating
 point
   example (with yet another style of unit testing,
 BTW),
   and I agree that the subtleties of floating point
 do
   kind of cloud the issue.  I welcome a better
 example. 
   What I didn't realize is that there's an actual
 error.
Are you saying the program fails?  On which
 test?
 
 Python 2.5.1 on XP:
 
 Failed example:
 add_money([0.13, 0.02])
 Expected:
 0.15
 Got:
 0.14999
 
 

Ok, you make a lot of good points.  I was the original
author of the page, so I'll make a few points.

  1) Your attention to detail is greatly appreciated. 
At the very least, I don't want the examples to be
broken.  I tested the above on Unix 2.5, and they
worked, but it was obviously just luck, as the
implementation is clearly broken.  (Actually, it's not
so much the implementation--it's the interface, which
should just return pennies.)

  2) Both the unittest and doctest examples are
probably broken.

  3) I'd like for unittest and doctest example to show
up somewhere on the page, but perhaps they merit
longer examples.

  4) I don't use doctest myself.  It never hit my
sweet spot, mostly because I prefer external unit
tests.  So I'm not the best person to judge the most
idiomatic way to write them.

  5) My biggest goal for the page is that examples are
simple and mostly uncontroversial.

  6) It was pointed out when I originally wrote this
example that the solution to money rounding is, of
course, to use a Decimal data type.

  7) Feel free to change the page as you see fit,
although thanks for discussing it here first.



 

It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Jonathan Fine
Sridhar Ratna [EMAIL PROTECTED] wrote in message

 What about JSON? You can serialize your dictionary, for example, in
 JSON format and then unserialize it in any language that has a JSON
 parser (unless it is Javascript).

Thank you for this suggestion.  The growing adoption of JSON in Ajax
programming is a strong argument for my using it in my application, although
I think I'd prefer something a little more binary.

So it looks like I'll be using JSON.

Thanks.


Jonathan


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


Re: The Modernization of Emacs

2007-06-20 Thread David Kastrup
Kaldrenon [EMAIL PROTECTED] writes:

 I'm very, very new to emacs. I used it a little this past year in
 college, but I didn't try at all to delve into its features. I'm
 starting that process now, and frankly, the thought of it changing -
 already- upsets me. I don't feel like the program ought to change in
 order to accommodate me.

Actually, the E in Emacs stands for extensible.  Part of the
appeal of Emacs is that you can change it to accommodate you.

 I'm excited about the prospect of mastering something new and
 different. The fewer resemblances to the common- denominator,
 extra-friendly stuff I've worked with in the past, the better.

 Emacs' uniqueness may hurt its adoption rate, but it still has
 plenty of users, who are all perfectly happy with how things are
 done.

Oh, but Emacs is not TeX: it _is_ being developed further.  And some
changes are done in order to synchronize Emacs with the other world
where the latter has been oversleeping.  For example, Emacs 23 will
internally use utf-8/Unicode as its encoding when it has used
emacs-mule up to now, a multibyte code of its own.

In spirit, this will not change Emacs much, yet it will remove
other-world friction and make Emacs more obviously the incarnation of
editing descended into this world.

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


Re: Internationalised email subjects

2007-06-20 Thread bugmagnet
Thanks Martin, I actually have read that page before.  The part that
confuses me is the line:

h = Header('p\xf6stal', 'iso-8859-1')

I have tried using:

h = Header('  ', 'GB2312')

but when I run the code, I get the following error:

UnicodeDecodeError: 'gb2312' codec can't decode bytes in position 2-3:
illegal multibyte sequence

Is there something I need to do in order to encode the Chinese
characters into the GB2312 character set?

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


Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-19, Bjoern Schliessmann
[EMAIL PROTECTED] wrote:
 Diez B. Roggisch wrote:
 With other OOP languages you mean Java. Which does have static
 methods because they lack the notion of a function by its own,
 so the shoehorned them into their everything is inside a
 class-paradigm.

 ACK, but doesn't C++ have static methods too?

C++ does have what it calls static member functions.

class foo
{
  public:
static void bar() { /* nada */ }
};

Python names a similar thing a @staticmethod (the name taken from
C++, obviously, since C++ originated the essentially meaningless
word-grouping static member function in order to reuse an
existing keyword).

// It may be called with two different syntaxes, as in Python:

void goo()
{
  // ...using the qualified name:
  foo::bar();
  // ...or with an instance of the class:
  foo f;
  f.bar();
}

In C++ they are used most often for factory functions, since they
conveniently have access to the class's private members, and
don't want or need an existing instance. Python seems to have
adopted this use-case (ConfigParser, for example), but without a
need for it (code organization?).

-- 
Neil Cerutti
I am free of all prejudices. I hate everyone equally. --W. C. Fields
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs

2007-06-20 Thread Kaldrenon
On Jun 20, 9:28 am, David Kastrup [EMAIL PROTECTED] wrote:
 Kaldrenon [EMAIL PROTECTED] writes:
  I'm very, very new to emacs. I used it a little this past year in
  college, but I didn't try at all to delve into its features. I'm
  starting that process now, and frankly, the thought of it changing -
  already- upsets me. I don't feel like the program ought to change in
  order to accommodate me.

 Actually, the E in Emacs stands for extensible.  Part of the
 appeal of Emacs is that you can change it to accommodate you.

Well put. Perhaps I should have said that I don't feel like the
program ought to change to accommodate -everybody-.

I know that Emacs is still being worked on, is still growing and
changing, and also that, because of its extensibility, anyone can
change it as they wish. In fact, if the OP wants Emacs to behave the
way he describes, I'm sure it's doable. But my statement was that the
changes he suggests are things that should not be enforced
universally, because not only is there nothing wrong with the things
he suggests changing, but the idea of enforcing uniform changes is not
entirely in the spirit of Emacs.

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


How to code dynamically created methods?

2007-06-20 Thread kj


I've tried a bazillion ways to code dynamically generated methods,
to no avail.

The following snippet is a very simplified (and artificial) demo
of the problem I'm running into, featuring my latest attempt at
this.  The idea here is to use __getattr__ to trap any attempt to
invoke a nonexistent method, have it return a generic handler called
_auto which creates the new method dynamically, invokes it, and
installs it in the class, so that subsequent calls to the same
method go directly to the newly created method, instead of to
__getattr__.  It is this last step, the installation of the new
method, that is giving me problems.


class A( object ):
def __getattr__( self, name ):
self._auto_name = name
return self._auto

def hello( self, name ):
print hi! my name is %s % name

def _auto( self, *args ):
name = self._auto_name
def m( self, *args ): self.hello( name )
m( self, *args )

m = classmethod( m )
setattr( A, name, m )

x = A()
x.foo()  # ok
x.foo()  # bombs


 reload(test) hi! my name is foo Traceback (most recent call
last):
  File stdin, line 1, in ? File test.py, line 19, in ?
x.foo() File test.py, line 12, in m
self.hello( name ) TypeError: unbound method hello() must be
called with A instance as first argument (got str instance instead)


I'm sure that the problem is with my naive attempt to add a method
to class A dynamically (in the last two lines of the definition of
_auto).  What's the right way to do this?

Thanks!

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to hide a program?

2007-06-20 Thread jvdb
Hi all,

I've created a program that receives files and opens the corresponding
program (for example adobe acrobat). However, when started, i would
like to see nothing of the running program. I only want to see the
program that will be opened.
Is it possible to start a program 'hidden' or minimized to at least
the system tray? And, if yes., could some one help me on this?

Thanks already!

Jeroen

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


Re: How to code dynamically created methods?

2007-06-20 Thread kj

Nevermind, I found the problem...

Thanks,

kj

In [EMAIL PROTECTED] kj [EMAIL PROTECTED] writes:



I've tried a bazillion ways to code dynamically generated methods,
to no avail.

The following snippet is a very simplified (and artificial) demo
of the problem I'm running into, featuring my latest attempt at
this.  The idea here is to use __getattr__ to trap any attempt to
invoke a nonexistent method, have it return a generic handler called
_auto which creates the new method dynamically, invokes it, and
installs it in the class, so that subsequent calls to the same
method go directly to the newly created method, instead of to
__getattr__.  It is this last step, the installation of the new
method, that is giving me problems.


class A( object ):
def __getattr__( self, name ):
self._auto_name = name
return self._auto

def hello( self, name ):
print hi! my name is %s % name

def _auto( self, *args ):
name = self._auto_name
def m( self, *args ): self.hello( name )
m( self, *args )

m = classmethod( m )
setattr( A, name, m )

x = A()
x.foo()  # ok
x.foo()  # bombs


 reload(test) hi! my name is foo Traceback (most recent call
last):
  File stdin, line 1, in ? File test.py, line 19, in ?
x.foo() File test.py, line 12, in m
self.hello( name ) TypeError: unbound method hello() must be
called with A instance as first argument (got str instance instead)


I'm sure that the problem is with my naive attempt to add a method
to class A dynamically (in the last two lines of the definition of
_auto).  What's the right way to do this?

Thanks!

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to hide a program?

2007-06-20 Thread Diez B. Roggisch
jvdb wrote:

 Hi all,
 
 I've created a program that receives files and opens the corresponding
 program (for example adobe acrobat). However, when started, i would
 like to see nothing of the running program. I only want to see the
 program that will be opened.
 Is it possible to start a program 'hidden' or minimized to at least
 the system tray? And, if yes., could some one help me on this?

I'm not exactly sure what you  mean here, but I guess you want the
command-window suppressed. You can do so by naming your scripts *.pyw,
which will invoke pythonw.exe instead. That has no command-window.

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


Re: HTMLParser.HTMLParseError: EOF in middle of construct

2007-06-20 Thread sergio
Rob Wolfe wrote:

 
 Sérgio Monteiro Basto wrote:
 Stefan Behnel wrote:

  Sérgio Monteiro Basto wrote:
  but is one single error that blocks this.
  Finally I found it , it is :
  td colspan=2align=center
  if I put :
  td colspan=2 align=center
 
  p = re.compile('align')
  content = p.sub(' align', content)
 
  I can parse the html
  I don't know if it a bug of HTMLParser
 
  Sure, and next time your key doesn't open your neighbours house, please
  report to the building company to have them fix the door.
 

 The question, here, is if
 td colspan=2align=center
 is valid HTML or not ?
 I think is valid , if so it's a bug on HTMLParser
 
 According to the HTML 4.01 specification this is *not valid* HTML.
 
 
 Elements may have associated properties, called attributes, which may
 have values
 (by default, or set by authors or scripts). Attribute/value pairs
 appear before the final
  of an element's start tag. Any number of (legal) attribute value
 pairs, separated
 by spaces, may appear in an element's start tag.
 
 
 if not, we still have a very bad message error (EOF in middle of
 construct !?)
 
 HTMLParser can deal with some errors e.g. lack of ending tags,
 but it can't handle many other problems.
 
 I have to use HTMLParser because I want use only python 2.4 standard , I
 have to install the scripts in many machines.
 And I have to parse many different sites, I just want extract the links,
 so with a clean up before parse solve very quickly my problem.
 
 In Python 2.4 you have to use some third party module. There is no
 other option for _invalid_ HTML. IMHO BeautifulSoup is the best among
 them.
 

Many thanks Rob , you have been clear has water thanks, 

 --
 HTH,
 Rob

-- 
Best regards,
--
Sérgio M. B. 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Controlling Firefox with Python

2007-06-20 Thread kyosohma
On Jun 19, 4:35 pm, Méta-MCI [EMAIL PROTECTED]
wrote:
 Hi!

 See Mozlab:  http://dev.hyperstruct.net/mozlab

 and give a report, please.
 Thank you in advance.

 Michel Claveau

There seems to be some kind of weird bug with the current version of
MozLab. When I use telnet on my Windows XP box, it tries to evaluate
every character I type, which only results in lots of syntax errors. I
tried Putty in raw mode, and it works, but not well. Each line doesn't
get output to the far left. Instead, each line is dropped down one
line and tabbed over so it's one character ahead of the previous line.

I assume you think I can use Python to telnet to a running MozLab to
execute my commands? I will need to be able to do this to all the
users on a network and installing extensions on everyone's PC will be
somewhat difficult.

Mike

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

Re: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Cameron Laird
In article [EMAIL PROTECTED],
Diez B. Roggisch [EMAIL PROTECTED] wrote:
Joe Riopel wrote:

 Precisely what? You complained that the OP didn't provide the location
 of the event, which he did.
 
 Well, where is DFW?

Google, first hit:

The Dallas Ft. Worth Pythoneers

They even have their own website. So - what's the fuss about? The BayPIGgies
also announce their meetings here. I don't mind, even though Berlin is
about 10-12 hours away on a jet-plane.
.
.
.
The upset surprises me, too.  I appreciate people who esteem Usenet
enough to help police specific newsgroups, discouraging traffic in
marginal content best handled elsewhere.  On the other hand,
comp.lang.python has a tradition of productive announcements of local
events, DFW is both *very* meaningful to the target audience, and,
as noted, 'bout as easy to decipher with the help of Google as
anything can be.

Beyond all that, there's particular value in announcements like this
because they *are* of regional, rather than local, significance.  By
that I mean I know of several cases where Pythoneers from somewhere
else in the US (or even, in a couple of cases, other countries) have
been traveling, and found it possible to schedule a visit with a local
interest group.  That's neat!  Dallas gets a lot of traffic because
it's an airline hub, and close moreover to fellow computing-industry
centers in Austin and Houston (and, to a lesser extent, San Antonio
and El Paso).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython - embed separate script in panel?

2007-06-20 Thread kyosohma
On Jun 19, 7:28 pm, [EMAIL PROTECTED] wrote:
 This is a wxPython question.. the wxPython group is pretty much
 inactive.

 I have an MDI parent frame and child frame set up. In the child frame,
 I want to use part of the frame to display the output from a .py that
 is mainly matplotlib (a graph) in a section of the frame. How can I
 get it to automatically run that script and place the resultant graph
 in a panel?

 Thanks

I'm not sure what you're talking about. I get a digest email from the
wxPython user's group at least twice a day. Try going here and posting
to it:

http://www.wxpython.org/maillist.php

Are you signed up to the dev group or something?

Mike

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


Re: caseless dictionary howto ?

2007-06-20 Thread stef
Carsten Haese wrote:
 On Wed, 2007-06-20 at 11:14 +0200, stef wrote:
   
 Stefan Behnel wrote:
 Serial_HW_Read = the name of a function
 F = the type of that function (procedure / function / pseudo variable 
 / interrupt /..)
 ++ = the direction of each parameters, (input / output / input+output )
 T = a tupple, containing the type of each of the parameters (bit / byte/ 
 sbyte / word / ...)
 
  maybe a class to hold them would look better),
   
 maybe, but no human is looking at it ;-)
 

 But humans might look at the code that looks at the thing.
 thing.func_type is self-documenting, thing[0] is not.
   
I think you might be right,
but for a one-time/one-programmer program,
I think the documentation will be good enough.

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


SIGSEGV gcmodule.c:241 closing python after module import

2007-06-20 Thread stuffduff
Hi,

I have a python extension that works fine while it is running, but
when I exit python I get this error:

GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for
details.
This GDB was configured as i386-redhat-linux-gnu...Using host
libthread_db library /lib/libthread_db.so.1.

(gdb) run
Starting program: python2.4

...

ctrl-d

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208243504 (LWP 12884)]
collect (generation=2) at Modules/gcmodule.c:241
241 Modules/gcmodule.c: No such file or directory.
in Modules/gcmodule.c
(gdb) bt
#0  collect (generation=2) at Modules/gcmodule.c:241
#1  0x080e1ec5 in PyGC_Collect () at Modules/gcmodule.c:1196
#2  0x080da88a in Py_Finalize () at Python/pythonrun.c:353
#3  0x08055176 in Py_Main (argc=0, argv=0xbfb8dae4) at Modules/main.c:
513
#4  0x08054962 in main (argc=-1208273400, argv=0x812ed68)
at Modules/python.c:23

I haven't figured out what it is trying to collect.  Is there a way to
tell?

Thanks,

Sean

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


python website

2007-06-20 Thread james_027
hi,

what are you list of favorite python website (news, articles,
tutorials)?

cheers,
james

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


Re: How to hide a program?

2007-06-20 Thread jvdb
On 20 jun, 15:59, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 jvdb wrote:
  Hi all,

  I've created a program that receives files and opens the corresponding
  program (for example adobe acrobat). However, when started, i would
  like to see nothing of the running program. I only want to see the
  program that will be opened.
  Is it possible to start a program 'hidden' or minimized to at least
  the system tray? And, if yes., could some one help me on this?

 I'm not exactly sure what you  mean here, but I guess you want the
 command-window suppressed. You can do so by naming your scripts *.pyw,
 which will invoke pythonw.exe instead. That has no command-window.

 Diez

Hi Diez,

I forgot to mention that i have created a Windows executable of the
script.
What i want is to run the application minimized in the system tray or
totally hidden.

regards,
Jeroen

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


Re: The Modernization of Emacs

2007-06-20 Thread Bjorn Borud
[Kaldrenon [EMAIL PROTECTED]]
| Just so everyone's clear:
| 
| Nothing he has said makes much sense, if any.

(it'd be good if you explicitly specify who he is since pronouns by
nature are extremely context sensitive, and in this context an
unattentive reader might think you are referring to me.  thanks :-).

| Emacs' uniqueness may hurt its adoption rate, but it still has plenty
| of users, who are all perfectly happy with how things are done.

I don't see popularity as a goal in itself.  I am selfish.  I only
care what the software can do for me and I think that this is the only
way to write good software:  make something you'd want to use
yourself.

-Bjørn
-- 
http://mail.python.org/mailman/listinfo/python-list


class attributes data attributes

2007-06-20 Thread james_027
hi everyone,

I am now in chapter 5 of Dive Into Python and I have some question
about it. From what I understand in the book is you define class
attributes  data attributes like this in python

class Book:

total # is a class attribute

def __init__(self):
self.title  # is a data attributes
self.author # another data attributes

To define class attributes is like defining a function in class, to
define a data attributes is defining a variable inside the __init__
method.

what makes me confuse is this model from Django

from django.db import models

class Person(models.Model):
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=30)

I believe the first_name and last_name are data attributes? but why it
is they look like a class attributes as being define.

Thanks in advance for explaining

james

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


Re: python website

2007-06-20 Thread kyosohma
On Jun 20, 9:22 am, james_027 [EMAIL PROTECTED] wrote:
 hi,

 what are you list of favorite python website (news, articles,
 tutorials)?

 cheers,
 james


wxPython.org (and the wxPython wiki)
Python.org
ActiveState - http://aspn.activestate.com/ASPN/Python/Cookbook/
Charming python series - http://www.ibm.com/developerworks/library/l-pycon.html
http://gnosis.cx/publish/tech_index_cp.html
Devshed - http://www.devshed.com/c/b/Python/

Mike

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



Re: stftime %z time conversion character

2007-06-20 Thread sergio
Evan Klitzke wrote:

 Although it is not present in ANSI C, the GNU version of stftime
 supports the conversion character %z, which is a time offset from GMT.
 The four digit time offset is required in RFC 2822 dates/times, and is
 used by a number of other programs as well. I need to convert times
 that use this convention to python time representations, and because
 Python does not support the %z time conversion character I cannot
 simply use the time.strptime function.
 
 What solutions have people used for this? I'm currently thinking of
 creating a dict that maps four digit time offsets to the time zone
 name and then use the %Z token on that. Is there another (or better)
 way?
 

I had a similar problem, currently I had solved with a system call 

#The Linux Date Command: TZ=WET date -d 20070823 +%:z 
#example 
timezone = WET
year = 2007
month = 2
day = 27
#end of example
cmd=TZ=%s /bin/date -d %.4d%.2d%.2d +%%z % (timezone,year,month,day) 
print DEBUG cmd=%s % cmd
handler=os.popen(cmd, 'r', 1) 
output = .join(handler.readlines()).strip() 
tz=output[:3]+:+output[3:] 
handler.close() 
print DEBUG timezone=%sXX % tz

 
before I test timezone of my machines like this : 
import time
tzstr=time.strftime(%Z,time.localtime()) 
if tzstr == WEST :
do something 

Hope that can help something 

Best regards,
--
Sérgio M. B. 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python website

2007-06-20 Thread Martin Skou
The Daily Python-URL
http://www.pythonware.com/daily/

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


Re: SimplePrograms challenge

2007-06-20 Thread Pete Forman
Steve Howell [EMAIL PROTECTED] writes:

  Feel free to change the page as you see fit, although thanks for
  discussing it here first.

Done.  I've moved classes up as unittest depends on it.

The changes that I made to classes were:

1) Use new style class.
2) Demonstrate Pythonic use of attribute (no get/set).
3) Pare some lines.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Transfer file name input from one .py to another

2007-06-20 Thread Larry Bates
[EMAIL PROTECTED] wrote:
 How do I transfer the file name which is input in one .py (an MDI
 parent frame in wxPython) to another .py (an MDI child frame)? The
 parent gets the file name from the user via a file select dialog, but
 the child frame is the one that needs to know what file it is working
 with.
 
 Thanks
 
Normally I do something like:

class childFrame:
def __init__(self, parent, *args):
self.parent=parent

#
# Now you can refer to the filename by accessing
#
self.parent.filenamefromdialog

class main:
def getfilefromdialog(self):
self.filenamefromdialog=...

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


Re: class attributes data attributes

2007-06-20 Thread Diez B. Roggisch
james_027 wrote:

 hi everyone,
 
 I am now in chapter 5 of Dive Into Python and I have some question
 about it. From what I understand in the book is you define class
 attributes  data attributes like this in python
 
 class Book:
 
 total # is a class attribute
 
 def __init__(self):
 self.title  # is a data attributes
 self.author # another data attributes
 
 To define class attributes is like defining a function in class, to
 define a data attributes is defining a variable inside the __init__
 method.
 
 what makes me confuse is this model from Django
 
 from django.db import models
 
 class Person(models.Model):
 first_name = models.CharField(maxlength=30)
 last_name = models.CharField(maxlength=30)
 
 I believe the first_name and last_name are data attributes? but why it
 is they look like a class attributes as being define.

First of all, the common term for what you call a data attribute is
is instance attribute.

Furthermore - you're right and wrong.

The django-code above defines a model class, which has some class-attributes
declaring the fields the database shall have. and the instances as well!

So while the above clearly are class attributes, the ORM runtime of django
will create instances of that class that have instance attributes of the
same name.

Something along these lines (albeit a contrived example):

class Foo(object):
   bar = baz

   def __init__(self):
   for name, value in self.__class__.__dict__.items():
   if isinstance(value, str):
  setattr(self, name, some other value)

f = Foo()
print f.bar

Which should result in some other value. But it's untested code above.

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


Re: How to hide a program?

2007-06-20 Thread Larry Bates
jvdb wrote:
 Hi all,
 
 I've created a program that receives files and opens the corresponding
 program (for example adobe acrobat). However, when started, i would
 like to see nothing of the running program. I only want to see the
 program that will be opened.
 Is it possible to start a program 'hidden' or minimized to at least
 the system tray? And, if yes., could some one help me on this?
 
 Thanks already!
 
 Jeroen
 
You can do this with:

import win32process

STARTUPINFO=win32process.STARTUPINFO()
STARTUPINFO.dwX=0
STARTUPINFO.dwY=0
STARTUPINFO.dwXSize=800
STARTUPINFO.dwYSize=600
execute_target=enter program to run here
commandLine=None
processAttributes=None
threadAttributes=None
bInheritHandles=0
dwCreationFlags=0
currentDirectory=None
#
# Start the program
#
win32process.CreateProcess(execute_target,
   commandLine,
   processAttributes,
   threadAttributes,
   bInheritHandles,
   dwCreationFlags,
   newEnvironment,
   currentDirectory,
   STARTUPINFO)


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


business on line follow me !

2007-06-20 Thread jim
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
@ hello: madam and sir .
we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam and
sir. we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
@ hello: madam and sir .
we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam and
sir. we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
@ hello: madam and sir .
we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam and
sir. we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL 

Re: class attributes data attributes

2007-06-20 Thread Bruno Desthuilliers
james_027 a écrit :
 hi everyone,
 
 I am now in chapter 5 of Dive Into Python and I have some question
 about it. From what I understand in the book is you define class
 attributes  data attributes like this in python

s/data/instance/

 class Book:
 
 total # is a class attribute
 
 def __init__(self):
 self.title  # is a data attributes
 self.author # another data attributes
 
 To define class attributes is like defining a function in class, to
 define a data attributes is defining a variable inside the __init__
 method.
 
 what makes me confuse is this model from Django
 
 from django.db import models
 
 class Person(models.Model):
 first_name = models.CharField(maxlength=30)
 last_name = models.CharField(maxlength=30)
 
 I believe the first_name and last_name are data attributes? but why it
 is they look like a class attributes as being define.

first_name and last_name are actually class attributes. AFAICT, they are 
descriptors[1] controlling access to the resultset returned by the db query.

[1] cf the doc for the descriptor protocol on python.org. This is the 
feature that - amongst other things - allow Python to have a support for 
'computed attributes' (aka properties).



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


Re: static python classes ?

2007-06-20 Thread Alex Martelli
Neil Cerutti [EMAIL PROTECTED] wrote:

 In C++ they are used most often for factory functions, since they
 conveniently have access to the class's private members, and
 don't want or need an existing instance. Python seems to have
 adopted this use-case (ConfigParser, for example), but without a
 need for it (code organization?).

What staticmethod does ConfigParser have?  Can't recall one offhand.

I think Python more commonly uses classmethod, rather than staticmethod,
for factories (i.e. a la Smalltalk, not a la C++).  In that case the
advantage wrt a function _is_ there: when you subclass, you can get
instances of the new class, rather than the base class, from the
factory:

 class zap(dict): pass
... 
 z = zap.fromkeys(range(4))
 z
{0: None, 1: None, 2: None, 3: None}
 type(z)
class '__main__.zap'


If dict_fromkeys was a plain function (or if fromkeys was a staticmethod
rather than a classmethod of dict) then z would be an instance of dict,
rather than one of zap (unless you also specifically passed the desired
class, kind of cumbersome).


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


Python live environment on web-site?

2007-06-20 Thread Thomas Lenarz
Hi all,

I was wondering if there was a python-live-environment available on a
public web-site similar to the ruby-live-tutorial on

http://tryruby.hobix.com/

I would prefer something which allows to paste small scripts into a
text-field, to run them on the server, and to be able to read the
produced output of the script.

I searched using google but didn't come across such a site. However, I
imagine there must be at least one

Thanks for any hint,

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


ebay

2007-06-20 Thread jim
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
@ hello: madam and sir .
we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam and
sir. we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
@ hello: madam and sir .
we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam and
sir. we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
@ hello: madam and sir .
we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam and
sir. we sell all kinds of laptops and digital cam .our product is a
quantity best, the price is the lowest in the world, i think you will
be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL PROTECTED] thanks for everyone good luck with everyone
hello: madam and sir . we sell all kinds of laptops and digital
cam .our product is a quantity best, the price is the lowest in the
world, i think you will be interested in our product . thanks a lot!
Our Website:http://www.prs-123.com/ Msn: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED] thanks for everyone good luck with
everyone . @@@ hello : madam
and sir. we sell all kinds of laptops and digital cam .our product is
a quantity best, the price is the lowest in the world, i think you
will be interested in our product . thanks a lot! Our Website:http://
www.prs-123.com/ Msn: [EMAIL PROTECTED] mail:
[EMAIL 

Re: How to hide a program?

2007-06-20 Thread jvdb
On 20 jun, 17:05, Larry Bates [EMAIL PROTECTED] wrote:
 jvdb wrote:
  Hi all,

  I've created a program that receives files and opens the corresponding
  program (for example adobe acrobat). However, when started, i would
  like to see nothing of the running program. I only want to see the
  program that will be opened.
  Is it possible to start a program 'hidden' or minimized to at least
  the system tray? And, if yes., could some one help me on this?

  Thanks already!

  Jeroen

 You can do this with:

 import win32process

 STARTUPINFO=win32process.STARTUPINFO()
 STARTUPINFO.dwX=0
 STARTUPINFO.dwY=0
 STARTUPINFO.dwXSize=800
 STARTUPINFO.dwYSize=600
 execute_target=enter program to run here
 commandLine=None
 processAttributes=None
 threadAttributes=None
 bInheritHandles=0
 dwCreationFlags=0
 currentDirectory=None
 #
 # Start the program
 #
 win32process.CreateProcess(execute_target,
commandLine,
processAttributes,
threadAttributes,
bInheritHandles,
dwCreationFlags,
newEnvironment,
currentDirectory,
STARTUPINFO)

 -Larry Bates

Hi Larry,

The thing is, i don't want to see anything of my program, just the
launched program.
I already have the program working. But when i create an executable of
it with py2exe and start it, i don't want to see that it is running,
perhaps just in the systemtray. That is my problem.

thanks!
Jeroen

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


RE: DFW Pythoneers Meeting THIS Saturday

2007-06-20 Thread Looney, James B
Short answer:
DFW = Dallas-Fort Worth

Longer answer:
I'm not pointing fingers or making opinions, I just wanted to point out
that after reading Jeff's original email (in its entirity), I found:

Jeff wrote:
snip
 at the usual location of Nerdbooks.com bookstore in Richardson.  For
/snip
So, after looking at Nerdbooks.com, they're in Richardson, TX.
http://maps.google.com/maps?f=qhl=enq=1681+Firman+Drive,+richardson,+t
xsll=37.0625,-95.677071sspn=31.371289,59.765625ie=UTF8ll=32.876127,-
96.792297spn=0.259504,0.466919z=11om=1

snip
 By the way, I've been contacted by a developer at the Travelocity
Dallas
 office, who is looking for local Python developers with experience in
Django
 or Genshi.  If you're interested, let me know and I can put you in
touch.
/snip
Otherwise, after reading to this point in his email (and not knowing
what DFW was), I'd guess that they're near Dallas.

 -Original Message-
 Subject: Re: DFW Pythoneers Meeting THIS Saturday
 
  Precisely what? You complained that the OP didn't provide 
 the location
  of the event, which he did.
 
 Well, where is DFW?
 -- 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess.popen question

2007-06-20 Thread [EMAIL PROTECTED]
I am trying to modify a programming example and I am coming up with
two problems...  first is that I can't seem to pass along the
arguments to the external command (I have been able to do that with
the old module and cmd is the command I wish to try) all the output
seems to be returned as one line (at least when I run the program in
spe).

import subprocess
from os import system
cmd = gawk -f altertime.awk -v time_offset=4 -v
outfile=testdat.sco i1.sco 
#subprocess.Popen.
last_line = subprocess.Popen(['gawk.exe'],
stdout=subprocess.PIPE).communicate()[0]
xx = 0
for line in last_line:
xx = xx + 1
if xx  2:
  print line
print str(xx)

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


Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-20, Alex Martelli [EMAIL PROTECTED] wrote:
 Neil Cerutti [EMAIL PROTECTED] wrote:

 In C++ they are used most often for factory functions, since they
 conveniently have access to the class's private members, and
 don't want or need an existing instance. Python seems to have
 adopted this use-case (ConfigParser, for example), but without a
 need for it (code organization?).

 What staticmethod does ConfigParser have?  Can't recall one
 offhand.

I misremembered which module I had recently seen it in: it was
datetime, not ConfigParser. And ('datetime.today') is, as you
point out, a class method rather than a static method.

Thanks for the correction.

 I think Python more commonly uses classmethod, rather than
 staticmethod, for factories (i.e. a la Smalltalk, not a la
 C++).  In that case the advantage wrt a function _is_ there:
 when you subclass, you can get instances of the new class,
 rather than the base class, from the factory:

 class zap(dict): pass
 ... 
 z = zap.fromkeys(range(4))
 z
 {0: None, 1: None, 2: None, 3: None}
 type(z)
class '__main__.zap'


 If dict_fromkeys was a plain function (or if fromkeys was a
 staticmethod rather than a classmethod of dict) then z would be
 an instance of dict, rather than one of zap (unless you also
 specifically passed the desired class, kind of cumbersome).

Thanks. That makes much more sense than my misunderstanding did. ;)

-- 
Neil Cerutti
Ask about our plans for owning your home --sign at mortgage company
-- 
http://mail.python.org/mailman/listinfo/python-list


Edit Audio Using Python?

2007-06-20 Thread Ultrus
Hello Python Gurus,
I picked up a book the other day on Python programming. Python rocks!
I'm learning Python as I want to call upon it to handle some intensive
tasks from PHP/web server.

The top goal right now is automating audio editing using Python. Is it
possible? I was able to do this directly through php, but it was
rey slo. PHP is not designed for that sort of
thing.

So far I googled the Snack Sound Toolkit at http://www.speech.kth.se/snack/
. It seems to have potential, but is very limited, and has not been a
very active project lately from what I can tell. I'm not sure I can
use it without learning C or C++ to make it do what I want (fading
ends, appending - there but not working?, mixing). It may work once I
learn more about it.

Do you know of any other modules, scripts, or whatnot that allows for
fast .wav audio editing from a Python script (not through a visual
interface)? Would it be better to start from scratch?

Thank you much for the advise :)

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


  1   2   3   >