Re: What tools are used to write and generate Python Library documentation.

2005-09-26 Thread Robert Kern
Kenneth McDonald wrote:
> I have a module I'd like to document using the same style...

http://docs.python.org/doc/doc.html

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: What tools are used to write and generate Python Library documentation.

2005-09-26 Thread beza1e1
Do you think of pydoc? Just make comments in your code this way:

def add10(x):
"""this function adds ten to the given variable"""

Then save this into add.py and now (in the same directory):

pydoc add

Voila, your documentation.

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


Re: Dynamic character substitution.

2005-09-26 Thread Steve Jorgensen
On Mon, 26 Sep 2005 21:09:51 -0400, "John Bausano" <[EMAIL PROTECTED]> wrote:

>Hello all,

...
Funny enough, some people have wanted to substitute a more dynamic character
for me on occasion .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic character substitution.

2005-09-26 Thread Tim Roberts
"John Bausano" <[EMAIL PROTECTED]> wrote:
>
>Hello all,
>
>I've been using Ansys which is a commercial FEA package which can be 
>controlled through its own scripting language they call APDL.  Now I'm 
>trying to write some stand alone code in Python to supplement my current 
>efforts.
>
>In Ansys I can do something like this.
>
>*do,n,1,3   #loop through n
>
>  *dim,data%n%,1000,2   #creates variables 
>arrays data1(1000,2), data2(1000,2)..
>
>  *vread,data%n%,filename%n%#fills arrays with data 
>from filename1,.

Generally, you need to think about your problem in a slightly different
way.  Instead of thinking about creating variables called data1 and data2,
think about creating a dictionary called "data" which contains three
elements.  For example:

data = {}
for n in range(3):
data[n] = read_from( 'filename%d' % n )

It IS possible to create variables on the fly, but except in very special
situations, it is almost never the right way to do things.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Metaclasses, decorators, and synchronization

2005-09-26 Thread Michele Simionato

Michael Ekstrand ha scritto:
> One issue remains in this function: my method's signature is lost when
> synchronized is applied (at least as somemeth=synchronized(somemeth);
> I'm currently in a 2.3 environment that doesn't have the decorator
> syntax, but my understanding is that makes no difference). I've been
> able to preserve the doc string by setting the __doc__ attribute of the
> inner function before returning it, but is there a way to make this
> inner function appear to bear the same argument list as the original
> method? I've been poking around in new and inspect, but it is not
> appearing like an easy task.

It is not that easy, but you can leverage on my decorator module
which does exactly what you want:
http://www.phyast.pitt.edu/~micheles/python/decorator.zip

 Michele Simionato

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


Re: Best practices for dynamically loading plugins at startup

2005-09-26 Thread Jeff Schwab
Christoph Haas wrote:
> On Sun, Sep 25, 2005 at 11:33:03PM -0400, Jeff Schwab wrote:
> 
>>I recently came up against this exact problem.  My preference is to have 
>>the plugin writer call a method to register the plugins, as this allows 
>>him the most control.  Something along these lines:
>>
>>  class A_plugin(Plugin):
>>  ...
>>
>>  class Another_plugin(Plugin):
>>  ...
>>
>>  register( A_plugin )
>>  register( Another_plugin, optional_custom_registration_parameters )
> 
> 
> I like the idea. And "supybot" seems to do just that. What would the
> "def register:" do? Maintain a global list of registered plugins?
> I didn't like the idea of having global variables. Or would register
> be a method of some "main" class? How would I access that?

The registry clearly has to be shared between modules, so I think it's 
best to make it a module-level variable.  In the simple-minded code 
below, I've stored it in the "plugins" module.  A better choice might be 
the module that defines your plugins' common base class, if they have one.


# BEGIN framework.py
if __name__ == "__main__":
import plugins
print plugins.plugin_registry
# END framework.py

# BEGIN plugins.py
# Define some plugins.

class A_plugin(object):
def __init__(self):
print "A_plugin()"

class Another_plugin(object):
def __init__(self):
print "Another_plugin()"

# Register the plugins.

import registry

plugin_registry = registry.Registry()
plugin_registry.register(A_plugin)
plugin_registry.register(Another_plugin)
# END plugins.py

# BEGIN registry.py
class Registry(object):
"Each instance may be used to store a set of objects."

def __init__(self):
"Initialize an empty registry."
self.registered_objects = set()

def register(self, o):
"Add an object to the registry."
self.registered_objects.add(o)

def __repr__(self):
return "Registry Contents:\n\t" + \
"\n\t".join(repr(o) for o in self.registered_objects)
# END registry.py
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webbrowser failing

2005-09-26 Thread DogWalker
"Thomas Thomas" <[EMAIL PROTECTED]> said:

>Hi All,
>
>import webbrowser
>url='http://www.cnn.com'
>webbrowser.open(url)
>
>giving the error
>
>Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
>Type "help", "copyright", "credits" or "license" for more information.
 ## working on region in file 
 c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/python-1720WXU.py...
>Traceback (most recent call last):
>  File "", line 1, in ?
>  File "c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/python-1720WXU.py", line 3, in ?
>webbrowser.open(url)
>  File "C:\Python23\lib\webbrowser.py", line 43, in open
>get().open(url, new, autoraise)
>  File "C:\Python23\lib\webbrowser.py", line 250, in open
>os.startfile(url)
>WindowsError: [Errno 2] The system cannot find the file specified: 
>'http://www.cnn.com'
 
>
>any help
>Thoma

Were you connected when you tried?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PEP 350: Codetags

2005-09-26 Thread Paul Rubin
Tony Meyer <[EMAIL PROTECTED]> writes:
> Does this mean that you think that PEP 8 (Python Code Style Guide)
> should be enforced by the compiler?  So that (e.g) lines that are too
> long just don't compile?

I'd be ok with compiler warning messages from lines that are too long.
I think it's appropriate to have such messages, if someone took the
trouble to specify a maximum preferred line length in the PEP.  There
could be a compile time flag and/or some kind of code pragma to turn
off the warnings.

> I really doubt you'll find much agreement for this (the compiler
> should enforce it) position.  The 'fewer conventions are better'
> position might enjoy more support, but doesn't strike me as
> particularly Pythonic (e.g. compare whitespace in Python and C).

It's ok if the enforcement isn't strict.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What tools are used to write and generate Python Library documentation.

2005-09-26 Thread James Stroud
ReStructureText is pretty cool. Try it out.

http://docutils.sourceforge.net/rst.html

On Monday 26 September 2005 20:24, Kenneth McDonald wrote:
> I have a module I'd like to document using the same style...
>
> Thanks,
> Ken

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


What tools are used to write and generate Python Library documentation.

2005-09-26 Thread Kenneth McDonald
I have a module I'd like to document using the same style...

Thanks,
Ken
-- 
http://mail.python.org/mailman/listinfo/python-list


A 'find' utility that continues through zipped directory structure?

2005-09-26 Thread B Mahoney
Is there a Python 'find' -like utility that will continue the file
search through any zippped directory structure on the find path?

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


Re: number of python users

2005-09-26 Thread Bryan
Fredrik Lundh wrote:
> Bryan wrote:
> 
>>is there a rough estimate somewhere that shows currently how many python 1.5 
>>vs
>>2.2 vs 2.3 vs 2.4 users there are?  have a majority moved to 2.4? or are they
>>still using 2.3? etc...
> 
> 
> Here are current PIL download statistics (last 10 days):
> 
> 75.6% /downloads/PIL-1.1.5.win32-py2.4.exe
> 18.0% /downloads/PIL-1.1.5.win32-py2.3.exe
>  2.2%  /downloads/PIL-1.1.5.win32-py2.2.exe
>  4.2%  /downloads/PIL-1.1.5.win32-py2.1.exe
> 
> Note that these are fresh downloads for Windows, not users.  People
> who run other systems, or are happy with their existing installation,
> isn't included (so older versions are probably more common than they
> appear).
> 
> (fwiw, I still have users on 1.5.2 for most of my libraries.  usually huge
> Unix systems that nobody wants to break just because they can...)
> 
> 
> 
> 
> 

just for fun, i looked at the top linux distros at distrowatch and looked at 
what version of python the latest released version is shipping with out of the 
box:

1. ubuntu hoary - python 2.4.1
2. mandriva 2005 - python 2.4
3. suse 9.3 - python 2.4
4. fedora core 4 - python 2.4.1
5. mepis 3.3.1 - python 2.3.5
6. knoppix 4.0.2  - python 2.3.5
7. debian sarge - python 2.3.5
8. gentoo 2005.1 - python 2.3.5
9. slackware 10.2 - python 2.4.1
10.kubuntu hoary - python 2.4.1
11. freebsd 5.4 - python 2.4
12. xandros 3.0 - python 2.3.4
13. pclinuxos 0.91 - python 2.3.4


bryan

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


Re: PEP 350: Codetags

2005-09-26 Thread Tony Meyer
On 27/09/2005, at 12:21 PM, Paul Rubin wrote:

> Neil Hodgson <[EMAIL PROTECTED]> writes:
>
>> The PEP system allows for the documentation of a convention as an
>> "Informational PEP". Documenting conventions is useful.
>
> If the preferred method of doing something is
> consistent enough that it can be codified as a convention in a PEP, it
> should be implemented in the compiler, so it becomes a language
> feature, not a convention.

Does this mean that you think that PEP 8 (Python Code Style Guide)  
should be enforced by the compiler?  So that (e.g) lines that are too  
long just don't compile?

I really doubt you'll find much agreement for this (the compiler  
should enforce it) position.  The 'fewer conventions are better'  
position might enjoy more support, but doesn't strike me as  
particularly Pythonic (e.g. compare whitespace in Python and C).

=Tony.Meyer

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


Re: Struggling with this concept please help

2005-09-26 Thread John Hazen
* George <[EMAIL PROTECTED]> [2005-09-25 16:20]:
> Hello everyone I know many have helped but I cannot get this to work
> out correctly.

> Please help I have never done python before and I can't seem to get the
> hang of it.

You posted code.  Is what's in the docstring actual output?  If so, what
isn't it doing that you want it to?

If it's not working correctly, what's it doing?  Just saying "I cannot
get this to work" doesn't give us much to go on.  If you want specific
help, be sure to:

1) post actual code
2) explain what you expect it to do
3) post actual output (or traceback)
4) ask a specific question about what you don't understand about item 3.

Even though we know this is schoolwork, I'm OK with offering you a hint
or answering a specific question.

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


Dynamic character substitution.

2005-09-26 Thread John Bausano
Hello all,



I've been using Ansys which is a commercial FEA package which can be 
controlled through its own scripting language they call APDL.  Now I'm 
trying to write some stand alone code in Python to supplement my current 
efforts.



In Ansys I can do something like this.



*do,n,1,3  #loop 
through n

*dim,data%n%,1000,2 #creates variables 
arrays data1(1000,2), data2(1000,2)..

*vread,data%n%,filename%n%#fills arrays with data 
from filename1,.



Thanks



john


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


Sparse matrices

2005-09-26 Thread George Sakkis
Is there any sparse matrix package compatible with Numeric/Numarray ? Ideally, 
the implementation of
a matrix (dense/sparse) should be transparent to the application. However the 
APIs of the only
packages I'm aware of -- the Sparse module in Scipy and PySparse --are both 
pretty incomplete
compared to (dense) numeric arrays. Any alternatives ?

George


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


How does company culture affect you?

2005-09-26 Thread bruce_taylor
Please forgive me if this is a little off topic, but I'm trying to
reach a population of active programmers and this seems to be a popular

gathering place.

I am conducting research on how company cultures affect programmer
productivity.  If you would be willing to take 5 minutes to answer a
few  questions, you would help me very much and win my undying
gratitude. At the end of the survey, you'll have an opportunity to see
the results so far, and that might prove interesting.

This is NOT a stealth marketing campaign or a recruiting troll. Your
data is collected completely anonymously and will be reported only as
aggregate statistics.

If you're willing to take the survey, please go to this URL:

   http://www.surveymonkey.com/s.asp?u=596961324075&c=12

In any case, I thank you for your time and attention 

Bruce

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


Re: PEP 350: Codetags

2005-09-26 Thread Paul Rubin
Neil Hodgson <[EMAIL PROTECTED]> writes:
> The PEP system allows for the documentation of a convention as an
> "Informational PEP". Documenting conventions is useful.

Where there are conventions, they should be documented.  I'm in favor
of fewer conventions.  If the preferred method of doing something is
consistent enough that it can be codified as a convention in a PEP, it
should be implemented in the compiler, so it becomes a language
feature, not a convention.

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


Re: PEP 350: Codetags

2005-09-26 Thread George Sakkis
"Paul Rubin"  wrote:

> I'm opposed to pretty much every proposal of this sort.  If you want
> to propose adding a feature to the language, add it in a way that the
> compiler can know about it and notice when it's not used correctly.
> Mere conventions that are not checked by the compiler are just more
> stuff for people to remember.  That doesn't say they're always useless
> but in general they should not be the subject of PEP's.

There are more than a dozen "informational PEPs" so far, or two dozens if you 
count the meta-PEPs as
well (http://www.python.org/peps/). This PEP states upfront that it is 
informational, so I don't see
the problem, unless are you suggesting a (meta-)PEP against informational PEPs 
in general :-)

George


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


Re: PEP 350: Codetags

2005-09-26 Thread Neil Hodgson
Paul Rubin:

> Mere conventions that are not checked by the compiler are just more
> stuff for people to remember.  That doesn't say they're always useless
> but in general they should not be the subject of PEP's.

The PEP system allows for the documentation of a convention as an 
"Informational PEP". Documenting conventions is useful. If you don't 
want conventions documented in PEPs then you should propose a change to 
PEP 1, "PEP Guidelines".

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


Re: PEP 350: Codetags

2005-09-26 Thread Terry Reedy

"Micah Elliott" <[EMAIL PROTECTED]> [CCed] wrote in message 
[news:[EMAIL PROTECTED]

The nice thing about this is that I can use whatever part (or whatever 
version) I want regardless of whether it becomes a standard library style 
recommendation.  I would prefer tags that are short and pronouncable.  I 
think I would generally give preference to verbs over nouns when the tag 
means 'act'.  I think the tools should be able to handle local additions to 
the list since there will never be universal agreement to a reasonable size 
list.

> ``TODO (MILESTONE, MLSTN, DONE, YAGNI, TBD, TOBEDONE)``
>   *To do*: Informal tasks/features that are pending completion.

Some of the 'synonyms' don't look like synonyms to me.
I prefer the shorter verb DO.  The TO adds nothing.
For a particular project with lots of optional additions, I may use the 
more specific ADD.  DO could mean to do literally anything.

> ``FIXME (XXX, DEBUG, BROKEN, REFACTOR, REFACT, RFCTR, OOPS, SMELL, 
> NEEDSWORK, INSPECT)``
>   *Fix me*: Areas of problematic or ugly code needing refactoring or
>   cleanup.

FIX is shorter and more competitive with XXX.  In context, the addition of 
ME is meaningless.  Leave it off.  (Or write tools that let me ;-).
FIX corresponds to NOFIX and variants.
What is missing is a convention as to whether the code to be fixed (the ME) 
is above or below the note.

> ``GLOSS (GLOSSARY)``
>   *Glossary*: Definitions for project glossary.

DEF for define or definition (for glossary)

> ``TODOC (DOCDO, DODOC, NEEDSDOC, EXPLAIN, DOCUMENT)``
>   *Needs Documentation*: Areas of code that still need to be
>   documented.

DOC for document this.  TO or DO add no meaning.

> DONE File
> -
> It may sound burdensome to have to delete codetag lines every time one
> gets completed.  But in practice it is quite easy to setup a Vim or
> Emacs mapping to auto-record a codetag deletion in this format (sans
> the commentary).

Not everyone uses Vim or Emacs.  Would it be as easy to setup IDLE or 
PythonWin to do the same?  Suggestion: add an x:comment field, to mean 
'this tag  is ready to be deleted, perhaps to be transferred to a done file 
first'.
-

I generally agree with your objection defenses except possible this one.

> :Objection: I can't use codetags when writing HTML, or less
>specifically, XML.  Maybe [EMAIL PROTECTED]@`` would be a better than
> as the delimiters.
>
> :Defense: Maybe you're right, but ``<>`` looks nicer whenever
>applicable.  XML/SGML could use [EMAIL PROTECTED] while more common
>programming languages stick to ``<>``.

XML is not going change.  On the other hand, < and > routinely occur in 
Python code already.  Don't they already have to be escaped to embed Python 
in HT/XML?

Terry J. Reedy



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


Re: PEP 350: Codetags

2005-09-26 Thread Paul Rubin
I'm opposed to pretty much every proposal of this sort.  If you want
to propose adding a feature to the language, add it in a way that the
compiler can know about it and notice when it's not used correctly.
Mere conventions that are not checked by the compiler are just more
stuff for people to remember.  That doesn't say they're always useless
but in general they should not be the subject of PEP's.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 350: Codetags

2005-09-26 Thread Tom Anderson
On Mon, 26 Sep 2005, Micah Elliott wrote:

> Please read/comment/vote.  This circulated as a pre-PEP proposal 
> submitted to c.l.py on August 10, but has changed quite a bit since 
> then.  I'm reposting this since it is now "Open (under consideration)" 
> at .

Seems generally fine to me; i'm not the best person to comment, though, 
since it's highly unlikely i'll use them.

I did notice one thing that is sort of wrong, though:

:Objection: *WorkWeek* is an obscure and uncommon time unit.

:Defense: That's true but it is a highly suitable unit of granularity
 for estimation/targeting purposes, and it is very compact.  The
 `ISO 8601`_ is widely understood but allows you to only specify
 either a specific day (restrictive) or month (broad).

Actually, ISO 8601 includes a week notation. Have a read of this:

http://www.cl.cam.ac.uk/~mgk25/iso-time.html

Which explains that you can write things like 2005-W20 to mean the 20th 
week of 2005, and ISO won't send you to hell for it.

tom

-- 
Brace yourself for an engulfing, cowardly autotroph! I want your photosynthetic 
apparatii!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attribute error

2005-09-26 Thread Mike Meyer
"M.N.A.Smadi" <[EMAIL PROTECTED]> writes:

> HI;
>
> I am  having the following error.  I am using someone else's code and
> all they are doing is pass an argv to a function then
>
> def execute_action(manager, argv):
> method_name = argv.pop(0).lower()
>
>
> and am getting this strange error.
> AttributeError: 'str' object has no attribute 'pop'
>
> am using Python 2.3.4 and am importing the following libraries:
>
> import sys, os, inspect
> from Asterisk import Manager, BaseException, Config
> import Asterisk.Util
>
> but i always thought that something like this will be standard stuff.
> Any ideas?

Yes - show us the rest of the code. execute_action is never called in
the snippets you posted, and it's pretty clear that it's being invoked
with the wrong thing as an argument. Can you provide a minimal working
(well, executable) code sample that generates the error message you
are getting?

Oh yeah - post the full traceback as well.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess considered harmfull?

2005-09-26 Thread Roger Upole
"Uri Nix" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Roger Upole wrote:
>> "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
>> > Steven Bethard wrote:
>> >
>> >> >  Using the following snippet:
>> >> >   p =
>> >> > subprocess.Popen(nmake,stderr=subprocess.PIPE,stdout=subprocess.PIPE, \
>> >> >universal_newlines=True, bufsize=1)
>> >> >   os.sys.stdout.writelines(p.stdout)
>> >> >   os.sys.stdout.writelines(p.stderr)
>> >> >  Works fine on the command line, but fails when called from within
>> >> > Visual Studio, with the following error:
>> >> >   File "C:\Python24\lib\subprocess.py", line 549, in __init__
>> >> > (p2cread, p2cwrite,
>> >> >   File "C:\Python24\lib\subprocess.py", line 609, in _get_handles
>> >> > p2cread = self._make_inheritable(p2cread)
>> >> >   File "C:\Python24\lib\subprocess.py", line 650, in _make_inheritable
>> >> > DUPLICATE_SAME_ACCESS)
>> >> > TypeError: an integer is required
>> >>
>> >> This looks like these known bugs:
>> >>  http://python.org/sf/1124861
>> >>  http://python.org/sf/1126208
>> >>
>> >> Try setting stderr to subprocess.PIPE.  I think that was what worked for
>> >> me.  (You might also try setting shell=True.  That's what I currently
>> >> have in my code that didn't work before.)
>> >
>> > if someone wants to investigate, is seeing this problem, and have the win32
>> > extensions on their machine, try changing this line in subprocess.py:
>> >
>> >if 0: # <-- change this to use pywin32 instead of the _subprocess driver
>> >
>> > to:
>> >
>> >if 1: # <-- change this to use _subprocess instead of the pywin32 driver
>> >
>> > and see if it either fixes the problem (not very likely) or gives you a 
>> > better
>> > error message (very likely).
>> >
>> > 
>> >
>>
>> The error msg is only slightly better:
>>
>> error: (6, 'DuplicateHandle', 'The handle is invalid.')
>>
>> Basically, gui apps like VS don't have a console, so
>> GetStdHandle returns 0.   _subprocess.GetStdHandle
>> returns None if the handle is 0, which gives the original
>> error.  Pywin32 just returns the 0, so the process gets
>> one step further but still hits the above error.
>>
>> Subprocess.py should probably check the
>> result of GetStdHandle for None (or 0)
>> and throw a readable error that says something like
>> "No standard handle available, you must specify one"
>>
>>  Roger
>>
>>
>>
>>
>> == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet 
>> News==
>> http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
>> Newsgroups
>> = East and West-Coast Server Farms - Total Privacy via Encryption =
>
> I gathered as much about why this happens in VS. A further question is
> why does n't os.popen fall in the same trap?
>
> Cheers,
>  Uri
>


>From a quick glance at the source, it looks like it always
creates new pipes.

 Roger



== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vancouver Python and Zope: Next Meeting Oct 2nd

2005-09-26 Thread David Ascher
On 9/26/05, Casey Hawthorne <[EMAIL PROTECTED]> wrote:
> Where is ActiveState?

580 Granville St, (corner of Dunsmuir).  See
http://maps.google.com/maps?q=580+Granville+St,+Vancouver+BC&spn=0.027339,0.057730&hl=en
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attribute error

2005-09-26 Thread Steven D'Aprano
On Mon, 26 Sep 2005 18:28:56 -0400, M.N.A.Smadi wrote:

> HI;
> 
> I am  having the following error.  I am using someone else's code and 
> all they are doing is pass an argv to a function then
> 
> def execute_action(manager, argv):
> method_name = argv.pop(0).lower()
> 
> 
> and am getting this strange error.
> AttributeError: 'str' object has no attribute 'pop'

Since you haven't told us what you have passed as argv, I will look into
my crystal ball and use my psychic powers... 

Things are unclear... no, wait, I see a glimmer of light... are you using
a single string, something like "this is a list of arguments"? The
function is expecting a list of strings ["this", "is", "a", "list", "of",
"arguments"].

You may find the split() method useful for breaking up a single string
into a list of strings.


-- 
Steven.

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


Re: ncurses programming

2005-09-26 Thread Colin Bell
Theres also Urwid , a user interface library
built around curses which looks quite good. I started using it on a
project a little while ago but got sidetracked.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vancouver Python and Zope: Next Meeting Oct 2nd

2005-09-26 Thread Casey Hawthorne
Where is ActiveState?

On Mon, 26 Sep 2005 11:58:33 -0700, you wrote:

>The Vancouver Python and Zope user groups next meeting is on Oct 4th, at 
>the usual place, ActiveState at 7.
>
>Mishtu Banerjee will be giving a talked entitled "Desperately Seeking 
>Abstraction"
>
>"I built an SQL query generator (as part of a larger project) based on 
>the underlying abstraction of representing data models as "networks". 
>It's a nice illustration of abstracting a particular analysis pattern 
>(in this case, we're abstracting the pattern of multi-table inner joins, 
>which is one of the most common ad-hoc query types)"
>
>For more information see our website: http://www.vanpyz.org
>
>Mailing list: http://www.agmweb.ca/cgi-bin/mailman/listinfo/list
--
Regards,
Casey
-- 
http://mail.python.org/mailman/listinfo/python-list


attribute error

2005-09-26 Thread M.N.A.Smadi
HI;

I am  having the following error.  I am using someone else's code and 
all they are doing is pass an argv to a function then

def execute_action(manager, argv):
method_name = argv.pop(0).lower()


and am getting this strange error.
AttributeError: 'str' object has no attribute 'pop'

am using Python 2.3.4 and am importing the following libraries:

import sys, os, inspect
from Asterisk import Manager, BaseException, Config
import Asterisk.Util

but i always thought that something like this will be standard stuff.  
Any ideas?

thanks
moe smadi
-- 
http://mail.python.org/mailman/listinfo/python-list


PEP 350: Codetags

2005-09-26 Thread Micah Elliott
Please read/comment/vote.  This circulated as a pre-PEP proposal
submitted to c.l.py on August 10, but has changed quite a bit since
then.  I'm reposting this since it is now "Open (under consideration)"
at .

Thanks!

-- 
Micah Elliott 


PEP: 350
Title: Codetags
Version: $Revision: 1.2 $
Last-Modified: $Date: 2005/09/26 19:56:53 $
Author: Micah Elliott 
Status: Draft
Type: Informational
Content-Type: text/x-rst
Created: 27-Jun-2005
Post-History: 10-Aug-2005, 26-Sep-2005


Abstract


This informational PEP aims to provide guidelines for consistent use
of *codetags*, which would enable the construction of standard
utilities to take advantage of the codetag information, as well as
making Python code more uniform across projects.  Codetags also
represent a very lightweight programming micro-paradigm and become
useful for project management, documentation, change tracking, and
project health monitoring.  This is submitted as a PEP because its
ideas are thought to be Pythonic, although the concepts are not unique
to Python programming.  Herein are the definition of codetags, the
philosophy behind them, a motivation for standardized conventions,
some examples, a specification, a toolset description, and possible
objections to the Codetag project/paradigm.

This PEP is also living as a wiki_ for people to add comments.


What Are Codetags?
==

Programmers widely use ad-hoc code comment markup conventions to serve
as reminders of sections of code that need closer inspection or
review.  Examples of markup include ``FIXME``, ``TODO``, ``XXX``,
``BUG``, but there many more in wide use in existing software.  Such
markup will henceforth be referred to as *codetags*.  These codetags
may show up in application code, unit tests, scripts, general
documentation, or wherever suitable.

Codetags have been under discussion and in use (hundreds of codetags
in the Python 2.4 sources) in many places (e.g., c2_) for many years.
See References_ for further historic and current information.


Philosophy
==

If you subscribe to most of these values, then codetags will likely be
useful for you.

1. As much information as possible should be contained **inside the
   source code** (application code or unit tests).  This along with
   use of codetags impedes duplication.  Most documentation can be
   generated from that source code; e.g., by using help2man, man2html,
   docutils, epydoc/pydoc, ctdoc, etc.

2. Information should be almost **never duplicated** -- it should be
   recorded in a single original format and all other locations should
   be automatically generated from the original, or simply be
   referenced.  This is famously known as the Single Point Of
   Truth (SPOT) or Don't Repeat Yourself (DRY) rule.

3. Documentation that gets into customers' hands should be
   **auto-generated** from single sources into all other output
   formats.  People want documentation in many forms.  It is thus
   important to have a documentation system that can generate all of
   these.

4. The **developers are the documentation team**.  They write the code
   and should know the code the best.  There should not be a
   dedicated, disjoint documentation team for any non-huge project.

5. **Plain text** (with non-invasive markup) is the best format for
   writing anything.  All other formats are to be generated from the
   plain text.

Codetag design was influenced by the following goals:

A. Comments should be short whenever possible.

B. Codetag fields should be optional and of minimal length.  Default
   values and custom fields can be set by individual code shops.

C. Codetags should be minimalistic.  The quicker it is to jot
   something down, the more likely it is to get jotted.

D. The most common use of codetags will only have zero to two fields
   specified, and these should be the easiest to type and read.


Motivation
==

* **Various productivity tools can be built around codetags.**

  See Tools_.

* **Encourages consistency.**

  Historically, a subset of these codetags has been used informally in
  the majority of source code in existence, whether in Python or in
  other languages.  Tags have been used in an inconsistent manner with
  different spellings, semantics, format, and placement.  For example,
  some programmers might include datestamps and/or user identifiers,
  limit to a single line or not, spell the codetag differently than
  others, etc.

* **Encourages adherence to SPOT/DRY principle.**

  E.g., generating a roadmap dynamically from codetags instead of
  keeping TODOs in sync with separate roadmap document.

* **Easy to remember.**

  All codetags must be concise, intuitive, and semantically
  non-overlapping with others.  The format must also be simple.

* **Use not required/imposed.**

  If you don't use codetags already, there's no obligation to start,
  and no risk of affecting code (but see Objections_).  A small subset
  can be 

Re: Memory stats

2005-09-26 Thread Martin v. Löwis
Tarek Ziadé wrote:
> I am trying to find a general memory profiler that can measure the
> memory usage in Python program
> and gather some stats about object usages, and things like that.

As Diez says, use gc: gc.getobjects() gives you all container objects.
If you want a list of all objects (container or not), you have to
compile a debug build of Python.

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


Re: Metaclasses, decorators, and synchronization

2005-09-26 Thread Michael Ekstrand
On Sep 26, 2005, at 4:21 PM, Scott David Daniels wrote:
> Unnecessarily holding a lock while acquiring another can be a nasty
> source of deadlock or at least delay.  Another source of problems is
> holding a lock because an exception skipped past the release code.

I had thought of part of that after I sent my email. Didn't think of 
the exception issue or the specific deadlock scenario though.  Thank 
you much for your help/advice.

One issue remains in this function: my method's signature is lost when 
synchronized is applied (at least as somemeth=synchronized(somemeth); 
I'm currently in a 2.3 environment that doesn't have the decorator 
syntax, but my understanding is that makes no difference). I've been 
able to preserve the doc string by setting the __doc__ attribute of the 
inner function before returning it, but is there a way to make this 
inner function appear to bear the same argument list as the original 
method? I've been poking around in new and inspect, but it is not 
appearing like an easy task.

Thanks,
- Michael

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


Re: Metaclasses, decorators, and synchronization

2005-09-26 Thread Scott David Daniels
Michael Ekstrand wrote:
> Something like this (not yet tested):
> 
> import threading
> global_lock = threading.Lock()
> def synchronized(meth):
> def inner(self, *args, **kwargs):
> try:
> self._sync_lock.acquire()
> except AttributeError:
> global_lock.acquire()
> if not hasattr(self, '_sync_lock'):
> self._sync_lock = threading.RLock()
> self._sync_lock.acquire()
> global_lock.release()
> meth(self, *args, **kwargs)
> self._sync_lock.release()
> return inner
> I don't think this solution has any race conditions (hence the re-check 
> of the existence of _sync_lock), and I've tried to optimize it for the 
> common case in my project (calling the method after the lock has been 
> put in place - that will happen much more than a call to a synchronized 
> method of a fresh object).

Better would probably be:

 > ...
 > except AttributeError:
 > global_lock.acquire()
 > if not hasattr(self, '_sync_lock'):
 > self._sync_lock = threading.RLock()
 > global_lock.release()  # release first
 > self._sync_lock.acquire()
 > ...
or even:
 > def synchronized(meth):
 > def inner(self, *args, **kwargs):
 > try:
 > self._sync_lock.acquire()
 > except AttributeError:
 > global_lock.acquire()
 > if not hasattr(self, '_sync_lock'):
 > try:
 > self._sync_lock = threading.RLock()
 > finally:
 > global_lock.release()  # release first
 > self._sync_lock.acquire()
 > try:
 > meth(self, *args, **kwargs)
 > finally:
 > self._sync_lock.release()
 > return inner

Unnecessarily holding a lock while acquiring another can be a nasty
source of deadlock or at least delay.  Another source of problems is
holding a lock because an exception skipped past the release code.

Imagine in your original code:
 > Atry:
 > Bself._sync_lock.acquire()
 > Cexcept AttributeError:
 > Dglobal_lock.acquire()
 > Eif not hasattr(self, '_sync_lock'):
 > Fself._sync_lock = threading.RLock()
 > Gself._sync_lock.acquire()
 > Hglobal_lock.release()
 > Imeth(self, *args, **kwargs)
 > Jself._sync_lock.release()

Thread one executes:
 o = TheClass()
 v = o.themethod()  # and executes: A, B, C, D, E, F
 # Now thread1 holds only global_lock
Then Thread two executes:
 w = o.themethod()  # and executes: A, B, I
 # now thread 2 holds o._sync_lock

Thread one cannot proceed (it needs o._sync_lock) until Thread two
completes its code.  If, for example, the method body in Thread two
calls an unrelated synchronized method (perhaps on another object)
and must create another _sync_lock, Threads one and two will be
deadlocked.


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


Re: Best practices for dynamically loading plugins at startup

2005-09-26 Thread Christoph Haas
On Sun, Sep 25, 2005 at 11:33:03PM -0400, Jeff Schwab wrote:
> I recently came up against this exact problem.  My preference is to have 
> the plugin writer call a method to register the plugins, as this allows 
> him the most control.  Something along these lines:
> 
>   class A_plugin(Plugin):
>   ...
> 
>   class Another_plugin(Plugin):
>   ...
> 
>   register( A_plugin )
>   register( Another_plugin, optional_custom_registration_parameters )

I like the idea. And "supybot" seems to do just that. What would the
"def register:" do? Maintain a global list of registered plugins?
I didn't like the idea of having global variables. Or would register
be a method of some "main" class? How would I access that?

Thanks to everybody else who posted ideas on my problem. I'm trying
all the proposals to get an idea of which approach works best.

Regards
 Christoph
-- 
~
~
~
".signature" [Modified] 3 lines --100%--3,41 All
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Carrying variables over from function to function

2005-09-26 Thread Bruno Desthuilliers
Ivan Shevanski a écrit :
> Alright heres my problem. . .Say I want to carry over a variable from 
> one function to another or even another run of the same function. Is 
> that possible? Heres a quick example of what I'm talking about.
> 
> def abc():
>x = 1
>y = x + 1
>print y
> 
> def abcd():
>y = x + 1
>print y
> 
> abc()
> abcd()
> 
> the output would be:
> 
 abc()
> 
> 2
> 
 abcd()
> 
> Traceback (most recent call last):
>File "(stdin)", line 1, in ?
>File "(stdin)", line 2, in abcd
> NameError: global name 'x' is not defined
> 
 
> 
> 
> See, I want y in the second function to equal 4, carrying the x from the 
> first function over to the next.  Is there any way to do this?
> 

Actually, there are at least 3 ways to do it.

1/ Dirty solution:
--
x = 0
def abc():
   global x
   x = 1
   print x + 1

def abcd():
   global x
   print x + 1


2/ functional solution:
---
def make_funcs():
   x = 0
   def _abc():
 x = 1
 return x + 1
   def _abcd():
 return x + 1
   return _abc, _abcd

abc, abcd = make_funcs()
print abc()
print abcd()


3/ OO solution:
---
class Foo(object):
   def __init__(self):
 self._init_x()

   def _init_x(self):
 self._x = 1

   def abc(self):
 self._init_x()
 return self.abcd()

   def abcd(self):
 return self._x + 1

f = Foo()
print f.abc()
print f.abcd()


Now guess which are:
A/ the pythonic solution
B/ the worst possible solution
C/ the most arcane solution

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


Dr. Dobb's Python-URL! - weekly Python news and links (Sep 26)

2005-09-26 Thread Diez B. Roggisch
QOTW:  "This is Open Source. If you want an initiative, start
one." -- Rheinold Birkenfeld

"I've found jython incredibly helpful in learning java." -- pythonUser_07


The fourth annual "Free Software and Open Source Symposium" hosted by
Canada's largest college includes a talk on "Python Power -- Learning,
Teaching and Doing with the World's Easiest Programming Language":
http://cs.senecac.on.ca/soss/2005/agenda.php
http://cs.senecac.on.ca/soss/2005/presentations/george.php

The first PyWeek Game Programming Challenge is finished - and it seems
it was a great success. See this thread for the results:
http://groups.google.com/group/comp.lang.python/msg/e33c3ee2550b90d3

py2exe has been a tremendous help for lots of application
developers - but its maintainer is getting tired maintaining it.
Any volunteers?
http://groups.google.com/group/comp.lang.python/msg/397dbc71441a8890

pythonXX.dll gets larger and larger - read on how you can reduce it
in size if you absolutely must in the age of gigabyte-equipped
mp3-players:
http://groups.google.com/group/comp.lang.python/msg/a20f937a67047406

Laszlo Zolt Nagy learns that self-reordering lists aren't the solution
for least-recently-used caches - and is given some pointers where to
find implementations of these:
http://groups.google.com/group/comp.lang.python/msg/5431d51de8d3c9a1

Mercurial is a Python-based "distributed SCM" .
http://www.selenic.com/mercurial/wiki/index.cgi  

This is to all of the home-brewn frankenstein-style DNA-sequence
manglers: use Python, but don't use immutable strings when a list
is all you need to fine-tune your next creation:
http://groups.google.com/group/comp.lang.python/msg/78b7f9df4f36b2db

sys.argv nicely provides command-line arguments - most of the time.
But when it comes to passing internationalized strings on windows,
one has to use the win32-API:

http://groups.google.com/group/comp.lang.python/browse_frm/thread/22bcdd80266c6b68/5ed8287c40c79e10?q=Python+argv+and+special+characters&rnum=1#5ed8287c40c79e10



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

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

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

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

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

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

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

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

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

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

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

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

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Py

Re: Need to pass Object by value into a list

2005-09-26 Thread Bruno Desthuilliers
Aaron a écrit :

> I have a data sructure setup and I populate it in a loop like so:
> 
> y=0
> while X:
>DS.name = "ASDF"
>DS.ID = 1234
>list[y] = DS;
>y = y + 1
> 
> print list

Traceback (most recent call last):
   File "", line 1, in ?
   File "/usr/tmp/python-9150sSF", line 2, in ?
 while X:
NameError: name 'X' is not defined

Please post running code. The rule is:
- explain what you did
- explain what you expected
- explain what you've got
- post the minimal running code that reproduce the problem

Here are a short listing of errors and bad style in this code:

1/ DS is not defined
2/ X is not defined
3/ 'list' is the name of the builtin class list. The list *class* is 
unsubscriptable.
4/ Assuming you rebound the name 'list' to a list instance (which is a 
very Bad Thing(tm)), you still can't assign to an inexistant index
5/ even if DS and X were defined, this loop would run forever
6/ In Python, identifiers in uppercase are constants (well... this is 
only a convention, but convention in Python are part of the language, 
even if there's nothing to enforce them)
7/ you mix arbitrary naming conventions ('DS.name' vs 'DS.ID', 'X' vs 'y').

Either this is not your real code or you did not try to run this code. 
In fact, I guess this is not your real code AND you did not try to run 
it. Please do *yourself* a favor: post running code (I don't mean 'code 
that don't crash', I mean: 'code that reproduce your real problem').

> This does not work 

"Does not work" is the worst possible description of a problem.

Now effectively, this code (the one you posted, not the one you are 
describing) crashes for a very obvious reason (see point n°1 above). The 
code you are describing (which is obviously different...) "works" - it 
may not behave how you'd expect it to, but this is another problem.

> because DS is passed in by reference causing all
> entries into the list to change to the most current value.

DS is not 'passed by reference', since there is no function call in your 
code. A reference to the object bound to the name DS is stored (well, I 
assume this is what happen in your real code) in the list  - which is 
not the same thing.


BTW, you need to understand that, in Python, an identifier is just a 
name bound to a reference to an object. Think of the namespace as a 
hashtable with names as keys and references to objects as values (this 
exactly how it's implemented). When it comes to function calls, the 
*name* is local to the function, but the object referenced by the name 
is the original object. If you rebind the name (ie: 'assign' another 
object to it), this change will be local, because the *name* is local. 
But if you modify the object itself, this will impact the 'original' 
object, ie:

def fun(aList, anotherList):
   # rebind local name 'aList', original object not impacted
   aList = [1, 2, 3]

   # modify ('mutate') object bound to 'anotherList',
   # original object impacted
   anotherList.append(42)

listOne = [4, 5, 6]
listTwo = [7, 8, 9]

fun(listOne, listTow)
print listOne
print listTwo



>  I cannot
> find a "new" function in Python like there is in C++.


In C++, 'new' is an operator, not a function.


In Python, classes are callable objects (a callable is something like a 
function - or, should I say, a function is a kind of callable object - 
everything in Python being an object...) that return an instance when 
called. So there is no need for a 'new' operator - just call the class 
object (like you'd call a function), and you'll get an instance. Also, 
if the class has an '__init__' method, this method will be called after 
object instanciation, with the arguments passed when calling the class.

ie:

class Foo(object):
   def __init__(self, name):
 self.name = name

f = Foo('foo')
f.name
=> 'foo'

>  How do you do
> this in Python?
> 

class Ds(object):
   def __init__(self, id, name):
 self.id = id
 self.name = name

x = 42 # or any other integer value

# short way
ds_list = [Ds(1234, "ASDF") for i in range(x)]
print ds_list

# verbose way:
ds=list = []
for i in range(x):
   ds_list.append(Ds(1234, "ASDF")

print ds_list
ds_list[0].name="FOO"
print ds_list

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


RE: Plotting points to screen

2005-09-26 Thread Michael . Coll-Barth
Jason,

YMMV = Your Mileage May Vary

In other words, how well it works for you depends on a lot of things.  You
need to determine the suitability for a given task.  :)

Michael




  Don't like the legal notice at the end of my email?  Too bad, you can
stuff it where the sun don't shine.



-Original Message-
From: Jason
Sent: Monday, September 26, 2005 3:46 PM
To: python-list@python.org
Subject: Re: Plotting points to screen


One question, that's twice in as many days that someone has said "YMMV".

What's it mean!?

-- 
http://mail.python.org/mailman/listinfo/python-list
___
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

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


Re: Plotting points to screen

2005-09-26 Thread Fredrik Lundh
Jay wrote:

> One question, that's twice in as many days that someone has said "YMMV".
>
> What's it mean!?

http://www.google.com/search?q=acronym+ymmv 



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


Re: Metaclasses, decorators, and synchronization

2005-09-26 Thread Michael Ekstrand
On Sep 26, 2005, at 2:16 PM, Tom Anderson wrote:
> You could define a meta-lock, and use that to protect the
> lock-installation action.

Something like this (not yet tested):

import threading

global_lock = threading.Lock()

def synchronized(meth):
 def inner(self, *args, **kwargs):
 try:
 self._sync_lock.acquire()
 except AttributeError:
 global_lock.acquire()
 if not hasattr(self, '_sync_lock'):
 self._sync_lock = threading.RLock()
 self._sync_lock.acquire()
 global_lock.release()
 meth(self, *args, **kwargs)
 self._sync_lock.release()
 return inner

I don't think this solution has any race conditions (hence the re-check 
of the existence of _sync_lock), and I've tried to optimize it for the 
common case in my project (calling the method after the lock has been 
put in place - that will happen much more than a call to a synchronized 
method of a fresh object).

As I said, I'm kinda new to this threading stuff... is there anything 
I'm missing in this implementation?

-Michael

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


Re: Plotting points to screen

2005-09-26 Thread Jason
jay graves wrote:
> I've used both pygame and PIL for this in the past.  (i'm plotting a
> non-standard 3d data format from a in-house app)
> Pygame was nice because I put a key handler in to reload the file and
> do a little zooming/panning and when I wanted to save a particular plot
> I would just use a screen capture program.
> Then I upgraded my harddrive and didn't re-install PyGame. The next
> time I had to plot some data, I tweaked my script to use PIL.  I ended
> up liking this solution better.  I could easily create large images
> (bigger than physical screen which was a limiting factor in PyGame) and
> used a regular image viewer to pan and shrink/zoom.  I had the drawing
> portions of my script well separated from the data parsing and
> manipulation so tweaking the script was simple.
> 
> YMMV, but PIL was the best way for me.
> 
> ...
> jay graves
> 
Thanks Jay.

One question, that's twice in as many days that someone has said "YMMV".

What's it mean!?

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


Re: Python Programming

2005-09-26 Thread Michael Ekstrand
On Sep 26, 2005, at 1:46 PM, David Edwards wrote:
> I've got a short, simple Python script that is
> supposed to read a midi file and produce a text file
> of note and volume information, then render that info
> in another program.
>
> Unfortunately, I can't get it to work, so I was
> wondering if anyone is skilled enough to rewrite the
> script to read and render the info using PIL instead,
> as well as allowing me to save the results in .ps,
> .eps, or .ai formats for use in other programs like
> Photoshop or Illustrator.

Not a direct answer, but... I'd check out Lilypond. It's a music 
typesetting system; as I recall, it has the capacity to extract music 
data from MIDI files and generate Lilypond files, and then the Lilypond 
data can be converted to PS, DVI, PDF, etc.

-Michael

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


Re: PyDev 0.9.8.2 released

2005-09-26 Thread Alacrite
Anyone know how to get IPython to display properly when using it as an
external tool? It will display nothing and give no feedback until
output of some kind then it will do it all at once.

Love the plug-in though! 
thanks Fabio

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



Re: Would this be Guido's pen? [OT]

2005-09-26 Thread Terry Reedy

"Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> http://www.empirepens.com/signum_python.html

"Each cap in this series is hand covered with genuine python."

Am I to understand that they actually mean real python skin, as opposed to 
a 'genuine' python skin design on whatever material?  Is there a European 
fetish for the real thing?

Terry




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


Re: Plotting points to screen

2005-09-26 Thread jay graves
I've used both pygame and PIL for this in the past.  (i'm plotting a
non-standard 3d data format from a in-house app)
Pygame was nice because I put a key handler in to reload the file and
do a little zooming/panning and when I wanted to save a particular plot
I would just use a screen capture program.
Then I upgraded my harddrive and didn't re-install PyGame. The next
time I had to plot some data, I tweaked my script to use PIL.  I ended
up liking this solution better.  I could easily create large images
(bigger than physical screen which was a limiting factor in PyGame) and
used a regular image viewer to pan and shrink/zoom.  I had the drawing
portions of my script well separated from the data parsing and
manipulation so tweaking the script was simple.

YMMV, but PIL was the best way for me.

...
jay graves

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


Debugging callbacks?

2005-09-26 Thread brucedickey
Title: Debugging callbacks?






Hi All,


I have a Python app that receives CORBA callbacks in Linux. I post a msg to the GUI and am having refresh issues with some GTK controls in wxPython. 

The Python-specific question is -- I have tried to set a breakpoint inside the event handler in the GUI, but the debugger does not break. (Works fine anywhere else). Is this activity not supported? Or is there a way to debug the event handler in the debugger (w/o resorting to prints)? How? 

More specifics: This is a two-way CORBA callback. In the Python module handling the callback I post a message (ProcessEvent) to the GUI and immediately returns. It is in the event handler in the GUI that I want to break with the debugger. (Using Wing 2.0). 

Thanks,


Bruce



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

Re: ncurses programming

2005-09-26 Thread Torsten Bronger
Hallöchen!

Grant Edwards <[EMAIL PROTECTED]> writes:

> On 2005-09-26, Mike Meyer <[EMAIL PROTECTED]> wrote:
> [...]
 Py Docs:   http://docs.python.org/lib/module-curses.html
>>>
>>> This document suggests that Python+ncurses won't work on windows.
>>> What's the reason for this?
>>
>> Could it be that ncurses doesn't work on Windows? At least, it
>> didn't last time I looked. There was a curses library for
>> Windows, but you'll have to google for it.
>
> I think there used to be something called pdcurses that 
> supposedly worked under windows.

Wouldn't http://gnuwin32.sourceforge.net/packages/ncurses.htm be a
good starting point?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetusICQ 264-296-646
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting tired with py2exe

2005-09-26 Thread Thomas Heller
> Thomas Heller wrote:
>> Bugs <[EMAIL PROTECTED]> writes:
>>
>>>Any luck on finding anyone to take over py2exe development Thomas?
>>>It's a GREAT project and would be a shame to see it fall into
>>>obsolescence.
>> No, nobody stepped up (yet).
>> Thomas

Bugs <[EMAIL PROTECTED]> writes:

> What do you think of the idea of putting both py2exe AND py2app under
> the same umbrella?  I don't know what the status of py2app is or who
> maintains it but I was thinking that it would be ideal if the 2
> utilities could share code, ideas, protocols, etc.  Seems like this
> synergy and consistency would be very beneficial.  Perhaps then a
> Linux version could be developed with an identical inferface.

That's not a bad idea.  Philip Eby even suggested to put something like
py2exe's modulefinder (well, it's really Python's) and py2app's
modulegraph into his setuptools package - although I didn't respond at
that time.

Anyway, these are changes that I don't want to do myself.  Whoever wants
to start that feel free...

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


Re: Metaclasses, decorators, and synchronization

2005-09-26 Thread Tom Anderson
On Mon, 26 Sep 2005, Jp Calderone wrote:

> On Sun, 25 Sep 2005 23:30:21 -0400, Victor Ng <[EMAIL PROTECTED]> wrote:
>> You could do it with a metaclass, but I think that's probably overkill.
>> 
>> It's not really efficient as it's doing test/set of an RLock all the
>> time, but hey - you didn't ask for efficient.  :)
>
> There's a race condition in this version of synchronized which can allow two 
> or more threads to execute the synchronized function simultaneously.

You could define a meta-lock, and use that to protect the 
lock-installation action.

To avoid bottlenecking on the single meta-lock, you could put a meta-lock 
in each class, and use that to protect installation of locks in instances 
of that class. You would, of course, then need a meta-meta-lock to protect 
those.

Also, and more helpfully, you can get a modest speedup by taking out the 
explicit test for the presence of the lock, and just rely on getting an 
AttributeError from self._sync_lock.acquire() if it's not there; you could 
then install the lock in the except suite.

tom

-- 
90% mental, 25% effort, 8% mathematics
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing class variable at class creation time

2005-09-26 Thread Dave Hansen
On 23 Sep 2005 14:01:21 -0700, "Carlos" <[EMAIL PROTECTED]>
wrote:

>Hi!
>
>class A:
>  X = 2
>  def F():
>print A.X
>  F()
>
>The above fails because the name A is not
>yet at global scope when the reference A.X

Maybe I'm missing something.  Python 2.4.1#65 under Win32 Idle 1.1.1
gives me the following:

--begin included file---
>>> class A:
X = 2
def F():
print A.X
F()


2
---end included file---

But what good is F?  You can't call A.F() because methods need an
instance, and calling A.F(instance) or instance.F() throws a TypeError
(argument count) exception.

Regards,

   -=Dave
-- 
Change is inevitable, progress is not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accesing Global variables in python

2005-09-26 Thread Terry Reedy

> I have a service written in python (on Apache 2.0) which

This is an exact duplicate of the same posting under the subject
'Accesing Global variables in multiple Requests (Apache 2.0)'
Let's put any substantive responses under that one.



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


Re: Plotting points to screen

2005-09-26 Thread Fredrik Lundh
Jason wrote:

> Like I said, it's nothing complicated, no flashing wotsits or 3d
> quad-linear vertexes with bi-linear real-time shading, just simple
> 'points' a few lines or circles and nothing more.

all UI toolkits can do that.  just pick one, and read up on the
graphics API.  for Tkinter, you can use the Canvas widget or
the WCK:

http://effbot.org/zone/wck-3.htm

or a pixel canvas, or perhaps WCK+AGG:

http://effbot.org/zone/wck-pixelcanvas.htm
http://effbot.org/zone/draw-agg.htm

etc.  more links:

http://piddle.sourceforge.net/
http://www.wxpython.org/
http://matplotlib.sourceforge.net/
http://www.riverbankcomputing.co.uk/pyqt/index.php

 



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


Re: ncurses programming

2005-09-26 Thread Grant Edwards
On 2005-09-26, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2005-09-26, Mike Meyer <[EMAIL PROTECTED]> wrote:
> [...]
 Py Docs:   http://docs.python.org/lib/module-curses.html
>>>
>>> This document suggests that Python+ncurses won't work on windows.
>>> What's the reason for this?
>>
>> Could it be that ncurses doesn't work on Windows? At least, it
>> didn't last time I looked. There was a curses library for
>> Windows, but you'll have to google for it.
>
> I think there used to be something called pdcurses that 
> supposedly worked under windows.  That was quite a while ago, I
> never tried it, and I may be misremembering the name.

 http://pdcurses.sourceforge.net/

> I've no idea if there was a pdcurses module for python.

Apparently there was at one time:

 http://teyc.editthispage.com/filedownloads

A more recent reference:
 
 http://mail.python.org/pipermail/patches/2005-June/017763.html
 
-- 
Grant Edwards   grante Yow!  I wish I was a
  at   sex-starved manicurist
   visi.comfound dead in the Bronx!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: add sys to __builtins__

2005-09-26 Thread Tom Anderson
On Sun, 25 Sep 2005, James Stroud wrote:

> I'm into *real* purity. I would rather begin every script:
>
>  from python import list, str, dict, sys, os
>
> Oh wait. I only use dict in less than 50% of my scripts:
>
>  from python import list, str, sys, os
>
> That's better.

What? How exactly is that pure? "from x import y" is bletcherosity 
incarnate! You should do:

import python

s = python.str(5)
# etc

And don't let me see you importing like that again!

tom

-- 
90% mental, 25% effort, 8% mathematics
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best practices for dynamically loading plugins at startup

2005-09-26 Thread Jack Diederich
On Sun, Sep 25, 2005 at 11:24:04PM +0200, Christoph Haas wrote:
> Dear coders...
> 
> I'm working on an application that is supposed to support "plugins".
> The idea is to use the plugins as packages like this:
> 
> Plugins/
>   __init__.py
>   Plugin1.py
>   Plugin2.py
>   Plugin3.py
> 
> When the application starts up I want to have these modules loaded
> dynamically. Users can put their own plugin modules into the
> Plugins/ directory and the application should know about it.
> 
> Each plugin is supposed to be a class derived from a general
> "Plugin" superclass. I just don't know how to 'register' every
> plugin. 

If you want every class that defines the Plugin class to be registered
a metaclass will get you there.  Here is one that I use.

class Register(type):
  """A tiny metaclass to help classes register themselves automagically"""
  def __init__(cls, name, bases, dict):
if ('register' in dict): # initial dummy class
  setattr(cls, 'register', staticmethod(dict['register']))
elif (getattr(cls, 'DO_NOT_REGISTER', 0)): # we don't want to register this 
non-concrete class
  delattr(cls, 'DO_NOT_REGISTER')
elif (object not in bases):
  cls.register(name, cls)
return

class Plugin(object):
  __metaclass__ = Register
  all_plugins = []
  def register(name, cls):
all_plugins.append(cls)
return

Plugin.all_plugins will be a list of all the classes that inherit from Plugin
(and that don't have a DO_NOT_REGISTER attribute).

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


Re: ncurses programming

2005-09-26 Thread Grant Edwards
On 2005-09-26, Mike Meyer <[EMAIL PROTECTED]> wrote:
[...]
>>> Py Docs:   http://docs.python.org/lib/module-curses.html
>>
>> This document suggests that Python+ncurses won't work on windows.
>> What's the reason for this?
>
> Could it be that ncurses doesn't work on Windows? At least, it
> didn't last time I looked. There was a curses library for
> Windows, but you'll have to google for it.

I think there used to be something called pdcurses that 
supposedly worked under windows.  That was quite a while ago, I
never tried it, and I may be misremembering the name.

I've no idea if there was a pdcurses module for python.

-- 
Grant Edwards   grante Yow!  I will SHAVE and
  at   buy JELL-O and bring my
   visi.comMARRIAGE MANUAL!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Plotting points to screen

2005-09-26 Thread Jason
If I'm wanting to plot points to the screen (nothing fancy at all for 
the moment), would you recommend PyGame, PyOpenGL or PIL?

Like I said, it's nothing complicated, no flashing wotsits or 3d 
quad-linear vertexes with bi-linear real-time shading, just simple 
'points' a few lines or circles and nothing more.

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


Re: Telephony project

2005-09-26 Thread Paul Rubin
"Roger" <[EMAIL PROTECTED]> writes:
>   1. Fetch phone number from my ASCII data.
>   2. Dial (always a local number) phone (through USRobotics 56K? ).
>   3. Ask @3 questions to called phone number. Y/N   Y/N   Y/N
>   4. Save answers to ASCII file.
>   5. Say 'Thanks', hang up.
>   Repeat till eof()

There is an excellent graphic on the web showing how to do this phone
spamming with Python.  It used to be at http://goatse.cx but I don't
know where it is now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Programming

2005-09-26 Thread David Edwards
I've got a short, simple Python script that is
supposed to read a midi file and produce a text file
of note and volume information, then render that info
in another program.

Unfortunately, I can't get it to work, so I was
wondering if anyone is skilled enough to rewrite the
script to read and render the info using PIL instead,
as well as allowing me to save the results in .ps,
.eps, or .ai formats for use in other programs like
Photoshop or Illustrator.

If anyone has the skills, what would you charge?

Thanks,

David

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


Re: ncurses programming

2005-09-26 Thread Mike Meyer
Torsten Bronger <[EMAIL PROTECTED]> writes:

> Hallöchen!
>
> "ncf" <[EMAIL PROTECTED]> writes:
>
>> [...]
>>
>> Py Docs:   http://docs.python.org/lib/module-curses.html
>
> This document suggests that Python+ncurses won't work on windows.
> What's the reason for this?

Could it be that ncurses doesn't work on Windows? At least, it didn't
last time  I looked. There was a curses library for Windows, but
you'll have to google for it.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ^ operator

2005-09-26 Thread Steve Holden
Tuvas wrote:
> What exactly does the ^ operator do? I've seen, for example, that
> 3^4=7, 3^5=8. but 3^3=0. Is it just adding them together if they are
> not equal, and if they are equal, outputs 0, or what? Thanks!
> 

^ is the "bit XOR" operation. It treats its left and right operands as 
binary numbers: the result has a one-bit in those bit positions where 
one operand has a zero and the other has a one.

A B | A XOR B
+
0 0 |0
0 1 |1
1 0 |1
1 1 |0

If you want exponentiation, try **.

  >>> 3**4
81
  >>> 3**5
243
  >>> 3**6
729
  >>> 3**7
2187
  >>>

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

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


Re: The ^ operator

2005-09-26 Thread Tuvas
Thanks alot! That sure makes lots of sense!

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


Re: The ^ operator

2005-09-26 Thread Peter Hansen
Tuvas wrote:
> What exactly does the ^ operator do? I've seen, for example, that
> 3^4=7, 3^5=8. but 3^3=0. Is it just adding them together if they are
> not equal, and if they are equal, outputs 0, or what? Thanks!

It performs an "exclusive-OR" (XOR) operation on the binary data 
corresponding to those values.  Where the boolean AND operation returns 
a 1 where both inputs are 1 and a 0 otherwise, and boolean OR returns a 
1 if either input is 1 but 0 otherwise, the XOR operator returns a 1 if 
the two inputs are different (i.e. one is 0 and the other is 1) but a 0 
if they are the same.

When done on the binary value, each corresponding bit is compared using 
the above logic.  For example, 3 is 0011 in binary, and 4 is 0100, so:

   011 binary for 3
^ 100 binary for 4
   ---
= 111 (which is binary for 7).

(match up the binary digits vertically, so the first digit in the result 
comes from the 0 and the 1 above it, in the two input values).

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


Telephony project

2005-09-26 Thread Roger
I'm new to Python and need to do a (low level, I think) telephony
project ( POTS, all local calling)  in WinXp.
  1. Fetch phone number from my ASCII data.
  2. Dial (always a local number) phone (through USRobotics 56K? ).
  3. Ask @3 questions to called phone number. Y/N   Y/N   Y/N
  4. Save answers to ASCII file.
  5. Say 'Thanks', hang up.
  Repeat till eof()
And...I've not seen any telephony books in/for Python.  Any and all
help, suggestions, directions, etc. would be *GREATLY* appreciated.

   TIA

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


Re: Getting tired with py2exe

2005-09-26 Thread Bugs
What do you think of the idea of putting both py2exe AND py2app under 
the same umbrella?  I don't know what the status of py2app is or who 
maintains it but I was thinking that it would be ideal if the 2 
utilities could share code, ideas, protocols, etc.  Seems like this 
synergy and consistency would be very beneficial.  Perhaps then a Linux 
version could be developed with an identical inferface.

Thomas Heller wrote:
> Bugs <[EMAIL PROTECTED]> writes:
> 
> 
>>Any luck on finding anyone to take over py2exe development Thomas?
>>It's a GREAT project and would be a shame to see it fall into
>>obsolescence.
> 
> 
> No, nobody stepped up (yet).
> 
> Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


The ^ operator

2005-09-26 Thread Tuvas
What exactly does the ^ operator do? I've seen, for example, that
3^4=7, 3^5=8. but 3^3=0. Is it just adding them together if they are
not equal, and if they are equal, outputs 0, or what? Thanks!

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


Re: Determine type of a socket

2005-09-26 Thread Peter Hansen
Reinhold Birkenfeld wrote:
> Peter Hansen wrote:
>>Tor Erik Sønvisen wrote:
>>>How can I determine the type of a socket (TCP or UDP) object?

>>Let's see... what looks good here?
>>
>> >>> u._sock
>>
>> >>> t._sock
>>
>>
>>Maybe that type field?
> 
> Heh. The type field isn't publicly accessible (yet). There is a
> patch on SF for this, in the meanwhile you'll have to parse the
> __repr__ output.

And he might not have to do either, depending on what his situation 
really is.  For example, if his socket is always going to be connected 
(in the case of a TCP socket) I expect checking something about the peer 
would be a quick way to tell the difference, since UDP sockets don't 
shouldn't have peers.  (I'm assuming, not having tested... but I think 
there are probably such approaches that don't involve either _sock or 
repr().  Let's see what the OP reveals.)

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


build problems on AIX

2005-09-26 Thread ersher
I'm having trouble building Python 2.4.1 on AIX 5. I've
built/installed tcl/tk under ~/local, added ~/local/lib to my
$LD_LIBRARY_PATH, and set $LDFLAGS and $CPPFLAGS appropriately. I'm
still getting the following errors:

./Modules/ld_so_aix cc_r -bI:Modules/python.exp \
-L/home/me/local/lib -I/home/me/local/include \
build/temp.aix-5.1-2.4/_tkinter.o build/temp.aix-5.1-2.4/tkappinit.o \
-L/usr/X11R6/lib64 -L/usr/X11R6/lib -L/home/me/local/lib\
-L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o \
build/lib.aix-5.1-2.4/_tkinter.so \
ld: 0706-006 Cannot find or open library file: -l tk8.4
ld:open(): No such file or directory
ld: 0706-006 Cannot find or open library file: -l tcl8.4
ld:open(): No such file or directory


At this point, i have no idea what i'm doing wrong. It looks as if i
should be picking up tcl/tk:

~/local/lib > ls

libtcl8.4.exp  libtclstub8.4.a  libtk8.4.so*tcl8.4/   tk8.4/
libtcl8.4.so*  libtk8.4.exp libtkstub8.4.a  tclConfig.sh
tkConfig.sh

I've tried using CC=xlC_r, as opposed to g++, but that didn't
help. Anyone seen this type of thing? BTW, i'm configuring like this:

./configure --prefix=/home/me/local



thanks in advance,
E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ncurses programming

2005-09-26 Thread Grant Edwards
On 2005-09-26, Sinan Nalkaya <[EMAIL PROTECTED]> wrote:

> hi, i want to use ncurses library in python i`ve found proper
> library for that, PyNcurses. then i searched for some
> documentation about ncurses programming, i only found that web
> site ; http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/
> this howto is nice but seems to me, this is for experienced
> ncurses programmers who have just migrated to python so i dont
> understand anything from examples and howto. what should i do
> ? firstly should i learn ncurses programmin on C then migrate
> to python? thanks.

Here's an introductory page:

http://gnosis.cx/publish/programming/charming_python_6.html

If what you want to do is fairly simple. the "newt" libarary
might worth looking at.  It's very light-weight, easy to use,
and has a bunch of built-in widget types (text entry boxes,
radio buttons, progress bars, message boxes, etc).  It's main
restriction when compated to something like ncurses/forms is
that newt's windows are "stacked" and the user can only
interact with the top one.

Newt was originally developed by RedHat for their text-mode
installer and sysadmin tools that were written in Python.

The documents are a bit sparse and sometimes out-of-date, but
there are a few decent example programs in the source distro.

The Python newt library module is called "snack", so be careful
not to get get confused with the sound library of the same name.

It's available for most Linux distros and requires the "slang"
library.

If your distro doesn't have a pre-built newt library you can
get it from here:

http://www.python.org/pyvault/SRPMS/repodata/repoview/newt-0-0.52.0-3.html

-- 
Grant Edwards   grante Yow!  Imagine--a WORLD
  at   without POODLES...
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ncurses programming

2005-09-26 Thread Torsten Bronger
Hallöchen!

"ncf" <[EMAIL PROTECTED]> writes:

> [...]
>
> Py Docs:   http://docs.python.org/lib/module-curses.html

This document suggests that Python+ncurses won't work on windows.
What's the reason for this?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetusICQ 264-296-646
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CRC16

2005-09-26 Thread Tuvas
I should probably have mentioned that my code is just 6 bytes long, we
send an 8 byte data packet with 2 bytes CRC. There's a CRC poly of
0x1021. Still having a bit of problems, but it's coming, thanks for the
help!

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


Re: Need to pass Object by value into a list

2005-09-26 Thread Fredrik Lundh
Aaron wrote:

> I have a data sructure setup and I populate it in a loop like so:
>
> y=0
> while X:
>DS.name = "ASDF"
>DS.ID = 1234
>
>list[y] = DS;
>y = y + 1
>
> print list
>
> This does not work because DS is passed in by reference causing all
> entries into the list to change to the most current value.  I cannot
> find a "new" function in Python like there is in C++.  How do you do
> this in Python?

I assume DS is a class?

to create an instance of a class, call the class object:

L = []

while X:
ds = DS()
ds.name = "ASDF"
ds.id = 1234
L.append(ds)

spending some time with the tutorial might help:

http://docs.python.org/tut/tut.html

(lists are described in chapter 3, classes in chapter 9)





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


Need to pass Object by value into a list

2005-09-26 Thread Aaron
I have a data sructure setup and I populate it in a loop like so:

y=0
while X:
   DS.name = "ASDF"
   DS.ID = 1234

   list[y] = DS;
   y = y + 1

print list

This does not work because DS is passed in by reference causing all
entries into the list to change to the most current value.  I cannot
find a "new" function in Python like there is in C++.  How do you do
this in Python?

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


PyDev 0.9.8.2 released

2005-09-26 Thread Fabio Zadrozny
Hi All,

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

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

Details for Release: 0.9.8.2

Major highlights:


* Content assistants reviewed (and better documented on the homepage 
-- I really reccomend checking it)
* Timeout parsing options added (this is available in the builder 
preferences page)
* Auto-dedent added

Others that are new and noteworthy:
-

* .pyc is removed when the corresponding .py file is removed.
* Debugger has been changed so that it becomes faster (still not as 
fast as I would like, but still... faster) -- looking for people with 
expertise on this to help me, as I'm kind of lost on which should be the 
'recommended' way to speed it more.
* Some escaped quotes problems fixed when formatting code
* Navigation with Ctrl+Shift+ (up or down) has been slightly 
improved, so that it goes to the start or the end of the file when no 
other class or method declaration is found
* Other bug-fixes (as ususal)

Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

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

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



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


Re: ncurses programming

2005-09-26 Thread ncf
I don't know too much about (n)curses, but I feel that it's worth
pointing out that Python has a (built-in?) module named `curses` that
supports ncurses as of Python version 1.6.

I don't think it'd be necessary to learn how to use ncurses in C first,
though. The Python docs for the curses module is pretty straight
forward, and they link to what I feel is a pretty good tutorial on the
module.

Py Docs:   http://docs.python.org/lib/module-curses.html
Tutorial:   http://www.python.org/doc/howto/curses/curses.html

Also, if you choose to take the Python module route, you might want to
consider using the curses.wrapper module to ensure that if any errors
happen, it will close out curses all of the way instead of allowing
curses to screw up your console window.

Wish I could be of more help. Any questions and I'll gladly look into
it to the best of my abilities.

-Wes

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


Re: ncurses programming

2005-09-26 Thread ncf
I don't know too much about (n)curses, but I feel that it's worth
pointing out that Python has a (built-in?) module named `curses` that
supports ncurses as of Python version 1.6.

I don't think it'd be necessary to learn how to use ncurses in C first,
though. The Python docs for the curses module is pretty straight
forward, and they link to what I feel is a pretty good tutorial on the
module.

Py Docs:   http://docs.python.org/lib/module-curses.html
Tutorial:   http://www.python.org/doc/howto/curses/curses.html

Also, if you choose to take the Python module route, you might want to
consider using the curses.wrapper module to ensure that if any errors
happen, it will close out curses all of the way instead of allowing
curses to screw up your console window.

Wish I could be of more help. Any questions and I'll gladly look into
it to the best of my abilities.

-Wes

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


Re: Getting tired with py2exe

2005-09-26 Thread Thomas Heller
Bugs <[EMAIL PROTECTED]> writes:

> Any luck on finding anyone to take over py2exe development Thomas?
> It's a GREAT project and would be a shame to see it fall into
> obsolescence.

No, nobody stepped up (yet).

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


Re: Determine type of a socket

2005-09-26 Thread Reinhold Birkenfeld
Peter Hansen wrote:
> Tor Erik Sønvisen wrote:
>> How can I determine the type of a socket (TCP or UDP) object?
> 
> In what context?  Do you have some code that gets passed a socket object 
> but it could have been created with either SOCK_STREAM or SOCK_DGRAM? 
> And you want a way of determining by looking just at the object passed 
> in which type it is?  (I could make other guesses, but let's start with 
> that... ;-)  )
> 
> How about this:
> 
>  >>> import socket
>  >>> t = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>  >>> u = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>  >>> dir(t)
> ['__class__',  '_sock', 'accept', 'bind', 'close'
> , 'connect', 'connect_ex', 'dup', 'fileno', 'getpeername',
> ...'setblocking', 'setsockopt', 'settimeout', 'shutdown']
> 
> Let's see... what looks good here?
> 
>  >>> u._sock
> 
>  >>> t._sock
> 
> 
> Maybe that type field?

Heh. The type field isn't publicly accessible (yet). There is a
patch on SF for this, in the meanwhile you'll have to parse the
__repr__ output.

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


Re: [RFC] Parametric Polymorphism

2005-09-26 Thread Bengt Richter
On Sun, 25 Sep 2005 09:30:30 +0100, Catalin Marinas <[EMAIL PROTECTED]> wrote:

>Hi,
>
>Sorry if this was previously discussed but it's something I miss in
>Python. I get around this using isinstance() but it would be cleaner
>to have separate functions with the same name but different argument
>types. I think the idea gets quite close to the Lisp/CLOS
>implementation of methods.
>
>Below is just simple implementation example (and class functions are
>not supported) but it can be further extended/optimised/modified for
>better type detection like issubclass() etc. The idea is similar to
>the @accepts decorator:
>
>
>methods = dict()
>
>def method(*types):
>def build_method(f):
>assert len(types) == f.func_code.co_argcount
>
>if not f.func_name in methods:
>methods[f.func_name] = dict()
>methods[f.func_name][str(types)] = f
>
>def new_f(*args, **kwds):
>type_str = str(tuple([type(arg) for arg in args]))
>assert type_str in methods[f.func_name]
>return methods[f.func_name][type_str](*args, **kwds)
>new_f.func_name = f.func_name
>
>return new_f
>
>return build_method
>
>
>And its utilisation:
>
>@method(int)
>def test(arg):
>print 'int', arg
>
>@method(float)
>def test(arg):
>print 'float', arg
>
>test(1) # succeeds
>test(1.5)   # succeeds
>test(1, 2)  # assert fails
>test('aaa') # assert fails
>
>
>Let me know what you think. Thanks.
>
I am reminded of reinventing multimethods, but an interesting twist, so I'll 
add on ;-)
The following could be made more robust, but avoids a separately named 
dictionary
and lets the function name select a dedicated-to-the-function-name dictionary 
(subclass)
directly instead of looking it up centrally with two levels involved.

Just thought of this variant of your idea, so not tested beyond what you see ;-)

 >>> def method(*types):
 ... def mkdisp(f):
 ... try: disp = eval(f.func_name)
 ... except NameError:
 ... class disp(dict):
 ... def __call__(self, *args):
 ... return self[tuple((type(arg) for arg in args))](*args)
 ... disp = disp()
 ... disp[types] = f
 ... return disp
 ... return mkdisp
 ...
 >>> @method(int)
 ... def test(arg):
 ... print 'int', arg
 ...
 >>> test
 {(,): }
 >>> @method(float)
 ... def test(arg):
 ... print 'float', arg
 ...
 >>> test(1)
 int 1
 >>> test(1.5)
 float 1.5
 >>> test(1, 2)
 Traceback (most recent call last):
   File "", line 1, in ?
   File "", line 7, in __call__
 KeyError: (, )
 >>> test('aaa')
 Traceback (most recent call last):
   File "", line 1, in ?
   File "", line 7, in __call__
 KeyError: 
 >>> test
 {(,): , (,): }

You could give it a nice __repr__ ...

Hm, I'll just cheat right here instead of putting it in the decorator's class 
where it belongs:

 >>> def __repr__(self):
 ... fname = self.values()[0].func_name
 ... types = [tuple((t.__name__ for t in sig)) for sig in self.keys()]
 ... return '<%s-disp for args %s>' % (fname, repr(types)[1:-1])
 ...
 >>> type(test).__repr__ = __repr__
 >>> test
 
 >>> @method(str, str)
 ... def test(s1, s2): return s1, s2
 ...
 >>> test
 
 >>> test('ah', 'ha')
 ('ah', 'ha')
 >>> test(123)
 int 123

That __repr__ could definitely be improved some more ;-)

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Shed Skin Python-to-C++ Compiler 0.0.3 Release: some fixes, 3 MB Windows package

2005-09-26 Thread cmkl
I'va got a trojan message by my virus scanner trying to download the
0.03 exe-file. Something to worry about?

Carl

Mark Dufour schrieb:

> Hi all,
>
> Thanks to the people trying out Shed Skin 0.0.2 and letting me know
> about several problems they encountered. I have released an updated
> version, 0.0.3. It contains some fixes, adds support for several
> builtin functions (sorted, xrange..) and the Windows version is now a
> mere 3 MB, instead of 20 :-)
>
> Shed Skin's main purpose is to optimize algorithmic-like Python code,
> by applying advanced global type inference techniques. It does not
> support e.g. exceptions (yet), and there are currently some other
> limitations. Importing modules requires some extra work on the part of
> the user (see the README for details,)  although some imports are
> currently supported (some math, random functions and sys.argv.) What
> you gain by using Shed Skin is highly optimized code (industrial C++
> compiler), independent of any virtual machine. It is also possible to
> create highly optimized extension modules this way.
>
> I invite anyone to try not too large algorithmic-like programs (e.g.
> AI stuff) with Shed Skin and to let me know if there are any problems.
> Even though 129 test programs already work well (6 of which are larger
> than 100 lines), there are still many unimplemented minor features
> that I can easily fix, provided someone shows me a nice use case.
> Thanks to the people that have sent me failing code snippets before!
>
> http://shedskin.sourceforge.net
> http://shed-skin.blogspot.com
> 
> 
> Thanks!
> Mark Dufour.

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


Re: Simple Dialogs

2005-09-26 Thread Grant Edwards
On 2005-09-26, Steve Holden <[EMAIL PROTECTED]> wrote:

from tkMessageBox import showerror
showerror('Problem','Program Crashed before Starting')
>>>
>>>Here's a faster method, though not cross-platform:
>>>
>>>import ctypes
>>>ctypes.windll.user32.MessageBoxA(0, "Hello World", "Title", 0x00)
>> 
>> Another easy way to do a dialog box:
>> 
>> import os
>> os.system('Xdialog --msgbox "Hello World" 0 0')
>
> Doesn't seem to work on my Winodws system at all ;-)

Odd. You don't have a full compliment of the usual GTK apps
installed?

I probably should have mentioned that Xdialog is a GTK+ app and
it needs to be installed and working on your platform.

In thoery, you could get it to work under Windows, but the last
time I checked, the Windows port of GTK+ was still a bit "beta".

-- 
Grant Edwards   grante Yow!  What PROGRAM are
  at   they watching?
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Dialogs

2005-09-26 Thread Steve Holden
Grant Edwards wrote:
> On 2005-09-26, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 
>>James Stroud wrote:
>>
>>>from tkMessageBox import showerror
>>>showerror('Problem','Program Crashed before Starting')
>>
>>Here's a faster method, though not cross-platform:
>>
>>import ctypes
>>ctypes.windll.user32.MessageBoxA(0, "Hello World", "Title", 0x00)
> 
> 
> Another easy way to do a dialog box:
> 
> import os
> os.system('Xdialog --msgbox "Hello World" 0 0')
> 

Doesn't seem to work on my Winodws system at all ;-)

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

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


Re: Question about smtplib, and mail servers in general.

2005-09-26 Thread Christos Georgiou
On Wed, 21 Sep 2005 07:50:26 +0100, rumours say that Steve Holden
<[EMAIL PROTECTED]> might have written:

>I agree that there's an element of the moral imperative in my assertion 
>that the mails "should" go through which is largely ignored by the real 
>world nowadays. Some ISPs force you to use their SMTP servers no matter 
>what the sending domain, which is rather annoying when you travel a lot. 
>I end up having to vary my default SMTP server as I move.

...or set up your email client to always connect to localhost ports eg
31025 and 31110, and then from wherever you are, you connect to an SSH
server trusted by your "standard" mail server and port-forward to it.

Don't know if this applies to your case, but it works for me :)
-- 
Christos Georgiou, Customer Support Engineer
Silicon Solutions, Medicon Ltd.
Melitonos 5, Gerakas 153 44 Greece
Tel +30 21 06606195 Fax +30 21 06606599 Mob +30 693 6606195
"Dave always exaggerated." --HAL
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determine type of a socket

2005-09-26 Thread Peter Hansen
Tor Erik Sønvisen wrote:
> How can I determine the type of a socket (TCP or UDP) object?

In what context?  Do you have some code that gets passed a socket object 
but it could have been created with either SOCK_STREAM or SOCK_DGRAM? 
And you want a way of determining by looking just at the object passed 
in which type it is?  (I could make other guesses, but let's start with 
that... ;-)  )

How about this:

 >>> import socket
 >>> t = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 >>> u = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 >>> dir(t)
['__class__',  '_sock', 'accept', 'bind', 'close'
, 'connect', 'connect_ex', 'dup', 'fileno', 'getpeername',
...'setblocking', 'setsockopt', 'settimeout', 'shutdown']

Let's see... what looks good here?

 >>> u._sock

 >>> t._sock


Maybe that type field?

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


Re: Question about smtplib, and mail servers in general.

2005-09-26 Thread Christos Georgiou
On Tue, 20 Sep 2005 16:48:41 +0200, rumours say that Piet van Oostrum
<[EMAIL PROTECTED]> might have written:

>And most smtp servers that I know also pass mail from any from-address to
>any to-address if the IP number of he client machine belongs to a trusted
>range (usually the range that belongs to the ISP). So I can send both my
>private mail and my work mail from both my home ISP's smtp server and my
>work's smtp server (but only if I am at the proper location).

You might start having troubles, though, as soon as SPF checks get more
widespread.

Say your work mail is [EMAIL PROTECTED], and your private mail is
[EMAIL PROTECTED]; if you send email through your office mail server
with the envelope "MAIL FROM: [EMAIL PROTECTED]", then some (and
eventually many) receiving servers shall ask yagoohoogle.com for their
SPF record, and since your office mail server won't probably show up as
a valid email sender from yagoohoogle.com , your email will get
rejected.

That's a good thing.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to implement propertyPage using wxPyhton?

2005-09-26 Thread Steve Holden
James Hu wrote:
> Hi, gurus,
> 
>  
> 
> I would like to implement something like propertyPage (VC++ term)
> 
> Ie. There are a few tabs in the  top, clicking any tab will display a 
> different panel.
> 
> I searched on the Internet, couldn’t get any clue.
> 
I think you're looking for the wx.Notebook control.

Search for "notebook" in

 http://wiki.wxpython.org/index.cgi/Getting_20Started

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

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


Re: [RFC] Parametric Polymorphism

2005-09-26 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Catalin Marinas <[EMAIL PROTECTED]> wrote:
...
> Of course, duck-typing is simple to use but the parametric
> polymorphism is useful when the types are unrelated. Let's say you
> want to implement a colour-print function which should support basic
> types like ints and floats as well as lists and dictionaries. In this
> case, and thank to the function decorations support, the code would be
> clearer.

What you're describing (and implementing) is not what I would
call parametric polymorphism, though.  See

http://en.wikipedia.org/wiki/Polymorphism_(computer_science)

You're talking about "ad-hoc" polymorphism.

Personally, I can't agree that, in principle, this practice
makes code clearer.  In more common, less formal implementations
you get functions like this --

   def dosome(cmd):
   if type(cmd) == StringType:
   cmd = [cmd]
   ...

Of course the first problem with this that it unnecessarily
constrains the input type:  if your API supports a string
parameter, then in Python you should expect any value to work
that supports string operations.  This isn't a hypothetical
matter, you can see relatively major Python applications have
trouble with Unicode for exactly this reason.

Secondly, rather than clarify the API, it confuses it.  How
many programmers will observe this usage and erroneously assume
that dosome() _just_ takes a string, when the list parameter
may in fact be the more ideal usage?  This isn't hypothetical
either.

Your example is a fine one, and some kind of table to resolve
the function according to type of input argument is a good idea.
I'm just saying that more general application of this idea is
best left to languages like C++.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to decompile an exe file compiled by py2exe?

2005-09-26 Thread Chris Lambacher
On Sat, Sep 24, 2005 at 09:29:30PM +0800, Leo Jay wrote:
> Thanks for all of your replies.
> 
> but my problem is not how to decompile .pyo or .pyc files.
Eventually that is what the problem will become.  hjparser.exe is a python
interpreter that runs a python module that it extracts from itself.  In other
words there are two steps to this.  Step one is to extract the .pyc file that
is embedded in hjparser.exe. The second step is to decompile the .pyc into
something that resembles your original file.

You may have some luck determining how to extract the .pyc file by examining
the source for py2exe, either for the creation of the exe or the exe itself.

-Chris 
> 
> i used py2exe to compile my source file `hjparser.py' into
> `hjparser.exe' and other files. but i deleted the `hjparser.py' file
> by misoperation.(of cause, i tried to recover, but failed)
> 
> I opened the `hjparser.exe' file in UltraEdit(a hex editor), and found
> some partial statements and comments but not complete.
> 
> so, my problem is i'm sure that the source code is in `hjparser.exe'
> but i don't know how to decompile the executable file `hjparser.exe'
> into `hjparser.py',
> i don't care about how to decompile .pyo or .pyc files.
> 
> Thanks
> 
> 
> On 9/24/05, Ivan Voras <[EMAIL PROTECTED]> wrote:
> > It is - py2exe embeds python bytecodes. It seems it does it in the
> > "library.zip" file (if I'm reading
> > http://starship.python.net/crew/theller/moin.cgi/Py2Exe correctly).
> > Bytecode files extracted should be decompilable to something resembling
> > original python code by a python decompiler (quick Googling finds
> > "decompyle": http://www.crazy-compilers.com/).
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> 
> 
> --
> Best Regards,
> Leo Jay
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Dialogs

2005-09-26 Thread Thorsten Kampe
* [EMAIL PROTECTED] (2005-09-23 23:39 +0100)
> James Stroud wrote:
>> from tkMessageBox import showerror
>> showerror('Problem','Program Crashed before Starting')
> 
> Thanks.  That works great when interpreted (though a blank window seems
> to open as well).  Unfortunately it still takes 40 seconds to execute
> after it has been 'compiled' with py2exe (I've only got a P3).  This
> probably has something to do with the fact that the resulting files for
> this two-liner weigh in at just under 8MB.

Try with Pyinstaller. There are issues with py2exe and EasyGui. I have
a script that uses either EasyGui or EasyDialog (on Windows) and the
Tkinter part crashes constantly (newest py2exe) while EasyDialogs
works just fine.

Compiled with Pyinstaller they both work fine (and the exe is at 1.7
MB)
-- 
http://mail.python.org/mailman/listinfo/python-list


Determine type of a socket

2005-09-26 Thread Tor Erik S�nvisen
Hi

How can I determine the type of a socket (TCP or UDP) object?

regards tores 


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


how to implement propertyPage using wxPyhton?

2005-09-26 Thread James Hu








Hi, gurus,

 

I would like to implement something like propertyPage (VC++ term)

Ie. There are a few tabs in the  top, clicking any tab will display
a different panel.

I searched on the Internet, couldn’t get any clue.

 

Thanks in advance.

 

James






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

Re: number of python users

2005-09-26 Thread Grant Edwards
On 2005-09-26, Bryan <[EMAIL PROTECTED]> wrote:
> is there a rough estimate somewhere that shows currently how many python 1.5 
> vs 
> 2.2 vs 2.3 vs 2.4 users there are?  have a majority moved to 2.4? or are they 
> still using 2.3? etc...

My guess is most are still using 2.3.  The last time I looked,
that was the version shipped in most of the popular Linux
distros.

-- 
Grant Edwards   grante Yow!  Here we are in
  at   America... when do we
   visi.comcollect unemployment?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: number of python users

2005-09-26 Thread Scott David Daniels
Bryan wrote:
> is there a rough estimate somewhere that shows currently how many python 
> 1.5 vs 2.2 vs 2.3 vs 2.4 users there are?  have a majority moved to 2.4? 
> or are they still using 2.3? etc...
> 
> thanks,
> bryan

I'd bet the majority is still using 2.3:
   * 2.3 has been around a very long time;
   * 2.3 was installed by Apple on OS-X;
   * 2.3 was called Python-in-a-tie;
   * SciPy (Scientific Python) is still running on 2.3 on Windows
 (there is some issue with I/O in 2.4 builds).
   * Any Windows user with C code for python support modules
 must expend some non-trivial effort to get a compatible
 C compiler either by purchasing a VC 7.1 C/C++ compiler or
 by downloading the free version of that compiler and runtime
 environment and following instructions at:
 http://www.vrplumber.com/programming/mstoolkit/
 [The move needed to happen, but it slowed 2.4 uptake on Windows]

But, 2.3 is getting long-in-the-tooth.  I don't believe another
bugfix release of 2.3 is in the cards.

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


Re: number of python users

2005-09-26 Thread Fredrik Lundh
Bryan wrote:
> is there a rough estimate somewhere that shows currently how many python 1.5 
> vs
> 2.2 vs 2.3 vs 2.4 users there are?  have a majority moved to 2.4? or are they
> still using 2.3? etc...

Here are current PIL download statistics (last 10 days):

75.6% /downloads/PIL-1.1.5.win32-py2.4.exe
18.0% /downloads/PIL-1.1.5.win32-py2.3.exe
 2.2%  /downloads/PIL-1.1.5.win32-py2.2.exe
 4.2%  /downloads/PIL-1.1.5.win32-py2.1.exe

Note that these are fresh downloads for Windows, not users.  People
who run other systems, or are happy with their existing installation,
isn't included (so older versions are probably more common than they
appear).

(fwiw, I still have users on 1.5.2 for most of my libraries.  usually huge
Unix systems that nobody wants to break just because they can...)





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


Re: Simple Dialogs

2005-09-26 Thread Grant Edwards
On 2005-09-26, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> James Stroud wrote:
>> from tkMessageBox import showerror
>> showerror('Problem','Program Crashed before Starting')
>
> Here's a faster method, though not cross-platform:
>
> import ctypes
> ctypes.windll.user32.MessageBoxA(0, "Hello World", "Title", 0x00)

Another easy way to do a dialog box:

import os
os.system('Xdialog --msgbox "Hello World" 0 0')

-- 
Grant Edwards   grante Yow!  I will establish
  at   the first SHOPPING MALL in
   visi.comNUTLEY, New Jersey...
-- 
http://mail.python.org/mailman/listinfo/python-list


Accesing Global variables in multiple Requests (Apache 2.0)

2005-09-26 Thread Pankaj Gupta

Hi All,      I have a service written in python (on Apache 2.0) which Initializes the global variables (or objects) when request comes for it. I want to use the same objects (or varaibles) in the subsequent 
requests. How could this one be done in Apache 2.0? can it be done by doing some configuration ? 
Sincere Thanks, Pankaj 
-- 
http://mail.python.org/mailman/listinfo/python-list

Accesing Global variables in python

2005-09-26 Thread Pankaj





Hi All,      I have a 
service written in python (on Apache 2.0) which Initializes the global 
variables (or objects) when request comes for it. I want to use the same 
objects (or varaibles) in the subsequent requests. How could this one be 
done in Apache 2.0? can it be done by doing some configuration ? 
Sincere Thanks, Pankaj 
-- 
http://mail.python.org/mailman/listinfo/python-list

extending and embedding python without distutils

2005-09-26 Thread Benjamin Rutt
I have a rather large C++ project which has his own build system
(scons) and I would prefer to stay inside scons in order to build some
python extensions/embeddings (that is, I prefer to avoid using
distutils directly to build my extensions).

Can someone confirm that I'm doing the right thing to pick up the
necessary dependencies to pick up the compilation flags (the first
output line below, once I prefix it with '-I'), location of
libpythonX.X.a (the second output line below, once I prefix it with
'-L'), and dependent linking libraries (the last three output lines
below).  This is the type of thing that pkg-config normally solves on
linux.  (I'd have to add -lpythonX.X to my build commands, which I can
do separately by grabbing the major and minor version and building up
a string).

  >>> import distutils.sysconfig
  >>> for v in 'INCLUDEPY', 'LIBPL', 'LOCALMODLIBS', 'BASEMODLIBS', 'LIBS':
  ... print distutils.sysconfig.get_config_var(v)
  ... 
  /home/rutt/.upak/installed/python-2.4/include/python2.4
  /home/rutt/.upak/installed/python-2.4/lib/python2.4/config
  -L/home/rutt/.upak/installed/tcltk/lib -L/usr/X11R6/lib -ltk8.4 -ltcl8.4 -lX11
  
  -lpthread -ldl  -lutil

The purpose of this posting is to see if anyone jumps in and says
"hey, you missed a variable called ...".  Thanks,
-- 
Benjamin Rutt
-- 
http://mail.python.org/mailman/listinfo/python-list


ncurses programming

2005-09-26 Thread Sinan Nalkaya
hi, i want to use ncurses library in python i`ve found proper library 
for that, PyNcurses.
then i searched for some documentation about ncurses programming, i only 
found that web site ;
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/
this howto is nice but seems to me, this is for experienced ncurses 
programmers who have just migrated to python so i dont understand 
anything from examples and howto. what should i do ? firstly should i 
learn ncurses programmin on C then migrate to python?
thanks.


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


  1   2   >