Re: yet another indentation proposal

2007-08-20 Thread Michael Tobis
On Aug 19, 11:51 pm, James Stroud <[EMAIL PROTECTED]> wrote:

> What's wrong with just saying the current indent level? I'd much rather
> hear "indent 4" than "tab tab tab tab".

Alternatively, you might also consider writing a simple pre and
postprocessor so that you could read and write python the way you
would prefer

In that you could cope with the existing code base and the existing
compiler could cope with code you write.

mt

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


Call for advice on how to start PyOpenGL!

2007-08-20 Thread math2life
I work with python for two years, are familiar with image processing,
but beginner on PyOpenGL and OpenGL.

Any advice appreciated!

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


Re: Python question (PyNoob)

2007-08-20 Thread Carl Banks
On Aug 19, 8:33 pm, Anonymous <[EMAIL PROTECTED]> wrote:
> I have exp with C/C++ (and a few other langs). I want to use Python to
> start doing the ff:
>
> 1). Data Munging (text processing) - instead of Perl
> 2). Automating my build process
> 3). (Possibly) some web data retrieval jobs
>
> Can anyone point me to resurces/possibly scripts that can get me up to
> speed (to do these 3 things) ASAP, without having to learn the basics of
> programming?

You want the Python Library Reference (quod googla).

If you know the basics of programming already, any old Python tutorial
will do, so just skim through the official one (q.g.) to pick up the
syntax and semantic rules.  Then refer to the Library Reference, which
is well organized and make it easy to track down what you need.  The
libraries come with very good built-in support for tasks 1 and 3; for
2 Python supports timestamp checking and subprocess calling and
whatnot, but stuff like dependency trees you'll have to work out
yourself.

(BTW, if "make" is failing or annoying you, you might want to consider
SCons, which for me has been a lot more intelligent and
straightforward than make ever was.)


Carl Banks

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


Re: Python question (PyNoob)

2007-08-20 Thread Carl Banks
On Aug 19, 10:18 pm, Benjamin <[EMAIL PROTECTED]> wrote:
> On Aug 19, 7:33 pm, Anonymous <[EMAIL PROTECTED]> wrote:
>
> > I have exp with C/C++ (and a few other langs). I want to use Python to
> > start doing the ff:
>
> > 1). Data Munging (text processing) - instead of Perl
> > 2). Automating my build process
> > 3). (Possibly) some web data retrieval jobs
>
> > Can anyone point me to resurces/possibly scripts that can get me up to
> > speed (to do these 3 things) ASAP, without having to learn the basics of
> > programming?
>
> I think if you've chosen Python as a language to use for these things,
> you could invest some time in learning the language. It is after all
> very easy to learn and you just have to do it once and many of your
> programming task will be taken care of.


I think you and several others are misunderstanding the OP: the OP
wants to learn some details of Python without having to *relearn* the
basics of programming.  It's a reasonable request.


Carl Banks

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


Re: yet another indentation proposal

2007-08-20 Thread Jakub Stolarski
Why not just use comments and some filter. Just write # _{ at the
beginning and # _} at the end. Then filter just before runing
indenting with those control sequences? Then there's no need to change
interpreter.

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


Re: best GUI library for vector drawing program

2007-08-20 Thread vijay . kumar . 75in
Hi All,

Today I have downloaded a SWT Software which is great to its features.
You can learn
many GUI details out of it. The basic functionality is it lists IP
Addresses of the
remote PC's your system is accessing.

You may find the project under sourceforge.net

http://sourceforge.net/projects/nettymaster

You can customize this software, please let me know your views

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


Re: best GUI library for vector drawing program

2007-08-20 Thread [EMAIL PROTECTED]
Hi All,

Today I have downloaded a SWT Software which is great to its features.
You can learn
many GUI details out of it. The basic functionality is it lists IP
Addresses of the
remote PC's your system is accessing.

You may find the project under sourceforge.net

http://sourceforge.net/projects/nettymaster

You can customize this software, please let me know your views

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


Newbie question about a web server

2007-08-20 Thread Frank Millman
Hi all

I have just started to dabble in writing my own web server.

I googled for 'python web server', and this is the first hit -

http://fragments.turtlemeat.com/pythonwebserver.php

It has the source code for a simple web server, based on HTTPServer
and BaseHTTPRequestHandler.

It demonstrates the concepts of
  - returning a static page
  - constructing and returning a dynamic page
  - sending a form with a POST method, and responding to the result

I typed it in and ran it, and it 'just worked', with one exception.

When responding to the initial request, it sends a 200 response,
followed by a content-type header, followed by an html page. This
works fine.

When responding to the POST data received, it sends a 301 response, no
headers, and then the html page.

This works with a Firefox browser on Linux, but MSW IE6 displays 'the
page cannot be displayed'.

According to the notes, "You don't have to know much about the HTTP
protocol at all. Except some basic that when the client request
something it is a "GET", and when the client sends something it is in
our case a POST. Some basic responce codes like 200 is OK for GET, and
404 is file not found, 301 is OK for a Post."

I googled for 'http response code 301', and found that it is actually
a redirection code. It seems that the notes are misleading.

So I guess my questions are -
  1. what is the correct response for a POST?
 I think the answer is 200.
 However, I assume the author is trying to demonstrate a
particular technique.
 Can anyone explain what that may be.
  2. why does the above work with Firefox?

TIA for any enlightenment.

Frank Millman

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


Re: best GUI library for vector drawing program

2007-08-20 Thread Mats
If you want to stay within Tcl/Tk you could take a look at my tkpath
package:
http://tclbitprint.sf.net/
and shots:
http://tclbitprint.sourceforge.net/tkpath/quartz/index.html
http://tclbitprint.sourceforge.net/tkpath/gdiplus/index.html
http://tclbitprint.sourceforge.net/tkpath/cairo/index.html

Mats

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


Re: Python question (PyNoob)

2007-08-20 Thread Ant
On Aug 20, 1:33 am, Anonymous <[EMAIL PROTECTED]> wrote:
...
> 1). Data Munging (text processing) - instead of Perl

Check out the re module (regexes) in the standard library, and the
pyparsing third party library: http://pyparsing.wikispaces.com/ for
more complex stuff.

> 2). Automating my build process

You'll want to look into the os, sys and subprocess modules. The PMOTW
this week was subprocess: 
http://www.oreillynet.com/onlamp/blog/2007/08/pymotw_subprocess_1.html.
A few weeks back it covered os: 
http://blog.doughellmann.com/2007/05/pymotw-os.html.
In fact one of Doug Hellmann's previous articles on the getopt module
may also be useful if you want your build scripts to be controlled by
command line args: http://blog.doughellmann.com/2007/08/pymotw-getopt.html
(Though I prefer optparse personally).

> 3). (Possibly) some web data retrieval jobs

urllib, urllib2 and cookielib in the standard library should do most
of what you want, perhaps with the addition of beautiful soup if you
need to scrape the pages for data: http://www.crummy.com/software/BeautifulSoup/

HTH.

--
Ant...

http://antroy.blogspot.com/


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


Re: Python and Tkinter Programming--Expensive!

2007-08-20 Thread peter
On 17 Aug, 18:59, "W. Watson" <[EMAIL PROTECTED]> wrote:
> Why is the book in Subject (author is Grayson) so expensive? $100 on Amazon
> and $195 on ABE. Aren't there alternatives?
> --
>   Wayne Watson (Nevada City, CA)
>
> Web Page: 


I got hold of a copy a couple of years ago via my public library, and
quite frankly didn't find it much use.  It was too brief on the
basics, and the bulk of the book was taken up with a description of an
extension called Python Megawidgets.  Such Tkinter knowledge as I have
acquired came from Frederik Lundh's tutorial, which is free!

http://www.pythonware.com/media/data/an-introduction-to-tkinter.pdf

I recorded my experiences here:

http://www.aqzj33.dsl.pipex.com/how_i_learned_tkinter/contents.htm

Surprisingly the address is still valid, as I stoped that isp
subscription about a year ago.  But the email I cite there has been
abandoned to spam now.

Peter


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


Where we need to use Python ?

2007-08-20 Thread gperumal
Hi

Iam new to Python
I know Perl, JScript,C,C++,Java
But i want to know where excatly this python come in to picture

And Is it a interpreted language or a programming language
It comes in which category

I very keen to know this please tell

Regards
Ganesh P

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


Re: Xah's Edu Corner: Under the spell of Leibniz's dream

2007-08-20 Thread Ingo Menger
On 20 Aug., 01:56, Xah Lee <[EMAIL PROTECTED]> wrote:

> (for you math illiterates out there: ...
> (for you mathematicians out there: ...

Please, Xah Lee, could you possibly stop to "explain" things that are
absolutely trivial? If somebody has doubts about the etymology of a
word, he may use the dictionary, or he could ask.


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


Re: Retry: Question about FutureWarning

2007-08-20 Thread Gabriel Genellina
En Tue, 14 Aug 2007 22:44:17 -0300, Steven W. Orr <[EMAIL PROTECTED]>  
escribi�:

> The shell compile command I use to generate both the .pyc and the .pyo
> files is:
>
> python=/usr/bin/python2.3
> i_python ()
> {
>   $python -c "import $1"
>   $python -O -c "import $1"
> }

This is irrelevant to your main question - but try the compileall module  
in the standard library.

-- 
Gabriel Genellina

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

Re: Problem with Thread.join()

2007-08-20 Thread Gabriel Genellina
En Mon, 13 Aug 2007 20:10:53 -0300, Robert Dailey <[EMAIL PROTECTED]>  
escribi�:

> I have a class that derives from threading.Thread. To signal the thread  
> to
> exit its infinite loop, I set an Event. Once the thread checks  
> Event.isSet()
> and it is true, it proceeds to break out of the loop and exit the  
> function.
> In the main thread, right after calling Event.set(), I call  
> Thread.join() to
> wait on the thread to exit. However, if I call Thread.join() the  
> application
> locks up because for some reason calling Thread.join() prevents the  
> thread
> from exiting. I don't know why. Any help? Thanks...

Conceptually you're doing it the right way. Post some code demonstrating  
the problem...

-- 
Gabriel Genellina

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

Re: passing arguments with ampersands

2007-08-20 Thread Gabriel Genellina
En Sat, 18 Aug 2007 09:24:35 -0300, SHY <[EMAIL PROTECTED]> escribi�:

> theres no special portion of code, just the one that handles filenames  
> with
> spaces.
> the problem is that when i associate a file extension to my application  
> and
> i open it, the filename is not quoted before passed as an arguement. i  
> dont
> know if its the problem of windows or something, or it was just my fault
> when i incorrectly associated the extension.

How did you associate it?
Usually the registry entries are:

HKCR\.ext = filetype
HKCR\filetype = File Description
HKCR\filetype\shell\open\command = "path\to\your\program" "%1"

(Note the double quotes around %1)

Get it right at the registry, and forget all that trickery joining  
sys.argv parts

-- 
Gabriel Genellina

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

Re: Importing DLLs

2007-08-20 Thread Gabriel Genellina
En Wed, 15 Aug 2007 14:20:26 -0300, Corbitt, Kyle <[EMAIL PROTECTED]>  
escribi�:

> I'm running Linux with Python 2.3.  I have a C shared object file (*.so)  
> and I need to be able to call its functions from within Python.  I have  
> found a couple of Python modules that allow me to do this (dl, ctypes)  
> but unfortunately I am only able to get them to return integers, even  
> for function calls that I KNOW the library is supposed to return other  
> types for.  I need the library to be able to return doubles, 2D arrays

Use the ctypes module. Read the tutorial - you have to set the restype  
attribute on functions.

-- 
Gabriel Genellina

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

Re: swapping

2007-08-20 Thread Gabriel Genellina
En Sat, 18 Aug 2007 02:58:23 -0300, Beema shafreen  
<[EMAIL PROTECTED]> escribi�:

> result:
> klp5bub1
>
> apn1apn2
>
> but i have do the same for the revere ,to check the result like this for
> eg:
> apn2apn1
> what is the concept to do this

I don't understand exactly what you want to do.
If you want to transform "apn1apn2" into "apn2apn1", try this:

col1, col2 = line.split()
print col2,"   ",col1

-- 
Gabriel Genellina

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

Re: imaplib & Received: header(s)???

2007-08-20 Thread Petri Savolainen
Donn Cave wrote:

> | I need to get at the Received-for header to figure out at which address 
> | we received an email. We subscribe to a number of mailing lists using 
> | per-mailing-list addresses, and often, To: field contains something else 
> | than our address, thus the need for Received-for.
> |
> 
> "Anything recent"?  If you're getting IMAP advice from comp.lang.python,
> I think it's fair to say you will need to be more resourceful.  The
> RFC for IMAP4rev1 should be helpful.  I don't know the IMAP to get a
> single header field, but my guess is that your error is there.  Can you
> retrieve other fields that way?  Does the one you're looking for appear
> in the data if you get the whole header, for example with 'RFC822.HEADER'?
> It certainly does in my Python IMAP client, and this would have at least
> helped you refine your question.

Thanks Donn,

I had already checked everything relevant, including what you suggested. 
The only examples that I found including the Received header utilized 
the now-obsoleted rfc822 library in python from many years and versions 
back. Thus nothing recent.

However, you mentioning "RFC822.HEADER" working for you prompted me to 
try another mail server... to my surprise, everything worked. It appears 
some imap servers do not allow programmatic fetching of Received: 
information. Should've done this check sooner :-(

Thanks,

  Petri




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


Re: popen4 not returning output

2007-08-20 Thread Michael Bentley

On Aug 19, 2007, at 8:58 PM, [EMAIL PROTECTED] wrote:

> I am trying to run the following script:
>
>
> #!/usr/bin/python
>
> import popen2
>
> commandToRun = """scp scp_trial.py [EMAIL PROTECTED]:/targetDirectory"""
> #commandToRun = "ls"
> print commandToRun
> p_out, p_in = popen2.popen4 (commandToRun)
>
> theOut = p_out.readlines ()
> print theOut
>
>
> When I run this command with the "ls" command I see the output.
> When I run this with the scp command I do not see the output of my
> command -- however the file is successfully transfered.  How can I see
> the output?
>

scp will not produce output on stdout or stderr if stdout/stderr is  
redirected.  I assume it uses an ioctl with TCGETA to determine the  
terminal characteristics of the device connected to stdout, and get  
either an EINVAL (for a pipe) or ENOTTY (for a file) failure when no  
terminal is attached.

You can test whether it works the same on your system by running your  
scp from the command line and redirecting the output:

scp scp_trial.py [EMAIL PROTECTED]:/targetDirectory >scp.stdout 2>scp.stderr

Both files will exist (the shell does this before starting the scp  
command), but will (I think) be empty.

hope this helps,
Michael

---
The Rules of Optimization are simple.
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.
  -Michael A. Jackson


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


How to decompress .Z file?

2007-08-20 Thread Hyunchul Kim
Hi, all

How can .Z file be decompressed?

According to python library reference, .Z file might not be supported by
python, yet.

Best,
Hyunchul Kim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Call for advice on how to start PyOpenGL!

2007-08-20 Thread Diez B. Roggisch
math2life wrote:

> I work with python for two years, are familiar with image processing,
> but beginner on PyOpenGL and OpenGL.
> 
> Any advice appreciated!

You should check out the pyweek (http://www.pyweek.org/). There you find
pygame & OpenGL-based games, of a comprehensible size.

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


building exe from script

2007-08-20 Thread vedrandekovic
Hello,

Is there any solution for building exe file from python script
something like bbfreeze.When user write some script in
my program, it must compile script into exe without opening console
( cmd ).I'am working on Windows XP  SP2 and Python 2.5.



Regards,
Vedran

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


Re: Where we need to use Python ?

2007-08-20 Thread Olexandr Melnyk
2007/8/20, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Hi
>
> Iam new to Python
> I know Perl, JScript,C,C++,Java
> But i want to know where excatly this python come in to picture
>
> And Is it a interpreted language or a programming language
> It comes in which category
>
> I very keen to know this please tell


Python is an interpreted programming languages, although there are
compiled implementations.

You can use it for a variety of tasks, except low-level programming.

Regards
> Ganesh P
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to decompress .Z file?

2007-08-20 Thread [EMAIL PROTECTED]
On Aug 20, 9:02 am, Hyunchul Kim <[EMAIL PROTECTED]> wrote:
> How can .Z file be decompressed?
>
> According to python library reference, .Z file might not be supported by
> python, yet.


Guess you can *outsource* the process to 7zip:

http://7-zip.org/download.html

It supports .z archives.

Lorenzo

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


Re: Call for advice on how to start PyOpenGL!

2007-08-20 Thread Richard Jones
Diez B. Roggisch wrote:
> math2life wrote:
> 
>> I work with python for two years, are familiar with image processing,
>> but beginner on PyOpenGL and OpenGL.
>> 
>> Any advice appreciated!
> 
> You should check out the pyweek (http://www.pyweek.org/). There you find
> pygame & OpenGL-based games, of a comprehensible size.

Also, there's plenty of good opengl tutorials on the web. They all translate
pretty easily into Python if they're not in Python already. For example:

http://nehe.gamedev.net

I highly recommend pyweek as a way of focusing on your learning task :)


 Richard

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


Re: building exe from script

2007-08-20 Thread Furkan KURU
you can embed py2exe in your program.


On 8/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Is there any solution for building exe file from python script
> something like bbfreeze.When user write some script in
> my program, it must compile script into exe without opening console
> ( cmd ).I'am working on Windows XP  SP2 and Python 2.5.
>
>
>
> Regards,
> Vedran
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


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


Re: best GUI library for vector drawing program

2007-08-20 Thread pachiburke
On Aug 17, 3:27 pm, chewie54 <[EMAIL PROTECTED]> wrote:

> What would be the best cross-platform GUI library to use for a vector
> based CAD program ( something like Visio on Windows )   WxWidgets,
> Tk,   PyQt,  Java Swing,  Java SWT,   I need the capibility to
> draw and edit in a window that looks like a page of paper so WYSIWYG
> is very important,  and I need to save the drawings in vector based
> file formats like PS, EPS,  SVG, as well as image formats like jpg,
> png, and gif.  Also, the images need to be high resolution so that
> they can be pasted into various other programs in Windows OS,  and
> Linux OS,  and the Mac OS.

You could use pythoncad (www.pythoncad.org) as a base and develop it
further, or even contract its main developer to expand its features to
fulfill your needs and improve it. It's based on the GTK+ toolkit,
written in python and has scripting capabilities. IMHO, it's the most
promising free CAD effort around though even if it's not as mature as
QCad.
You could use it in commercial applications as long as you comply with
the GPL, or the author agrees to dual license it for you, but it would
be very welcome if the improvements are avaliable for all users.

Regards,

Rafael

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


Re: Sorting a list of Unicode strings?

2007-08-20 Thread Tommy Nordgren

On 19 aug 2007, at 18.50, [EMAIL PROTECTED] wrote:

> Hey Guys,
>
> Maybe I'm missing something fundamental here, but if I have a list of
> Unicode strings, and I want to sort these alphabetically, then it
> places those that begin with unicode characters at the bottom. Is
> there a way to avoid this, and make it sort them properly?
>
> I'm sure that this is the "proper way" programatically with character
> entities etc. - but when I have a list of countries, and I have Åland
> Islands right at the bottom, it just doesn't look right.
>
> Any help would be really appreciated.
>
> Thanks,
> Oliver
>
> --  
> http://mail.python.org/mailman/listinfo/python-list
That is the correct alfabetic sort order for Åland.
The Swedish letters Å , Ä and Ö sorts last in Alphabetic order.
-
An astronomer to a colleague:
-I can't understsnad how you can go to the brothel as often as you  
do. Not only is it a filthy habit, but it must cost a lot of money too.
-Thats no problem. I've got a big government grant for the study of  
black holes.
Tommy Nordgren
[EMAIL PROTECTED]



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


Re: Sorting a list of Unicode strings?

2007-08-20 Thread [EMAIL PROTECTED]
Thank you all for your very quick and informative replies. I was
basing this assumption that Å was classed as a standard 'A' from a
list of countries I was looking at (Wikipedia sorts it like this, too
- though this isn't what I was using 
http://en.wikipedia.org/wiki/List_of_countries#A)

I will leave it as it is, with Å at the bottom, if this is the correct
ordering.

Once again, thank you!

Oliver

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


Re: best GUI library for vector drawing program

2007-08-20 Thread Roedy Green
>What would be the best cross-platform GUI library to use for a vector
>based CAD program ( something like Visio on Windows ) 
I don't know about he best, but I have collected a list of them at
http://mindprod.com/jgloss/graph.html
-- 
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: building exe from script

2007-08-20 Thread nih
A bit more information is clearly needed...

1. Create a file called py2exeSetup.py with the following contents:

from distutils.core import setup
import py2exe

def compile(appName, console=False):
OPTIONS = {"py2exe": {"compressed": 1, "optimize": 0, "bundle_files": 
1, } }
ZIPFILE = None

if console:
setup(
options=OPTIONS,
zipfile=ZIPFILE,
console=[appName]
)
else:
setup(
options=OPTIONS,
zipfile=ZIPFILE,
windows=[appName]
)


2. Create another file called setup.py with the following contents

import py2exeSetup

# to stop a wxPython program from loading a console window you just need to 
change the
# file extension from .py to .pyw

# change Filename to your XXXApp.pyw filename
# change to py2exeSetup.compile('Filename.pyw', console=True) to show the 
console
py2exeSetup.compile('Filename.pyw')


3. Create a file called Compile.bat with the following contents

REM change Filename to your XXXApp.exe filename
REM make sure that python is in your system path

python setup.py py2exe
copy dist\Filename.exe Filename.exe
if errorlevel 1 pause


4. Put all these files in the same place as the program you want to convert 
to exe and run Compile.bat
an *.exe file will now be in the same folder as your python files :)

I have py2exeSetup.py in a separate 'Shared' folder so there is only one 
copy of it,
so all my programs only have setup.py and compile.bat in them


btw if you have a load of programs that you want to compile in one go the 
add a file CompileAll.bat
in the root folder that all the programs are in, with the following 
contents:

cd "ProgramOne"
call py2exe.bat
cd..

cd "ProgramTwo"
call py2exe.bat
cd..

# REM this part will execute if all programs compiled & copied ok
echo all copied ok!
pause


I know hardly anything about ms-dos, but this works ok:/

gl!

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello,
>
> Is there any solution for building exe file from python script
> something like bbfreeze.When user write some script in
> my program, it must compile script into exe without opening console
> ( cmd ).I'am working on Windows XP  SP2 and Python 2.5.
>
>
>
> Regards,
> Vedran
> 


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


Re: ctypes and unsigned char*

2007-08-20 Thread [EMAIL PROTECTED]
On 19 Aug., 20:40, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> In the first case, use a plain c_char_p - the individual "chars" are
> already unsigned in Python (that is, ord(xxx[i]) is always positive)
> In the second case, first define the pointer type:
>
> c_ubyte_p = POINTER(c_ubyte)
> your_function.restype = c_ubyte_p

I will have to look into that. My function I want to wrap has the
following signature

unsigned char *MagickGetImageProfile(MagickWand *wand,const char
*name,
size_t *length)

Well, the first argument and the second are straight forward, and work
as expected. The last argument also works and it should take up the
length of the string (unsigned char *). If I now do

dll.MagickGetImageProfile.restype = c_char_p
result = dll.MagickGetImageProfile(wand, "8bim", byref(length))

result is either an empty string or a 3 bytes long string, while
length containes the correct length of 1086 bytes for example. I also
tried

dll.MagickGetImageProfile.restype = POINTER(c_ubyte)

with the same result. But maybe I should do some further debugging

Best regards,
Oliver

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


Re: Where we need to use Python ?

2007-08-20 Thread Dustan
On Aug 20, 3:02 am, [EMAIL PROTECTED] wrote:
> Hi
>
> Iam new to Python
> I know Perl, JScript,C,C++,Java
> But i want to know where excatly this python come in to picture
>
> And Is it a interpreted language or a programming language
> It comes in which category
>
> I very keen to know this please tell
>
> Regards
> Ganesh P

http://www.python.org

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


Re: best GUI library for vector drawing program

2007-08-20 Thread Thomas Kellerer
Roedy Green wrote:
>> What would be the best cross-platform GUI library to use for a vector
>> based CAD program ( something like Visio on Windows ) 
> I don't know about he best, but I have collected a list of them at
> http://mindprod.com/jgloss/graph.html

Roedy,

you might want to add NetBeans' Graph library to the list. It is very 
similar to Eclipse's GEF

http://graph.netbeans.org/

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


datetime in microseconds

2007-08-20 Thread mroeloffs
Hi I have a time in microseconds, for example 0x8C905CBA7F84AF4. I
want this to a normal view in hh:mm:ss DD:MM:. I tried with
datetime, but it only takes a max of 100 microseconds is there
another solution?

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


Re: Latest models of Gibson guitars

2007-08-20 Thread Lew
Twisted wrote:
> On Aug 19, 2:41 pm, [EMAIL PROTECTED] wrote:
>> This is  a newsgroup of programming language Python, stop with this!
> 
> Python?! Python is as off-topic here as guitars, unlike, say, Java...

When referring to "this" newsgroup or "here", one must remember that this is a 
cross-posted thread, so those concepts have multiple referents.

Take another look at the address field ("Newsgroups:") of the message, then 
redefine "this newsgroup" accordingly - there are more than one due to the 
spammish cross-posting of the original message.

So let's all stop being so parochial, hmm?

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


Re: LRU cache?

2007-08-20 Thread qyloxe
#simple, but effective (sometimes)

class ICORCache:
   def __init__(self,agetfunc,amaxlen=100):
  self.GetValue=agetfunc
  self.MaxLen=amaxlen
  self.VDict={}
  self.KDict={}
  self.VPos=1
  self.AccessRatio=0
  self.HitRatio=0
   def __getitem__(self,key):
  self.AccessRatio=self.AccessRatio+1
  id=self.KDict.get(key,0)
  if id:
 self.HitRatio=self.HitRatio+1
 return self.VDict[id][1]
  else:
 v=self.VDict.get(self.VPos,0)
 if v:
del self.KDict[v[0]]
 ret=apply(self.GetValue,(key,))
 self.VDict[self.VPos]=[key,ret]
 self.KDict[key]=self.VPos
 self.VPos=self.VPos+1
 if self.VPos>self.MaxLen:
self.VPos=1
 return ret
   def dump(self):
  print 'Access ratio:',self.AccessRatio
  print 'Hit ratio:',self.HitRatio
  print 'Hit %:',100.0*self.HitRatio/self.AccessRatio
  print 'VDict len:',len(self.VDict.keys())
  print 'KDict len:',len(self.KDict.keys())

#tests
if __name__=='__main__':
   import random

   def GetCalculatedValue(key):
  x=`key`+''
  y=key*0.5
  z=x+`y`
  return z

   # model of distribution
   amax=1000
   def GetIterative(key):
  return key
   def GetRandom(key):
  return random.randint(1,amax)
 
l1,l2,l3=random.randint(1,amax),random.randint(1,amax),random.randint(1,amax)
   def GetNDist(key):
  global l1,l2,l3
  l1,l2,l3=l2,l3,random.randint(1,amax)
  return int((l1+l2+l3)/3)

   def Main():
  for aname,afunc in [['Iterative',GetIterative],
['Random',GetRandom],['NDist',GetNDist]]:
 acache=ICORCache(GetCalculatedValue,100)
 for i in range(1000):
k=afunc(i)
x=acache[k]
y=GetCalculatedValue(k)
if x!=y:
   print 'Error!!!',k,x,y
 print 'Name:',aname
 acache.dump()
 print
  return

   Main()

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


Shed Skin Python-to-C++ compiler 0.0.23

2007-08-20 Thread Mark Dufour
Hi all,

I have just released Shed Skin 0.0.23. It doesn't contain the type
inference scalability improvements I was working on, but it does have
quite a few bug fixes and minor feature additions. Here's a list of
changes:

-support for __iadd__, __imul__ and such (except __ipow__ and __imod__)
-some overdue set optimizations
-fix for string formatting problem (%% did not always work)
-extension module stability fixes
-fix for particular inheritance problem
-other minor bugfixes, cleanups, and error messages

I could really use some systematic help in pushing Shedskin further. Some ideas:

-send in bug reports - these are extremely valuable and motivating to
me, yet I don't receive many..
-find out why test 148 is currently broken under windows
-add datetime, re or socket support
-look into supporting custom classes in generated extension modules
-write a Shedskin tutorial for 'novice' programmers
-systemically test performance and suggest and work on improvements
-investigate replacements for std::string and __gnu_cxx::hash_set
-perform janitorial-type work in ss.py and lib/builtin.?pp
-support extension modules under OSX (OSX gives me accute mental RSI)
-add more tests to unit.py


Thanks,
Mark Dufour.
--
"One of my most productive days was throwing away 1000 lines of code"
- Ken Thompson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: desperately in need of a tool

2007-08-20 Thread A.T.Hofkamp
On 2007-08-19, yagyala <[EMAIL PROTECTED]> wrote:
> Hi.
>
> one of those standards is that the comments for each routine must
> indicate every other routine that it calls. As I try to keep my

> to do this by hand. Does anyone know of a tool that could do this for
> me, or at least a tool that can tell what other routines a given
> routine calls that I could program against? (Preferably something that
> works under pydev, but I'm not going to be choosy.)

Wouldn't a regular expression be enough here?

Something like

# x.py
import re, sys

fcallpat = re.compile(r'\w+\(')

data = sys.stdin.read()
for match in fcallpat.findall(data):
print match



$ python x.py < x.py
compile(
read(
findall(

You may want to have a wider matching criterium than \w+


Albert

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


Re: Xah's Edu Corner: Under the spell of Leibniz's dream

2007-08-20 Thread Carsten Haese
On Mon, 2007-08-20 at 01:23 -0700, Ingo Menger wrote:
> On 20 Aug., 01:56, Xah Lee <[EMAIL PROTECTED]> wrote:
> 
> > (for you math illiterates out there: ...
> > (for you mathematicians out there: ...
> 
> Please, Xah Lee, could you possibly stop to "explain" things that are
> absolutely trivial? If somebody has doubts about the etymology of a
> word, he may use the dictionary, or he could ask.

And to underline your criticism, allow me to point out the irony:

"No one can write decently who is distrustful of the reader's
intelligence, or whose attitude is patronizing." (From "The elements of
Style" by Strunk and White as quoted by Dijkstra in the very paper Xah
Lee pointed out to us.)

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


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


Re: datetime in microseconds

2007-08-20 Thread kyosohma
On Aug 20, 6:52 am, [EMAIL PROTECTED] wrote:
> Hi I have a time in microseconds, for example 0x8C905CBA7F84AF4. I
> want this to a normal view in hh:mm:ss DD:MM:. I tried with
> datetime, but it only takes a max of 100 microseconds is there
> another solution?

Just truncate the value so that it's less than 100. A slight
difference of a couple seconds shouldn't matter for the output format
you're talking about.

Mike

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


Server-side scripting in python

2007-08-20 Thread Nagarajan
Hi group,
I need to develop a web application. I am in a fix as to choose among
the various server-side scripting options. I want to explore python
(am a newbie) to gain expertise and upon search, I learnt about
PSP(Python Server Pages) that uses Jython as its scripting language.
Is it a better option over PHP or Perl? Could anyone point out the
pros and cons of using PSP over others?

Help much appreciated.

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


Re: Public Telnet Server?

2007-08-20 Thread Dave
On Aug 12, 2:03 pm, Jorgen Grahn <[EMAIL PROTECTED]>
wrote:
> On Sat, 11 Aug 2007 15:07:25 -, Dave <[EMAIL PROTECTED]> wrote:
> > Hi there. I'm a beginner at Python and I'm writing my first Python
> > script. It's a text adventure about coffee and mixing drinks and being
> > crazy and such. I keep updating it and want my friends to beta test it
> > for me, but some of them don't have the right version of Python or
> > don't want to get Python at all. Is there an easy way I can set up a
> > public telnet server so they can just telnet the server and play it?
>
> - get yourself a Unix machine with a real, routable IP address
> - enable telnet (or better, ssh) access
> - create a new user
> - make the game this user's login shell, or let her login script
>   exec the game
> - test it out
> - distribute address, user name and password to people
>
> "netcat ... -e the_game" may be another option.
>
> However, the security implications of this may be serious. You should
> assume these people can get local user shell access whenever they feel
> like it, and use your machine for evil purposes. I trust my brother
> with local access to my machines, and noone else[1].
>
> /Jörgen
>
> [1] Well, his two cats too, but they have never logged in so far.
> Probably forgot the password, too.
>
> --
>   // Jorgen Grahn  \X/ snipabacken.dyndns.org>  R'lyeh wgah'nagl fhtagn!

Thanks for the suggestions. I'm actually on Linux and a friend helped
me enabled SSH and make the game the login script for a dummy account,
but then he was generous enough to let me put it on a spare server of
his too. :)

As for the py2exe suggestion, I actually just tried that yesterday so
now there's a Windows Executable version of the game for friends to
try as well.

Both versions are available, plus source, from http://thegriddle.net/python/
if you want to check it out. Thanks again!

Dave

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

Re: datetime in microseconds

2007-08-20 Thread John Machin
On Aug 20, 9:52 pm, [EMAIL PROTECTED] wrote:
> Hi I have a time in microseconds, for example 0x8C905CBA7F84AF4. I
> want this to a normal view in hh:mm:ss DD:MM:. I tried with
> datetime, but it only takes a max of 100 microseconds is there
> another solution?

Your question can be interpreted in two possible ways:

1. You have an interval or duration (independent of a calendar point)
and you want to express it in years, months, days, hours, etc. This is
not possible, due to the variable number of days in a month. The best
that you can do is express it as days, hours, etc.

>>> microsecs = 0x8C905CBA7F84AF4
>>> secs = microsecs // 100 # or round to nearest if you prefer
>>> mins, secs = divmod(secs, 60)
>>> hrs, mins = divmod(mins, 60)
>>> days, hrs = divmod(hrs, 24)
>>> days, hrs, mins, secs
(7326893L, 11L, 1L, 16L)
>>>

2. You want to know the (Gregorian) calendar point that is
0x8C905CBA7F84AF4 microseconds after some epoch. In this case you need
to specify what the epoch is. Then you can try something like:

>>> datetime.datetime.fromordinal(1) + datetime.timedelta(microseconds=microsecs
)
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: date value out of range
>>> # Whoops!
>>> years_approx = days / 365.25
>>> years_approx
20059.939767282682
>>>

Hmmm, one of us seems to be missing something ...

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


Re: Where we need to use Python ?

2007-08-20 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| And Is it a interpreted language or a programming language
| It comes in which category

Python is an algorithm programming language.

The CPython implementation of the langauge compiles Python to proprietary 
byte code and then interprets the byte code.
The Jython implementation compiles to javacode which is then handled 
however by a Java runtime.
The IronPython implementation compiles to the .NET language handled by the 
.NET runtime.
The PyPy implementation acts similarly to CPython, I believe, but can also 
compile a subset of the language to C or other low level languages that can 
be compiled to object code.  There are other projects that compile subsets, 
possible with additional instructions to the compiler.

Do visit www.python.org and take a look around.  The documentation section 
has a tutorial that will give an experienced programmer a good overview in 
just a few hours.

tjr





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


Handwriting Recognition

2007-08-20 Thread Ian Dickinson
Hi

My name is Ian Dickinson and I am a professional software developer working in 
the UK and reasonably familiar with Python.

However a friend of mine who is a special educational needs teacher was asking 
me if I could write some handwriting recognition software for her, which would 
allow here pupils to write their input directly on a graphics tablet and then 
have this input converted to a text sting for further processing. The 
handwriting would be distinct letters either upper or lower case but not joined 
up writing.  I would like to help out here as I think this is a valuable  and 
worthwhile area of education so has anyone out there got any advice that could 
help me out.


Thanks in advance

Ian

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


Re: How do I call anonymous classes from imported modules?

2007-08-20 Thread JoeSox
On 8/19/07, James Stroud <[EMAIL PROTECTED]> wrote:
> This was the poor design I was hinting to. do_foobar is type-checking
> for ticker. "Casting" as you might think of it does not exist in python.
> Creating new objects based on the values of existing objects (lets call
> it "conversion" for lack of a better name) does (e.g. int(2.0)). But
> this is not casting. Unless you have the power to re-author all of the
> do_foobar()s to not type-check, you should create an instance of ticker
> and pass that:
>
> t = ticker(param1, param2, parametc)
> [...]
>   anobj.do_foobar(t)
>
> The "got nothing instead" means that you should have passed an
> argument--and unfortunately whoever authored do_foobar() type-checked
> for a ticker, which is not a desirable way to design an API.

I designed the system using this 'tutorial'
http://lucumr.pocoo.org/blogarchive/python-plugin-system

With your help and revisiting the article I figured out that this call works:
>>> for plugin in get_plugins_by_capability('do_foobar'):
plg=plugin()
print plg.do_foobar()

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


Re: yet another indentation proposal

2007-08-20 Thread Aaron
"Michael Tobis" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> Alternatively, you might also consider writing a simple pre and
> postprocessor so that you could read and write python the way you
> would prefer
>
> In that you could cope with the existing code base and the existing
> compiler could cope with code you write.
>
> mt
>


Hi.

That's probably what I'll end up doing.  The only drawback to that is that 
it solves the problem for me only.  Perhaps I will open source the scripts 
and write up some documentation so that other folks in a similar situation 
don't have to reinvent the wheel.  The only unfortunate aspect to that is 
that blind newbies to the language will have to figure out setting up a 
shell script or batch file to pipe the output of the filter into Python on 
top of learning the language.  I admit, it's probably not that much work, 
but it is one more stumblingblock that blind newcomers will have to 
overcome.

Aaron 



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


Python-URL! - weekly Python news and links (Aug 20)

2007-08-20 Thread Gabriel Genellina
QOTW:  "So I never let the age of the universe intimidate me." - mensanator,
on (roughly) the occurrence of large integral exponents in combinatorics and
more

"You're coming from a Perl background, right?  No one else would think of
using a regexp for such a simple thing." - Sion Arrowsmith


More people concerned about Python performance on dual core processors:

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

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

Alex Martelli explains why using reduce() in some cases is a bad idea,
and how to efficiently obtain a result combining all items in a container:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/78b5953488d772e9/4951b0e0bfd859eb#b65604f723047457

A recursive defaultdict (or an infinite level dictionary)

http://groups.google.com/group/comp.lang.python/browse_thread/thread/9519c885a24a65ea/7a5bd10726f2c079?#7a5bd10726f2c079

Sorting Unicode is not as easy as one would think ...

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

Some thoughts on making indentation play well with blind people

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

Using itertools to allow re-processing of lines already read from a file

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



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.

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish "the efforts of Python enthusiats":
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

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

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

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

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

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

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

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

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

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

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

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

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

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Many Python conferences around the world are in preparation.
Watch this space for links to them

regular expression dictionary search

2007-08-20 Thread dorje tarap
Hi

I have a dictionary with a list of patterns:
 Code: ( text )

   1. >>> words = {'sho.':6, '.ilk':8,'.an.':78 }


Where the "." character means any pattern - this can easily be changed to
the "*" symbol if need be.

When the user submits a word, I want to be able to look for a corresponding
pattern (if it exists). For example if the user said "show" or "shoe", then
the value 6 would be returned. If it was "band", "land", "sand", "pant" etc
then 78 would be returned - but not "pants" as it is longer than the
pattern.

I know the normal way is to provide the reg exp and search the dictionary
with it, but this is the other way round :(

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

Python equivalent of Perl's $/

2007-08-20 Thread John K Masters
I am currently working my way through Jeffrey Friedl's book Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.

One particular expression that interests me is '$/ = ".\n"' which,
rather than splitting a file into lines, splits on a period-newline
boundary. Combined with Perl's 'while (<>)' construct this seems a great
way to process the files I am interested in.

Without wishing to start a flame war, is there a way to do this in Python?

Regards, John
-- 
War is God's way of teaching Americans geography
Ambrose Bierce (1842 - 1914)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where we need to use Python ?

2007-08-20 Thread Michael Bentley

On Aug 20, 2007, at 1:02 AM, [EMAIL PROTECTED] wrote:

> And Is it a interpreted language or a programming language
> It comes in which category
>
> I very keen to know this please tell

[ open on suburban kitchen, Wife and Husband arguing ]

Wife: New Shimmer is a floor wax!

Husband: No, new Shimmer is a dessert topping!

Wife: It's a floor wax!

Husband: It's a dessert topping!

Wife: It's a floor wax, I'm telling you!

Husband: It's a dessert topping, you cow!

Spokesman: [ enters quickly ] Hey, hey, hey, calm down, you two. New  
Shimmer is both a floor wax and a dessert topping! Here, I'll spray  
some on your mop.. [ sprays Shimmer onto mop ] ..and some on your  
butterscotch pudding. [ sprays Shimmer onto pudding ]

[ Husband eats while Wife mops ]

Husband: M, tastes terrific!

Wife: And just look at that shine! But will it last?

Spokesman: Hey, outlasts every other leading floor wax, 2 to 1. It's  
durable, and it's scuff-resistant.

Husband: And it's delicious!

Spokesman: Sure is! Perks up anything from an ice cream sundae to a  
pumpkin pie!

Wife: Made from an exclusive non-yellowing formula.

Husband: I haven't even touched my pudding and I'm ready for more!

Wife: But what about black heel marks?

Spokesman: Dirt, grime, even black heel marks, wipe clean with a damp  
mop.

[ Husband accidentally sprays Shimmer onto the floor ]

Husband: Oh, sorry, honey, I'll clean that up!

Wife: Oh, no problem, sweetheart, not with new Shimmer!

[ Spokesman laughs continuously as he approaches the camera ]

Spokesman: New Shimmer, for the greatest shine you ever tasted!

Ducking,
Michael
---
"If we had asked people what they wanted they would have said 'a  
faster horse'."  --Henry Ford


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


Mouse control with ctypes in OS X

2007-08-20 Thread Niklas Ottosson

Hi all


I need to get hold of the mouse position and also need to be able to change it. In windows I have used ctypes.windll.user32.getCursorPos() and ctypes.windll.user32.setCursorPos() with great success in my program but now I also need to make a Mac OS X version of the program. 

Does anyone know what the above libraries and functions are called in OS X? Any help is greatly appreciated. 



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

I Need help from all the group participants

2007-08-20 Thread Boris Ozegovic
Hi, 

I am working on some system, and the communication will take place through
the chatterbot which will be written in AIML (interpreter is written in
Python).  English is not my mother tongue, so I need huge favor:  if all of
you can write two sentences, so that I could have greater pattern base.
The first sentence is finding someone's heart rate, example: "Please, can
you tell me John's heart rate", and the other one is setting the alarm when
someone's heart rate is lower then x, and greater than y, example: "Can
you, please, send me information when John's heart rate is lower than 60,
and greater than 100".  You can manipulate time (right now, now, right this
moment), and everything else you can think about.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python equivalent of Perl's $/

2007-08-20 Thread kyosohma
On Aug 19, 1:13 pm, John K Masters <[EMAIL PROTECTED]>
wrote:
> I am currently working my way through Jeffrey Friedl's book Mastering
> Regular Expressions. Great book apart from the fact it uses Perl for the
> examples.
>
> One particular expression that interests me is '$/ = ".\n"' which,
> rather than splitting a file into lines, splits on a period-newline
> boundary. Combined with Perl's 'while (<>)' construct this seems a great
> way to process the files I am interested in.
>
> Without wishing to start a flame war, is there a way to do this in Python?
>
> Regards, John
> --
> War is God's way of teaching Americans geography
> Ambrose Bierce (1842 - 1914)

Python has a Regular Expressions module. Check it out here:
http://docs.python.org/lib/module-re.html

There's also a chapter from Dive Into Python that covers this topic
too:
http://www.diveintopython.org/regular_expressions/index.html

Finally, Python "while" statement's docs can be found here:
http://docs.python.org/ref/while.html

Hope that helps!

Mike

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


Re: datetime in microseconds

2007-08-20 Thread mroeloffs
On Aug 20, 3:15 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Aug 20, 9:52 pm, [EMAIL PROTECTED] wrote:
>
> > Hi I have a time in microseconds, for example 0x8C905CBA7F84AF4. I
> > want this to a normal view in hh:mm:ss DD:MM:. I tried with
> > datetime, but it only takes a max of 100 microseconds is there
> > another solution?
>
> Your question can be interpreted in two possible ways:
>
> 1. You have an interval or duration (independent of a calendar point)
> and you want to express it in years, months, days, hours, etc. This is
> not possible, due to the variable number of days in a month. The best
> that you can do is express it as days, hours, etc.
>
> >>> microsecs = 0x8C905CBA7F84AF4
> >>> secs = microsecs // 100 # or round to nearest if you prefer
> >>> mins, secs = divmod(secs, 60)
> >>> hrs, mins = divmod(mins, 60)
> >>> days, hrs = divmod(hrs, 24)
> >>> days, hrs, mins, secs
>
> (7326893L, 11L, 1L, 16L)
>
>
>
> 2. You want to know the (Gregorian) calendar point that is
> 0x8C905CBA7F84AF4 microseconds after some epoch. In this case you need
> to specify what the epoch is. Then you can try something like:
>
> >>> datetime.datetime.fromordinal(1) + 
> >>> datetime.timedelta(microseconds=microsecs
>
> )
> Traceback (most recent call last):
>   File "", line 1, in 
> OverflowError: date value out of range
>
> >>> # Whoops!
> >>> years_approx = days / 365.25
> >>> years_approx
> 20059.939767282682
>
> Hmmm, one of us seems to be missing something ...

Sorry,  sorry, sorry it was the wrong value, it should be
0xE0E6FAC3FF3AB2.

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


Newbee Question

2007-08-20 Thread HD1956
This is probably a simple code. I am a truck driver who gets paid by 
stops and cases. I am trying to figure out how to code my stop pay. I 
get 40 cents per stop up to 22 stops, and $1.40 per stops after that. 

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


Re: Newbee Question

2007-08-20 Thread kyosohma
On Aug 20, 9:23 am, "HD1956" <[EMAIL PROTECTED]> wrote:
> This is probably a simple code. I am a truck driver who gets paid by
> stops and cases. I am trying to figure out how to code my stop pay. I
> get 40 cents per stop up to 22 stops, and $1.40 per stops after that.

def calc(num):
if num < 23:
return 0.4 * num
else:
overtime = num - 22
x = 0.4 * 22
x += overtime * 1.4
return x

# Use your own brain next time

Mike

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


Re: Newbee Question

2007-08-20 Thread Shawn Milochik
#!/usr/bin/env python

normalPay = 0.4
overPay = 1.4
normalLimit = 22

def calcPay(numStops):

pay = 0

if numStops > normalLimit:
pay = overPay * (numStops - normalLimit)
numStops = normalLimit

return pay + (numStops * normalPay)

if __name__ == "__main__":

print "Pay for 1 stops: %.2f." % calcPay(1)
print "Pay for 10 stops: %.2f." % calcPay(10)
print "Pay for 17 stops: %.2f." % calcPay(17)
print "Pay for 25 stops: %.2f." % calcPay(25)
print "Pay for 30 stops: %.2f." % calcPay(30)
print "Pay for 31 stops: %.2f." % calcPay(31)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to decompress .Z file?

2007-08-20 Thread Thomas Jollans
On Monday 20 August 2007, Hyunchul Kim wrote:
> Hi, all
>
> How can .Z file be decompressed?
>
> According to python library reference, .Z file might not be supported by
> python, yet.

The GNU zip program (gzip) supports .Z and .z archives, so if you only want to 
support UNIX-like systems you could simply look for a program named "gunzip" 
or "uncompress" and use that.

See also: http://mail.python.org/pipermail/python-list/2004-May/261669.html

The format is now so antiquated (replaced almost totally with zlib/gzip 
compression) that I doubt you'll see it in python, but 
http://en.wikipedia.org/wiki/LZW seams to sport a python implementation.

-- 
  Regards,   Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu
Hacker key :
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Problem with Thread.join()

2007-08-20 Thread James Matthews
Post some code so we can see the issue! I would say that the issue is where
your function that you are calling isn't exiting!

On 8/20/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>
> En Mon, 13 Aug 2007 20:10:53 -0300, Robert Dailey <[EMAIL PROTECTED]>
> escribi�:
>
> > I have a class that derives from threading.Thread. To signal the thread
> > to
> > exit its infinite loop, I set an Event. Once the thread checks
> > Event.isSet()
> > and it is true, it proceeds to break out of the loop and exit the
> > function.
> > In the main thread, right after calling Event.set(), I call
> > Thread.join() to
> > wait on the thread to exit. However, if I call Thread.join() the
> > application
> > locks up because for some reason calling Thread.join() prevents the
> > thread
> > from exiting. I don't know why. Any help? Thanks...
>
> Conceptually you're doing it the right way. Post some code demonstrating
> the problem...
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list




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

Re: Newbee Question

2007-08-20 Thread Shawn Milochik
On 8/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Aug 20, 9:23 am, "HD1956" <[EMAIL PROTECTED]> wrote:
> > This is probably a simple code. I am a truck driver who gets paid by
> > stops and cases. I am trying to figure out how to code my stop pay. I
> > get 40 cents per stop up to 22 stops, and $1.40 per stops after that.
>
> def calc(num):
> if num < 23:
> return 0.4 * num
> else:
> overtime = num - 22
> x = 0.4 * 22
> x += overtime * 1.4
> return x
>
> # Use your own brain next time
>
> Mike
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>




Mike,

I wonder if we were both just duped into helping someone with their homework...

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


Re: datetime in microseconds

2007-08-20 Thread mroeloffs
On Aug 20, 4:17 pm, [EMAIL PROTECTED] wrote:
> On Aug 20, 3:15 pm, John Machin <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 20, 9:52 pm, [EMAIL PROTECTED] wrote:
>
> > > Hi I have a time in microseconds, for example 0x8C905CBA7F84AF4. I
> > > want this to a normal view in hh:mm:ss DD:MM:. I tried with
> > > datetime, but it only takes a max of 100 microseconds is there
> > > another solution?
>
> > Your question can be interpreted in two possible ways:
>
> > 1. You have an interval or duration (independent of a calendar point)
> > and you want to express it in years, months, days, hours, etc. This is
> > not possible, due to the variable number of days in a month. The best
> > that you can do is express it as days, hours, etc.
>
> > >>> microsecs = 0x8C905CBA7F84AF4
> > >>> secs = microsecs // 100 # or round to nearest if you prefer
> > >>> mins, secs = divmod(secs, 60)
> > >>> hrs, mins = divmod(mins, 60)
> > >>> days, hrs = divmod(hrs, 24)
> > >>> days, hrs, mins, secs
>
> > (7326893L, 11L, 1L, 16L)
>
> > 2. You want to know the (Gregorian) calendar point that is
> > 0x8C905CBA7F84AF4 microseconds after some epoch. In this case you need
> > to specify what the epoch is. Then you can try something like:
>
> > >>> datetime.datetime.fromordinal(1) + 
> > >>> datetime.timedelta(microseconds=microsecs
>
> > )
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > OverflowError: date value out of range
>
> > >>> # Whoops!
> > >>> years_approx = days / 365.25
> > >>> years_approx
> > 20059.939767282682
>
> > Hmmm, one of us seems to be missing something ...
>
> Sorry,  sorry, sorry it was the wrong value, it should be
> 0xE0E6FAC3FF3AB2.

The solution I made, with thanks to John. Maybe someone a better one??
def DecodeDateTime(self,dateTime):
dateTime = self.Rotate(dateTime)
microsecs = int(hexlify(dateTime),16)
microsecs -= 315360   # -1 Year
microsecs -= 11232# -13 Days (magic?)
secs = microsecs // 100
mins, secs = divmod(secs, 60)
hrs, mins = divmod(mins, 60)
days, hrs = divmod(hrs, 24)
timed = datetime.datetime.fromordinal(1) +
datetime.timedelta(days)
return "%02d-%02d-%02d %02d:%02d:%02d"%(timed.day,
timed.month, timed.year, hrs, mins, secs)

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


Re: Newbee Question

2007-08-20 Thread Diez B. Roggisch
HD1956 schrieb:
> This is probably a simple code. I am a truck driver who gets paid by 
> stops and cases. I am trying to figure out how to code my stop pay. I 
> get 40 cents per stop up to 22 stops, and $1.40 per stops after that. 
> 

Sounds a bit like homework. Which usually isn't simply delivered here.

Can you show us some code you worked on, then we might suggest enhancements.

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


Re: Newbee Question

2007-08-20 Thread kyosohma
On Aug 20, 9:58 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> On 8/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 20, 9:23 am, "HD1956" <[EMAIL PROTECTED]> wrote:
> > > This is probably a simple code. I am a truck driver who gets paid by
> > > stops and cases. I am trying to figure out how to code my stop pay. I
> > > get 40 cents per stop up to 22 stops, and $1.40 per stops after that.
>
> > def calc(num):
> > if num < 23:
> > return 0.4 * num
> > else:
> > overtime = num - 22
> > x = 0.4 * 22
> > x += overtime * 1.4
> > return x
>
> > # Use your own brain next time
>
> > Mike
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> Mike,
>
> I wonder if we were both just duped into helping someone with their 
> homework...
>
> Shawn

I like to write code, so it's not a big deal when it's something so
simple. Still, that is beyond dumb! Nice code, by the way.

Mike

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


Re: Where we need to use Python ?

2007-08-20 Thread Wildemar Wildenburger
Michael Bentley wrote:
> On Aug 20, 2007, at 1:02 AM, [EMAIL PROTECTED] wrote:
>
>   
>> And Is it a interpreted language or a programming language
>> It comes in which category
>>
>> I very keen to know this please tell
>> 
>
> [ open on suburban kitchen, Wife and Husband arguing ]
>
> Wife: New Shimmer is a floor wax!
>
> Husband: No, new Shimmer is a dessert topping!
>
> [snip 50s-style add]
>
> Spokesman: New Shimmer, for the greatest shine you ever tasted!
>   
Not the most to-the-point reply, but a very amusing one :).

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


Re: Call for advice on how to start PyOpenGL!

2007-08-20 Thread Mike C. Fletcher
math2life wrote:
> I work with python for two years, are familiar with image processing,
> but beginner on PyOpenGL and OpenGL.
>
> Any advice appreciated!
>   
As has been mentioned, the NeHe tutorials[1] are a good starting point.  
There are (multiple) translations of the first 8 or so and then some 
cherry-picked translations further along the set.  There is a set of 
OpenGL demo/sample code available[2] as a separate download from the 3.x 
series (these files are mostly included in the 2.x series, though there 
is new material in the 3.x set).  OpenGLContext also has a large number 
of simple samples, though I've still got "release OpenGLContext" on my 
seemingly infinitely long and growing todo list, so that might not be 
the easiest way to start.

The "Red Book" is an older standard manual for getting started with (C) 
OpenGL code, often you can find older editions online for free.  There 
are hundreds of C tutorials hanging around the net that normally 
translate easily into Python/PyOpenGL.  The PyOpenGL manual pages *try* 
to have links to source code, but unfortunately the (java, ick!) based 
system that generates the base files has been broken for a while and I 
haven't had time to fix it properly so I can re-run the generator to 
update the links.  In the meantime, Google's code search helps a lot 
when you restrict to Python code.[3]

HTH,
Mike

[1] http://nehe.gamedev.net
[2] 
http://sourceforge.net/project/showfiles.php?group_id=5988&package_id=221827
[3] http://www.google.com/codesearch?q=lang%3Apython

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: yet another indentation proposal

2007-08-20 Thread Terry Reedy
If there is not one already, a page for blind and visually impaired 
programmers on the Python site would be a good addition. 



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


Re: Latest models of Gibson guitars

2007-08-20 Thread RickH
On Aug 19, 9:24 pm, Randall Ainsworth <[EMAIL PROTECTED]>
wrote:
> In article <[EMAIL PROTECTED]>, Hermit
>
> <[EMAIL PROTECTED]> wrote:
> > How does the image quality compare with a DSLR?
>
> Depends on whether it's a Paul or a Strat.

A Strat is a Fender, but I'd rather win a Gibson es175.


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


Re: clarification

2007-08-20 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes:
> > turn indicates that both implementations actually work about same and
> > your "O(n squared)" argument is irrelevant.
> 
> It's indeed irrelevant when the behavior _isn't_ quadratic (as in the
> case of intersections) -- but unfortunately it _is_ needlessly quadratic
> in most interesting cases involving containers (catenation of sequences,
> union of sets, merging of dictionaries, merging of priority-queues,
> ...), because in those cases the intermediate temporary values tend to
> grow, as I tried to explain in more detail above.

Mostly directed to samwyse: Alex is correct here and I'd add that
Python and its libraries are written for an imperative, mutating
approach though there are some situations in which you can write in
functional style without a big efficiency hit.  In particular, the
quadratic behavior Alex points out is because of Python's hash-based
implementation of sets, so you can't make a new set that adds or
removes one element from the old set, without copying all the elements
around.

A more purist functional approach would probably implement sets with
some other data structure such as AVL trees, so you can make a new one
that adds or deletes some node in O(log n) time (it would share almost
all of its structure with the old one).  So instead of O(n) for the
hash-based mutating implementation or O(n**2) for the hash/copying
based functional implementation, you get O(n log n) for the functional
tree implementation.  Haskell's Data.Map module does something like
this.  There's a book "Purely Functional Data Structures" by Chris
Okasaki that shows how to implement dicts, priority queues, and
fancier objects in functional style based on similar principles.

If you want to try out functional programming in a lightweight
language (much easier to grok than Haskell) you might look at Hedgehog Lisp:

   http://hedgehog.oliotalo.fi/

It includes a functional dictionary implementation based on AVL trees
but with a Python dictionary-like API.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbee Question

2007-08-20 Thread Shawn Milochik
> I like to write code, so it's not a big deal when it's something so
> simple. Still, that is beyond dumb! Nice code, by the way.
>
> Mike

Yeah, it was fun to write anyway. Thanks for the compliment on the
code. I still consider myself a Python newbie, so it's good to know
I'm not trying to write it like Perl or VBScript anymore. ^_^

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


Re: Newbee Question

2007-08-20 Thread Wildemar Wildenburger
Diez B. Roggisch wrote:
> Sounds a bit like homework. Which usually isn't simply delivered here.
>
>   
Wrong! Usually that happens pretty quickly here (as proven again in this 
case). Not that it should, but only the seniors seem to detect lazy 
learners.

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


Re: Python equivalent of Perl's $/

2007-08-20 Thread Mark T

"John K Masters" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I am currently working my way through Jeffrey Friedl's book Mastering
> Regular Expressions. Great book apart from the fact it uses Perl for the
> examples.
>
> One particular expression that interests me is '$/ = ".\n"' which,
> rather than splitting a file into lines, splits on a period-newline
> boundary. Combined with Perl's 'while (<>)' construct this seems a great
> way to process the files I am interested in.
>
> Without wishing to start a flame war, is there a way to do this in Python?
>
> Regards, John
> -- 
> War is God's way of teaching Americans geography
> Ambrose Bierce (1842 - 1914)

>>> 'test\ntest2.\ntest3\ntest4.\ntest5'.split('.\n')
['test\ntest2', 'test3\ntest4', 'test5']

-Mark T. 

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


Re: Newbee Question

2007-08-20 Thread Paul McGuire
On Aug 20, 9:23 am, "HD1956" <[EMAIL PROTECTED]> wrote:
> This is probably a simple code. I am a truck driver who gets paid by
> stops and cases. I am trying to figure out how to code my stop pay. I
> get 40 cents per stop up to 22 stops, and $1.40 per stops after that.

You'll get top marks for turning in the shortest program!

norm = 0.4
ot = 1.4-norm
otStart = 22
calcPay = lambda stops : norm*stops+ot*max(stops-otStart,0)

-- Paul

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


Re: Python equivalent of Perl's $/

2007-08-20 Thread Nick Craig-Wood
John K Masters <[EMAIL PROTECTED]> wrote:
>  I am currently working my way through Jeffrey Friedl's book Mastering
>  Regular Expressions. Great book apart from the fact it uses Perl for the
>  examples.
> 
>  One particular expression that interests me is '$/ = ".\n"' which,
>  rather than splitting a file into lines, splits on a period-newline
>  boundary. Combined with Perl's 'while (<>)' construct this seems a great
>  way to process the files I am interested in.
> 
>  Without wishing to start a flame war, is there a way to do this in Python?
> 
>  Regards, John

Something like this maybe?

import re

input_data = """I am currently working my way through Jeffrey Friedl's book 
Mastering
Regular Expressions. Great book apart from the fact it uses Perl for the
examples.

One particular expression that interests me is '$/ = ".\\n"' which,
rather than splitting a file into lines, splits on a period-newline
boundary. Combined with Perl's 'while (<>)' construct this seems a great
way to process the files I am interested in.

Without wishing to start a flame war, is there a way to do this in Python?
"""

for para in re.split(r"\.\n", input_data):
print "para = %r" % para

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


Re: How to decompress .Z file?

2007-08-20 Thread Nick Craig-Wood
Hyunchul Kim <[EMAIL PROTECTED]> wrote:
>  How can .Z file be decompressed?

The old unix program compress used to generate these files.

  http://packages.debian.org/unstable/utils/ncompress

You'll find the command line programs gzip/gunzip/zcat can decompress
them too.

>  According to python library reference, .Z file might not be
>  supported by python, yet.

Unfortunately the python gzip library doesn't read .Z files.

I'd pipe the data to zcat using subprocess to decompress from python.

I haven't used a .Z files for many many years - where are you getting
them from?

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


Re: regular expression dictionary search

2007-08-20 Thread Shawn Milochik
#!/usr/bin/env python

import re

patterns = { 'sho.' : 6, '.ilk' : 8, '.an.' : 78 }

def returnCode(aWord):
for k in patterns:
p = "^%s$" % k
regex = re.compile(p)
if re.match(regex, aWord):
return patterns[k]

if __name__ == "__main__":

print "The return for 'fred' : %s" % returnCode('fred')
print "The return for 'silk' : %s" % returnCode('silk')
print "The return for 'silky' : %s" % returnCode('silky')
print "The return for 'hand' : %s" % returnCode('hand')
print "The return for 'strand' : %s" % returnCode('strand')
print "The return for 'bank' : %s" % returnCode('bank')


Note: If a word matches more than one pattern, only one will be returned.

I'm not sure if I'm doing the patterns thing properly -- if anyone
could instruct me on whether it would be proper to declare it in the
function, or use a global declaration, please let me know. However, it
runs properly as far as I tested it.

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


Re: yet another indentation proposal

2007-08-20 Thread Alex Martelli
Jakub Stolarski <[EMAIL PROTECTED]> wrote:

> Why not just use comments and some filter. Just write # _{ at the
> beginning and # _} at the end. Then filter just before runing
> indenting with those control sequences? Then there's no need to change
> interpreter.

As I pointed out in another post to this thread, that's essentially what
Tools/scripts/pindent.py (part of the Python source distribution) does
(no need to comment the beginning of a block since it's always a colon
followed by newline; block-end comments in pindent.py are more
informative).  Just use and/or adapt that...


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


Re: yet another indentation proposal

2007-08-20 Thread Alex Martelli
Aaron <[EMAIL PROTECTED]> wrote:
   ...
> That's probably what I'll end up doing.  The only drawback to that is that
> it solves the problem for me only.  Perhaps I will open source the scripts
> and write up some documentation so that other folks in a similar situation
> don't have to reinvent the wheel.  

As I pointed out in another post to this thread,
Tools/scripts/pindent.py IS open-source, indeed it's part of the Python
source distribution.  Why not use and/or adapt that?

> The only unfortunate aspect to that is 
> that blind newbies to the language will have to figure out setting up a
> shell script or batch file to pipe the output of the filter into Python on
> top of learning the language.  I admit, it's probably not that much work,
> but it is one more stumblingblock that blind newcomers will have to 
> overcome.

pindent.py's approach ensures that the tool's output is also entirely
valid Python (as it only adds comments to mark and "explain" block
ends!) so no "piping the output into Python" is at all needed; you only
need (editor-dependent) to ensure pindent.py is run when you LOAD a
Python source file into your editor.  If anything, pindent.py and/or the
screen reader of choice might be tweaked to "read out" Python sources
more clearly (e.g. by recognizing block-end comments and reading them
differently than other comments are read).


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


Re: yet another indentation proposal

2007-08-20 Thread Alex Martelli
Michael Tobis <[EMAIL PROTECTED]> wrote:

> On Aug 19, 11:51 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> 
> > What's wrong with just saying the current indent level? I'd much rather
> > hear "indent 4" than "tab tab tab tab".
> 
> Alternatively, you might also consider writing a simple pre and
> postprocessor so that you could read and write python the way you
> would prefer

As I pointed out in another post to this thread, that's essentially what
Tools/scripts/pindent.py (part of the Python source distribution) does.
Just use and/or adapt that...


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


Re: question

2007-08-20 Thread Shawn Milochik

> And Shawn, I didn't post any of my work because the network I work on
> isn't
> connected to the internet. So it didn't seem constructive to re-type
> all of my
> failed code just to satisfy your "standards" of proving that I've been
> trying to
> hack this myself for the past few days. All in all, thanks for your,
> u,
> constructive comments.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Your original post said clearly that you didn't post your code because
it didn't work. That's a completely different reason/excuse than "no
Internet connection so I didn't want to re-type it." So either you're
lying or lazy, and in either case I don't appreciate your snarky
comments about my "uhhh constructive" comments.

Don't get me wrong -- I'm not saying you're definitely being
dishonest, but you have to admit that the appearance you gave is
questionable, and questionable behavior on lists like this gets
questioned.

Just so this isn't interpreted badly and doesn't start a flame-war, I
will just give up and say that if there was a misunderstanding it was
on my end, and I apologize. I just wanted to respond to your
passive-aggressive attack, since I'm a friendly, helpful person and
don't want to be unfairly labled as "uhhh constructive."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression dictionary search

2007-08-20 Thread mkPyVS
On Aug 20, 9:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/env python
>
> import re
>
> patterns = { 'sho.' : 6, '.ilk' : 8, '.an.' : 78 }
>
> def returnCode(aWord):
> for k in patterns:
> p = "^%s$" % k
> regex = re.compile(p)
> if re.match(regex, aWord):
> return patterns[k]
>
> if __name__ == "__main__":
>
> print "The return for 'fred' : %s" % returnCode('fred')
> print "The return for 'silk' : %s" % returnCode('silk')
> print "The return for 'silky' : %s" % returnCode('silky')
> print "The return for 'hand' : %s" % returnCode('hand')
> print "The return for 'strand' : %s" % returnCode('strand')
> print "The return for 'bank' : %s" % returnCode('bank')
>
> Note: If a word matches more than one pattern, only one will be returned.
>
> I'm not sure if I'm doing the patterns thing properly -- if anyone
> could instruct me on whether it would be proper to declare it in the
> function, or use a global declaration, please let me know. However, it
> runs properly as far as I tested it.
>
> Shawn

I think global/local declaration should in part depend on the scope of
your usage. Are you going to re-use the function over and over again
in multiple modules? Does it need any state collecting statistics? If
so I would recommend you upgrade your function to a class then define
"patterns" as a static class level variable. Then the initialization
cost is eaten only for creation of the class (most often) the 1st
time.

As a side note unless you are searching large buffers it is possibly
more costly to compile into a re object then do a match with it as
opposed to let the match object perform a compile a function level
itself- if you use the class option above I would recommend storing
the re.compiled versions of your patterns in the dictionary
(everything is an object!) rather than the string repr and issuing a
compile.

mkPyVS

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


Re: regular expression dictionary search

2007-08-20 Thread Paul McGuire
On Aug 20, 10:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/env python

> if __name__ == "__main__":
>
> print "The return for 'fred' : %s" % returnCode('fred')
> print "The return for 'silk' : %s" % returnCode('silk')
> print "The return for 'silky' : %s" % returnCode('silky')
> print "The return for 'hand' : %s" % returnCode('hand')
> print "The return for 'strand' : %s" % returnCode('strand')
> print "The return for 'bank' : %s" % returnCode('bank')
>

Shawn -

All that copy/pasting has got to have carpal tunnel written all over
it - DRY!

tests = "fred silk silky hand strand bank".split()
for test in tests:
print "The return for '%s' : %s" % (test, returnCode(test))

-- Paul

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


Re: regular expression dictionary search

2007-08-20 Thread Shawn Milochik
On 8/20/07, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Aug 20, 10:35 am, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> > #!/usr/bin/env python
> 
> > if __name__ == "__main__":
> >
> > print "The return for 'fred' : %s" % returnCode('fred')
> > print "The return for 'silk' : %s" % returnCode('silk')
> > print "The return for 'silky' : %s" % returnCode('silky')
> > print "The return for 'hand' : %s" % returnCode('hand')
> > print "The return for 'strand' : %s" % returnCode('strand')
> > print "The return for 'bank' : %s" % returnCode('bank')
> >
>
> Shawn -
>
> All that copy/pasting has got to have carpal tunnel written all over
> it - DRY!
>
> tests = "fred silk silky hand strand bank".split()
> for test in tests:
> print "The return for '%s' : %s" % (test, returnCode(test))
>
> -- Paul
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


You're right. Thanks for the correction. My wrists are shot as it is,
and it's easy enough in vim to copy & paste. You know how it is -- I
made one test line, then copied it to a second, then copied it to a
third... Guilty of not planning ahead. ;o)
-- 
http://mail.python.org/mailman/listinfo/python-list


str().join() isn't working

2007-08-20 Thread Robert Dailey
Hi,

First have a look at the following code:


In main.py:
---
space = " "

includes = space.join( system._user_includes ) + " " + space.join(
system._system_includes )


In system.py:
---
_user_includes = [
]

_system_includes = [
]


The above does not work. The interpreter states: "TypeError: sequence item
0: expected string, list found". I'm not sure what this means. Can anyone
help me figure out what I'm doing wrong? Thanks.

PS: I've also tried putting strings in the lists above just to make sure
that them being empty wasn't the problem. I got no different results.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Problem with Thread.join()

2007-08-20 Thread Robert Dailey
Hey guys,

Sorry for taking so long to respond. I had actually figured out what
this issue is over on the wxPython mailing list. The issue was that I
was attempting to configure wxPython controls from a remote thread,
which is apparently illegal due to some state persistance issues.

Thanks all for responding and I do apologize for not having given
proper code snippets on my first post. Take care all.

On 8/20/07, James Matthews <[EMAIL PROTECTED]> wrote:
> Post some code so we can see the issue! I would say that the issue is where
> your function that you are calling isn't exiting!
>
>
> On 8/20/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> > En Mon, 13 Aug 2007 20:10:53 -0300, Robert Dailey <[EMAIL PROTECTED]>
> > escribi�:
> >
> > > I have a class that derives from threading.Thread. To signal the thread
> > > to
> > > exit its infinite loop, I set an Event. Once the thread checks
> > > Event.isSet()
> > > and it is true, it proceeds to break out of the loop and exit the
> > > function.
> > > In the main thread, right after calling Event.set(), I call
> > > Thread.join() to
> > > wait on the thread to exit. However, if I call Thread.join() the
> > > application
> > > locks up because for some reason calling Thread.join() prevents the
> > > thread
> > > from exiting. I don't know why. Any help? Thanks...
> >
> > Conceptually you're doing it the right way. Post some code demonstrating
> > the problem...
> >
> > --
> > Gabriel Genellina
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
>
>
> --
> http://www.goldwatches.com/
> http://www.jewelerslounge.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: yet another indentation proposal

2007-08-20 Thread Paddy
On Aug 19, 5:22 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Paddy <[EMAIL PROTECTED]> wrote:
>
>...
>
> > Can screen reaaderss be customized?
>
> Open-source ones surely can (e.g., NVDA is an open-source reader for
> Windows written in Python,  -- alas, if
> you search for NVDA Google appears to be totally convinced you mean
> NVidia instead, making searches pretty useless, sigh).
>
> > Maybe their is a way to get the screen reader to say indent and dedent
> > at thee appropriate places?
>
> There definitely should be.
>
> > Or maybe a filter to put those wordds into the source?
>
> .../Tools/scripts/pindent.py (comes with the Python source distribution,
> and I hope that, like the whole Tools directory, it would also come with
> any sensible packaged Python distribution) should already be sufficient
> for this particular task.  The "indent" always happens (in correct
> Python sources) on the next line after one ending with a colon;
> pindent.py can add or remove "block-closing comments" at each dedent
> (e.g., "# end for" if the dedent is terminating a for-statement), and
> can adjust the indentation to make it correct if given a Python source
> with such block-closing comments but messed-up indentation.
>
> Alex

Aaron, here's the comment at the beginning of the script. Would it
work for you?

# This file contains a class and a main program that perform three
# related (though complimentary) formatting operations on Python
# programs.  When called as "pindent -c", it takes a valid Python
# program as input and outputs a version augmented with block-closing
# comments.  When called as "pindent -d", it assumes its input is a
# Python program with block-closing comments and outputs a commentless
# version.   When called as "pindent -r" it assumes its input is a
# Python program with block-closing comments but with its indentation
# messed up, and outputs a properly indented version.

# A "block-closing comment" is a comment of the form '# end '
# where  is the keyword that opened the block.  If the
# opening keyword is 'def' or 'class', the function or class name may
# be repeated in the block-closing comment as well.  Here is an
# example of a program fully augmented with block-closing comments:

# def foobar(a, b):
#if a == b:
#a = a+1
#elif a < b:
#b = b-1
#if b > a: a = a-1
## end if
#else:
#print 'oops!'
## end if
# # end def foobar

# Note that only the last part of an if...elif...else... block needs a
# block-closing comment; the same is true for other compound
# statements (e.g. try...except).  Also note that "short-form" blocks
# like the second 'if' in the example must be closed as well;
# otherwise the 'else' in the example would be ambiguous (remember
# that indentation is not significant when interpreting block-closing
# comments).

# The operations are idempotent (i.e. applied to their own output
# they yield an identical result).  Running first "pindent -c" and
# then "pindent -r" on a valid Python program produces a program that
# is semantically identical to the input (though its indentation may
# be different). Running "pindent -e" on that output produces a
# program that only differs from the original in indentation.

# Other options:
# -s stepsize: set the indentation step size (default 8)
# -t tabsize : set the number of spaces a tab character is worth
(default 8)
# -e : expand TABs into spaces
# file ...   : input file(s) (default standard input)
# The results always go to standard output

# Caveats:
# - comments ending in a backslash will be mistaken for continued
lines
# - continuations using backslash are always left unchanged
# - continuations inside parentheses are not extra indented by -r
#   but must be indented for -c to work correctly (this breaks
#   idempotency!)
# - continued lines inside triple-quoted strings are totally garbled

# Secret feature:
# - On input, a block may also be closed with an "end statement" --
#   this is a block-closing comment without the '#' sign.

# Possible improvements:
# - check syntax based on transitions in 'next' table
# - better error reporting
# - better error recovery
# - check identifier after class/def

# The following wishes need a more complete tokenization of the
source:
# - Don't get fooled by comments ending in backslash
# - reindent continuation lines indicated by backslash
# - handle continuation lines inside parentheses/braces/brackets
# - handle triple quoted strings spanning lines
# - realign comments
# - optionally do much more thorough reformatting, a la C indent

-Paddy

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


Re: Newbee Question

2007-08-20 Thread Neil Cerutti
On 2007-08-20, HD1956 <[EMAIL PROTECTED]> wrote:
> This is probably a simple code. I am a truck driver who gets
> paid by stops and cases. I am trying to figure out how to code
> my stop pay. I get 40 cents per stop up to 22 stops, and $1.40
> per stops after that. 

I wish *I* could make a deal like that. I stop working all the
time!

-- 
Neil Cerutti
Customers who consider our waitresses uncivil ought to see the manager --sign
at New York restaurant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I Need help from all the group participants

2007-08-20 Thread [EMAIL PROTECTED]
On Aug 20, 9:16 am, Boris Ozegovic <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am working on some system, and the communication will take place through
> the chatterbot which will be written in AIML (interpreter is written in
> Python).  English is not my mother tongue, so I need huge favor:  if all of
> you can write two sentences, so that I could have greater pattern base.
> The first sentence is finding someone's heart rate, example: "Please, can
> you tell me John's heart rate", and the other one is setting the alarm when
> someone's heart rate is lower then x, and greater than y, example: "Can
> you, please, send me information when John's heart rate is lower than 60,
> and greater than 100".  You can manipulate time (right now, now, right this
> moment), and everything else you can think about.

The only sentence that comes to mind is:

"I hope I never find myself in a hospital that uses your system."

>
> --
> Ne dajte da nas la¾ljivac Bandiæ 
> truje:http://cnn.blog.hr/arhiva-2007-06.html#1622776372


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


Re: I Need help from all the group participants

2007-08-20 Thread Boris Ozegovic
[EMAIL PROTECTED] wrote:

> The only sentence that comes to mind is: 
> 
> "I hope I never find myself in a hospital that uses your system."

You are not funny. The system isn't for hospitals, it is for university
purposes.

-- 
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I Need help from all the group participants

2007-08-20 Thread Shawn Milochik
On 8/20/07, Boris Ozegovic <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>
> > The only sentence that comes to mind is:
> >
> > "I hope I never find myself in a hospital that uses your system."
>
> You are not funny. The system isn't for hospitals, it is for university
> purposes.
>
> --
> Ne dajte da nas lažljivac Bandić truje:
> http://cnn.blog.hr/arhiva-2007-06.html#1622776372
> --
> http://mail.python.org/mailman/listinfo/python-list
>


I disagree. He is funny. Sorry you can't appreciate the humor -- it
must be the language barrier.

Lighten up and enjoy this life -- it's the only one we have.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hot subject: a good python editor and/or IDE?

2007-08-20 Thread Dave Cook
On 2007-08-19, Sébastien <[EMAIL PROTECTED]> wrote:

> I am currently using Eclipse+PyDev when developping Python projects but 
> I lack a fast, simple editor for tiny bit of scripts. So here is my 
> question: what is, for you, the current best ( but still kind of light! 
> ) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking 
> for a linux compatible editor.

JED has a nice python mode for fast, simple editing.  

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


Re: Mouse control with ctypes in OS X

2007-08-20 Thread Paul McNett
Niklas Ottosson wrote:
> I need to get hold of the mouse position and also need to be able to 
> change it. In windows I have used ctypes.windll.user32.getCursorPos() 
> and ctypes.windll.user32.setCursorPos() with great success in my program 
> but now I also need to make a Mac OS X version of the program.
> 
> Does anyone know what the above libraries and functions are called in OS 
> X? Any help is greatly appreciated. 

All I can offer you is the knowledge that OS X will probably not let you 
set the mouse position, as it is a gross violation of the HIG (The user 
is in charge of where the mouse appears, not the application).

But, I'm sure someone will chime in on how to get the mouse position.

-- 
pkm ~ http://paulmcnett.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading a line in file

2007-08-20 Thread Shawn Milochik
Write some code, even if it doesn't quite work, and post it. We'll
help you fix it.

You can open a file with:  input = open("file.txt", "r")

You can read a line with: someText = input.readline()

You can loop through an open file like this:

for line in input:
#do something with line


That should get you started.
-- 
http://mail.python.org/mailman/listinfo/python-list


reading a line in file

2007-08-20 Thread Brian McCann
 
Hi,
 
does anyone have a good example of how to read a line in a file?

say you have a file build.log and in the file are values like

buildnum = 1
date = 20070820

I know how to read the contents and write them to a file, but how would one
grab just the date or build number in order to create a directory named 
20070820_build1

Thanks,
Brian

 
<mailto:[EMAIL PROTECTED]> 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: I Need help from all the group participants

2007-08-20 Thread ŠućMućPaProlij

"Shawn Milochik" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 8/20/07, Boris Ozegovic <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>>
>> > The only sentence that comes to mind is:
>> >
>> > "I hope I never find myself in a hospital that uses your system."
>>
>> You are not funny. The system isn't for hospitals, it is for university
>> purposes.
>>
>> --
>> Ne dajte da nas lažljivac Bandić truje:
>> http://cnn.blog.hr/arhiva-2007-06.html#1622776372
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
> I disagree. He is funny. Sorry you can't appreciate the humor -- it
> must be the language barrier.
>

hahahahahahahahahahahahaha

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


'REPL' style IDE

2007-08-20 Thread beginner
Hi Everyone,

I am using the Wing IDE. It works great when developing applications,
but the workflow is like Visual Studio -- after you execute it or
debug it, the python script ends.

What I want is an interactive interpreting environment. I want the IDE
to execute a boot script to initialize my environment and create some
basic data objects. And then I want to be able to type in command on
the command line using these objects. The IDLE that comes with Python
does this, but compared with Wing, it does not have a lot of the
convenient features.

I am wondering if there is anything more powerful than IDLE that can
do this.

Thanks,
Geoffrey

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


Re: 'REPL' style IDE

2007-08-20 Thread beginner
On Aug 20, 12:50 pm, beginner <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
> I am using the Wing IDE. It works great when developing applications,
> but the workflow is like Visual Studio -- after you execute it or
> debug it, the python script ends.
>
> What I want is an interactive interpreting environment. I want the IDE
> to execute a boot script to initialize my environment and create some
> basic data objects. And then I want to be able to type in command on
> the command line using these objects. The IDLE that comes with Python
> does this, but compared with Wing, it does not have a lot of the
> convenient features.
>
> I am wondering if there is anything more powerful than IDLE that can
> do this.
>
> Thanks,
> Geoffrey

If Wing could load my init script into a python session ONCE and then
run my code in another files MANY times, with or without the debugger,
without starting a new python session, that would be great.

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


Re: str().join() isn't working

2007-08-20 Thread Robert Dailey
here is a more realized example of the lists I'm trying to join:


_user_includes = [
"../src",
"../resource",
"../inc",
"../src",
"../data",
"../gui",
"../script",
"../script/actions",
"../gui/dispatch",
"../gui/factories",
"../gui/frames",
"../gui/getters",
"../gui/localization",
"../gui/player",
"../gui/setters",
"../gui/utilities",
"../sis",
"../player",
"../platform/ngi",
"../../engine",
"../../engine/audio/NGI",
"../../engine/io",
"../../engine/io\NGI",
"../../engine/math",
"../../engine/math/fixed",
"../../engine/path/NGI",
"../../engine/text/NGI",
"../../engine/mem",
"../../engine/text",
"../../engine/observer",
"../../sdk/tiny_xml",
"../../sdk/zlib",
"../../sdk/lpng",
"../../sdk/IFDLib/Source/Precompile",
"../../sdk/IFDLib/Source/CoreLib",
"../../sdk/IFDLib/inc",
"../../sdk/IFDLib/Source/UtilLib",
"../../sdk/IFDLib/Source/GameLib",
"../../sdk/IFDlib/Source/OSLib/_NGI",
"../../sdk/stl-port/NGI",
"../../sdk/mini-boost/NGI",
"../../sdk/mini-boost/COMMON",
]

_system_includes = [
"../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include",

"../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include/osextensions/rga",

"../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include/osextensions/stdapis",

"../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include/osextensions/stdapis/stlport",
"../../../../../../Symbian/9.1/NGAGE_SDK_1.1/epoc32/include/variant"
]





On 8/20/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
> Hi,
>
> First have a look at the following code:
>
>
> In main.py:
> ---
> space = " "
>
> includes = space.join ( system._user_includes ) + " " + space.join(
> system._system_includes )
>
>
> In system.py:
> ---
> _user_includes = [
> ]
>
> _system_includes = [
> ]
>
>
> The above does not work. The interpreter states: "TypeError: sequence item
> 0: expected string, list found". I'm not sure what this means. Can anyone
> help me figure out what I'm doing wrong? Thanks.
>
> PS: I've also tried putting strings in the lists above just to make sure
> that them being empty wasn't the problem. I got no different results.
>
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >