cx_Logging 1.1

2006-01-11 Thread Anthony Tuininga
What is cx_Logging?

cx_Logging is a Python extension module which operates in a fashion
similar to the logging module that ships with Python 2.3 and higher.
It also has a C interface which allows applications to perform logging
independently of Python.


Where do I get it?

http://starship.python.net/crew/atuining


What's new?

1) Raise an exception if a write fails during logging.
2) Add module constants version and buildtime in order to aid in support and
debugging.

Anthony Tuininga
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: wxPython 2.6.2.1

2006-01-11 Thread Robin Dunn
Announcing
--

The 2.6.2.1 release of wxPython is now available for download at
http://wxpython.org/download.php.  There have been many enhancements
and fixes implemented in this version, listed below and at
http://wxpython.org/recentchanges.php.


What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit Microsoft Windows, most Linux
or other Unix-like systems using GTK2, and Mac OS X 10.2+, in most
cases the native widgets are used on each platform.


Changes in 2.6.2.1
--

wxMSW: Fix for bug #1211907, popup menu indenting inconsistent with
bitmaps.

wxMac: Don't send an event for wx.RadioButton deselections, just the
selections.  This was done to make it consistent with the other
platforms.

wxMSW: Always set flat toolbar style, even under XP with themes: this
is necessary or separators aren't shown at all.

Fixes for bug #1217872, pydocview.DocService not correctly initialized.

Fix for bug #1217874, Error in parameter name in DocManager.CreateView.

Added wrappers for the wx.RendererNative class.

Added the wx.lib.splitter module, which contains the
MultiSplitterWindow class.  This class is much like the standard
wx.SplitterWindow class, except it allows more than one split, so it
can manage more than two child windows.

Docview and IDE patch from Morgan Hua with fix for bug #1217890
Closing view crashes Python plus some new features::

 New feature added to the IDE is 'Extensions'.  Under
 Tools|Options|Extensions, you can add calls to external programs.
 For example you can add a Notepad extension (under windows) that
 will exec Notepad on the currently open file.  A new Notepad
 menu item will appear under the Tools menu.

Some fixes to XRCed to make encoding errors a bit more user friendly.

XRCed changes from Roman Rolinsky:

 * Added new controls (Choicebook, Listbook, StatusBar,
   DatePicker), and completed style flags. Test window is opened
   for an available parent control if no specific view
   defined. Better handling of exceptions (highlighting does not
   'stick' anymore).

 * Use system clipboard for Copy/Paste.

 * Improved some dialogs (window styles, growable cols). Changed
   the range for wxSpinCtrl min/max to all integers (default 0/100
   is not always good).

Updates for wx.lib.foldpanelbar and wx.lib.hyperlink from Andrea
Gavana.

Fix for Bug #1283496: wxPython TheClipboard class causes problems for
pychecker.  Ensure the app has been created before initializing
wx.TheClipboard.

Fix for Bug #1352602: FileBrowseButtonWithHistory can't type in Value.

wxHTML: Added space after list item number.

wx.lib.printout:  Applied patch #1384440.

wxMSW:  Fix for Bug #1293225 Window_FromHWND crashes if parent is
None.

Fix for Bug #1261669, use a wx.TE_RICH2 style for the Process demo so
it doesn't fill up too soon.

Applied Patch #1354389: wxPython MenuItem SetBitmaps fix.

Applied Patch #1239456: wxPython wx.DataObject.GetAllFormats fix.

Applied Patch # #1230107 which allows image handlers to be written in
Python by deriving from wx.PyImageHandler.

Applied patch #1072210: generalize printout.py to allow text printing.

Applied patch #1243907: Give Throbber much more flexibility by
allowing the user to set the rest image, the direction, the current
index, custom sequence.  Allows user to manually step through the
sequence with Next(), Previous(), Increment(), Decrement() 
SetCurrent(). Very handy if you have multiple throbbers that you want
to synchronize with a single timer.

Fix for bug #1336711: wx.lib.calendar.CalenDlg can yield incorrect
result.

Applied patch from Morgan Hua for updates to ActiveGrid code
(pydocview, ActiveGrid IDE, etc.)

Applied patch #1326241: Supporting setup.py install --install-headers=path

Applied patch from Morgan Hua to fix bug #1219423: CommandManager
should not repeat old commands after a branch.

Applied patch #1238825 adding search backward capabilities to the
demo.  Modified to use the up/down options in the wx.FindReplaceDialog
instead of a separate menu item.

Fix for bug #1266745 and #1387725 in the wx.FindReplaceDialog on MSW.
Actually check we are using MSLU before doing the hack designed to
workaround a bug in MSLU!

wxMSW: wx.lib.iewin.IEHtmlWindow now properly handles tabbing, return
and other special keys properly.

Lots of PyCrust enhancments started by Franz Steinaeusler, Adi Sieker,
and Sebastian Haase, and which in turn were further enhanced, fixed
tweaked and finished 

PyDev 0.9.8.6 released

2006-01-11 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.8.6 has been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.

Details for Release: 0.9.8.6:

Major highlights:
---

   * Added a new 'Pydev project' wizard (Mikko Ohtamaa contribution) -- 
it is named as Pydev Project instead of Python project because it 
creates Python and Jython projects.
   * Added a new 'Pydev module' wizard (Mikko Ohtamaa contribution) -- 
NOTE: it still needs some work.
   * Changes in the shell spawning were done, and no hangs should appear 
when trying to do code-completion anymore (if it still hapens, please 
report it as a bug -- NOTE: a little delay on the first time 
code-completion is executed is expected, as this is the time the shell 
is started).
   * Other bugfixes (as usual)

Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com

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

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


ANN: Chandler 0.6

2006-01-11 Thread Heikki Toivonen
Open Source Applications Foundation (OSAF) released Chandler 0.6 on
December 20, 2005. Chandler 0.6 includes an “experimentally usable”
calendar, with support for recurring events, time-zones and the ability
to share calendars with others.

Chandler is a Personal Information Management (PIM) client application
with innovative design and ambitious plans for sharing, extensibility
and cross-platform support. Chandler is written mainly in Python.

There is a wealth of information about the application and this
particular release at the Chandler 0.6 Home Page:

http://chandler.osafoundation.org/

-- 
  Heikki Toivonen
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Spelling mistakes!

2006-01-11 Thread Antoon Pardon
Op 2006-01-10, Terry Hancock schreef [EMAIL PROTECTED]:
 On 9 Jan 2006 11:21:10 GMT
 Antoon Pardon [EMAIL PROTECTED] wrote:
 Op 2006-01-06, Terry Hancock schreef
 [EMAIL PROTECTED]:
  On 6 Jan 2006 07:30:41 -0800
  KraftDiner [EMAIL PROTECTED] wrote:
  in an init method I declare a variable 
 self.someLongName  
  later in a different method of the class I use
  self.sumLongName
  Now I really meant self.someLongName.
  In fact I don't want a variable called sumLongName.
  Frankly how are you ever to know if this type of error
 is  occuring?
 
  Both unit tests and interfaces are useful for
  catching simple errors like this one.  There is a
  'unittest' module in the Python standard library, and
  'interface' modules are available from the Zope 3
  project and PyProtocols, both are good.
 
 I don't think unit tests are that helpfull in this case.
 Unit tests help you in finding out there is a bug, they
 don't help that much in tracking down a bug.
 
 I for some reason a person is reading over the difference
 between sumLongName and someLongName and doesn't notice
 the different spelling in his source a unit test won't
 be of much help.

 Well, if you are doing fairly frequent unit tests, then you
 will have written a unit test to test the someLongName
 method, and if you manage to type sumLongName in BOTH the
 code and the unit test, then there must be some Freudian
 reason you really did want to use sumLongName. ;-)

Who says someLongName is a method?

 It's a bit like the standard practice of making you type a
 password twice. In fact, most of the common bug avoidance
 methods in programming all come down to this -- you have to
 type the same thing twice in two different places to get
 the result.

 C and C++ make you do declarations -- so you have
 to mention the name before you can use it.  You have to type
 the variable names twice.

But that is not an accepted idea here in c.p.l. I also find
it strange that redundancy via type declarations is so hard
resisted here and is then defended with the argument it
isn't needed is you test sufficiently (with unit tests)
which is also a kind of redundancy.

 Interfaces define the publically viewable parts of a
 class, then you have to actually create them in a separate
 class definition.  You have to type the methods twice.

 In unit testing, you write the code, then write code to test
 the code, which must correctly identify the methods in the
 code. So you have to type 'everything' twice.

But you don't type attribute names twice in unit tests,
because attributes are in general implementation details
that are of no concern to the tester. So unit tests can
not introduce the redundancy to find out a missed spelled
attribute in some methods.

 The ideal of don't repeat yourself seems to get
 nudged out by repeat yourself exactly once when it's
 really important to get it right. ;-)

 It's really just a fancy way to force you to proof-read your
 own work carefully enough (which is tricky because you 
 tend to ignore stuff that's too repetitious).

Yes and you also tend to read over your own spelling errors.

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


Re: Why keep identity-based equality comparison?

2006-01-11 Thread Antoon Pardon
Op 2006-01-10, Christopher Subich schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Op 2006-01-10, Peter Decker schreef [EMAIL PROTECTED]:

I don't see the two comparisons as equivalent at all. If two things
are different, it does not follow that they can be ranked.
 
 
 That a  b returns false doesn't imply that a and b can be ranked.
 take sets. set([1,2]) and set([1,3)) can't be ranked but 
 set([1,2])  set([1,3)) returns False just as set([1,2])  set([1,3))
 does.

 Breaking my resolution already, but you're ignoring the fact that the 
 set type uses the '' and '' operators from a set-theoretic, not 
 number-theoretic point of view.

That is irrelevant. the '' and '' symbols are usable to denote any
mathematical order and are often enough used for even other order
relations. The only reason that other symbols like the subset symbol
are used is to avoid confusion about which order you are talking
because numbers and sets are used together often enough.

But the superset relationship is mathematically just as much an
order relation as is the greater than relationship.

 Saying set(1,3) is greater than 
 set(1,2) is meaningless (and not false), because the mathematical basis 
 of the operator in this context is superset -- set(1,3) is a superset 
 of set(1,2) is well-defined and false.

No it is not meaningless. The superset relationship is just as much
an order relationship and thus can mathematically make use of the
'' and '' symbol just as any mathematical order relation can.

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


Re: Failing unittest Test cases

2006-01-11 Thread Michele Simionato

[EMAIL PROTECTED] wrote:
 Michele I am also +1 to run the tests in the code order.

 Got any ideas how that is to be accomplished short of jiggering the names so
 they sort in the order you want them to run?

 Skip

Well, it could be done with a decorator, but unittest is already
cumbersome how it is,
I would not touch it. Instead, I would vote for py.test in the standard
library.

   Michele Simionato

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


python-soappy

2006-01-11 Thread Yves Glodt
Hi list,

can anybody point me to a tutorial, howto or example code of 
python-soappy...? google did not have really useful results about...


Best regards,
Yves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding sniffer?

2006-01-11 Thread Stuart Bishop
[EMAIL PROTECTED] wrote:
 Andreas Does anyone know of a Python module that is able to sniff the
 Andreas encoding of text?
 
 I have such a beast.  Search here:
 
 http://orca.mojam.com/~skip/python/
 
 for decode.
 
 Skip

We have similar code. It looks functionally the same except that we also:

Check if the string starts with a BOM.
Detects probable ISO-8859-15 using a set of characters common
is ISO-8859-15 but uncommon in ISO-8859-1
Doctests :-)

# Detect BOM
_boms = [
(codecs.BOM_UTF16_BE, 'utf_16_be'),
(codecs.BOM_UTF16_LE, 'utf_16_le'),
(codecs.BOM_UTF32_BE, 'utf_32_be'),
(codecs.BOM_UTF32_LE, 'utf_32_le'),
]

try:
for bom, encoding in _boms:
if s.startswith(bom):
return unicode(s[len(bom):], encoding)
except UnicodeDecodeError:
pass

[...]

# If we have characters in this range, it is probably ISO-8859-15
if re.search(r[\xa4\xa6\xa8\xb4\xb8\xbc-\xbe], s) is not None:
try:
return unicode(s, 'ISO-8859-15')
except UnicodeDecodeError:
pass

Feel free to update your available code. Otherwise, I can probably post ours
somewhere if necessary.

-- 
Stuart Bishop [EMAIL PROTECTED]
http://www.stuartbishop.net/


signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Change Gateway Programmatically

2006-01-11 Thread Godwin Burby
Thanx again.

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


Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]

2006-01-11 Thread Steve Holden
Steven D'Aprano wrote:
 On Tue, 03 Jan 2006 08:27:39 -0800, Alex Martelli wrote:
 
 
Or some even more stringent qualification, such as the state's Bar exam
for lawyers -- you may not be able to sit for that exam w/o the
appropriate degree, but the degree by itself is not enough, you still
have to pass the exam.  It is that way for Engineers in Italy (I passed
my State Exam in the early '80s), although you only need the certificate
for some specific professional undertakings (e.g. design a ship, or a
large building, or technically supervise building operations beyond a
certain size -- not to write software or to design chips).

Personally, I agree with the theory, first expressed by Adam Smith, that
such barriers to entry are mostly useful to grant practitioners of a
certain profession the scarcity value that lets them charge higher
prices, although of course they're always presented as good for
society.  Note that in Europe in the Middle Ages you needed strict
qualifications of that kind for just about anything -- you could not
make hats unless you belonged to the Hatters' Guild, etc; most of those
restrictions have since been lifted, but a few groups (doctors, lawyers,
accountants, ...) have managed to keep them in place.
 
 
 Let's not confuse the medieval guild system with today's system. Guilds
 were more like clubs than professional bodies: it was who you knew, rather
 than what you knew, that decided whether you got in. You were forbidden
 from becoming (say) a hat maker unless the other hat makers allowed you to
 join the guild. There was no independent, or even semi-independent, body
 who decided what qualifications were needed to make hats. It was all about
 who you knew -- if your uncle's best friend was a hat maker, you could be
 apprenticed to a hat maker and join the guild, otherwise there was no exam
 to sit that got you in, no matter how talented you were.
 
I believe you are overlooking the fact that you had to serve an 
apprenticeship that only ended when you ether produced work of master 
craftsman quality or decided you would be better employed elsewhere. 
This isn't to refute the truth of Smith's assertion that the guilds 
controlled scarcity, giving them some control over price. But today's 
world, the world of polite incompetence (a phrase used about Virginia 
society by a dear neighbour in the USA) where few can perform the jobs 
they are paid to, but everything is cheap.

 This system combined the worst of all outcomes: you got artificial
 scarcity with the monopoly pricing that leads to, *plus* it failed to
 enforce or even encourage minimum standards of skill and strategy.
 
Wrong [see above]. I don't remember many mediaeval cathedrals falling 
down, but the Tacoma Narrows bridge was a practical lesson in 
engineering. So what's your real point?

 By contrast, today's professional bodies like law, medicine etc. have
 independent standards of skill that must be met. I don't wish to deny
 that knowing the right people can help smooth the procedure of becoming
 a doctor, lawyer, etc., but failing to have an uncle who is a lawyer is no
 barrier to becoming a lawyer, provided you can pass the bar exam. That is
 very different from the guild system.
 
Well, one might equally argue that becoming a master mason in the past 
required you to produce master masonic work. Since professions and 
crafts are somewhat different, however, it's unlikely to be fruitful to 
attempt to draw direct comparisons. Maybe having an uncle helped you in 
to the trade, but it didn't cut you much slack in terms of required 
standards, hence the absence of cathedral-shaped heaps of rubble. York 
Minster was built in the 1400s, for example, and doesn't look like 
falling down any time soon.

I can't think of many modern American houses likely to survive more than 
a century. They are built to a price, not a quality. The situation is 
rather different in some other countries, where natural resources have 
been depleted for longer and are correspondingly more valued.

 In general, professional bodies like engineers, doctors, etc. do a
 reasonable job of enforcing minimum standards of skill and quality.
 Certainly there are a lot fewer building collapses in countries that
 enforce building standards than countries that allow the free market to
 decide.
 
The major problem with professional bodies is precisely their lack of 
insistence on a practical demonstration of capability. Paper MCSEs, 
for example, frequently make bad Windows system administrators because 
their education has been geared to the acquisition not of practical 
skills but of the qualification itself. The medical profession acquits 
itself reasonably because it does still require a good amount of 
doctoring before qualification. Why are the lawyer jokes not doctor jokes?

 Free market radicals like to sneer at for the good of society arguments,
 but the problem with their reasoning is that they only consider the
 monetary cost of hiring a 

Re: python-soappy

2006-01-11 Thread Nico Grubert
  can anybody point me to a tutorial, howto or example code of
  python-soappy...? google did not have really useful results about...

This might be helpful:
  http://www-128.ibm.com/developerworks/library/ws-pyth5/
  http://users.skynet.be/pascalbotte/rcx-ws-doc/python.htm

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


Re: Why keep identity-based equality comparison?

2006-01-11 Thread Antoon Pardon
Op 2006-01-10, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 There is no way in python now to throw an exception when you
 think comparing your object to some very different object
 is just meaningless and using such an object in a container
 that can be searched via the in operator.
 I claim that comparing for equality is *never* meaningless. Either two
 objects are equal, or they aren't.  It may be that they are of
 different types - like the enum example above - in which case they
 will never compare equal.
 Note that this is different from an ordering. It's possible to have a
 pair of objects - maybe even of the same type - that can't be ordered
 in anyway. In this case, raising an exception when you try that
 comarison makes sense.
 IMO you have the choice between taking the mathematical route or
 the practical route.

 The behavior proposed for Py3k *is* the practical route. It gives a
 reasonable behavior, and one that leads to simple implemenations for
 container operations.

Then I have to ask, practical for who, user of python or the
implementor, because I don't find it practical that a language
says at the same times that two objects can use a comparision
and can't.

 Now you can take the practical option and decide that programmatically
 it make no sense to compare a specific couple of values and throw an
 exception in this case, but it doesn't matter much which test you are
 conducting at that point.

 Can you provide a case where having a test for equality throw an
 exception is actually useful?

I'm not going to bother with that. Sure uses cases are interesting
but if you always wait for a use case before implementing something,
whatever the other arguments are, you will disappoint the future
people with a use case because they can't do what they want yet.

I haven't seen a case where testing for unequality throwing an
exception would be actually usefull, yet that is considered,
why do I have to provide a use case.

 BTW, the case you're arguing for is *different* from the case the OP
 proposed. By my reading, he wanted equality testing to throw an
 exception for two objects unless a comparison was explicitly coded. So
 that even a == a could cause an exception.

Why not? If a is of a type where == is a meaningless operation then
a == a is meaningless too.

 Maybe python should adopt both approaches and introduce a new family
 of comparators. Then one family will always succeed and the other
 family can throw an exception.

 Comparators - including equality comparators - can already throw
 exceptions. The enum case proved that.

Your point? Your remark says nothing for or against python having
two families of comparators, one that is defined as never throwing
an exception and one defined as exception throwable.

 Also, every container type now has this split between identity and
 equality has to be dealt with for *every* container class. If you want
 identity comparisons on objects, you have to store them in an idlist
 for the in operator and index methods to work properly.
 I also think your basic idea is wrong. The expression x == y is
 intuitively False if x and y aren't comparable.
 But there are certainly circumstances that I would prefer 1 == (1,2)
 to throw an exception instead of simply turning up False.
 So what are they?

 Again - give us real use cases.

I didn't see a real use case for 1  (1,2) throwing an exception either.
The only argument seems to be that the current behaviour confuses
beginners. But I don't see that as such a strong argument because
a number of other things confuse beginners too and are not up
for a change. I also think that 1 == (1,2) returning False but
1  (1,2) throwing an excpetion masy not be that less confusing
as the current behaviour.

I don't care that much what it will be, but I would prefer a consistent
approach for all comparators. No either all throw an exception when
the two operands are of differnt type or None does (or two families)

 I would say some more thinking is needed in this area. Now we can
 have weird circumstances where A == B and B == C but A != C.
 Nothing wierd about that at all. Anyone who's dealt with floats at all
 should be used to it.
 With floats that is entirely a problem of precision. When you are
 working with discrete types such circumstances remain weird.

 Floats *are* a discrete type. The equality *relationship* is what's
 fuzzy. There are lots of non-transitive relationships around. I don't
 find them wierd at all.

That there are a lot of non-transitive relationships and that there
is nothing weird about them, says nothing about one specific
relationship, == which normaly is considered to be transitive
and turns out not to be.

Beside I think the == comparison is transitive on the floats. It
is just that if you do your calculations that the imprecision in
the numbers can give you a result that give false where you expect
true when comparing for equality, but that is because you 

Re: Cross Compile Mips / Linux

2006-01-11 Thread Frithiof Andreas Jensen

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Everyone,

 Should I try using a Linux based machine for the build,  would that
 help??

YES -

The problem is that the Linux build tools generally assume that they are
sitting in the target environment and therefore tries to use facilites
discovered by the tools and discoveries about endianess and such; This is
a general problem with the design of the Linux build system - the I am on
the target assumptions are likely to be smeared over many applications.

WindRiver (an embedded Linux provider) f.ex. makes a living off - amongst
other things - providing an environment enabling Linux+applications to be
reliably cross compiled!

What we prefer to do is to use a King-Size version of the target hardware
with a full set of tools and libraries to build on and then pack a file
system with just the built Kernel + Application(s) for the target into an
initrd image (
http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/initrd.html ) and
have the real target download  boot that.

This is because we are often doing tricky stuff with new CPU's where the
Kernel is barely ready so we like to be sure that the bugs are in the code
and not freebies provided by the cross compiler tools.

 ... and the latest embedded target happens to be an 8-Way Opteron card with
16 GB RAM that does not take eons to compile ;-)


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


Restart process with SIGHUP

2006-01-11 Thread LukasMeyerUK
Hello,

I'm trying to restart a process with the os.kill command. My Problem is
that if the command gets executed, my python script stops working. I
want to SIGHUP a process with the following command: os.kill(pid,
signal.SIGHUP).

Can anyone give me a hint in solving this?

Best regards,

Lukas

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


Re: New Python.org website ?

2006-01-11 Thread Steve Holden
Bugs wrote:
 Aahz wrote:
 
Dunno about in time for the new year, but there is a new design that is
supposedly in final stages of getting implemented.  What's your hurry?
 
 
 No hurry:
 http://tinyurl.com/8d9ar

http://beta.python.org

Happy New Year. We could do with some help completing the conversion if 
people have some free time. It would be nice if it could be completed 
for PyCon. Start at

http://psf.pollenation.net/

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Bug in struct.pack?

2006-01-11 Thread Alex Stapleton
from struct import pack
  pack(B, 1)
'\x01'
  pack(BB, 0, 1)
'\x00\x01'
  pack(BI, 0, 1)
'\x00\x00\x00\x00\x01\x00\x00\x00'
  calcsize(BI)
8
  calcsize(BB)
2

Why does an unsigned char suddenly become 4 bytes long when you  
include an unsigned int in the format string? It's consistent  
behaviour but it's incorrect.

Also.

  calcsize('BL')
8
  calcsize('BBL')
8
  calcsize('BBBL')
8
  calcsize('L')
8
  calcsize('BL')
12
  pack(BBBL, 255,255,255,0)
'\xff\xff\xff\x00\x00\x00\x00\x00' ### That's 3 255's and 5(!?!?)  
0's
  pack(L, 255,255,255,255,0)
'\xff\xff\xff\xff\x00\x00\x00\x00' # 4 255's and 4 0's!

Which is all kinds of wrong.

BL should be 9
BBL should be 10


Python 2.4.1 (#2, May  5 2005, 11:32:06)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2

Same behaviour on my PowerBook using

Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin

sizeof(unsigned long) should be 8 on both of these platforms
sizeof(unsigned char) should be 1 on both as well

So am I just being stupid and not specifying something I should be?  
Or is struct really that broken?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python.org website ?

2006-01-11 Thread Steve Holden
Bugs wrote:
 Aahz wrote:
 
Dunno about in time for the new year, but there is a new design that is
supposedly in final stages of getting implemented.  What's your hurry?
 
 
 No hurry:
 http://tinyurl.com/8d9ar

http://beta.python.org

Happy New Year. We could do with some help completing the conversion if 
people have some free time. It would be nice if it could be completed 
for PyCon. Start at

http://psf.pollenation.net/

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Reading from input file.

2006-01-11 Thread Sheldon
Hi Kyrstian,

Try reading the file with ope(file,'r').read()
and  then split the string using '\n' as the delimiter (this will break
the file down into each individual line consisting of several columns).
Then string split each line of the file (unsing '  ' as the delimiter),
they should now be 3, or more, columns per line, and store each column
in a vector - adding each line to the vector with append function. Then
place each vector in a list.
Now you  should have a file to compare with the next one. But watch out
for files of varying lengths as they cannot be compared on a one-to-one
basis. One you have each file in a list or vector or dictionary or
array style, comparison and calculations should be straight forward.

Hope this points you in the right direction. I haven't tried this
myself but I have done a similar thing earlier but I strongly believe
that it should work.

Sincerely,
Sheldon

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


Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership!Google, Guido van Rossum, PSF]

2006-01-11 Thread Richard Brodie

Steve Holden [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Wrong [see above]. I don't remember many mediaeval cathedrals falling down.

Your memory of medieval times has gone a bit hazy I expect; in truth,
some would fall down from time to time, particularly if the builders tried
something particularly ambitious. What are left are the good designs. 


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


PyDev 0.9.8.6 released

2006-01-11 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.8.6 has been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.

Details for Release: 0.9.8.6:

Major highlights:
---

   * Added a new 'Pydev project' wizard (Mikko Ohtamaa contribution) -- 
it is named as Pydev Project instead of Python project because it 
creates Python and Jython projects.
   * Added a new 'Pydev module' wizard (Mikko Ohtamaa contribution) -- 
NOTE: it still needs some work.
   * Changes in the shell spawning were done, and no hangs should appear 
when trying to do code-completion anymore (if it still hapens, please 
report it as a bug -- NOTE: a little delay on the first time 
code-completion is executed is expected, as this is the time the shell 
is started).
   * Other bugfixes (as usual)

Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com

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


Re: Bug in struct.pack?

2006-01-11 Thread Raymond Hettinger
[Alex Stapleton]
 from struct import pack
   pack(B, 1)
 '\x01'
   pack(BB, 0, 1)
 '\x00\x01'
   pack(BI, 0, 1)
 '\x00\x00\x00\x00\x01\x00\x00\x00'
   calcsize(BI)
 8
   calcsize(BB)
 2

 Why does an unsigned char suddenly become 4 bytes long when you
 include an unsigned int in the format string? It's consistent
 behaviour but it's incorrect.

You're seeing native alignment come into play.
Specify a standard alignment to avoid padding.

 pack(BI, 0, 1)
'\x00\x00\x00\x00\x01\x00\x00\x00'
 pack(=BI, 0, 1)
'\x00\x01\x00\x00\x00'

All is explained in the docs:
 http://docs.python.org/lib/module-struct.html


Raymond

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


Re: Bug in struct.pack?

2006-01-11 Thread Alex Stapleton
 Idiot.

On 11 Jan 2006, at 10:46, Alex Stapleton wrote:

 from struct import pack
 pack(B, 1)
 '\x01'
 pack(BB, 0, 1)
 '\x00\x01'
 pack(BI, 0, 1)
 '\x00\x00\x00\x00\x01\x00\x00\x00'
 calcsize(BI)
 8
 calcsize(BB)
 2

 Why does an unsigned char suddenly become 4 bytes long when you
 include an unsigned int in the format string? It's consistent
 behaviour but it's incorrect.

 Also.

 calcsize('BL')
 8
 calcsize('BBL')
 8
 calcsize('BBBL')
 8
 calcsize('L')
 8
 calcsize('BL')
 12
 pack(BBBL, 255,255,255,0)
 '\xff\xff\xff\x00\x00\x00\x00\x00' ### That's 3 255's and 5(!?!?)
 0's
 pack(L, 255,255,255,255,0)
 '\xff\xff\xff\xff\x00\x00\x00\x00' # 4 255's and 4 0's!

 Which is all kinds of wrong.

 BL should be 9
 BBL should be 10
 

 Python 2.4.1 (#2, May  5 2005, 11:32:06)
 [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2

 Same behaviour on my PowerBook using

 Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
 [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin

 sizeof(unsigned long) should be 8 on both of these platforms
 sizeof(unsigned char) should be 1 on both as well

 So am I just being stupid and not specifying something I should be?
 Or is struct really that broken?
 -- 
 http://mail.python.org/mailman/listinfo/python-list

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


exec a string in an embedded environment

2006-01-11 Thread Tommy R
Hi all pythonistas!

I have a problem with my embedding of python inside a c app.

very short background
I work on a safety critical embedded application that runs on VxWorks.
I have successfully ported the interpreter to VW. In my solution I have
restricted other classes to use python through my simplified api. Its
a really complex architecture that force me to work this way, I have
encapsulated the entire interpreter with its own memspace and so on.
Redirected all IO signals and such.

To the problem
I need some way to execute a string and pass arguments to the functions
inside the string. We have discussed a solution where we first load the
string (containing some funcs) and then run something similar to
Py_RunString(foo(1.0, 'str'));  We need to do this in a generic way
so we can send in arbitrary arguments.

Can I use Py_CompileString to get a PyObject to that 'module' and then
in some magic way call a function within that module?

I am totaly out of ideas so please help me anyone.


//Tommy

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


Re: String question - find all possible versions of a person's firstname

2006-01-11 Thread bonono

Nico Grubert wrote:
  This sounds like a homework problem.  You might try splitting the name
  at the e's, check the length of the resulting list and do that many
  nested loops.

 This was my idea too but I am wondering if there are any scripts for
 tasks like this.

 Nico

def combine_lol(seq): return reduce(lambda x,y: (a+(b,) for a in x for
b in y), seq, [()])

def shuffle(seq, elem):

hello,eo - helle,hello,hollo,hollo

idx = [i for (i,c) in enumerate(seq) if c in elem]
l = 2**len(idx)
com = combine_lol([elem]*len(idx))
pos = ( zip(*x) for x in izip([idx]*l, com) )
def replace(s, ki):
for i,e in ki: s[i] = e
return s

r = imap(replace, (list(seq) for x in xrange(l)), pos)
if isinstance(seq,basestring): return ( ''.join(x) for x in r)
else: return r

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


Re: Maximum List size (item number) limit?

2006-01-11 Thread Steve Holden
Kriston-Vizi Janos wrote:
 Dear Mr. Kern, and Members,
 
 Thank you very much for the fast answer, my question became 
 over-simplified.
 
 My source code is appended below. It uses two text files (L.txt and 
 GC.txt) as input and merges them. Please find these two files here:
 http://kristonvizi.hu/L.txt
 http://kristonvizi.hu/GC.txt
 
 Both L.txt and GC.txt contains 3000 rows. When running, the code stops 
 with error message:
 
 'The debugged program raised the exception IndexError list index out of 
 range
 File: /home/kvjanos/file.py, Line: 91'
 
This error does not indicate that you cannot add further items to a 
list. It indicates that you are trying to address a list item that 
hasn't yet been added.

It would have been more helpful to post the *whole* traceback. 
Furthermore, why  do you assume that a 999 is an implementation limit on 
the basis of this search result:

 What is the maximum listsize in python? In characters
 or items. Thnx.
 
 2147483647 items, on most platforms.  if you have enough
 memory, that is.

Does 2147483647 look similar enough to 999 to be confusing?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Maximum List size (item number) limit?

2006-01-11 Thread Juho Schultz
Kriston-Vizi Janos wrote:
 Dear Mr. Kern, and Members,
 
 Thank you very much for the fast answer, my question became 
 over-simplified.
 
 My source code is appended below. It uses two text files (L.txt and 
 GC.txt) as input and merges them.
 
 Both L.txt and GC.txt contains 3000 rows. When running, the code stops 
 with error message:
 
 'The debugged program raised the exception IndexError list index out of 
 range
 File: /home/kvjanos/file.py, Line: 91'
 
 And I noticed that all the lists that should contain 3000 items, 
 contains less as follows:
 NIR_mean_l = 1000 items

 Code that's failing:

 # Processing L file
 line_no_l =0# Input L file line number
 type_l = 1  # Input L file row type: 1 (row n),2 (row n+1) or 3 (row n+2)
 # Append L values to lists.
 for line in inp_file_l.xreadlines():
 line_no_l = line_no_l + 1
 if line_no_l == 1:  # To skip the header row
continue  
 data_l = []   # An L row  
 data_l = line.split()
 if type_l == 1: 
NIR_mean_l.append(data_l[2])  # Append 3rd item of the row to the list
NIR_stdev_l.append(data_l[3])  # Append 4th item of the row to the list
type_l = 2  # Change to row n+1
 else:
 if type_l == 2:
 R_mean_l.append(data_l[2])
 R_stdev_l.append(data_l[3])
 type_l = 3
 else:
 G_mean_l.append(data_l[2])
 G_stdev_l.append(data_l[3]) 
 area_l.append(data_l[1])  
 type_l = 1
 inp_file_l.close()
 

Looking at the data files, it seems there is no header row to skip.
Skipping 1st row seems to cause the discrepancy of vector sizes,
which leads to the IndexError. should NIR_mean_l[0] be 203 or 25?

As the comments in your code suggest, the code adds values to
NIR_mean_l only from lines 1, 4, 7, ...
R_mean_l only from lines 2, 5, 8, ...
G_mean_l only from lines 3, 6, 9, ...
Try with 12 lines of input data and see how the vectors
are 4 elements before filtering/writing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python.org website ?

2006-01-11 Thread Fuzzyman
Now that is a very cool site.

I'm not very good with HTML - but can write content... I might see if
there is something I can do.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
(and yes I do get referrals from these links...)

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


Re: How can I test if an argument is a sequence or a scalar?

2006-01-11 Thread Fuzzyman
That's a neat little piece of code there.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

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


Re: File Paramaterized Abstract Factory

2006-01-11 Thread Charles Krug
On 2006-01-11, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Charles Krug wrote:

 What I'd like is to do something like this:

 factoryFile = sys.argv[1] # we assume that argv[1] implements a
   # correct ThingMaker interface.

 sys.argv[1] is a string, so I assume that you meant to say that
 the module named by argv[1] implements the correct interface.

Yes.


 Anywho, my problem is with the whole Miracle thing.

 I've tried using __import__:

 a = 'HerFactory'
 __import(a)

 Which returns:

 module 'HerFactory' from 'HerFactory.py'

 try:

 factoryObject = __import__(factoryFile)
 print dir(factoryObject)


Ah Ha!

That's what comes of working from memory instead of letting the computer
remember for me.

 factoryFile = 'ThingMaker'
 factoryObject = __import__(factoryFile)
 print dir(factoryObject)
['MakeOtherThing', 'MakeThing', '__builtins__', '__doc__', '__file__', 
'__name__']
 factoryObject.MakeThing()
I made a Thing!

Wonderful!  Exactly what I'm after, thanks.

 this should give you a list of the functions in the given module,
 or an ImportError if it doesn't exist.


Yes, that's what I was getting.  Should have pasted that as well, but I
was feeling grumpy and impatient.

Thanx


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


Re: Maximum List size (item number) limit?

2006-01-11 Thread bearophileHUGS
Juho Schultz
NIR_mean_l only from lines 1, 4, 7, ...
R_mean_l only from lines 2, 5, 8, ...
G_mean_l only from lines 3, 6, 9, ...

This can be the problem, but it can be right too.
The following code is shorter and I hope cleaner, with it maybe
Kriston-Vizi Janos can fix his problem.

class ReadData:
def __init__(self, filename):
self.NIR_mean = []
self.NIR_stdev = []
self.R_mean = []
self.R_stdev = []
self.G_mean = []
self.G_stdev = []
self.area = []

for line in file(filename):
row = line.split()
self.area.append(row[1])
self.NIR_mean.append(row[2])
self.NIR_stdev.append(row[3])
self.R_mean.append(row[4])
self.R_stdev.append(row[5])
self.G_mean.append(row[6])
self.G_stdev.append(row[7])

# ---
L = ReadData('L.txt')
GC = ReadData('GC.txt')
out_file = file('merged.txt', 'w')

# Create output rows from lists
for i in xrange(len(L.NIR_mean)): # Process all input rows

# Filter L and GC rows by area values
if (1 = float(L.area[i]) = 10) and \
   (1 = float(GC.area[i]) = 10):

# Create output line and write out
newline = [str(i+1)]
for obj in L, GC:
newline.extend([obj.NIR_mean[i], obj.NIR_stdev[i],
obj.R_mean[i],   obj.R_stdev[i],
obj.G_mean[i],   obj.G_stdev[i],
obj.area[i]])
outline =  '\t'.join(newline) + '\n'
out_file.write(outline)

out_file.close()

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


Re: python-soappy

2006-01-11 Thread tooper
On the client side :
 from SOAPpy import SOAPProxy
 server= SOAPProxy(http://foo.bar.org:8090;)
 print server.Hello(world)

On the server side :
 from SOAPpy import SOAPServer

 def Hello(name):
return Hello +name+ !

 server= SOAPServer((localhost,8080))
 server.registerFunction(Hello)
 server.serve_forever()

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-11 Thread Anton Vredegoor
Alex Martelli wrote:

 Anton Vredegoor [EMAIL PROTECTED] wrote:
...
  You are not my superior (or even considered to be more succesfull) as
  you seem to imply.

 Depends on who does the considering, I'm sure.  If the considerer loves
 the English language, for example, a horrible mis-spelling such as
 successfull with two final L's would count for a lot in their judgment
 (English is neither your native language nor mine, so it's not unfair to
 either of us to consider it...;-).

Well this sums it all up for me, about you. Making stupid claims to
superiority while comfortably sitting at a computer *with a
spellchecker* and denying me the same priviliges, not even by
correcting google's _usenet_ interface (while its mail interface
includes at least a minimally functional editor/spellchecker) to the
point where a comparison would be fair. Stop whining and being
insulted, your elitist selection policies have far more worldwrecking
consequences than a few artificially magnified and misunderstood
'insults'.

Anton

'you could always join the dutch unemployment inquisition'

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


Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]

2006-01-11 Thread A.M. Kuchling
On Tue, 10 Jan 2006 23:13:01 +, 
Steve Holden [EMAIL PROTECTED] wrote:
 attempt to draw direct comparisons. Maybe having an uncle helped you in 
 to the trade, but it didn't cut you much slack in terms of required 
 standards, hence the absence of cathedral-shaped heaps of rubble. York 
 Minster was built in the 1400s, for example, and doesn't look like 
 falling down any time soon.

Googling for cathedral collapse finds an interesting page at
http://www.newcomen.com/excerpts/beauvais.htm:

... As a matter of structural fact there is almost no argument
possible. The decay sensed by the eye after about 1250 stems
from a slow relaxation of the firm structural grasp that had
been acquired during the preceding hundred years.

...

Beauvais seems to have been particularly unfortunate. The apse
and choir were started in 1247, and finished in 1272. On 29
November 1284 the vault fell... Whatever the actual reason, it
was certainly believed at the time that the pier spacing was
too large, and the repairs over the next 50 years included the
intercalation of piers between these originally built for the
choir, so that the bays were halved from about 9m to about
4.5m. ...

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


Re: Maximum List size (item number) limit?

2006-01-11 Thread Juho Schultz
[EMAIL PROTECTED] wrote:
 Juho Schultz
 
NIR_mean_l only from lines 1, 4, 7, ...
R_mean_l only from lines 2, 5, 8, ...
G_mean_l only from lines 3, 6, 9, ...
 
 
 This can be the problem, but it can be right too.

I guess he is expecting 3000 elements, not 1000, as he wrote:

And I noticed that all the lists that should contain 3000 items, 
contains less as follows:
NIR_mean_l = 1000 items
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode Pythonwin / win32 / console?

2006-01-11 Thread Robert

Martin v. Löwis schrieb:
 Robert wrote:
 win32ui.MessageBox(s)
 
  Traceback (most recent call last):
File interactive input, line 1, in ?
  UnicodeEncodeError: 'ascii' codec can't encode characters in position
  12-16: ordinal not in range(128)

 Can't comment on that - this is a PythonWin issue.

 print s
 
  /devel/test\?.txt
 

 I see. You need to do chcp 1251 in your console first, for this
 to print this string correctly (and potentially also set the
 console font to Lucida Console).

is in a PythonWin Interactive session - ok results for cyrillic chars
(tolerant mbcs/utf-8 encoding!).
But if I do this on Win console (as you probably mean), I get also
encoding Errors - no matter if chcp1251, because cyrillic chars raise
the encoding errors also.
I think this is not a good behaviour of python to be so picky. In
[EMAIL PROTECTED] I showed, how I
solved this so far. Any better/portable idea?

 However, if you would do the same on a Russian Windows installation,
 the user will not need to change anything - cyrillic letters come
 out right. Likewise for Umlauts in a German windows installation,
 and Greek letters in a Greek installation.

Yes. But the original problem is, that occasionally unicode strings
(filenames in my case) arise which are not defined on the local
platform, but have to be displayed (in 'replace' - encoding-mode)
without breaking the app flow. Thats the pain of the default behaviour
of current python - and there is no simple switch. Why should print
xy not print something _always_ as good and as far as possible?

Robert

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


Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]

2006-01-11 Thread Anton Vredegoor
Steve Holden wrote:

 Consider yourself excused.

Thanks.

Anton

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


Re: A bug for unicode strings in Python 2.4?

2006-01-11 Thread Szabolcs Nagy
 Thanks. I'll write my own split().

do you want to split character by character?
then use 
list(u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32')

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


how to improve this simple block of code

2006-01-11 Thread py
Say I have...
x = 132.00

but I'd like to display it to be 132 ...dropping the trailing
zeros...I currently try this

if x.endswith(0):
x = x[:len(x)-1]
if x.endswith(0):
x = x[:len(x)-1]
if x.endswith(.):
x = x[:len(x)-1]

I do it like this because if
x = 132.15  ...i dont want to modify it.  But if
x = 132.60 ...I want it to become 132.6

is there a better way to do this?  It seems a bit ugly to me.

T.I.A
(thanks in advance)

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


Re: New Python.org website ?

2006-01-11 Thread Roy Smith
Steve Holden [EMAIL PROTECTED] wrote:

 http://beta.python.org

All I can say is, Wow!.  If nothing else, it will forever eliminate the 
idea that the web site doesn't look professional.  It's almost *too* slick.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python.org website ?

2006-01-11 Thread Steve Holden
Fuzzyman wrote:
 Now that is a very cool site.
 
 I'm not very good with HTML - but can write content... I might see if
 there is something I can do.
 
 All the best,
 
 Fuzzyman
 http://www.voidspace.org.uk/python/index.shtml
 (and yes I do get referrals from these links...)
 
Please note that one major rationale behind the new design is precisely 
becuase relatively few people *are* good with HTML. Consequently Tim 
Parkin, the principal designer of the new architecture, has gone to 
great lengths to design a scheme that allows most of the authoring to be 
done in REstructured Text.

It's quite an legenat design, and if all you want to do is edit content 
rather than change layout it's *very* easy to use. Climb aboard!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: how to improve this simple block of code

2006-01-11 Thread Juho Schultz
py wrote:
 Say I have...
 x = 132.00
 
 but I'd like to display it to be 132 ...dropping the trailing
 zeros...I currently try this
 
 if x.endswith(0):
 x = x[:len(x)-1]
 if x.endswith(0):
 x = x[:len(x)-1]
 if x.endswith(.):
 x = x[:len(x)-1]
 
 I do it like this because if
 x = 132.15  ...i dont want to modify it.  But if
 x = 132.60 ...I want it to become 132.6
 
 is there a better way to do this?  It seems a bit ugly to me.
 
 T.I.A
 (thanks in advance)
 

x = x.rstrip('0') # removes trailing zeros
x = x.rstrip('.') # removes trailing dot(s)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to improve this simple block of code

2006-01-11 Thread py
hanz wrote:
 x = x.rstrip('0.') # removes trailing zeroes and dots

knew there had to be a way, thanks.

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


Re: try: except never:

2006-01-11 Thread Duncan Booth
Tom Anderson wrote:

 class NeverRaised(Exception):
def __init__(self, *args):
raise RuntimeError('NeverRaised should never be raised')
 
 Briliant! Although i'd be tempted to define an
 UnraisableExceptionError to signal what's happened. Or ...
 
 class ImpossibleException(Exception):
   def __init__(self, *args):
raise ImpossibleException, args
 
 Although crashing the interpreter is probably overkill.

Crashng the interpreter would be, but what you just wrote is simply a more 
obscure way of raising RuntimeError :-)

 class ImpossibleException(Exception):
... def __init__(self, *args):
... raise ImpossibleException, args
...
 raise ImpossibleException
Traceback (most recent call last):
  File stdin, line 3, in __init__
RuntimeError: maximum recursion depth exceeded
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Fucking) Unicode: console print statement and PythonWin: replacement for off-table chars HOWTO?

2006-01-11 Thread Robert

Neil Hodgson schrieb:
 Robert:
 PythonWin did have some Unicode support but I think Mark Hammond was
 discouraged by bugs. In pythonwin/__init__.py there is a setting
 is_platform_unicode = 0 with a commented out real test for Unicode on
 the next line. Change this to 1 and restart and you may see

   x = u'sytest3\\\u041f\u043e\u0448\u0443\u043a.txt'
   print x
 sytest3\Пошук.txt
  

thanks for that hint. But found that it is still not consistent or even
buggy:

After is_platform_unicode = auto, scintilla displays some unicode
as you showed. but the win32-functions (e.g. MessageBox) still do not
pass through wide unicode. And pasting/inserting/parsing in scintilla
doesn't work correct:

PythonWin 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
see 'Help/About PythonWin' for further copyright information.
 x = u'sytest3\\\u041f\u043e\u0448\u0443\u043a.txt'
 print x
sytest3\Пошук.txt
 print sytest3\Пошук.txt
sytest3\?.txt

!!!



Then tried in __init__.py to do more uft-8:

default_platform_encoding = utf-8  #mbcs # Will it ever ...this?
default_scintilla_encoding = utf-8 # Scintilla _only_ supports this
ATM

Pasting around in scintilla then works correct. But MessageBox then
shows plain utf-8 encoded chars. Even german umlauts are not
displayable any more on my machine and when opening document files with
above-128 chars, Pythonwin breaks (because files are not valid utf-8
streams, I guess):

 Traceback (most recent call last):
  File
C:\PYTHON23\Lib\site-packages\pythonwin\pywin\scintilla\document.py,
line 27, in OnOpenDocument
text = f.read()
  File C:\Python23\lib\codecs.py, line 380, in read
return self.reader.read(size)
  File C:\Python23\lib\codecs.py, line 253, in read
return self.decode(self.stream.read(), self.errors)[0]
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa9 in position
19983: unexpected code byte
win32ui: OnOpenDocument() virtual handler (bound method
SyntEditDocument.OnOpenDocument of
pywin.framework.editor.color.coloreditor.SyntEditDocument instance at
0x00E356E8) raised an exception


Thus the result is: no combination provides a real improvement so far.
wide unicode in win32-functions is obviously not possible at all.  I
switch back to the original setup.

Guess I have to create special C-code for my major wide unicode needs -
especially listctrl-SetItem and TextOut-Stuff...

Or does anybody know of some existing wide-unicode functions/C-code
parallel to normal pywin32?

Robert

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

Re: New Python.org website ?

2006-01-11 Thread Fuzzyman
Content in ReST - iot ought to be using rest2web then. ;-)

Fuzzyman
http://www.voidspace.org.uk/python/rest2web/

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


Re: New Python.org website ?

2006-01-11 Thread Stefan Rank
on 11.01.2006 11:44 Steve Holden said the following:
 
 http://beta.python.org
 

Very nice!

Just wanted to note that the content area and the menu area overlap 
(leaving some content unreadable)
in Opera 8.51 / WinXP

str

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


for OpenOffice:how acces to file-properties-user defined without xml solution

2006-01-11 Thread nicourjal
is it possible to know user defined properties with python by dealing
with an object or something

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


Re: Spelling mistakes!

2006-01-11 Thread Mike Meyer
Dennis Lee Bieber [EMAIL PROTECTED] writes:
 On Wed, 11 Jan 2006 06:57:06 +, Steve Holden [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:
 I suppose most readers aren't old enough to remember the punch card 
 days, when you would hand your work in on coding sheets to the punch 
 room and it would be punched onto cards using huge machines (anyone 
 remember the 026 and 029 punches?).
   FORTRAN and COBOL on 029s -- and had to submit the school ID card to
 check-out a drum; coding a drum card was actually taught in the COBOL
 class.

Pretty much everything on the 029. Like you, I had to punch things
myself. And had a drum card with one track for FORTRAN and a second
for ALGOL.

Of course, I was employed to work with them. At one point, I actually
helped someone do data processing with the card sorter.

 mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-soappy

2006-01-11 Thread m.banaouas
tooper a écrit :
 On the client side :
  from SOAPpy import SOAPProxy
  server= SOAPProxy(http://foo.bar.org:8090;)
  print server.Hello(world)
 
 On the server side :
  from SOAPpy import SOAPServer
 
  def Hello(name):
   return Hello +name+ !
 
  server= SOAPServer((localhost,8080))
  server.registerFunction(Hello)
  server.serve_forever()
 
look at http://diveintopython.org/, Mark Pilgrim
there is a Python book including interesting chapter about SOAP.

While talking about SOAPpy module, I'm facing an authentication problem 
with it:

I'm consuming a WebServices server requiring authentication, and I did 
not found yet how to give authentication code (username:password) while 
calling any mehode of the webservice.

I did a temp trick around while waiting the *right* solution...

When authentication is not required , it works very well, and the 
automatic introspection is transparently handled by simple or imbriqued 
python types (sequences, etc. ...)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to improve this simple block of code

2006-01-11 Thread Matt Hammond
On Wed, 11 Jan 2006 13:58:05 -, py [EMAIL PROTECTED] wrote:

 Say I have...
 x = 132.00

 but I'd like to display it to be 132 ...dropping the trailing
 zeros...

How about:

   if . in x:
 x, frac = x.split(.)
 frac = frac.rstrip(0)
 if frac:
 x = x + . + frac


Copes if x = 132 too. If there'll always be a decimal point, then you  
can leave off the initial if.



Matt
-- 

| Matt Hammond
| RD Engineer, BBC Research  Development, Tadworth, Surrey, UK.
| http://kamaelia.sf.net/
| http://www.bbc.co.uk/rd/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why keep identity-based equality comparison?

2006-01-11 Thread Mike Meyer
Antoon Pardon [EMAIL PROTECTED] writes:
 Op 2006-01-10, Mike Meyer schreef [EMAIL PROTECTED]:
 Now you can take the practical option and decide that programmatically
 it make no sense to compare a specific couple of values and throw an
 exception in this case, but it doesn't matter much which test you are
 conducting at that point.
 Can you provide a case where having a test for equality throw an
 exception is actually useful?
 I'm not going to bother with that.

Since you're being vague about what you want, and won't provide
examples to show why you want things to behave whatever way you want,
I can't really say much else about it.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Restart process with SIGHUP

2006-01-11 Thread Mike Meyer
[EMAIL PROTECTED] writes:
 I'm trying to restart a process with the os.kill command. My Problem is
 that if the command gets executed, my python script stops working. I
 want to SIGHUP a process with the following command: os.kill(pid,
 signal.SIGHUP).

That looks right.

 Can anyone give me a hint in solving this?

Not without knowing what the problem really is. Show us code. Show us
a traceback (best) or otherwise provide details about what stops
working means.

 mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to improve this simple block of code

2006-01-11 Thread Mike Meyer
py [EMAIL PROTECTED] writes:
 Say I have...
 x = 132.00
 but I'd like to display it to be 132 ...dropping the trailing
 zeros...I currently try this

The two-strip solution is cleaner, but:

 if x.endswith(0):
 x = x[:len(x)-1]
  x = x[:-1]
or
  del x[-1]

both improve that one statement.

  mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Fucking) Unicode: console print statement and PythonWin: replacement for off-table chars HOWTO?

2006-01-11 Thread Thomas Heller
Robert [EMAIL PROTECTED] writes:


 Guess I have to create special C-code for my major wide unicode needs -
 especially listctrl-SetItem and TextOut-Stuff...

 Or does anybody know of some existing wide-unicode functions/C-code
 parallel to normal pywin32?

You could use ctypes to access and call the ...W functions directly.

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


Re: Why keep identity-based equality comparison?

2006-01-11 Thread Antoon Pardon
Op 2006-01-11, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 Op 2006-01-10, Mike Meyer schreef [EMAIL PROTECTED]:
 Now you can take the practical option and decide that programmatically
 it make no sense to compare a specific couple of values and throw an
 exception in this case, but it doesn't matter much which test you are
 conducting at that point.
 Can you provide a case where having a test for equality throw an
 exception is actually useful?
 I'm not going to bother with that.

 Since you're being vague about what you want,

I would like some consistency. Either all comparisons between objects
of different types throw an exception by default or none does.

 and won't provide
 examples to show why you want things to behave whatever way you want,
 I can't really say much else about it.

Did you see examples that show why Guido wants things to behave whatever
way he wants? I didn't and I didn't see examples from you either.

Guido's idea is a change from current behaviour. Each time I saw some
argue a change here, people seem to expect a use case from that person.
So why ask a use case of me and just accepy Guido's idea.

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-11 Thread Christopher Subich
Fredrik Lundh wrote:
TAG.did.you.just.call.me.a.kook.questionmark
 
 
 TAG.no.dash.but.if.you.keep.replying.to.them.all.the.time.i.may.have.to.plonk.you.too.smiley

TAG.you're.it.exclamation.point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Optimal Control Algorithms in Python

2006-01-11 Thread aprasad21k
Is anyone aware of Python code for Optimal Control Algorithms based on
Pontryagin's Maximum Principle? Thanks in advance for any leads on this.

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


Re: how to improve this simple block of code

2006-01-11 Thread Peter Otten
Mike Meyer wrote:

 py [EMAIL PROTECTED] writes:
 Say I have...
 x = 132.00
 but I'd like to display it to be 132 ...dropping the trailing
 zeros...I currently try this
 
 The two-strip solution is cleaner, but:
 
 if x.endswith(0):
 x = x[:len(x)-1]
   x = x[:-1]
 or
   del x[-1]
 
 both improve that one statement.

 del it's tempting not to try[-1]
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: object doesn't support item deletion

Just-pointing-out-what-does-not-work-ly yours

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


Re: Optimal Control Algorithms in Python

2006-01-11 Thread [EMAIL PROTECTED]
Not exactly but I am aware of Python code for nonlinear optimization
algorithms. Check the nlpy project at http://nlpy.sf.net It is
specifically targeted at finite-dimensional problems. However the
current trend in optimal control algorithms is to use grid-refinement
and iteratively solve finite-dimensional problems. You may thus find
nlpy useful. The missing part is the collocation/discretization part.
That may be available some place else.

Similarly, SciPy has some optimization algorithms ready for use but, as
far as I know, nothing for control.

Good luck,
Dominique

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


Python script running as Windows service: Clean shutdown

2006-01-11 Thread Stefan Krah
Hello,

I'm trying to run a Python script as a Windows service with a defined
shutdown. The script (enigma-client.py) handles the communications with
the server in a distributed computing effort and calls a C program
(enigma.exe) to do the computations.

enigma.exe should save its current state when receiving SIGINT or SIGTERM.
This (obviously) works under Unix and also when running the script from the
Windows command line and terminating it with Ctrl-C.

I understand that for a clean shutdown of a Windows service one would
have to use the win32 extensions and have the working thread check
for the shutdown event in short intervals ([EMAIL PROTECTED]).


This would leave me with these options:

 a) Write enigma-client.py as a service. Write enigma.exe as a
service and have it poll regularly for shutdown events.

 b) Have enigma.exe save its state regularly, use srvany.exe
and forget about a graceful shutdown.


I'm new to Windows services, so I'd be grateful for corrections or
better solutions. Here is relevant part of the code (The whole thing
is at http://www.bytereef.org/enigma-client.txt ):



 main 
cmdline = 'enigma.exe -R 00trigr.naval 00bigr.naval 00ciphertext  NUL'
eclient = Eclient()

if len(sys.argv) != 3:
eclient.usage()

if os.path.isfile(LOCKFILE):
print enigma-client: error: found lockfile %s. \n \
  Check that no other enigma-client process is using this directory. \
  % LOCKFILE
sys.exit(1)

atexit.register(eclient.rm_lockfile)
eclient.touch_lockfile()

win32process.SetPriorityClass(
   win32process.GetCurrentProcess(),
   win32process.IDLE_PRIORITY_CLASS
)

while 1:
retval =  os.system(cmdline)  8
if retval == 0:
eclient.submit_chunk(sys.argv[1], int(sys.argv[2]))
eclient.get_chunk(sys.argv[1], int(sys.argv[2]))
elif retval == 1:
eclient.get_chunk(sys.argv[1], int(sys.argv[2]))
time.sleep(10)
else:
./enigma has caught a signal
sys.exit(retval)



Stefan Krah

-- 
Break original Enigma messages:  http://www.bytereef.org/m4_project.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python.org website ?

2006-01-11 Thread Rocco Moretti
Roy Smith wrote:
 Steve Holden [EMAIL PROTECTED] wrote:
 
http://beta.python.org
 
 All I can say is, Wow!.  If nothing else, it will forever eliminate the 
 idea that the web site doesn't look professional.  It's almost *too* slick.

I agree with the too slick impression. The learn why pictures 
particularly unnerve me. It looks like a marketing team with a focus 
group got ahold of the website.

Great for reaching the PHB crowd. I'm not sure what J. Random Hacker 
will think though.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Change Gateway Programmatically

2006-01-11 Thread Tim Golden
[Godwin Burby]
| Subject: Re: Change Gateway Programmatically
| 
| Well netsh turned out to be the perfect solution for my problem(even
| though doing it in python would have given me some kicks).

Just in case you fancied an alternative approach, you can do
this with WMI.

(untested, because I don't want to mess up my gateway)
code
import wmi

c = wmi.WMI ()
nic = c.Win32_NetworkAdapterConfiguration (IPEnabled=True)[0]
print nic.DefaultIPGateway, nic.GatewayCostMetric
nic.SetGateways (DefaultIPGateway=[aaa.bbb.ccc.ddd],
GatewayCostMetric=[20])
/code

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Spelling mistakes!

2006-01-11 Thread skip

Steve I suppose most readers aren't old enough to remember the punch
Steve card days, when you would hand your work in on coding sheets to
Steve the punch room and it would be punched onto cards using huge
Steve machines (anyone remember the 026 and 029 punches?).

I do remember the IBM Model 29 punch card machines, though as a student
nobody was there to punch my cards or verify them for me...  :-(

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


Re: New Python.org website ?

2006-01-11 Thread Mike Meyer
Stefan Rank [EMAIL PROTECTED] writes:

 on 11.01.2006 11:44 Steve Holden said the following:
 http://beta.python.org
 Very nice!
 Just wanted to note that the content area and the menu area overlap
 (leaving some content unreadable)
 in Opera 8.51 / WinXP

Ditto for Opera 8.51 / OSX, and for Safari.

It's a problem with not handling users who need large fonts. I
recreated it in Mozilla by changing the minimum font size setting from
None to 20 (just a value I chose at random). I use Opera and
Safari on a day-to-day basis, and probably configured them
appropriately for my aging eyes.

Of course, this is typical on the web: Works in IE really means
works in IE in the configurations we tested it for, and usually
means works in our favorite configuration.

In particular, creating a good-looking design that remains readable in
all possible browser configurations is impossible. Getting one that is
readable in all reasonable browser configurations is hard, unless you
make your definition of reasonable very narrow.

 mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MVC programming with python (newbie) - please help

2006-01-11 Thread bwaha
snip

Well I read this in daylight hours. Talk about Enlightening!!!. It all
became clear. Now I even understand the point of an observer class, which
was shown in an example I posted back to the group from an earlier reply.

Thanks again for sharing your knowledge.

Be Well and Happy Always

Chris



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


Re: New Python.org website ?

2006-01-11 Thread Fuzzyman

Steve Holden wrote:
 Fuzzyman wrote:
  Now that is a very cool site.
 
  I'm not very good with HTML - but can write content... I might see if
  there is something I can do.
 
  All the best,
 
  Fuzzyman
  http://www.voidspace.org.uk/python/index.shtml
  (and yes I do get referrals from these links...)
 
 Please note that one major rationale behind the new design is precisely
 becuase relatively few people *are* good with HTML. Consequently Tim
 Parkin, the principal designer of the new architecture, has gone to
 great lengths to design a scheme that allows most of the authoring to be
 done in REstructured Text.

 It's quite an legenat design, and if all you want to do is edit content
 rather than change layout it's *very* easy to use. Climb aboard!


Seriously though... I've downloaded the whole shooting match. It's not
*obvious* from trac what needs doing or who's working on what (although
I have yet to trawl through the SVN checkout).

I'd hate to start working on something, only to discover someone else
was already doing it...

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 regards
   Steve
 --
 Steve Holden   +44 150 684 7255  +1 800 494 3119
 Holden Web LLC www.holdenweb.com
 PyCon TX 2006  www.python.org/pycon/

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


PyConn--anyone needing roommates?

2006-01-11 Thread Jeremy Moles
There's a specific list, I believe, for this sort of question, but it
has been surprisingly quiet since I registered. :)

My employer has agreed to send me to PyConn this year (yay!) but I'm on
my own as far as roomage is concerned. If anyone needs another body--or
wants to find another body--I'm game. Anything to keep costs down is
good by me. :)

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


Re: Cross Compile Mips / Linux

2006-01-11 Thread Nick Craig-Wood
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Has anyone successfully built for Mips/Linux using a PC for the
  build??, Should I try using a Linux based machine for the build,
  would that help??

One thing you could try is to build a linux/mips file system image
(say debian which support mips) and run it with quemu on your PC.

  http://fabrice.bellard.free.fr/qemu/
  http://www.debian.org/ports/mips/

  MIPS R4K target Emulation
  Operating SystemState   Tested QEMU version
  GNU/Linux 2.6.14 Debian OK  0.8.0 

I've used a similar technique to cross build stuff for ARM.  I found
the debian ARM python quite sufficient for my needs so I didn't have
to build that!

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


MVC in wxPython HELP!

2006-01-11 Thread meonimarco
Hi to all.
I woud implement MVC with wxPython. Is it possible? Is there anyone
that have experience in this?
The only correct example according to Observer Pattern that i  found on
web is not the formal implementation of MVC (is Document/View) and is
implemented with gtk...
How can i translate this gtk example in wx?
Does exist a tutorial, a archive of example or anything about MVC in
wx?
Thanks all!
Sorry for my italian english!

The gtk example that i talk about in my previous message is here:
http://www.pyj.it/sorgenti/2004/01/doc-view.zip

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


Re: how to improve this simple block of code

2006-01-11 Thread Gary Duzan
py wrote:
 x = 132.15  ...i dont want to modify it.  But if
 x = 132.60 ...I want it to become 132.6
 
 is there a better way to do this?  It seems a bit ugly to me.

The following works as long as you don't mind losing leading zeros 
as well:

x = x.strip('0')

Gary Duzan
Motorola CHS
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MVC in wxPython HELP!

2006-01-11 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

 Hi to all.
 I woud implement MVC with wxPython. Is it possible? Is there anyone
 that have experience in this?
 The only correct example according to Observer Pattern that i  found on
 web is not the formal implementation of MVC (is Document/View) and is
 implemented with gtk...
 How can i translate this gtk example in wx?
 Does exist a tutorial, a archive of example or anything about MVC in
 wx?
 Thanks all!
 Sorry for my italian english!

The problem here is that MVC is not a thing (or class or whatever) that
can demonstrated once and for all, but a design concept for
GUI-applications.

You can do MVC in _all_ toolkits, and html, and even ncurses. Some toolkits
have support built-in in the way that their more complex widgets - like
tables or treeviews - expect a so-called model. That means that instead of
having e.g. a table-row-object that you add to a table and that you fill,
the table will query your model with an interface like this:

class TableModel:
   def __len__(self):
  

   def column_count(self):
  

   def get_value(self, row, column):
  


I have very limited experience with wx - but short googling reveals e.g. 

wx.lib.mvctree

Note the (Basic)TreeModel

Basically, you should try and look for wx(Python)-examples that use tree or
list widgets.

Regards,

Diez


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


Re: Spelling mistakes!

2006-01-11 Thread Hans Nowak
Antoon Pardon wrote:

 Op 2006-01-10, Terry Hancock schreef [EMAIL PROTECTED]:
 
In unit testing, you write the code, then write code to test
the code, which must correctly identify the methods in the
code. So you have to type 'everything' twice.
 
 But you don't type attribute names twice in unit tests,
 because attributes are in general implementation details
 that are of no concern to the tester. So unit tests can
 not introduce the redundancy to find out a missed spelled
 attribute in some methods.

I wouldn't call attributes implementation details, at least not in 
Python.  And while it is true that unit tests might not find the 
misspelling *directly* (i.e. you rarely test if you have misspelled 
something), your tests should definitely show unexpected behavior and 
results, if that attribute is of any importance.  Otherwise there's a 
loophole in your tests. :-)

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Django 0.91 released

2006-01-11 Thread Adrian Holovaty
We're pleased to announce Django 0.91, the result of a month and a half
of feature additions, bug fixes, usability changes and other
improvements to the Django Web framework.

http://www.djangoproject.com/

There are literally hundreds of improvements since version 0.90 -- but
some of the most notable are:

* Merged the new-admin branch, which heavily refactored the way
the admin works, to make it more extensible.

* Changed passwords to be stored with a salt, and with a tighter
(and swappable) encryption algorithm.
http://www.djangoproject.com/weblog/2005/nov/20/passwordchange/

* URLconfs no longer require named groups; you can use simple
parentheses. http://www.djangoproject.com/weblog/2005/nov/28/urls/

* Changed the default project layout to add a manage.py utility,
which avoids frustration with DJANGO_SETTINGS_MODULE.

* Added a gorgeous template-debugging error page in the case of
template syntax errors.
http://www.djangoproject.com/weblog/2005/nov/23/template_errors/

* Added an {% include %} template tag.
http://www.djangoproject.com/documentation/templates/#include

* Added a framework for template context processors.
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext

* Improved the e-mail library to prevent header injections.
http://www.djangoproject.com/documentation/email/#preventing-header-injection

* Added OR lookups to the database API.
http://www.djangoproject.com/weblog/2005/nov/30/or/

* Made the template system scoped to the parser instead of the
template module. Also changed the way tags/filters are registered and
added support for multiple arguments to the {% load %} tag.

In addition to the many, many changes, we've reworked the tutorial to
simplify things -- namely using the new manage.py utility instead of
futzing with the Python path and environment variables.
http://www.djangoproject.com/documentation/tutorial1/

Many thanks to all the great people who've contributed to this project.
You can check them out in the AUTHORS file:
http://code.djangoproject.com/browser/django/trunk/AUTHORS


About Django


Django is a high-level Python Web framework that encourages rapid
development and clean, pragmatic design. It lets you write high-quality
Web apps very quickly, with very little code.

It gives you:

* An object-relational mapper, which currently works with PostgreSQL,
MySQL and SQLite. (Oracle and MS-SQL support are coming.) This lets you
query databases in Python; there's no need to write SQL if you don't
want to.

* A template system.

* A beautiful, production-ready admin interface -- for free.

* Full internationalization (i18n) support.

* A super-cool community!

* An RSS/Atom-producing framework.

* Tons of other niceties, such as generic views (which abstract common
Web-development patterns), based on several years' worth of solving
Real Problems in the Real World.

Enjoy!

The Django team

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

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


Re: MVC in wxPython HELP!

2006-01-11 Thread snoe
See this recent explanation by has:
http://groups.google.ca/group/comp.lang.python/msg/f8990a2c666a793c?hl=en;
(The rest of the thread may lead you to more concrete examples as well.)

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


Re: Why keep identity-based equality comparison?

2006-01-11 Thread Mike Meyer
Antoon Pardon [EMAIL PROTECTED] writes:
 Op 2006-01-11, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 Op 2006-01-10, Mike Meyer schreef [EMAIL PROTECTED]:
 Now you can take the practical option and decide that programmatically
 it make no sense to compare a specific couple of values and throw an
 exception in this case, but it doesn't matter much which test you are
 conducting at that point.
 Can you provide a case where having a test for equality throw an
 exception is actually useful?
 I'm not going to bother with that.
 Since you're being vague about what you want,
 I would like some consistency. Either all comparisons between objects
 of different types throw an exception by default or none does.

That's a very silly thing to ask for. It presumes that all types are
the same. They aren't. It also presumes that all comparisons are the
same. They aren't. To use an overworked analogy, you might as well ask
that you either have to peel all fruit, or that you never have to peel
a fruit.

In any case, the proposeed behavior *is* consistent. The behavior for
all builtin types will be that comparisons that don't make sense will
throw exceptions. Since we're talking about Py3K here, there is no
default behavior. User-defined classes all inherit from builtin
types, and will get the behavior of their comparison operators from
those types. In particular, those that inherit from object will get
objects behavior, which means they'll get equality as identity.

 and won't provide
 examples to show why you want things to behave whatever way you want,
 I can't really say much else about it.
 Did you see examples that show why Guido wants things to behave whatever
 Guido's idea is a change from current behaviour. Each time I saw some
 argue a change here, people seem to expect a use case from that person.
 So why ask a use case of me and just accepy Guido's idea.

For one thing, Guido has a long history of doing excellent Python
design work. For another, this issue was thrashout out at length in
comp.lang.python some years ago. What Guido proposed is inline with
the conclusions of those discussions.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I determine an HTTPMessage ?

2006-01-11 Thread Kevin
Can you tell me what to look for in an HTTPMessage that is an error?  I
have looked at the header objects and I cannot determine an error
message.

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


Re: how to improve this simple block of code

2006-01-11 Thread Matt Hammond
 How about:

if . in x:
  x, frac = x.split(.)
  frac = frac.rstrip(0)
  if frac:
  x = x + . + frac

Or simpler still:

 if . in x:
 x = x.rstrip(0)
 x = x.rstrip(.)


More concise, but slightly less readable IMO:

 if . in x:
 x = x.rstrip(0).rstrip(.)

-- 

| Matt Hammond
| RD Engineer, BBC Research  Development, Tadworth, Surrey, UK.
| http://kamaelia.sf.net/
| http://www.bbc.co.uk/rd/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MVC in wxPython HELP!

2006-01-11 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
 Hi to all.
 I woud implement MVC with wxPython. Is it possible? Is there anyone
 that have experience in this?
 The only correct example according to Observer Pattern that i  found on
 web is not the formal implementation of MVC (is Document/View) and is
 implemented with gtk...
 How can i translate this gtk example in wx?
 Does exist a tutorial, a archive of example or anything about MVC in
 wx?
 Thanks all!
 Sorry for my italian english!
 
 The gtk example that i talk about in my previous message is here:
 http://www.pyj.it/sorgenti/2004/01/doc-view.zip
 
Can I just suggest you search in Google Groups for the message by
has labelled Re: MVC programming with python (newbie) - please help.
Dated: 7 Jan 2006 07:03:04 -0800.  It is one of the nicest short
descriptions of the MVC pattern and why it works.

The link I have is huge, but:
 http://groups.google.com/group/comp.lang.python/browse_thread/
   thread/eb0be1531e010273/
   9b80e79d4706200d?tvc=2q=MVC+daniels#9b80e79d4706200d

I've inserted returns at two points in the url directly after slashes,
drop tose returns and the associated spaces.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Memory Profiler

2006-01-11 Thread Dave
Hi,

Is there any memory profiler for Python programs? I
would like to see how much memory objects take up,
cache misses, etc. I tried to patch PySizer, but got a
build error (Error 138). 

Thanks!

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exec a string in an embedded environment

2006-01-11 Thread Graham Fawcett
Tommy R wrote:
 I need some way to execute a string and pass arguments to the functions
 inside the string. We have discussed a solution where we first load the
 string (containing some funcs) and then run something similar to
 Py_RunString(foo(1.0, 'str'));  We need to do this in a generic way
 so we can send in arbitrary arguments.

You could use

foo_ptr = Py_RunString(foo, Py_eval_input, globals_ptr,
locals_ptr)

to get a reference to the foo function, and then use

result_ptr = PyObject_Call(foo_ptr, args_ptr, kwargs_ptr)

to call it with arbitrary arguments and keyword arguments. Of course,
you're responsible for setting up the globals and locals, as well as
the args list and kwargs dictionary objects.

The PyObject_Call signature, from abstract.h, is:

 PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object,
 PyObject *args, PyObject *kw);

Does this help?

Graham

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


Re: Memory Profiler

2006-01-11 Thread Grig Gheorghiu
See

http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy#MiscellaneousPythonTestingTools

In particular, PySizer and HeapPy might be what you're looking for. I
can't say for sure, since I haven't used these tools myself.

Grig

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


Problems with WX and program loop...

2006-01-11 Thread Mr BigSmoke
Hi everybody... I have an app that has to controll some ascii files
every 10/30 seconds... I was planning to have an GUI using wxpython.
The problems is that i wasn't able to manage my application loop and
the wxApp loop, so my interface is always freezing...
My app do something like this:
- creates a new wx and wxframe instance
- loads some configuration info
- starts looping every 30 seconds (while True: sleep(30); do something,
bla,bla)
- update some labels and textboxes on my frame...

On every loop step, if i find some info in those ascii files i want to
change some labels on my wxFrame... But my frame just freezes...
because of the loop.

Any hint?

I'll post some of the code down here...


...
loadSystemConfiguration() # Carico la configurazione delle tag
dell'intero sistema
self.loadMonitorConfiguration() # Carico le configurazioni del
monitor
# monitorGUI.monitorGUI is my wxFrame class...
self.mG = monitorGUI.monitorGUI(None, app_path, screen_dx=1024,
screen_dy=768)
self.mG.Show()

self.monitorize = True
while self.monitorize:
time.sleep(30)
do my stuff
if something:
  self.mG.status.SetValue(Registering new event...)
  self.mG.Update()



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


Re: OT: Degrees as barriers to entry [was Re: - E04 -Leadership!Google, Guido van Rossum, PSF]

2006-01-11 Thread Fredrik Lundh
Richard Brodie wrote:

  Wrong [see above]. I don't remember many mediaeval cathedrals falling down.

 Your memory of medieval times has gone a bit hazy I expect

probably because he was hit in the head by a falling stone during a trip to 
southern
france, many years ago.

/F



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


The effbot does not exist!

2006-01-11 Thread David Murmann
http://effbot.org/F

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


Re: New Python.org website ?

2006-01-11 Thread rzed
Steve Holden [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Bugs wrote:
 Aahz wrote:
 
Dunno about in time for the new year, but there is a new
design that is supposedly in final stages of getting
implemented.  What's your hurry? 
 
 [...]
 http://beta.python.org
 
So what's the character encoding? I haven't found (WinXP Firefox) 
that displays that city in Sweden without a paragraph symbol or 
worse. 

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


Re: how to improve this simple block of code

2006-01-11 Thread Peter Hansen
py wrote:
 hanz wrote:
x = x.rstrip('0.') # removes trailing zeroes and dots
 
 knew there had to be a way, thanks.

But that's not it. :-)

This is a wonderful opportunity for you to learn about unit testing, and 
begin the long process of developing good testing habits.  Of all the 
ideas posted, I believe only Mark Hammond's would correctly pass the 
basic obvious test cases, and I don't think anyone (without actually 
having checked with tests) should be saying even his is clearly correct.

import unittest
from yourmodule import stripZeros  # or whatever you have

class Tests(unittest.TestCase):
 def test01(self):
 'check zero-stripper'
 for input, expected in [
 ('', ''),
 ('0', '0'),
 ('0.0', '0'),
 ('0.', '0'),
 ('000.', '000'),
 ('10', '10'),
 ('10.0', '10'),
 ('foo', 'foo'),
 ('foo.', 'foo'), # ??
 ('132.15', '132.15'),
 ('132.60', '132.6'),
 ('132.00', '132'),
 ('132.0', '132'),
 ('132.01', '132.01'),
 # add others to taste
 ]:
 self.assertEquals(expected, stripZeros(input))

unittest.main()


Change the above test cases to match what you really want if they're not 
correct, then run the script and make sure everything passes.

-Peter

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


Python Scripts to logon to websites

2006-01-11 Thread BartlebyScrivener
New to Python and Programming. Trying to make scripts that will open
sites and automatically log me on.

The following example is from the urllib2 module.

What are realm and host in this example.

import urllib2
# Create an OpenerDirector with support for Basic HTTP
Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('realm', 'host', 'username', 'password')
opener = urllib2.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib2.install_opener(opener)
urllib2.urlopen('http://www.example.com/login.html')

Does anyone have a simple example of a script that opens, say, gmail or
some other commonly accessed site that requires a username and password
so that I can see how one is made?

Thanks very much for any help.

rpd

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


Re: for OpenOffice:how acces to file-properties-user defined without xml solution

2006-01-11 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
 is it possible to know user defined properties with python by dealing
 with an object or something

Have you investigated the Python interface to the OpenOffice APIs?  I 
don't recall the name offhand, but I'm sure Googling for python 
openoffice would tell you.

If you are in fact using that already, please clarify your question in 
that context since it's obviously crucial to giving you a useful answer.

-Peter

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


Re: Why keep identity-based equality comparison?

2006-01-11 Thread Steven Bethard
Mike Meyer wrote:
 Steven Bethard writes:
 
 Not to advocate one way or the other, but how often do you use
 heterogeneous containers?
 
 Pretty much everything I do has heterogenous containers of some sort
 or another.

Sorry, I should have been a little more specific.  I meant heterogeneous 
containers where you've used the in operator.

 SQL queries made to DP API compliant modules return
 homogenous lists of heterogenous containers. The cgi module turns the
 request string into a dictionary-like container of objects with values
 of different types.

Are the keys of different types too?  Because if the keys are all the 
same types, then using the in operator here wouldn't raise an 
exception.  Unless, of course, you used the in operator on the 
.values() of the dictionary...

 The last thing I did that was both more than a script and didn't use
 either a database or a web front end was (IIRC) a media player for
 multiple media types. It revolved around lists of things to play, and
 the things in question could be any playable object - video or
 audio files, track on a CD, or a DVD, or even a playlist.

That seems pretty reasonable.  Your code used the in operator with 
these lists?

 Come to think of it, recursive data structures of this type - a
 container that contains a heterogenous list of things, possibly
 including instances of the container type itself - are pretty
 common.

Sure.  I have a number of tree-like containers, and in at least a few 
implementations, BranchNode and LeafNode are different classes.  But I 
haven't needed the in operator with these.  With the 
raise-exceptions-between-objects-of-different-types proposal, it would 
probably raise an exception if you tried, but I can't decide whether 
that's a good or a bad thing...

 The other proposal - if I have it right - would not change the
 behavior of equality comparisons between objects of the same class,
 but would make comparisons between objects of different classes raise
 an exception instead of returning false by default.

Perhaps, given duck-typing, a better proposal would be to raise an 
exception if the objects have different interfaces.  Of course, at the 
moment, I can't think of any even vaguely efficient way of checking 
that. ;-)

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


How do initial login/password before can download web file with urllib?

2006-01-11 Thread [EMAIL PROTECTED]
I finally figured out how to use the wonderful module urllib to
download files.

What if web page requires you to fill out a form with login and
password first?

Is this just like any other FORM?  Can login/password from a GET method
form be handled by appending something like ?login=foo,password=bar
to URL?

Is that right way?

Chris

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


batch tiff to jpeg conversion script

2006-01-11 Thread [EMAIL PROTECTED]
Hope it's not inappropriate to post this here.

Could someone critique my code? I have no Python programmers in my
office to show this to. The script works OK, but should I do it
differently? I especially don't like how I check to see if jpegs exist.

The style may not be acceptable to some, but I'm concerned with
substance, not style. Is there a 'more appropriate' way to do this?

Thanks to all who take the time to give advice!

-
import os
import os.path
#From PIL
import Image

def tiff_to_jpeg(path):

for root, dirs, files in os.walk(path):
for f in files:
if os.path.splitext(os.path.join(root,f))[1].lower() ==
.tif:

# If a jpeg is already present. Don't do anything.
if
os.path.isfile(os.path.splitext(os.path.join(root,f))[0] + .jpg):
print A jpeg file already exists for %s %f

# If a jpeg is *NOT* present, create one from the tiff.
else:
outfile = os.path.splitext(os.path.join(root,f))[0]
+ .jpg
try:
im = Image.open(os.path.join(root,f))
print Generating jpeg for %s %f
im.thumbnail(im.size)
im.save(outfile, JPEG, quality=100)
except Exception, e:
print e

# Run Program
path = '.'
tiff_to_jpeg(path)

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


Re: How can I determine an HTTPMessage ?

2006-01-11 Thread Peter Hansen
Kevin wrote:
 Can you tell me what to look for in an HTTPMessage that is an error?  I
 have looked at the header objects and I cannot determine an error
 message.

I think you're missing most of the context and detail that would help us 
provide a useful answer for you.

Think about it from a reader's point of view.  We don't know what 
packages you are using, we don't know what you mean by HTTPMessage (is 
it a specific class, or is it just how you refer to the more generic 
HTTP message entity?), we don't know what version of anything you are 
using or what platform you're on.

-Peter

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


Re: How do initial login/password before can download web file with urllib?

2006-01-11 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
 I finally figured out how to use the wonderful module urllib to
 download files.
 
 What if web page requires you to fill out a form with login and
 password first?
 
 Is this just like any other FORM?  Can login/password from a GET method
 form be handled by appending something like ?login=foo,password=bar
 to URL?
 
 Is that right way?

If by the URL you mean the one that was used to retrieve the page in 
the first place, then the answer is not necessarily, and rarely. 
Generally you need to parse the FORM and use its action attribute as 
the URL, plus whatever form fields are required.  It might be just login 
and password, but the choice of names is form-specific and there may be 
other (even hidden) fields that are required.  Tools such as 
http://wwwsearch.sourceforge.net/mechanize/ can help you with this.

-Peter

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


Re: How do initial login/password before can download web file withurllib?

2006-01-11 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 I finally figured out how to use the wonderful module urllib to
 download files.

 What if web page requires you to fill out a form with login and
 password first?

the examples section shows how to encode form data for either GET
or POST requests:

http://www.python.org/doc/current/lib/node483.html

(look at the page sources to see what the server wants you to use:
http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1 )

/F



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


Re: how to improve this simple block of code

2006-01-11 Thread Peter Otten
Peter Hansen wrote:

 Of all the ideas posted, I believe only Mark Hammond's would correctly 
 pass the basic obvious test cases 

Too bad he didn't post at all :-)

Peter

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


Re: How can I test if an argument is a sequence or a scalar?

2006-01-11 Thread Russell E. Owen
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:

I want to be able to pass a sequence (tuple, or list) of objects to a
function, or only one.

It's easy enough to do:

isinstance(var, (tuple, list))

But I would also like to accept generators. How can I do this?

Anything else is assumed to be a single value (my fault if I pass a
dict or something else to the function) and I make it into a tuple with
a single value (var, ) in order to simplify the algorithm (wasn't there
a special name for a one item tuple? Its been a while since I've
programmed in Python.)

Is there an easy way to do that?

Here is the code I use for that purpose, but it does not handle 
generators or iterators. You could easily combine this with code 
suggested in other replies to accomplish that. (I intentionally excluded 
iterators because I didn't need them and they can be unbounded. Still, 
now that they are so widely used it may be worth reconsidering.)

def isSequence(item):
Return True if the input is a non-string sequential collection,
False otherwise. Note: dicts and sets are not sequential.

try:
item[0:0]
except (AttributeError, TypeError):
return False
return not isString(item)

def isString(item):
Return True if the input is a string-like sequence.
Strings include str, unicode and UserString objects.

From Python Cookbook, 2nd ed.

return isinstance(item, (basestring, UserString.UserString))

def asSequence(item):
Converts one or more items to a sequence,
If item is already a non-string-like sequence, returns it unchanged,
else returns [item].

if isSequence(item):
return item
else:
return [item]

I then use asSequence on each argument that can either be one item or a 
sequence of items (so I can always work on a sequence).

-- Russell

P.S. this code is from RO.SeqUtil 
http://www.astro.washington.edu/rowen/ROPython.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Scripts to logon to websites

2006-01-11 Thread Peter Hansen
BartlebyScrivener wrote:
 New to Python and Programming. Trying to make scripts that will open
 sites and automatically log me on.
 
 The following example is from the urllib2 module.
 
 What are realm and host in this example.

http://www.ietf.org/rfc/rfc2617.txt probably provides more background 
than you want on that topic, but googling for basic authentication and 
maybe realm and/or host will find you other sites with less 
technically detailed material.  The first hit has a little summary 
amidst some Apache-specific detail.

 Does anyone have a simple example of a script that opens, say, gmail or
 some other commonly accessed site that requires a username and password
 so that I can see how one is made?

realm and host are associated with basic authentication and not 
all sites use that.  If the browser pops up a little dialog box of its 
own (i.e not some Javascript-triggered thing) and you have to enter your 
username and password there, that's probably a basic auth (or digest 
auth) site.  If you fill that info into a form (as on gmail.com) you 
don't want any of that realm/host stuff.

I'll leave it to others more expert in this to provide a more directly 
useful answer.

-Peter

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


Re: Problems with WX and program loop...

2006-01-11 Thread Chris Mellon
On 11 Jan 2006 10:33:08 -0800, Mr BigSmoke [EMAIL PROTECTED] wrote:
 Hi everybody... I have an app that has to controll some ascii files
 every 10/30 seconds... I was planning to have an GUI using wxpython.
 The problems is that i wasn't able to manage my application loop and
 the wxApp loop, so my interface is always freezing...
 My app do something like this:
 - creates a new wx and wxframe instance
 - loads some configuration info
 - starts looping every 30 seconds (while True: sleep(30); do something,
 bla,bla)
 - update some labels and textboxes on my frame...

 On every loop step, if i find some info in those ascii files i want to
 change some labels on my wxFrame... But my frame just freezes...
 because of the loop.

 Any hint?

 I'll post some of the code down here...


Welcome to the exciting world of event-based programming ;)

You want to use a wx.Timer to trigger your event every 30 seconds
instead of sleeping.

snip

 

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

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


Re: Reading from input file.

2006-01-11 Thread paczkow
I do not clearly understand what you say.

I am no going to change input files in anyway. I just want to read them
with Python, and postprocess.

I understand:
open(inputfile.txt, 'r').read()
However what you mean saying split the string using '\n'. Where should
I put it? After file name, or what? Sorry, but I am still learing
Python.

Looking forward hearing from you,

Regards

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


  1   2   3   >