[ANN] XPN 0.5.6

2006-03-12 Thread Nemesis
XPN (X Python Newsreader) is a multi-platform newsreader with Unicode
support. It is written with Python+GTK. It has features like
scoring/actions, X-Face and Face decoding, muting of quoted text,
newsrc import/export, find article and search in the body, spoiler
char/rot13, random taglines and configurable attribution lines.

You can find it on:

http://xpn.altervista.org/index-en.html

or

http://sf.net/projects/xpn


Changes in this release:

*  added message-id recognition. Now XPN tries to recognize
   message-ids in the text and make them clickable in order
   to open a search window. 
*  added a dialog window that informs you when XPN downloads new
   articles in watched threads. 
*  some improvements in Global Search, now is possible to perform
   multiple searches. 
*  now XPN checks if there are other istances running (it uses the
   file xpn.lock in the XPN directory). This behaviour should
   prevent database break off. 
*  some fixes in the Score Window 
*  fixed some bugs in header management 
*  fixed a bug that caused crashes with multipart articles with
   email attached

XPN is translated in Italian French and German, if you'd like to
translate it in your language and you are familiar with gettext and
po-files editing please contact me ([EMAIL PROTECTED]).

-- 
No wanna work. Wanna bang on keyboard.
 
 |\ |   |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org


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

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


Re: Xah's Edu Corner: Examples of Quality Technical Writing

2006-03-12 Thread dcrockett355

Please come to my forum. Why others hate America . and invite others to join
in the conversation.
--
View this message in context: 
http://www.nabble.com/Xah%27s-Edu-Corner%3A-Examples-of-Quality-Technical-Writing-t684449.html#a3362284
Sent from the Python - python-list forum at Nabble.com.

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


Re: Python Love :)

2006-03-12 Thread Paddy
Spread the love - tell your Java freinds :-)

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


Re: IOS-style command line interface module?

2006-03-12 Thread [EMAIL PROTECTED]
Are you by any chance referring to the cmd module?

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


Re: New python.org site

2006-03-12 Thread Fredrik Lundh
Michael Tobis wrote:

 Steve, what you say is true. Possibly people who are experienced in
 making a six page site for their aunt's catering business may not
 understand how much the site implementation is constrained by the huge
 amount of existing content

the problem with the new python.org is that the tool makers have treated
it as a 6-page site for their aunt's catering business, and have attempted
to address the rest with manpower.

you may be impressed with people who compensate idiotic approaches
with more man hours, but I'm not.  bulk translation of HTML content is
pretty easy if you use the right Python tools, especially when most of
the material can be translated from HTML to HTML.

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
A.M. Kuchling wrote:

 richard [EMAIL PROTECTED] wrote:
  So I did what people always do in this situation, I asked Barry Warsaw to
  name. it. And he did, Cheese Shop. I liked the name, so it was done. When
  the new pydotorg machines went live last year, so too did the name
  cheeseshop.python.org

 Given the endless whiny complaints about the name, though, I think we
 should just give up and go back to PyPI (pronounced 'Pippy').

just change the link on the main site to read packages, change the self-
references on the cheeseshop.python.org page to Packages or Package
Index, move the quote down to the bottom of the page, and and leave
the rest as is.

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
 just change the link on the main site to read packages

and while you're at it, change python-dev to developers and
psf to foundation (or use a title on that link).

/F



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


python crashes in Komodo

2006-03-12 Thread swisscheese
Using the Komodo IDE under XP I often get python.exe has encountered a
problem and needs to close. Running python direct on the same app
gives a list index out of bounds error. Any ideas how to get Komodo to
give the proper error?

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


Re: Is the standard output thread-safe?

2006-03-12 Thread Skull
Fernando Rodríguez [EMAIL PROTECTED] writes:

 Hi,

 Is the standard output thread-safe? Can I use print from several
 threads without having to use a mutex?

 Thanks



Check this: 
http://me.in-berlin.de/doc/python/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe

from my experience, it seems 'print' is not thread-safe. especially
when it is called with formated string, such as:

print id:%d, my_id

I think it is not an atomic operation.

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


Pythons (undefined) Practical Atoms ? - Re: RuntimeError: dictionary changed ...

2006-03-12 Thread robert
Alex Martelli wrote:

 robert [EMAIL PROTECTED] wrote:
...
 
What? When I add/del an item to a dict or list, this is not an atomic
thread-safe operation?
 
 Exactly: there is no such guarantee in the Python language.
 
E.g.:
One thread does things like  d['x']='y'
Another thread reads d['z'] or sets  d['z']='w' or dels something.

If those operations are not atomic, then you'd have to use locks all the
time to not get RuntimeErrors and worse !?
 
 If you want to be writing correct Python, yes. A preferred approach is
 to simply avoid sharing objects among threads, except for objects
 designed to be thread-safe (chiefly Queue.Queue).

I don't know the Python language (non?-)definition about this. But the 
day, that will be a requirement in the Python implementation, I'll put 
the last Python in a safe :-)  ( ..and rethink my bad opinion about Ruby )

For example hundreds of things like sre._cache  and tenthousands of 
common global variables are shared thread safe in the standard lib 
whithout locks.

;-)  They never will change any Python implementation and do the work to 
put millions of lock.acquire()'s into the standard lib...


Infact I rely on that all the time and standard python modules also do
so AFAIK
 
 You're relying on an accident of a specific, particular implementation;
 if any Python-coded standard library module does likewise, and I'm not
 aware of any, that's somewhat different (since that module is PART of
 the implementation, it may rely on all kinds of implementation details,
 correctly if maybe not wisely). The situation is quite different for
 C-coded modules in the CPython implementation, Java-coded ones in the
 Jython one, C#-coded one in the IronPython one; each of these is subject
 to specific constraints that it's perfectly wise to rely on (since each
 implementation, as the language specification fully allows it to do,
 adopts a different locking strategy at these low levels).

the other implementations whould also have a hard time to rewrite the 
standard lib.
Python byte code is kind of defined and always interpreted similar and..

  d={'a':1}
  def f():
... print d['a']
... print d.keys()
... d['b']=2
... 
  dis.disassemble(f.func_code)
   2   0 LOAD_GLOBAL  0 (d)
   3 LOAD_CONST   1 ('a')
   6 BINARY_SUBSCR
   7 PRINT_ITEM
   8 PRINT_NEWLINE

   3   9 LOAD_GLOBAL  0 (d)
  12 LOAD_ATTR1 (keys)
  15 CALL_FUNCTION0
  18 PRINT_ITEM
  19 PRINT_NEWLINE

   4  20 LOAD_CONST   2 (2)
  23 LOAD_GLOBAL  0 (d)
  26 LOAD_CONST   3 ('b')
  29 STORE_SUBSCR
  30 LOAD_CONST   0 (None)
  33 RETURN_VALUE
 


..things like LOAD_CONST / STORE_SUBSCR will be atomic as long as there 
is a GIL or at least a GIL during execution of one byte code. No 
threaded script language can reasonably afford to have thread-switching 
open down to native microprocessor execution atoms.


I think cPickle has not necessarily to iterate free over native dicts.
 
 It's not forced to by language specification, but neither is it
 forbidden. It would be an absurd implementation strategy to waste time
 and space to extract a dict's keys() first, as it would NOT buy
 atomicity anyway -- what if some other thread deletes keys while
 you're looping, or calls any nonatomic method on the very value you're
 in the process of serializing?!

First I look at the practical requirement: I have the threads and the 
fast object tree and the need to autosave in this process. And don't 
want to lock everywhere any dict-access to the tree just because of the 
autosave (for app-reasons I need only a handful of locks so far). And I 
don't want to use a slow  overkill method like ZODB.

One clean method (A) in order to stay practical would be possible if a 
global lock for Python treading would be offered by the thread-lib as 
described in [EMAIL PROTECTED]

The other method (B), (that I believed to use so far) is to have a 
little discipline, but no need for massive trivial locking:
* add complex objects to the hot tree only if the objects are 
complete/consistent.
* don't do nasty things on removed complex objects; just forget them as 
usual
* most attribute changes are already app-atomic; the overall majority of 
operations is read-only access anyway - both regarding the number of 
executions and the amount of source code (that is 99% the reason for 
using this disciplined method in threaded apps)
* ..in case of non-atomic attribute changes, create a new appropriate 
top object with compound changes (same logic as in fact you have, when 
you use ZODB) and replace the whole top object in one step. Or use locks 
in rare cases.

Now a practical autosave method in my app could fit to such practical 
disciplined method ( or not :-( 

Re: Python IDE: great headache....

2006-03-12 Thread Dag Fjeld Edvardsen
I like PyScripter. It has some of, but not all, the
features you request.
http://mmm-experts.com/Products.aspx?ProductId=4

  -Dag


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


[ANN] XPN 0.5.6

2006-03-12 Thread Nemesis
XPN (X Python Newsreader) is a multi-platform newsreader with Unicode
support. It is written with Python+GTK. It has features like
scoring/actions, X-Face and Face decoding, muting of quoted text,
newsrc import/export, find article and search in the body, spoiler
char/rot13, random taglines and configurable attribution lines.

You can find it on:

http://xpn.altervista.org/index-en.html

or

http://sf.net/projects/xpn


Changes in this release:

*  added message-id recognition. Now XPN tries to recognize
   message-ids in the text and make them clickable in order
   to open a search window. 
*  added a dialog window that informs you when XPN downloads new
   articles in watched threads. 
*  some improvements in Global Search, now is possible to perform
   multiple searches. 
*  now XPN checks if there are other istances running (it uses the
   file xpn.lock in the XPN directory). This behaviour should
   prevent database break off. 
*  some fixes in the Score Window 
*  fixed some bugs in header management 
*  fixed a bug that caused crashes with multipart articles with
   email attached

XPN is translated in Italian French and German, if you'd like to
translate it in your language and you are familiar with gettext and
po-files editing please contact me ([EMAIL PROTECTED]).

-- 
No wanna work. Wanna bang on keyboard.
 
 |\ |   |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org


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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Parkin
Fredrik Lundh wrote:
just change the link on the main site to read packages
 
 
 and while you're at it, change python-dev to developers and
 psf to foundation (or use a title on that link).
 
 /F

For most people 'developers' would mean people developing *with* python,
not developing python.

Also 'Foundation' could be confused with 'beginners' or 'basic'.

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Tim Parkin wrote:

 For most people 'developers' would mean people developing *with* python,
 not developing python.

the page it leads has headings that say Python Developers Guide and
Links for Developers, and contains links about Development Process,
Developer FAQ, etc.

I'm convinced that people visiting python.org can distinguish between
using python to develop stuff and developing python, but that's me.

 Also 'Foundation' could be confused with 'beginners' or 'basic'.

while PSF is completely incomprehensible for someone who doesn't
already know what it is...  why even keep it on the front page ?

(give it its own section on the community page instead.  the link is
already there; all it needs is a heading and a short blurb).

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Parkin
Fredrik Lundh wrote:
 Tim Parkin wrote:
 
 
For most people 'developers' would mean people developing *with* python,
not developing python.
 
 
 the page it leads has headings that say Python Developers Guide and
 Links for Developers, and contains links about Development Process,
 Developer FAQ, etc.
I think telling people they are in the wrong place isn't quite as good
as helping them get to the right place.

 I'm convinced that people visiting python.org can distinguish between
 using python to develop stuff and developing python, but that's me.
Simple user questions (i.e. asking people what they think a 'developers'
link would lead to on a programming site) suggests that the majority of
people think differently to you.

Also 'Foundation' could be confused with 'beginners' or 'basic'.
 
 while PSF is completely incomprehensible for someone who doesn't
 already know what it is...  why even keep it on the front page ?
Usability says that people choose the first appropriate link to click
on.  They will only click on psf if they already know what it is. If it
was called *foundation* and they were a beginner then they may well
click on 'foundation'. If they wanted to know about the support and
community behind python, that material should be obviously placed under
'community' and the information should also be under 'about'.

Navigation usability isn't about trying to make every link mean
something to every user, it's about making sure that for each use case,
a clear path to the information is available. The difference is subtle
but important.

Calling the link *foundation* goes halfway to solving the problem in the
wrong place.

 
 (give it its own section on the community page instead.  the link is
 already there; all it needs is a heading and a short blurb).
 
It was in the community section but most people wanted it back on the
top level.

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Tim Parkin wrote:

 Simple user questions (i.e. asking people what they think a 'developers'
 link would lead to on a programming site) suggests that the majority of
 people think differently to you.

so where's this mythical user group that you're using for the site testing ?

/F



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


Python and Dbxml

2006-03-12 Thread Raffaele
Hi all,

is here anyone who can help me with python and Dbxml???

I've tried the example of python that I found in dbxml\docs\, but I 
don't understand how to use XMLResolver.

I'm new in python and Xml, so if you can give me some example it's the best.

Thank you, Raffaele 


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


Cross Module Command Useage

2006-03-12 Thread Keith








Ok so Im new to the python programming language
and this is my first post to this mailing list so here it is



So lets say have two modules.. moduleA and moduleB
they are both imported into a main python program using the from module
import * command now moduleA has a dynamic command that needs to access
a command that is in moduleB but when I run these modules from the main
python scrip they cant see each other. it gives me an error that the
command does not exist Dose this mean that I need to import moduleB into
moduleA for it to see it or is there a way that I can tell moduleA too
look out to the main python program for the commands 



I would hate to have to import lets say the socket
module into every module rather than just having it look to the main module for
the commands










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

Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Parkin
Fredrik Lundh wrote:

Tim Parkin wrote:

  

Simple user questions (i.e. asking people what they think a 'developers'
link would lead to on a programming site) suggests that the majority of
people think differently to you.



so where's this mythical user group that you're using for the site testing ?

/F


  

freinds and colleagues both online and off.. Some of whom are python
programmers, most not. Without a budget for 'comprehensive testing' then
the next best thing is asking people, at least you'll generally get rid
of the big bloopers.. it's typically referred to as guerilla testing and
whilst not scientific, it's better than nothing at all.

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Peter Decker
On 3/12/06, Tim Parkin [EMAIL PROTECTED] wrote:
 freinds and colleagues both online and off.. Some of whom are python
 programmers, most not. Without a budget for 'comprehensive testing' then
 the next best thing is asking people, at least you'll generally get rid
 of the big bloopers.. it's typically referred to as guerilla testing and
 whilst not scientific, it's better than nothing at all.

I consider myself a Python developer, and if I saw a 'Developers' link
on a Python site, it would seem obvious that it would be something
that might interest me. It would not occur to me that this referred to
people who are developing the language itself.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross Module Command Useage

2006-03-12 Thread Peter Decker
On 3/12/06, Keith [EMAIL PROTECTED] wrote:
 So lets say have two modules.. moduleA and moduleB… they are both imported
 into a main python program using the from module import * command…

There's your big mistake. This sort of import pollutes the namespace,
because now all the items in the module are no longer linked by their
module name. You're much better off doing a straight 'import module'
command.

 now moduleA has a dynamic command that needs to access a command that is in
 moduleB… but when I run these modules from the main python scrip they cant
 see each other…. it gives me an error that the command does not exist… Dose
 this mean that I need to import moduleB into moduleA for it to see it… or is
 there a way that I can tell moduleA too look out to the main python program
 for the commands…

If you use the import format above, it's simple: if you want to call a
ModuleB command, the syntax is ModuleB.command().

The big advantage of preserving the module namespaces is that if both
ModuleA and ModuleB have a function with a common name, such as
'start()', there is no confusion as to which one you are calling.
Spelling out ModuleA.start() and ModuleB.start() takes care of all
possible ambiguities.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Peter Decker wrote:

 I consider myself a Python developer, and if I saw a 'Developers' link
 on a Python site, it would seem obvious that it would be something
 that might interest me.

even when it appeared below News, Documentation, Download,
Community, and Links buttons on a site dedicated to the Python
programming language ?

who would you, intuitively, think that the other buttons were tar-
geted for ?

(and why wouldn't the development process behind Python be
of interest to you, btw?  don't tell me that you've never dis-
covered a bug in Python or its documentation... ;-)

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Aahz wrote:

 Given the number of people who post off-topic to python-dev, I don't
 agree with you.

have you ever asked them where they found the mail address?

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Tim Parkin wrote:

  the page it leads has headings that say Python Developers Guide and
  Links for Developers, and contains links about Development Process,
  Developer FAQ, etc.

 I think telling people they are in the wrong place isn't quite as good
 as helping them get to the right place.

you read that backwards, by the way: the site uses Development and
Developers in lots of places to refer to Development of Python.  it very
seldom uses these words to refer to Using Python to Develop Other Stuff.

I surely hope you're not optimizing the site only for people who don't in-
tend to leave the front page...

/F



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


Re: time series calculation in list comprehension?

2006-03-12 Thread Jim Segrave
In article [EMAIL PROTECTED],
falcon [EMAIL PROTECTED] wrote:
Is there a way I can do time series calculation, such as a moving
average in list comprehension syntax?  I'm new to python but it looks
like list comprehension's 'head' can only work at a value at a time.  I
also tried using the reduce function and passed in my list and another
function which calculates a moving average outside the list comp. ...
but I'm not clear how to do it.  Any ideas?  Thanks.

I used the following to return an array of the average of the last n
values -it's not particularly pretty, but it works

# set number of values to average
weighting = 10

# an array of values we want to calculate a running average on
ratings = []
# an array of running averages
running_avg = []

# some routine to fill ratings with the values
r = random.Random()
for i in range(0, 20):
  ratings.append(float(r.randint(0, 99)))

for i in range(1, 1 + len(ratings)):
  if i  weighting:
running_avg.append(ratings[i - 1])
  else:
running_avg.append(reduce(lambda s, a: s+ a,
  ratings[i - weighting : i]) /
   len(ratings[i - weighting : i]))

for i in range(0, len(ratings)):
print %3d: %3d %5.2f % (i, ratings[i], running_avg[i])


sample output:
  0:  34 34.00
  1:  28 28.00
  2:  58 58.00
  3:  16 34.00
  4:  74 44.00
  5:  32 45.00
  6:  74 49.00
  7:  21 50.25
  8:  78 51.25
  9:  28 50.25
 10:  32 39.75
 11:  93 57.75
 12:   2 38.75
 13:   7 33.50
 14:   8 27.50
 15:  30 11.75
 16:   1 11.50
 17:   8 11.75
 18:  40 19.75
 19:   8 14.25

For all but the first 3 rows, the third column is the average of the
values in the 2nd column for this and the preceding 3 rows. 



-- 
Jim Segrave   ([EMAIL PROTECTED])

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


Re: put multiple condition in if statement

2006-03-12 Thread Jim Segrave
In article [EMAIL PROTECTED],
Dennis Lee Bieber  [EMAIL PROTECTED] wrote:
On 10 Mar 2006 21:12:57 -0800, [EMAIL PROTECTED] declaimed the
following in comp.lang.python:

 How can I put multiple condition in if statement?

   Lesson one: Python is NOT C
 
 I try this, but I can't get that to work.
 
 if ( (str !=  )  (str != ) ):

   Lesson two: an empty (aka, null) string is false, and a non-empty
string is true, so that gives us

   Lesson three:   is not equal toor  so you
might want to do strip whitespace first...

  ==  
False
   ==   
False
 .strip() ==   .strip()
True
 

   So... Your mixed C/Python simplifies to just...

   if str.strip(): # after removing leading/trailing spaces, 
   # if not empty, do something

str =  
and
str = \t 
fail with your substitution - the OP was looking only for strings
containing one space or empty strings. Tab characters and multi-spaces
would not match. 

-- 
Jim Segrave   ([EMAIL PROTECTED])

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Paul Boddie
Fredrik Lundh wrote:
 Peter Decker wrote:

  I consider myself a Python developer, and if I saw a 'Developers' link
  on a Python site, it would seem obvious that it would be something
  that might interest me.

Re-adding the missing disambiguating text:

It would not occur to me that this referred to people who are
developing the language itself.

 even when it appeared below News, Documentation, Download,
 Community, and Links buttons on a site dedicated to the Python
 programming language ?

 who would you, intuitively, think that the other buttons were tar-
 geted for ?

Both people who develop with Python and people who develop Python
itself.

 (and why wouldn't the development process behind Python be
 of interest to you, btw?  don't tell me that you've never dis-
 covered a bug in Python or its documentation... ;-)

True. But take a look at these two examples for the confusion we're
seeing here:

http://www.postgresql.org/
http://www.trolltech.com/

The first site has a Developers link which tells you after you've
visited the linked page that they meant developers of PostgreSQL by
the term; the second site has a Developer link which provides
resources for people using the company's products to write solutions.

It's clear that people use the term Python developer similarly to
Oracle developer, where you don't get many people in the wild
actually developing Oracle products themselves, and so the term has an
established meaning of someone developing with that technology. Thus,
many people, especially those accustomed to using more corporate
technologies like Oracle or Java would see Developers or Developer
links and think of stuff they can develop with, rather than finished
applications or solutions, for example; it certainly wouldn't occur to
them that the links would point to some internal Oracle portal strictly
for Oracle development staff, some Sun portal for Java development
staff, or tools for working on the Python implementation.

Paul

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Peter Decker
On 3/12/06, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Peter Decker wrote:

  I consider myself a Python developer, and if I saw a 'Developers' link
  on a Python site, it would seem obvious that it would be something
  that might interest me.

 even when it appeared below News, Documentation, Download,
 Community, and Links buttons on a site dedicated to the Python
 programming language ?

 who would you, intuitively, think that the other buttons were tar-
 geted for ?

I would expect 'Documentation' would lead to docs about *using*
Python, not about the nuts and bolts that go into enabling Python to
do its magic. Similarly, I would expect 'News' to be news that would
be relevant to the users of the language, 'Community' to be about the
community of people who use Python, etc.

The number of people who could potentially be Python developers is
immense compared to the number who will ever look at the source code
behind it, much less tinker with it.

 (and why wouldn't the development process behind Python be
 of interest to you, btw?

Probably because I have other work to do, and I use Python as the tool
to get that work done. If I were a baker, I would be preoccupied with
keeping my bakery in business; I wouldn't be spending much time
studying flour mills or wheat farming, even though those endeavors
make my bakery possible.

 don't tell me that you've never dis-
 covered a bug in Python or its documentation... ;-)

Can't say I've ever run into anything that hadn't already been
reported. But even if I did, my C skills are nowhere near good enough
to be able to delve into the source code and correct it. That doesn't
make me any less of a Python developer, though.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Paul Boddie wrote:

 It's clear that people use the term Python developer similarly to
 Oracle developer, where you don't get many people in the wild
 actually developing Oracle products themselves, and so the term has an
 established meaning of someone developing with that technology. Thus,
 many people, especially those accustomed to using more corporate
 technologies like Oracle or Java would see Developers or Developer
 links and think of stuff they can develop with, rather than finished
 applications or solutions, for example; it certainly wouldn't occur to
 them that the links would point to some internal Oracle portal strictly
 for Oracle development staff, some Sun portal for Java development
 staff, or tools for working on the Python implementation.

this assumes that the developers link lead to a page that's entirely
useless for people developing with Python.  that's not even true for
today's developer page...

(I'd solve this by adding disambiguation to the page itself, since
people can arrive on it in many different ways.  good information
design is not only about what's on the front page...)

/F



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


Re: Why property works only for objects?

2006-03-12 Thread Michal Kwiatkowski
Alex Martelli napisał(a):
 Can you also check my reasoning for getting attributes?

 value = obj.attr
   * if instance class has __getattribute__, call it
   * else: lookup attr in all parent classes using class __mro__;
 if it's a descriptor call its __get__ method, return its value
 otherwise (when descriptor doesn't have __get__, it's unreadable
 and AttributeError is raised)
   * else: check instance __dict__ for attr, return it when found
   * else: lookup __getattr__ in instance class and call it when found
   * else: raise AttributeError
 
 No, the value found in the instance (your second 'else' here) takes
 precedence if the descriptor found in the first 'else' is
 non-overriding.

Oh, right. My mistake comes from the subtle difference between defining
descriptor as a class and by property() builtin (I've tested only second
option and assumed that descriptor without __set__ cannot be rebinded):

class non_overriding(object):
def __get__(*a):
return 12

class C(object):
x = non_overriding()
y = property(lambda s:23)

c = C()

c.x = 4
print c.x # = 4

c.y = 5  # = AttributeError: can't set attribute

IMHO that's not very consistent. Well, probably some code rely on this,
so I just have to live with it.

Thanks for your time and patience in explaining my doubts.

mk
-- 
 . o . http://joker.linuxstuff.pl  
 . . o   It's easier to get forgiveness for being wrong
 o o o   than forgiveness for being right.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: time series calculation in list comprehension?

2006-03-12 Thread Raymond Hettinger
[Peter Otten]
 from __future__ import division

 from itertools import islice, tee, izip
 . . .
 def moving_average2(items, n):
 first_items, last_items = tee(items)
 accu = sum(islice(last_items, n-1))
 for first, last in izip(first_items, last_items):
 accu += last
 yield accu/n
 accu -= first

 While moving_average1() is even slower than your inefficient variant,
 moving_average2() seems to be a tad faster than the efficient one.

This is nicely done and scales-up well.  Given an n-average of m-items,
it has O(n) memory consumption and O(m) running time.  In contrast, the
other variants do more work than necessary by pulling the whole
sequence into memory or by re-summing all n items at every step,
resulting in O(m) memory consumption and O(m*n) running time.

This recipe gets my vote for the best solution.


Raymond

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Parkin
Fredrik Lundh wrote:
 Tim Parkin wrote:
 I surely hope you're not optimizing the site only for people who don't in-
 tend to leave the front page...
 

I sureley hope you can stop being facetious..

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


Re: Why property works only for objects?

2006-03-12 Thread Alex Martelli
Michal Kwiatkowski [EMAIL PROTECTED] wrote:
   ...
  No, the value found in the instance (your second 'else' here) takes
  precedence if the descriptor found in the first 'else' is
  non-overriding.
 
 Oh, right. My mistake comes from the subtle difference between defining
 descriptor as a class and by property() builtin (I've tested only second
 option and assumed that descriptor without __set__ cannot be rebinded):

property is always overriding, of course, since type property does have
a property.__set__ (which raises an exception if you build the instance
of property w/o a setter function).

 class non_overriding(object):
 def __get__(*a):
 return 12
 
 class C(object):
 x = non_overriding()
 y = property(lambda s:23)
 
 c = C()
 
 c.x = 4
 print c.x # = 4
 
 c.y = 5  # = AttributeError: can't set attribute

Right: another example of overriding and nonoverriding descriptors.

 IMHO that's not very consistent. 

How so? Given the lower-level semantics of descriptors (and the
distinction between overriding and non), are you suggesting that
property should not be a type but a factory function able to return
instances of either overriding or non-overriding types? I'm not sure how
that complication would make things consistent in your view.

 Well, probably some code rely on this,
 so I just have to live with it.

Backwards-incompatible changes can be proposed for Python 3.0, if they
lead to a situation that's preferable to what we have now. I just don't
see what you mean about not very consistent and what you would prefer
the language and built-ins to be.


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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Peter Decker wrote:

 Can't say I've ever run into anything that hadn't already been
 reported.

how did you check if it was already reported ?

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Peter Decker
On 3/12/06, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Peter Decker wrote:

  Can't say I've ever run into anything that hadn't already been
  reported.

 how did you check if it was already reported ?

I asked about it on this list, or on the wxPython list, or whatever
was the appropriate list. That's my first response; if people on the
list had confirmed it as a bug, I would have then asked where to
report it.

Of course, you're straying so far from the original thought behind
this thread, and that is that the Python website is using some terms
differently than the majority of people who will eventually use the
site would understand them. The number of people who are brilliant
enough to actually contribute to the development of the Python
language is miniscule compared to the potential number of programmers
out there who could adopt Python as their language of choice, and thus
consider themselves 'Python developers'.

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Peter Decker wrote:

 I would have then asked where to report it.

on the earlier site, there was a link on the frontpage.  on the current
site, you'll have to look under python-dev (or in a group of links de-
scribed as developer info on the download site).

 Of course, you're straying so far from the original thought behind
 this thread, and that is that the Python website is using some terms
 differently than the majority of people who will eventually use the
 site would understand them.

no, I'm saying that we should realize that we have to live with that
ambiguity, and fix the site so that someone who's not the right kind
of developer doesn't have to use the back button, whether he/she
arrives on the developer pages via google, via the front-page, or via
some other python developer link on or off the site.

/F



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


Tkinter / Mac OS X Question (Aqua vs. X11)

2006-03-12 Thread [EMAIL PROTECTED]
I am running Mac OS X.  I have Tcl/Tk installed.  I can run the Aqua
version (TkAqua) of wish by typing 'wish' at a terminal prompt.  I can
run the X11 version (TkX11) of wish by typing 'wish8.4-X11' in an
x-term.  If I run python and import Tkinter it always grabs the TkAqua
version.  How can I get Tkinter to load the TkX11 version?

I want to be able to switch back and forth between the two at will.

Thanks
David

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


Re: Why property works only for objects?

2006-03-12 Thread Michal Kwiatkowski
Alex Martelli napisał(a):
 IMHO that's not very consistent. 
 
 How so? Given the lower-level semantics of descriptors (and the
 distinction between overriding and non), are you suggesting that
 property should not be a type but a factory function able to return
 instances of either overriding or non-overriding types? I'm not sure how
 that complication would make things consistent in your view.

Nothing in property documentation suggest that if you don't define
__set__ method, you won't be able to set an attribute. It just states
Return a property attribute for new-style classes. After reading a bit
about descriptors I've just assumed that property is a handy way to
create (any) descriptors. Learning that it only creates overriding
descriptors was a bit shocking. I'm not suggesting it's bad behavior,
only that it seemed unexpected for an unaware programmer. What at first
glance looked like a shortcut, turned out to be designed for a specific
use case.

mk
-- 
 . o . http://joker.linuxstuff.pl  
 . . o   It's easier to get forgiveness for being wrong
 o o o   than forgiveness for being right.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ron Adam
Fredrik Lundh wrote:
 Tim Parkin wrote:

 Also 'Foundation' could be confused with 'beginners' or 'basic'.
 
 while PSF is completely incomprehensible for someone who doesn't
 already know what it is...  why even keep it on the front page ?

Looks like a good place for a tool tip,  PSF is obviously an acronym, so 
how about having the full name pop up when the mouse is over it?

I think the PSF is important enough to have a link on *every* page. It 
doesn't need a lot of space, but it should be easy to get to from 
anywhere on the web site.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Love :)

2006-03-12 Thread al pacino

Paddy wrote:
 Spread the love - tell your Java freinds :-)

well said paddy ! :-))

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Fredrik Lundh
Ron Adam wrote:

 I think the PSF is important enough to have a link on *every* page. It
 doesn't need a lot of space, but it should be easy to get to from
 anywhere on the web site.

a copyright blurb at the bottom of the page would be one obvious place to
put it.

/F



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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Steve Holden
Tim Parkin wrote:
 Fredrik Lundh wrote:
 
Tim Parkin wrote:
I surely hope you're not optimizing the site only for people who don't in-
tend to leave the front page...

 
 
 I sureley hope you can stop being facetious..
 
And I surely hope we can all work together for the better representation 
of Python to *all* of its communities :-)

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: Cheese Shop - BSOL?

2006-03-12 Thread Steve Holden
Bertrand Mansion wrote:
 On 3/12/06, Andrew Gwozdziewycz [EMAIL PROTECTED] wrote:
 
Look at the 'tadpoles' (i don't really think it's tadpoles really...
but i'll bite for now),
notice that it is a + sign, which we also always associate with life,
and health (red cross comes to mind). Python
is a healthy language. I can read it and write it without going blind
or crazy.
 
 
 The cross, the snake and the S shape are indeed very commonly
 associated with a medical universe. The current logo would be perfect
 for a drug company.
 
 
 Better eggs.python.org.  Would support the spread of the new file
 format, too.

eggs.python.org actually seems quite good to me. It'd be even cooler
if we could make EGGS an acronym for something.
How about 'Excellently Good Getting Solution' ? (joking).
 
 
 +1 for eggs.python.org
 
eggs: Easily Get Good Stuff?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


How can I implementing COM interfaces from Python objects

2006-03-12 Thread Luiz Siqueira
I'm developing a COM client application, I need implement a COM  interface from Python object to represent a element inside of a COM  server and pass this object trough COM. I know that I need create a  subclass from a specific class from win32com, but I don't find and  don't know the name of this class.Thanks for your time.
		 
Yahoo! Search 
Dê uma espiadinha e saiba tudo sobre o Big Brother Brasil.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Class attributes newbie question (before I join a cargocult)

2006-03-12 Thread Christoph Haas
Am Sonntag, 12. März 2006 19:36 schrieb EP:
 This is likely a stupid question, but I am confused about what is going
 on with class attributes as far as whether they stick.  I ran across
 this in a program I am writing, but have reproduced the behavoir below
 - can someone point me in the right direction (thanks):

 class AttStickiness(object):
 def __init__(self, myname=, mysex=):
 self.name=myname
 self.sex=mysex

   ^--- sex

 def changeSex(self, newsex=):
 self.mysex=newsex

   ^--- mysex

You are not altering the same attribute.

Cheers
 Christoph
-- 
~
~
.signature [Modified] 1 line --100%--1,48 All
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class attributes newbie question (before I join a cargocult)

2006-03-12 Thread kalahari
def changeSex(self, newsex=):
self.mysex=newsex --- self.mysex
return self.mysex

def whoAmI(self):
return self.name, self. sex - self.sex

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


Re: Class attributes newbie question (before I join a cargocult)

2006-03-12 Thread pclinch

EP wrote:
 Hi,

 This is likely a stupid question, but I am confused about what is going
 on with class attributes as far as whether they stick.  I ran across
 this in a program I am writing, but have reproduced the behavoir below
 - can someone point me in the right direction (thanks):

 class AttStickiness(object):
 def __init__(self, myname=, mysex=):
 self.name=myname
 self.sex=mysex

 def changeSex(self, newsex=):
 self.mysex=newsex
 return self.mysex


You might want self.sex = newsex and return self.sex here.

See __slots__ and PyChecker for possible ways to avoid misspelled
instance variables.

 def changeName(self, newname=):
 self.name=newname
 return self.name

 def whoAmI(self):
 return self.name, self. sex

  me=AttStickiness(Eric,Male)

  me.whoAmI()
 ('Eric', 'Male')

  me.changeName(Jimbo)
 'Jimbo'

  me.whoAmI()
 ('Jimbo', 'Male')

  me.changeSex(female)
 'female'

  me.whoAmI()
 ('Jimbo', 'Male')


 [while it is comforting to know my sex isn't so easily changed, this
 has confounded me in real code]
 
 thx,
 
 Eric

Regards, Paul

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Paul Boddie
Fredrik Lundh wrote:


[Developer links and developer/development resources]

 this assumes that the developers link lead to a page that's entirely
 useless for people developing with Python.  that's not even true for
 today's developer page...

True. As you say, there are links to bug reporting tools and, at least
on the current site, lots of links to other, potentially useful
resources - too many in the sidebar for my liking, though. However,
other projects and companies tend to move things which developers using
the technology might find useful to other, more focused pages. Again,
looking at the PostgreSQL site, they have such resources available via
the Support link:

http://www.postgresql.org/support/

Meanwhile, keeping the more corporate style of site in mind, the
Trolltech one does have bug tracking resources on the developer page,
but then that page isn't really about developing the offered products
themselves, so there is really only one kind of developer audience
involved.

 (I'd solve this by adding disambiguation to the page itself, since
 people can arrive on it in many different ways.  good information
 design is not only about what's on the front page...)

True, but then I'd hope that, for example, a Support link would lead
to a Support page which had support-related resources. Any front page
link to a developers of the implementation page would also have to
lead to something pertinent to that description, too. But having looked
in the past at various parts of the old site in order to find canonical
resources, perhaps the biggest challenge in maintaining the Python site
is having coherent navigation with less redundant content: I got the
impression that there were a number of pages that had been kept around
just in case we don't mention this somewhere else and links through
such pages with no guarantee that you'd get to an up-to-date summary of
the desired information in a timely fashion, if at all.

Paul

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


Re: Class attributes newbie question (before I join a cargocult)

2006-03-12 Thread [EMAIL PROTECTED]
Should't the changeSex method be:

def changeSex(self, newsex=):
self.sex = newsex
return self.sex


You're creating a new instance variable at the moment i.e 'self.mysex'
doesn't exist until you call changeSex.

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Parkin
Paul Boddie wrote:
 Fredrik Lundh wrote:
(I'd solve this by adding disambiguation to the page itself, since
people can arrive on it in many different ways.  good information
design is not only about what's on the front page...)
 True, but then I'd hope that, for example, a Support link would lead
 to a Support page which had support-related resources. Any front page
 link to a developers of the implementation page would also have to
 lead to something pertinent to that description, too. But having looked
 in the past at various parts of the old site in order to find canonical
 resources, perhaps the biggest challenge in maintaining the Python site
 is having coherent navigation with less redundant content: I got the
 impression that there were a number of pages that had been kept around
 just in case we don't mention this somewhere else and links through
 such pages with no guarantee that you'd get to an up-to-date summary of
 the desired information in a timely fashion, if at all.
 
Indeed, that is one of the big challenges and we're trying to approach
it from the top down. At the moment we've trimmed down the number of top
level sections and the next stage is to address the top page of each of
those sections (e.g. the 'community', 'documentation','python-dev' pages).

Still some work left cleaning up after the move to the new site but this
is going to be a priority very soon. Do you want me to include you on
any emails regarding this?

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Parkin
Steve Holden wrote:
 Tim Parkin wrote:
Fredrik Lundh wrote:

I sureley hope you can stop being facetious..

 
 And I surely hope we can all work together for the better representation 
 of Python to *all* of its communities :-)
 
 regards
   Steve

My apologies to all, I shouldn't rise to the bait..

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


Re: Class attributes newbie question (before I join a cargocult)

2006-03-12 Thread EP
Thanks.  Argh.  I've failed to find the behavoir I need to understand.
More coffee and re-reading my code.  Thanks!

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ron Adam
Fredrik Lundh wrote:
 Ron Adam wrote:
 
 I think the PSF is important enough to have a link on *every* page. It
 doesn't need a lot of space, but it should be easy to get to from
 anywhere on the web site.
 
 a copyright blurb at the bottom of the page would be one obvious place to
 put it.

Yes, that was my first thought, but I think since the PFS is directly 
involved in recruiting and organizing support for the development of 
python and the python community, it probably needs to be a bit more 
prominent than that.


I think there is still room for improving the grouping of the web site 
in general.  For example you could consider that there are three major 
groups...

* For Python users:  Those using python to write programs.  This would b 
e the introduction, the user/library guide, the tutorial, and other 
documentation on how to use python for writing programs along with the 
download links for the current versions.

* Python product(s) suppliers:  Finished applications modules and tools 
written in python and third party information/products for python users. 
  (outside website links, books, t-shirts, and other items ... also fit 
in this catagory)

* Python development and support:  For the development of the python 
core and the python library, the documentation, and the web site.  As 
well as the PFS.

These overlap, but the nice thing about hyper linked documents is that 
general groupings can be maintained and it still works.  While the PFS 
is in the third group, since it is involved in both seeking and 
promoting support of python, it needs to be visible in the other groups 
as well.

Of course, others would probably arrange things differently. :)

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


Re: New python.org site

2006-03-12 Thread skip

Steve ... where do we go from there to get the winning design up on a
Steve server behind www.python.org?

Hey, it's just a Simple Matter of Programming...

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


Customizing character set conversions with an error handler

2006-03-12 Thread Jukka Aho
When converting Unicode strings to legacy character encodings, it is 
possible to register a custom error handler that will catch and process 
all code points that do not have a direct equivalent in the target 
encoding (as described in PEP 293).

The thing to note here is that the error handler itself is required to 
return the substitutions as Unicode strings - not as the target encoding 
bytestrings. Some lower-level gadgetry will silently convert these 
strings to the target encoding.

That is, if the substitution _itself_ doesn't contain illegal code 
points for the target encoding.

Which brings us to the point: if my error handler for some reason 
returns illegal substitutions (from the viewpoint of the target 
encoding), how can I catch _these_ errors and make things good again?

I thought it would work automatically, by calling the error handler as 
many times as necessary, and letting it work out the situation, but it 
apparently doesn't. Sample code follows:

--- 8 ---

#!/usr/bin/python

import codecs

# ==
# Here's our error handler
# ==

def charset_conversion(error):

# error.object = The original unicode string we're trying to
#process and which has characters for which
#there is no mapping in the built-in tables.
#
# error.start  = The index position in which the error
#occurred in the string
#
# (See PEP 293 for more information)

# Here's our simple conversion table:

table = {
u\u2022: u\u00b7,  # BULLET to MIDDLE DOT
u\u00b7: u*# MIDDLE DOT to ASTERISK
}

try:

# If we can find the character in our conversion table,
# let's make a substitution

substitution = table[error.object[error.start]]

except KeyError:

# Okay, the character wasn't in our substitution table.
# There's nothing we can do. Better print out its
# unicode codepoint as a hex string instead:

substitution = u[U+%04x] % ord(error.object[error.start])

# Return the substituted string and let the built-in codec
# continue from the next position:

return (substitution,error.start+1)

# ==
# Register the above-defined error handler with the name 'practical'
# ==

codecs.register_error('practical',charset_conversion)

# ==
# TEST
# ==

if __name__ == __main__:

print

# Here's our test string: Three BULLET symbols, a space,
# the word TEST, a space again, and three BULLET symbols
# again.

test = u\u2022\u2022\u2022 TEST \u2022\u2022\u2022

# Let's see how we can print out it with our new error
# handler - in various encodings.

# The following works - it just converts the internal
# Unicode representation of the above-defined string
# to UTF-8 without ever hitting the custom error handler:

print   UTF-8: +test.encode('utf-8','practical')

# The next one works, too - it converts the Unicode
# BULLET symbols to Latin 1 MIDDLE DOTs:

print Latin 1: +test.encode('iso-8859-1','practical')

# This works as well - it converts the Unicode BULLET
# symbols to IBM Codepage 437 MIDDLE DOTs:

print  CP 437: +test.encode('cp437','practical')

# The following doesn't work. It should convert the
# Unicode BULLET symbols to ASTERISKS by calling
# the error handler two times - first time substituting
# the BULLET with the MIDDLE DOT, then finding out
# that that doesn't work for ASCII either, and falling
# back to a yet simpler form (by calling the error
# handler again, which will this time substitute the
# MIDDLE DOT with the ASTERISK) - but apparently it
# doesn't work that way. We'll get a
# UnicodeEncodeError instead.

print   ASCII: +test.encode('ascii','practical')

# So the question becomes: how can I make this work
# in a graceful manner?

--- 8 ---

-- 
znark

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread skip

amk Given the endless whiny complaints about the name, though, I think
amk we should just give up and go back to PyPI (pronounced 'Pippy').

There was already a pippy: Python for Palm...

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


Re: Tkinter - Drawing rotated text in a widget

2006-03-12 Thread Cameron Laird
In article [EMAIL PROTECTED],
Eric Apperley  [EMAIL PROTECTED] wrote:
How do I draw rotated text in a Tkinter widget using the draw.text method?

Alternatively, if I draw text as normal, how can I then subsequently 
rotate it about its start point?



Not easily.

The (base) Tk-ers have written a bit on this subject:
URL: http://wiki.tcl.tk/rotate .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread jjcassidy
richard wrote:
[snip]
Should the Python Cheeseshop have anything in it, though? Having a
stocked cheese shop in relation to Python is just silly!

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


Re: lighter weight options to Python's logging package?

2006-03-12 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
 Trent Do you have any profile information for where in the logging
 Trent package the time is being spent?
 
 Looking back at a recent run from a few days ago Formatter.formatTime()
 seems to be a current problem.

You might try using the raw creation time %(created)f rather than 
%(asctime)s in your format.

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


Re: Help Create Good Data Model

2006-03-12 Thread mwt
I get what you're saying fumanchu (or should I say Robert?).
I've been working and reworking this code. It's in a lot better shape
now (although I hestitate to keep flooding the conversation with each
iteration of the file). At the level this app should be operating, I
doubt I'll hit performance issues, and it's good to learn the basics
first. However, I doubt this would scale very well, so the next step
will be to educate myself aobut the performance-enhancing alternatives
you're talking about.

One thing I'm still not sure about -- and I suspect that there is no
right answer -- is the fact that although I am writing the code in
Python, the idiom is purely Java. Having my data bucket in the form of,
essentially, a bean with setters and getters, and each method
surrounded by (the Python version of) a synchronized piece, and so on
all comes from my Java background. It's ending up working well as code
(I'm a lot further along today), and it's accomplishing the decoupling
of front and back end I was looking for, so that's excellent. However I
do have the vague feeling that I am doing the equivalent of, say,
writing Greek hexameters in English (i.e. it works but it is
stylistically clunky).

Anyway, thanks for your insight. I will probably be posting more of the
code later, if you are interested in checking it out. The app is a
[EMAIL PROTECTED] client monitor (for Gnome) -- one of those applications,
like a web spider, that lots of people want to create, even though
there are already a zillion perfectly working versions out there. It's
just about the right level of complexity for me now.

mwt (Michael Taft)

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ed Leafe
On Mar 12, 2006, at 3:03 PM, [EMAIL PROTECTED] wrote:

 amk Given the endless whiny complaints about the name, though,  
 I think
 amk we should just give up and go back to PyPI (pronounced  
 'Pippy').

 There was already a pippy: Python for Palm...

I second the suggestion earlier for making it a simple, non-silly  
name like 'PPI' for the Python Package Index. I mean, does anyone  
ever feel tempted to refer to the FBI with a cute name like 'fibby'?

I'm a big Monty Python fan from way back, but I still cringe at  
names that sound like they were created at the Ministry of Silly Names.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com



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


Re: Which GUI toolkit is THE best?

2006-03-12 Thread invitro81
You guys are great :) thanx for the plenty answers and suggestions; I've 
made my search through a little more and decided to start coding the 
same app first with pygtk and second with wxpython.. and perhaps later 
with pyqt.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter / Mac OS X Question (Aqua vs. X11)

2006-03-12 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb:
 I am running Mac OS X.  I have Tcl/Tk installed.  I can run the Aqua
 version (TkAqua) of wish by typing 'wish' at a terminal prompt.  I can
 run the X11 version (TkX11) of wish by typing 'wish8.4-X11' in an
 x-term.  If I run python and import Tkinter it always grabs the TkAqua
 version.  How can I get Tkinter to load the TkX11 version?
 
 I want to be able to switch back and forth between the two at will.

Install python using fink, and invoke that. Should work against X11 for 
all GUI-Toolkits.

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


Re: Customizing character set conversions with an error handler

2006-03-12 Thread Serge Orlov
Jukka Aho wrote:
 When converting Unicode strings to legacy character encodings, it is
 possible to register a custom error handler that will catch and process
 all code points that do not have a direct equivalent in the target
 encoding (as described in PEP 293).

 The thing to note here is that the error handler itself is required to
 return the substitutions as Unicode strings - not as the target encoding
 bytestrings. Some lower-level gadgetry will silently convert these
 strings to the target encoding.

 That is, if the substitution _itself_ doesn't contain illegal code
 points for the target encoding.

 Which brings us to the point: if my error handler for some reason
 returns illegal substitutions (from the viewpoint of the target
 encoding), how can I catch _these_ errors and make things good again?

 I thought it would work automatically, by calling the error handler as
 many times as necessary, and letting it work out the situation, but it
 apparently doesn't. Sample code follows:


 # So the question becomes: how can I make this work
 # in a graceful manner?


change the return statement with this code:

return (substitution.encode(error.encoding,practical).decode(
error.encoding), error.start+1)

  -- Serge

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


Re: python crashes in Komodo

2006-03-12 Thread Trent Mick
[swisscheese wrote]
 Using the Komodo IDE under XP I often get python.exe has encountered a
 problem and needs to close. Running python direct on the same app
 gives a list index out of bounds error. Any ideas how to get Komodo to
 give the proper error?

Jim,
Have you logged a bug in our bug tracker?
http://bugs.activestate.com/Komodo/enter_bug.cgi
My apologies if you have and we haven't had a chance to get to it.

Note that we'd need specific details to have a chance at knowing what
the problem was. Komodo version. Python version. An example Python
script showing the crash would be invaluable. What OS are you on. Etc.
etc.

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help Create Good Data Model

2006-03-12 Thread Carl Banks
mwt wrote:
 One thing I'm still not sure about -- and I suspect that there is no
 right answer -- is the fact that although I am writing the code in
 Python, the idiom is purely Java. Having my data bucket in the form of,
 essentially, a bean with setters and getters, and each method
 surrounded by (the Python version of) a synchronized piece, and so on
 all comes from my Java background. It's ending up working well as code
 (I'm a lot further along today), and it's accomplishing the decoupling
 of front and back end I was looking for, so that's excellent. However I
 do have the vague feeling that I am doing the equivalent of, say,
 writing Greek hexameters in English (i.e. it works but it is
 stylistically clunky).

However, have a look at the Queue module.  It's arguably more Pythonic,
in the sense that it's in the standard libarary.  But interally it's
fairly similar to how you're doing it.  (It has a few extra locks to
handle empty and full conditions, IIRC.)

Carl Banks

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Paul Boddie
Tim Parkin wrote:

 Still some work left cleaning up after the move to the new site but this
 is going to be a priority very soon. Do you want me to include you on
 any emails regarding this?

I'll have a look into the site developer tools for python.org and see
what I can contribute.

Paul

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


Re: Help Create Good Data Model

2006-03-12 Thread mwt
The Queue won't work for this app, because it removes the data from the
Queue when you query (the way I understand it).

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Tim Hochberg
[EMAIL PROTECTED] wrote:
 richard wrote:
 [snip]
 Should the Python Cheeseshop have anything in it, though? Having a
 stocked cheese shop in relation to Python is just silly!

Well, it shouldn't have any *cheese*, but that's probably OK for a 
software repository.


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


Re: python crashes in Komodo

2006-03-12 Thread swisscheese
Komodo ver 3.5.2, build 227162, platform win32-ix86.
XP SP 2
Python 2.4.2

I did not think to enter the bug as it is so basic - list index out of
bounds. When I run python at a dos prompt python handles the error
properly.

In Komodo, a simple case like this is no problem.
x = [1,2,3]
print x[4]

I'll see if I can get the time to create an app that shows the problem.

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


Can't simultaneously read/write from ossaudio dsp device

2006-03-12 Thread Tito
For an internet telephone application, I need to be able to read and
write data to and from /dev/dsp simultaneously.  I wrote some code and
its not working.  Anyone have any working code to do this?  I am
assuming my card is full duplex, it is a built-in sound card on a new
dell 600m laptop, but I am not sure how to tell for sure.  But I think
the problem is not so much my sound card, but that I am making some
fundamentally wrong assumption on the way to do this ;)  Also I am
definitely a newbie when it comes to audio coding, so any corrections
or tips are welcome.

Here is some test code that is failing for me


from twisted.internet.task import LoopingCall
from twisted.internet import reactor
import os, sys, wave, audioop


While playing the contents of test1.wav,  talk into the mic
and have the audio recorded into /tmp/out.wav


def playnlisten_out():
audio = wavin.readframes(1024)
stereoaudio = audioop.tostereo(audio, 2, 1, 1)
dsp.write(stereoaudio)

def playnlisten_in():
audio = dsp.read(640)
wavout.write(audio)

def both():
playnlisten_out()
playnlisten_in()

dsp = ossaudiodev.open('/dev/dsp', 'rw')

wavin = wave.open(test1.wav, r)
wavout = wave.open(/tmp/out.wav, w)

both_loop = LoopingCall(both)
both_loop.start(0.02)

reactor.run()

 Actual behavior  

It fails with an error:

 dsp.write(stereoaudio)
exceptions.IOError: [Errno 19] No such device

If I comment either playnlisten_out() or playnlisten_in() then the
other function will work.  They just don't work at the same time.

 Sys info 
box:~# lsmod | grep -i audio
i810_audio 30356  1
ac97_codec 16908  1 i810_audio
soundcore   9824  3 snd,i810_audio
box:~# lsmod | grep -i snd
snd_pcm_oss48168  0
snd_mixer_oss  16640  1 snd_pcm_oss
snd_intel8x0m  18632  0
snd_intel8x0   33068  0
snd_ac97_codec 59268  2 snd_intel8x0m,snd_intel8x0
snd_pcm85412  3 snd_pcm_oss,snd_intel8x0m,snd_intel8x0
snd_timer  23172  1 snd_pcm
snd_page_alloc 11144  3 snd_intel8x0m,snd_intel8x0,snd_pcm
gameport4736  1 snd_intel8x0
snd_mpu401_uart 7296  1 snd_intel8x0
snd_rawmidi23232  1 snd_mpu401_uart
snd_seq_device  7944  1 snd_rawmidi
snd50148  10
snd_pcm_oss,snd_mixer_oss,snd_intel8x0m,snd_intel8x0,snd_ac97_codec,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device
soundcore   9824  3 snd,i810_audio

box:~# lspci
:00:1f.5 Multimedia audio controller: Intel Corp. 82801DB/DBL/DBM
(ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)

box:~# uname -a
Linux box 2.6.7-1-386 #1 Thu Jul 8 05:08:04 EDT 2004 i686 GNU/Linux

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


Re: Class attributes newbie question (before I join a cargocult)

2006-03-12 Thread Steven D'Aprano
On Sun, 12 Mar 2006 10:53:57 -0800, pclinch wrote:

 See __slots__ and PyChecker for possible ways to avoid misspelled
 instance variables.

__slots__ are not meant as a way to implement variable declarations.
__slots__ are meant as a memory optimization for cases where you have
large numbers (tens of thousands?) of almost identical instance variables
and you don't need to dynamically add or delete attributes.

Of course, just because __slots__ were invented for one purpose doesn't
mean that you can't find another use for them, but this is not the way.
PyChecker is a good solution for testing for misspelled variables. Another
way is to avoid setters and getters: instead of creating a method to
change the name and sex of the instance, just change the attributes
directly. Not getters and setters means less code, and less code means
fewer bugs (whether due to misspellings or not).


The Original Poster, EP, wrote:

 def changeName(self, newname=):
 self.name=newname
 return self.name

This is not a very Pythonic idiom. (I'm not saying that it is *wrong*,
merely that it is unusual.) Generally, methods should implement one of two
behaviours, as illustrated by the following simplified example:

class Number(object):
def __init__(self, num):
self.value = num

def __add__(self, other):
add two instances of Number and return a new instance
return Number(self.value + other.value)

def increment(self, inc):
increment this instance in place
self.value += inc

 foo = Number(5)
 bar = Number(3)
 foo.increment(2)
 foo.value
7
 baz = foo + bar
 baz.value
10

In other words, methods should generally return either a new instance, or
nothing. Unless you have a good reason for it to act differently.



-- 
Steven.

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


key recognition

2006-03-12 Thread [EMAIL PROTECTED]
When capturing a keystroke using pyhook or other methods, any key
pressed after ctrl is not recognized.  Is there a way around this?

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


Re: Help Create Good Data Model

2006-03-12 Thread fumanchu
If you used a Queue, it wouldn't be the container itself; rather, it
would be a gatekeeper between the container and consumer code. A
minimal example of user-side code would be:

class Request:
def __init__(self, op, data):
self.op = op
self.data = data
self.reply = None
req = Request('get', key)
data_q.put(req, block=True)
while req.reply is None:
time.sleep(0.1)
do_something_with(req.reply)

The container-side code would be:

while True:
request = data_q.get(block=True)
request.reply = handle(request)

That can be improved with queue timeouts on both sides, but it shows
the basic idea.


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]

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


how exactly do binary files work in python?

2006-03-12 Thread John Salerno
In C#, writing to a binary file wrote the actual data types into the 
file (integers, etc.). Is this not how Python binary files work? I tried 
to write integers into a file, but the write method only takes a string 
argument anyway.

Is there a way to actually store integers in a file, so that they can be 
read and used (added, compared, etc.) as integers?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE: great headache....

2006-03-12 Thread Fabio Zadrozny
Hi Sullivan,Just to let you know, pydev does all that you asked for (and if there's something you're missing you might want to add a feature request to it: 
http://sourceforge.net/tracker/?group_id=85796atid=577332)Some notes:To change the indentation in 'blocks', just select the lines you want and use Tab (indent) or shift+tab (dedent). The 'conditional pause' you said is regarded as 'conditional breakpoint' in pydev.
Cheers,FabioOn 11 Mar 2006 15:33:22 -0800, Sullivan WxPyQtKinter [EMAIL PROTECTED]
 wrote:IDLE is no longer satisfactory for me. Other IDEs make me veryconfused. Really do not know which one to use.
I use WinXP sp2 for current development.So far as I know, Eclipse + PyDev + PyDev Extension is perfect forsource code editing. Since I am really not sure how to use the debuggermodule, I really do not know how to add watch to variables etc. Anyone
knows if this platform is a good one?I hope that an IDE should be featured with:1. Grammar Colored highlights.2. Manage project in a tree view or something alike, ie, a project filenavigator.3. Code collapse and folding.
4. Code auto-completion: especially prompting function parameters whenI am typing a function previously defined by myself. Like the one inVisual Studio series.5. Debugging: Breakpoints, conditional pause. watch for 
variables.stepinto, over and out of a function.What about other IDEs? Since I do not need GUI development. More over,the free-of-charge IDE is highly preferred.6.Indentation management like in IDLE: press ctrl+[/] to modify the
identation of a line or a block.In addition, I have seen quite a few editors, which are definitely notwhat I want.Thank you so much for suggestions.--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how exactly do binary files work in python?

2006-03-12 Thread Erik Max Francis
John Salerno wrote:

 In C#, writing to a binary file wrote the actual data types into the 
 file (integers, etc.).

This was inherently nonportable.

 Is this not how Python binary files work? I tried 
 to write integers into a file, but the write method only takes a string 
 argument anyway.
 
 Is there a way to actually store integers in a file, so that they can be 
 read and used (added, compared, etc.) as integers?

You can use the struct module for converting fundamental types to a 
portable string representation for writing to binary files.  Since 
you're dealing with a high-level language, you can also just use the 
pickle module for a more general form of serialization and persistence.

-- 
Erik Max Francis  [EMAIL PROTECTED]  http://www.alcyone.com/max/
San Jose, CA, USA  37 20 N 121 53 W  AIM erikmaxfrancis
   My reputation grows with every failure.
   -- George Bernard Shaw
-- 
http://mail.python.org/mailman/listinfo/python-list


[JOB] Python/C++ Developer, Greenwich, CT | 80-160k | Relo/H1B OK

2006-03-12 Thread OSS
Python/C++ Developer, Greenwich, CT | 80-160k | Relo/H1B OK

My Greenwich, CT client is looking for programmers fluent in Python and C++
to build and improve systems in a variety of areas, including mathematical
programming, parallel computing, network servers, and user interfaces. They
are a relatively small and rapidly growing company offering opportunity for
growth and creativity in a resource-rich environment.

Requirements:
* Strong experience in Python and C++
* Financial programming experience a plus

All candidates will be considered (H1, H1B, Canadian, etc) but you must
currently be residing in the USA. No oversea relocations.

If you are interested in this position and are 100% ready to move to
Greenwich, CT, please submit your resume, a paragraph or cover letter
highlighting your experience as it pertains to this job and your salary
requirements to [EMAIL PROTECTED]


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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-12 Thread Raymond Hettinger
[robert]
 In very rare cases a program crashes (hard to reproduce) :

 * several threads work on an object tree with dict's etc. in it. Items
 are added, deleted, iteration over .keys() ... ). The threads are good
 in such terms, that this core data structure is changed only by atomic
 operations, so that the data structure is always consistent regarding
 the application. Only the change-operations on the dicts and lists
 itself seem to cause problems on a Python level ..

 * one thread periodically pickle-dumps the tree to a file:
 cPickle.dump(obj, f)

 RuntimeError: dictionary changed size during iteration is raised by
 .dump ( or a similar ..list changed ... )

 What can I do about this to get a stable pickle-dump without risiking
 execution error or even worse - errors in the pickled file ?

 Is a copy.deepcopy  ( - cPickle.dump(copy.deepcopy(obj),f) ) an
 atomic opertion with a guarantee to not fail?

No.  It is non-atomic.

It seems that your application design intrinsically incorporates a race
condition -- even if deepcopying and pickling were atomic, there would
be no guarantee whether the pickle dump occurs before or after another
thread modifies the structure.  While that design smells of a rat, it
may be that your apps can accept a dump of any consistent state and
that possibly concurrent transactions may be randomly included or
excluded without affecting the result.

Python's traditional recommendation is to put all access to a resource
in one thread and to have other threads communicate their transaction
requests via the Queue module.  Getting results back was either done
through other Queues or by passing data through a memory location
unique to each thread.  The latter approach has become trivially simple
with the advent of Py2.4's thread-local variables.

Thinking about future directions for Python threading, I wonder if
there is a way to expose the GIL (or simply impose a temporary
moratorium on thread switches) so that it becomes easy to introduce
atomicity when needed:

   gil.acquire(BLOCK=True)
   try:
  #do some transaction that needs to be atomic
   finally:
  gil.release()



 Or can I only retry several times in case of RuntimeError?  (which would
 apears to me as odd gambling; retry how often?)

Since the app doesn't seem to care when the dump occurs,  it might be
natural to put it in a while-loop that continuously retries until it
succeeds; however, you still run the risk that other threads may never
leave the object alone long enough to dump completely.


Raymond

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


Very, Very Green Python User

2006-03-12 Thread hanumizzle
I have used Perl for a long time, but I am something of an experimental
person and mean to try something new. Most of my 'work' with Vector
Linux entails the use of Perl (a bit of a misnomer as it is not now a
paid position -- I am not yet even out of K-12), and there a lot of
things I love about it. I can look past a number of misfeatures in
Perl, but I am surprised to see that Python has very few (that I know
of). Most of them are documented here, it would seem:
http://www.c2.com/cgi/wiki?PythonProblems. Is the Python debugger
fairly stable? The one you get with Perl stinks on ice. More than
anything else, I would like to have a powerful OO environment where I
do not have to worry about the debugger sucking ass.

A couple blemishes I'm concerned about, though:

Python closures are apparently very poor, but from what I can surmise
of the PyGTK2 page, instances of objects are dynamic enough to add new
methods, so you get your callbacks, at least.

Double-underscore methods are rewritten with the class name? That's an
ugly hack, but remember I'm coming from Perl. If the language doesn't
pull many other hijinks, that's OK.

I have plenty of docs and stuff, now I'm just looking for wisdom. As a
seasoned Python user, what do you have to impart?

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


Re: Cheese Shop: some history for the new-comers

2006-03-12 Thread Ron Adam
[EMAIL PROTECTED] wrote:
 richard wrote:
 [snip]
 Should the Python Cheeseshop have anything in it, though? Having a
 stocked cheese shop in relation to Python is just silly!

Cheese (or the lack of cheese) is never silly,  Thus the slogan... The 
power of cheese.

Now if you want silliness, then the correct establishment for that is 
The Ministry of Silly Walks. ;)

Ron

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


Re: Please, I Have A Question before I get started

2006-03-12 Thread Steven D'Aprano
On Mon, 13 Mar 2006 02:19:39 +, Skipper wrote:

 Hi All,
 
 I am going to try and learn Python because I want to write at least
 one program to help my disabled son with communitation.
 
 I am not asking for anyone to do this for me I simply want to know if
 I can do what I need to do with Python 

[snip]

 Can python do this?  I realize I am responsible for the menu sets,
 pictures  attaching sounds etc  

There is no reason why Python can't do this.

If you are new to programming, I suggest you have a look at Pythoncard.
Unfortunately, most of the Graphical User Interface libraries for Python
have a fairly steep learning curve, and in general building GUIs can be
tedious and difficult, regardless of language. Pythoncard is an attempt to
simplify the whole process and make simple things simple.

http://pythoncard.sourceforge.net/


-- 
Steven.

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


Re: how exactly do binary files work in python?

2006-03-12 Thread John Salerno
Erik Max Francis wrote:

 You can use the struct module for converting fundamental types to a 
 portable string representation for writing to binary files.

But if it's a string, why not just use a text file? What does a binary 
file do that a text file doesn't, aside from not converting the end of 
line characters?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how exactly do binary files work in python?

2006-03-12 Thread Grant Edwards
On 2006-03-13, John Salerno [EMAIL PROTECTED] wrote:

 You can use the struct module for converting fundamental types
 to a portable string representation for writing to binary
 files.

 But if it's a string, why not just use a text file?

Because string != text.

In Python a string is just an arbitrary length chunk of bytes.

 What does a binary file do that a text file doesn't, aside
 from not converting the end of line characters?

Nothing.  It's the end-of-line conversion that can break binary
data.

-- 
Grant Edwards
[EMAIL PROTECTED]

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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-12 Thread Jean-Paul Calderone
On 12 Mar 2006 17:56:37 -0800, Raymond Hettinger [EMAIL PROTECTED] wrote:

Thinking about future directions for Python threading, I wonder if
there is a way to expose the GIL (or simply impose a temporary
moratorium on thread switches) so that it becomes easy to introduce
atomicity when needed:

   gil.acquire(BLOCK=True)
   try:
  #do some transaction that needs to be atomic
   finally:
  gil.release()


This is vaguely possible using sys.setcheckinterval() now, although one has to 
pick a ridiculously large number and hope that the atomic operation takes fewer 
than that many opcodes.

Spelling do not switch threads as sys.setcheckinterval(None) seems somewhat 
natural, though.  Perhaps that would be a fruitful direction to explore.

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


Re: Tkinter / Mac OS X Question (Aqua vs. X11)

2006-03-12 Thread [EMAIL PROTECTED]
 Install python using fink, and invoke that. Should work against X11 for
 all GUI-Toolkits.

I prefer not to do this.  Darwin is already a Unix, and Apple provides
a version of X11 that works well with it.  Fink seems like an
unecessary layer that I would rather not mess with.  Tcl/Tk has a very
simple way to select.  It would be nice if Python did something similar
(command line option, an environment variable, whatever).  I looked for
an option in the build process, and from what I can tell, the OS X
version looks like it only builds a single version (TkAqua).

TkAqua and TkX11 do differ, and it would be nice to see the same script
run under both Aqua and X11 without having to switch machines.

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


Re: how exactly do binary files work in python?

2006-03-12 Thread Alex Martelli
Grant Edwards [EMAIL PROTECTED] wrote:
   ...
  What does a binary file do that a text file doesn't, aside
  from not converting the end of line characters?
 
 Nothing.  It's the end-of-line conversion that can break binary
 data.

I believe that a control-Z (ord(26)) in a file that's being read as
text, on Windows, is also taken as an end-of-file indication.


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


Re: Please, I Have A Question before I get started

2006-03-12 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote:
   ...
  Can python do this?  I realize I am responsible for the menu sets,
  pictures  attaching sounds etc  
 
 There is no reason why Python can't do this.
 
 If you are new to programming, I suggest you have a look at Pythoncard.

For the original poster's purposes, I was thinking as PyGame (and PyUI
on top of it) as perhaps more suitable. But, sure, it won't be a
cakewalk, for somebody without any programming experience, with either
toolkit set (Pythoncard+wxPython, or PyUI+PyGame).


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


Re: Please, I Have A Question before I get started

2006-03-12 Thread Yu-Xi Lim
Skipper wrote:
 Hi All,
 
 I am going to try and learn Python because I want to write at least
 one program to help my disabled son with communitation.
 
snip
 
 Can python do this?  I realize I am responsible for the menu sets,
 pictures  attaching sounds etc  

An interesting project.

As Steven mentioned, the GUI toolkits for python (and several other 
major programming languages such as Java and C) are challenging. I 
recommend you start with something that is already GUI-oriented that 
would eliminate a lot of the difficulty of display images, detecting 
mouse clicks, etc.

The first thing that comes to mind would be Powerpoint with some short 
custom Visual Basic code. Another very easy alternative may be HTML with 
some basic Javascript. It won't take 10 lines of code if you make some 
compromises on the presentation but you can't include sound. More 
complex would be stuff like Flash. All would probably take you less time 
to learn than Python and a GUI toolkit.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how exactly do binary files work in python?

2006-03-12 Thread Steven D'Aprano
On Sun, 12 Mar 2006 22:01:46 -0500, John Salerno wrote:

 Erik Max Francis wrote:
 
 You can use the struct module for converting fundamental types to a 
 portable string representation for writing to binary files.
 
 But if it's a string, why not just use a text file? What does a binary 
 file do that a text file doesn't, aside from not converting the end of 
 line characters?

Nothing. It is all bytes under the hood.

People generally consider a file to be text if it only includes bytes 32
through 126, plus a few control characters like 9 (tab) and 10 (newline).
Other applications don't care what bytes are included. Python is (mostly)
like that: you can deal with any bytes you collect from any file.

Other than this informal difference between text an binary, the major
difference comes about when you read lines from a text file. Each
operating system has a line separator: Unix/BSD/Linux systems use newline
(char 10), classic Macintosh used to use carriage return (char 12) and
DOS/Windows uses a two-byte carriage return + newline.

When writing lines to a file, Python does not automatically append the
line marker, so you need to do so yourself. But some other languages do --
I believe C++ is one of those languages. So C++ needs to know whether you
are writing in text mode so it can append that end-of-line maker, or
binary mode so it doesn't. Since Python doesn't modify the line you write
to the file, it doesn't care whether you are writing in text or binary
mode, it is all the same.

Operating systems such as Unix and Linux don't distinguish between binary
and text mode, the results are the same. I'm told that Windows does
distinguish between the two, although I couldn't tell you how they
differ.

-- 
Steven.

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


Re: Please, I Have A Question before I get started

2006-03-12 Thread Steven D'Aprano
On Sun, 12 Mar 2006 19:43:07 -0800, Alex Martelli wrote:

 Steven D'Aprano [EMAIL PROTECTED] wrote:
...
  Can python do this?  I realize I am responsible for the menu sets,
  pictures  attaching sounds etc  
 
 There is no reason why Python can't do this.
 
 If you are new to programming, I suggest you have a look at Pythoncard.
 
 For the original poster's purposes, I was thinking as PyGame (and PyUI
 on top of it) as perhaps more suitable. But, sure, it won't be a
 cakewalk, for somebody without any programming experience, with either
 toolkit set (Pythoncard+wxPython, or PyUI+PyGame).


Where did we go wrong? This sort of project would have been literally a 30
minute job with Apple's now defunct Hypercard program, and 20 of those
minutes would be looking for suitable images to use. 

It's half a decade into the 21st century. Why aren't there modern,
advanced GUI development systems that have as simple a front end as
technology that existed in 1988?

-- 
Steven.

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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-12 Thread Alex Martelli
Jean-Paul Calderone [EMAIL PROTECTED] wrote:
   ...
 This is vaguely possible using sys.setcheckinterval() now, although one
 has to pick a ridiculously large number and hope that the atomic operation
 takes fewer than that many opcodes.
 
 Spelling do not switch threads as sys.setcheckinterval(None) seems
 somewhat natural, though.  Perhaps that would be a fruitful direction to
 explore.

Indeed, it's a simple enough idea that it's worth proposing to
python-dev for consideration for 2.5, since the patch connected to
implementing it should be tiny. The only issue is whether Python
(meaning Guido) WANTS to change in order support this rough-and-ready
approach to multithreading; I hope he doesn't, but if he does we might
as well get it over with now.


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


Re: Please, I Have A Question before I get started

2006-03-12 Thread Ravi Teja
http://www-inst.eecs.berkeley.edu/~maratb/readings/NoSilverBullet.html

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


Re: New python.org site

2006-03-12 Thread [EMAIL PROTECTED]
Bertrand Mansion said
Now, there are also new features we might want:

 - documentation with user comments (like in PHP, Postgres, MySQL...)
 - RSS feeds
 - Efficient search engine (hyperestraier ?)
 - Database backend and CMS
 Add examples in the documentation  to your list also!!
Yes the php docs are by far much better. Both the examples and the user
comments make them easer to use. On the other hand I can see how the
user comments would add extra work to keep comment spam out.

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


Re: How to best update remote compressed, encrypted archives incrementally?

2006-03-12 Thread [EMAIL PROTECTED]
Would rsync into a remote encrypted filesystem work for you?

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


Please, I Have A Question before I get started

2006-03-12 Thread Skipper
Hi All,

I am going to try and learn Python because I want to write at least
one program to help my disabled son with communitation.

I am not asking for anyone to do this for me I simply want to know if
I can do what I need to do with Python 

Basically the program will blank the screen and call up (for example)
6 pictures.  A flashing border with travel from picture to picture.
When the computer senses a mouse click it will clear the screen and
present a second set of choices ... one level deeper than the first
... based on the chosen picture.

So again ...  menu pictures of food, drink, tv are highlited for 5
seconds each.  the chooser sends an input (mouse click for eample)
while the tv is highlited.  The screen clears and another picture menu
appears ... this one a deeper level of the chose TV - maybe it is
pictures of a cartoon and a ball ... a ball is chosen ... the screeen
clears and menu choices of a baseball, basketball or football
appear... my son chooses the baseball ... he has now worked through
three menu levels to let us know what he would like to watch on TV

Can python do this?  I realize I am responsible for the menu sets,
pictures  attaching sounds etc  

TIA

Mike

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


Re: how exactly do binary files work in python?

2006-03-12 Thread Grant Edwards
On 2006-03-13, Alex Martelli [EMAIL PROTECTED] wrote:
 Grant Edwards [EMAIL PROTECTED] wrote:
...
  What does a binary file do that a text file doesn't, aside
  from not converting the end of line characters?
 
 Nothing.  It's the end-of-line conversion that can break binary
 data.

 I believe that a control-Z (ord(26)) in a file that's being read as
 text, on Windows, is also taken as an end-of-file indication.

Ah yes.  IIRC, that's left over from CP/M, where the filesystem
didn't keep a file length for files other than a block count.
It was up to the application(s) to keep track of where in that
last block the real data ended.

-- 
Grant Edwards   grante Yow!  I wonder if I ought
  at   to tell them about my
   visi.comPREVIOUS LIFE as a COMPLETE
   STRANGER?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE: great headache....

2006-03-12 Thread jussij
 I use WinXP sp2 for current development.

You might want to take a look at the Zeus for Windows IDE:

  http://www.zeusedit.com

Here is how Zeus stacks up to your check list:

 I hope that an IDE should be featured with:
 1. Grammar Colored highlights.

It does syntax coloring for Python.

 2. Manage project in a tree view or something alike, ie, a
 project file navigator.

It has a project/workspace feature.

 3. Code collapse and folding.

It does code folding for Python.

 4. Code auto-completion: especially prompting function
 parameters when I am typing a function previously defined
 by myself. Like the one in Visual Studio series.

The code completion in Zeus is driven by the information
provided by the ctags utility and ctags works better for
some languages compared to others.

The net result is quality of the Zeus code completion does
vary from one language to next language.

 5. Debugging: Breakpoints, conditional pause. watch for
 variables.step into, over and out of a function.

It does have a built-in debugger, but most likely there
are be better standalone debuggers :(

 More over, the free-of-charge IDE is highly preferred.

Zeus is not freeware. It is shareware and has a 45 day
fully functional trail period.

 6.Indentation management like in IDLE: press ctrl+[/] to
 modify the identation of a line or a block.

It can handle Python indenting. It also has a block
indent/unindent feature (ie Tab/Shift tab marked areas).

Zeus is also fully scriptable an the macro scripts can be
written in Python.

Jussi Jumppanen
Author: Zeus for Windows

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


Re: New python.org site

2006-03-12 Thread Armin Ronacher
I don't like the new python.org

But i have I (in my mind) nice idea.

Dedicate python.org to the language developers and python interna. And
create a nice small page on go-python.org dedicated to the users. It
should *only* feature a documentation with a comment box on the bottom
of each side, a download section and links to important python pages as
well as a nice designed moinmoin wiki.

Regards,
Armin

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


Ossaudiodev in Windows

2006-03-12 Thread Ernest G Ngaruiya
I got some code for playin g sounds using python. The code was meant for 
alinux platform and so if I use it on Windows, it says there is no module 
named ossaudiodev. I'd like to try this out on windows. Could someone help 
me out? What's an alternative

Thanks,
Email me at [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >