Re: JEP and JPype in a single process

2005-06-28 Thread skn
Thanks for your prompt reply, Steve.
Just one suggestion, may be the startJVM method's implementation can itself
be changed to check for already existing JVM.
Of course this will also mean a change in shutdownJVM() semantics. If JVM
has been started earlier(not using startJVM()), shutdownJVM() should be a
do-nothing function.

Another question I had was, is there any option to suppress the JVM activity
report that gets displayed. For e.g.,

JVM activity report :
classes loaded   : 26
JVM has been shutdown

I know I can do it by re-directing the std err to NUL.
But is there any other option?

With best regards,
skn

"Steve Menard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> skn wrote:
> > Hello,
> >
> > I have written a very simple java class file, which invokes a Python
script
> > using JEP.
> >
> > Code snippet:-
> > ---
> > Jep jep = new Jep(false);
> > jep.runScript("C:\\temp\\testscript.py");
> > jep.close();
> >
> > Now inside this Python script I want to make Java calls using JPype.
> > If I use startjvm() inside this Python script, a Runtime Error
(exception)
> > is thrown.
> > Also tried attachThreadToJVM(), but doesn't work, again Runtime Error.
> >
> > Any clues as to how I could achieve my goal??
> > The interaction shown below should happen in a single process.
> >
> > JAVA ==> jep ==> PYTHON ==> jpype ==> JAVA
> >
> > Regards,
> > skn
> >
> >
>
> You're trying to do something I hope to make possible somewhere down the
> road ...
>
> As of today, I do not think it is possible. JPype does not provide a way
> to initialize the JVM-bridge system except for startJvm .. which seems
> to be prohibited when a JVM is already running.
>
> AttachThreadToJVM will only work once the JVM-bridge system has been
> initialize.
>
> I will look into providing a sister method to startJVM to attach to the
> currently running JVM instead of starting a new one. IF it does not
> require major changes I will release it as 0.5.1. If you'd like you can
> submit an enhancement request on the JPype sourceforge page, so this
> doesn't get lost.
>
>
>
> -- 
> Steve Menard
> 
> Maintainer of http://jpype.sourceforge.net


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


Re: How to compress a folder and all of its sub directories and files into a zip file?

2005-06-28 Thread could ildg
Thank you,
it works~~

On 6/29/05, Peter Szinek <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> What about this:
> 
> import os,zipfile
> from os.path import join
> 
> 
> zip = zipfile.ZipFile("myzipfile.zip", 'w')
> for root, dirs, files in os.walk('.'):
>  for fileName in files:
>  zip.write(join(root,fileName))
> zip.close()
> 
> Maybe it zips also the myzipfile.zip ;-)
> Probably this is not needed, so an additional test (something like
> fileName != 'myfile.zip' would be needed.
> 
> HTH,
> Peter
> 
> could ildg wrote:
> > I want to compress a folder and all of its sub files including empty folders
> > into a zip file. what's the pythonic way to do this?
> >
> > Thanks in advance.
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie: Help Figger Out My Problem

2005-06-28 Thread ChuckDubya
##Coin Flip: randomly flips 100 "coins" and prints results
##Original draft: june 27, 2005
##Chuck

import random
heads = 0
tails = 0
flips = 0
while flips < 99:
coin = random.randrange(0, 2)
if coin == 0:
heads = heads + 1
else:
tails = tails + 1
flips = flips + 1
if flips >= 99:
print "Heads: " + heads
print "Tails: " + tails
print "Total: " + flips + "flips"
raw_input("Press the enter key to exit.")



When I save and run this "program", I get a DOS window that flashes at
me and disappears.  What's wrong with it?

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


Re: How to compress a folder and all of its sub directories and files into a zip file?

2005-06-28 Thread could ildg
but the file is just stored,
and not compressed.

On 6/28/05, could ildg <[EMAIL PROTECTED]> wrote:
> Thank you,
> it works~~
> 
> On 6/29/05, Peter Szinek <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > What about this:
> >
> > import os,zipfile
> > from os.path import join
> >
> >
> > zip = zipfile.ZipFile("myzipfile.zip", 'w')
> > for root, dirs, files in os.walk('.'):
> >  for fileName in files:
> >  zip.write(join(root,fileName))
> > zip.close()
> >
> > Maybe it zips also the myzipfile.zip ;-)
> > Probably this is not needed, so an additional test (something like
> > fileName != 'myfile.zip' would be needed.
> >
> > HTH,
> > Peter
> >
> > could ildg wrote:
> > > I want to compress a folder and all of its sub files including empty 
> > > folders
> > > into a zip file. what's the pythonic way to do this?
> > >
> > > Thanks in advance.
> >
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> When I save and run this "program", I get a DOS window that flashes at
> me and disappears.  What's wrong with it?

You can't just click the file.py icon and expect a program like that
to do something reasonable.  There are two ways to deal with it:

1) start a DOS box and run the program from the command line.  Just
type "myprog.py" to the C:> prompt (or whatever your .py file is
called) and it will run in the dos box.  Of course you have to be
in the directory where the .py file is.

2) run IDLE, the integrated Python environment that you probably have
installd.  Select it from the programs menu.  Go to fhe file pulldown
and open your .py file (you may have to browse around for it).  Then
hit "F5" and IDLE will pop another window that shows you the output.


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


Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread db
On Tue, 28 Jun 2005 00:23:30 -0700, ChuckDubya wrote:

> ##Coin Flip: randomly flips 100 "coins" and prints results
> ##Original draft: june 27, 2005
> ##Chuck
> 
> import random
> heads = 0
> tails = 0
> flips = 0
> while flips < 99:
> coin = random.randrange(0, 2)
> if coin == 0:
> heads = heads + 1
> else:
> tails = tails + 1
> flips = flips + 1
> if flips >= 99:
> print "Heads: " + heads
> print "Tails: " + tails
> print "Total: " + flips + "flips"
> raw_input("Press the enter key to exit.")
> 
> 
> 
> When I save and run this "program", I get a DOS window that flashes at
> me and disappears.  What's wrong with it?
Your programm gives an error. You are trying to concatenate strings with  
integers.

http://docs.python.org/lib/typesseq-strings.html

import random
heads = 0
tails = 0
flips = 0
while flips < 99:
coin = random.randrange(0, 2)
if coin == 0:
heads = heads + 1
else:
tails = tails + 1
flips = flips + 1
if flips >= 99:
print "Heads: %s" % heads   ## string formatting
print "Tails: %s"  %tails   ## string formatting
print "Total: %s flips" % flips ## string formatting
raw_input("Press the enter key to exit.")

hth Arjen



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


Re: How to compress a folder and all of its sub directories and files into a zip file?

2005-06-28 Thread Brian van den Broek
could ildg said unto the world upon 28/06/2005 03:29:
> but the file is just stored,
> and not compressed.
> 
> On 6/28/05, could ildg <[EMAIL PROTECTED]> wrote:
> 
>>Thank you,
>>it works~~
>>
>>On 6/29/05, Peter Szinek <[EMAIL PROTECTED]> wrote:
>>
>>>Hi,
>>>
>>>What about this:
>>>
>>>import os,zipfile
>>>from os.path import join
>>>
>>>
>>>zip = zipfile.ZipFile("myzipfile.zip", 'w')
>>>for root, dirs, files in os.walk('.'):
>>> for fileName in files:
>>> zip.write(join(root,fileName))
>>>zip.close()
>>>
>>>Maybe it zips also the myzipfile.zip ;-)
>>>Probably this is not needed, so an additional test (something like
>>>fileName != 'myfile.zip' would be needed.
>>>
>>>HTH,
>>>Peter
>>>
>>>could ildg wrote:
>>>
I want to compress a folder and all of its sub files including empty folders
into a zip file. what's the pythonic way to do this?

Thanks in advance.
>>>
>>>

This thread got me to read the relevant docs:

7.18.1 ZipFile Objects
"class ZipFile( file[, mode[, compression]])
 Open a ZIP file, where file can be either a path to a file (a 
string) or a file-like object. The mode parameter should be 'r' to 
read an existing file, 'w' to truncate and write a new file, or 'a' to 
append to an existing file. For mode is 'a' and file refers to an 
existing ZIP file, then additional files are added to it. If file does 
not refer to a ZIP file, then a new ZIP archive is appended to the 
file. This is meant for adding a ZIP archive to another file, such as 
python.exe. Using

cat myzip.zip >> python.exe

 also works, and at least WinZip can read such files. compression 
is the ZIP compression method to use when writing the archive, and 
should be ZIP_STORED or ZIP_DEFLATED; unrecognized values will cause 
RuntimeError to be raised. If ZIP_DEFLATED is specified but the zlib 
module is not available, RuntimeError is also raised. The default is 
ZIP_STORED."
http://docs.python.org/lib/zipfile-objects.html

So, it would appear that compression requires a 3rd party module, not 
included in Python (and not present on my Windows box).

I'm presently filing a bug suggesting this be made a touch more 
explicit in the zlib docs.

Best to all,

Brian vdB

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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread gatti


Ivan Van Laningham wrote:
[...]
>
> Seriously, PostScript is a lot more fun to learn than Forth, and more
> directly useful.  Since the rewards are so immediate, a kid's attention
> could be gained and kept pretty easily.

PostScript is easy, but I'm afraid some technical details could get in
the way of enjoyable exploration, e.g. font types or scaling.
PostScript is also a single purpose language: it can print static
graphics and with a slightly more complex setup it can display static
graphics on the screen, period. No interactivity, no files, no network,
no general computation or data structures.

> But I'd still recommend Python as a first programming language.  Keep to
> the standard stuff--ignore list comprehensions and so on--until he or
> she has the basic control flow down pat.

Python is general purpose; it can do graphics with a path/stroke model
like Postscript's and a whole world of other things. There are many
complex features in Python that shouldn't be introduced before the need
arises.
List comprehensions, however, *are* the basic control flow; loops are
much more verbose and they should be used only when necessary.

Lorenzo Gatti

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


Re: How to compress a folder and all of its sub directories and files into a zip file?

2005-06-28 Thread could ildg
Thanks to Brian van den Broek ,
I've just reached the doc, too.
I'm now very clear.

On 6/28/05, Brian van den Broek <[EMAIL PROTECTED]> wrote:
> could ildg said unto the world upon 28/06/2005 03:29:
> > but the file is just stored,
> > and not compressed.
> >
> > On 6/28/05, could ildg <[EMAIL PROTECTED]> wrote:
> >
> >>Thank you,
> >>it works~~
> >>
> >>On 6/29/05, Peter Szinek <[EMAIL PROTECTED]> wrote:
> >>
> >>>Hi,
> >>>
> >>>What about this:
> >>>
> >>>import os,zipfile
> >>>from os.path import join
> >>>
> >>>
> >>>zip = zipfile.ZipFile("myzipfile.zip", 'w')
> >>>for root, dirs, files in os.walk('.'):
> >>> for fileName in files:
> >>> zip.write(join(root,fileName))
> >>>zip.close()
> >>>
> >>>Maybe it zips also the myzipfile.zip ;-)
> >>>Probably this is not needed, so an additional test (something like
> >>>fileName != 'myfile.zip' would be needed.
> >>>
> >>>HTH,
> >>>Peter
> >>>
> >>>could ildg wrote:
> >>>
> I want to compress a folder and all of its sub files including empty 
> folders
> into a zip file. what's the pythonic way to do this?
> 
> Thanks in advance.
> >>>
> >>>
> 
> This thread got me to read the relevant docs:
> 
> 7.18.1 ZipFile Objects
> "class ZipFile( file[, mode[, compression]])
>  Open a ZIP file, where file can be either a path to a file (a
> string) or a file-like object. The mode parameter should be 'r' to
> read an existing file, 'w' to truncate and write a new file, or 'a' to
> append to an existing file. For mode is 'a' and file refers to an
> existing ZIP file, then additional files are added to it. If file does
> not refer to a ZIP file, then a new ZIP archive is appended to the
> file. This is meant for adding a ZIP archive to another file, such as
> python.exe. Using
> 
> cat myzip.zip >> python.exe
> 
>  also works, and at least WinZip can read such files. compression
> is the ZIP compression method to use when writing the archive, and
> should be ZIP_STORED or ZIP_DEFLATED; unrecognized values will cause
> RuntimeError to be raised. If ZIP_DEFLATED is specified but the zlib
> module is not available, RuntimeError is also raised. The default is
> ZIP_STORED."
> http://docs.python.org/lib/zipfile-objects.html
> 
> So, it would appear that compression requires a 3rd party module, not
> included in Python (and not present on my Windows box).
> 
> I'm presently filing a bug suggesting this be made a touch more
> explicit in the zlib docs.
> 
> Best to all,
> 
> Brian vdB
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-28 Thread Peter Maas
Brian schrieb:
> Microsoft Visual Basic (.NET) would be your best bet for this type of 
> software development.  It allows you to create GUI apps that can work 
> with a variety of database options, such as Access or MS SQL Server.

Maybe you're right with .net, but I'd go for C# when doing .net. Basic
is the ugliest and most mind corrupting language I've come across. And
the OP has a C/C++ background.

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-28 Thread Cyril BAZIN
Hello,

If you have enough money to buy a licence, Visual Basic seem a very good option.
(But you should learn how to use design patterns.)
Without knowing this language I was able to perform a graphical user interface to 
interact with an automat, a mySQL database and many analogical sensors in less 
than 1 month. 

Cyril


On 27 Jun 2005 11:51:21 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I'm a manager where I work(one of the cogs in a food service company).The boss needed one of us to become the "tech guy", and part of that is
writing small windows programs for the office. He wants the developmentwork done in house, and he knows I am in school for a CS minor. I knowbasic C++(Part 2 of that is in the fall), and I will be taking Java 1
in the fall also. What is the easiest way for me to make windowsprograms that will do basic things like(Inventory, Menu Management,etc...)? I have heard visual basic is where it's at. I want to keep anopen mind though, so I am wondering if python could be an option. The
programs haveno speed requirement.  But they must be pretty, and not confuse myboss. Plus he wants well documented help for each function. I asked thewindows programming group, but I thought I would ask here also. Thanks.
Xeys--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: FlashMX and Py2exe doesn't fly...

2005-06-28 Thread Richie Hindle

[Jim]
> They did it with Gush: (I think)
>http://2entwine.com/
> 
> It's a py program that embeds Flash very nice.

Very nice indeed!  Does anyone know any details about the technology they
used for this?  It appears to be closed source, and I couldn't see anything
on their site about the architecture (other than a list of credits that
includes ctypes, win32all, Macromedia and SciTE|Flash).

-- 
Richie Hindle
[EMAIL PROTECTED]

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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Daniel Dittmar
BORT wrote:
> I told my son, who wants to learn how to compute probabilities, that we
> have to start with some boring stuff so we can learn how to do the cool
> stuff.  Adding and subtracting aren't really fun, but figuring odds on
> rolling dice IS fun.  Learning to program will be kind of like that.
> He accepted that explantion.

I'm not sure that you actually have to start with the boring stuff. 
Imagine that you have a small, but complete program that executes some 
random function a thousand times and plots the distribution. Your son 
could probably
* start to change parameters to the function
* try out the different distributions in the library
* combine them to form new distributions (e.g. roll two n-sided dice)
* build more complex simulations (pit two Dungeons&Dragons fighters 
against each other by rolling simulated dice)

It's a bit more work for you as you'll have to decide on each step how 
much of the infrastructure you implement without taking away all the 
challenges.

Python vs. FORTH: what you learn from Python is more easily transferred 
to other programming languages. And if you happend to speak German, 
there is "Python für Kids" 


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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote:
> List comprehensions, however, *are* the basic control flow; loops are
> much more verbose and they should be used only when necessary.

List comprehensions are probably a bad idea for entry level programmers:
- for and while loops are much easier to debug as you can insert print 
statements everywhere
- list comprehensions don't allow you to break complex expressions into 
several simpler ones by using local variables, everything has to happen 
in one expression

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


Re: Boss wants me to program

2005-06-28 Thread Adriaan Renting
Visual Basic is a good option for small programs on Windows. It does
cost a lot of money depending on your needs. It's not a good choice for
large programs (or at least used to be). The older versions of VC++ are
very hard and difficult, the newer versions seem to be o.k. I used to
prefer Borland C++Builder for large Windows projects.

Both Java and C++ are very complex languages, they wouldn't be my first
choice to learn programming basics.

Python is especially nice if you are using Some Unix environment. I like
how it interoperates with Qt for designing user interfaces. It's free
too, but for Windows you might need to wait for Qt version 4 to be able
to create User Interfaces o Windows. I like the Eric3 program to develop
my applications.

As to the actual programming:
Writing the documentation, helpfiles and maintaining the application is
what will take most of the time, not the actual writing itself.

Here are some sites that might have some useful hints for creating easy
to use applications:
"http://www.webpagesthatsuck.com/mysterymeatnavigation.html";
"http://www.nngroup.com/"; "http://www.rha.com/ui_hall_of_shame.htm";
"http://digilander.libero.it/chiediloapippo/Engineering/iarchitect/shame.htm";
"http://www.pixelcentric.net/x-shame/";
"http://www.joelonsoftware.com/articles/Wrong.html";

Adriaan Renting| Email: [EMAIL PROTECTED]
ASTRON | Phone: +31 521 595 217
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 597 332
The Netherlands| Web: http://www.astron.nl/~renting/
>>> Cyril BAZIN <[EMAIL PROTECTED]> 06/28/05 11:25 AM >>>
Hello,

If you have enough money to buy a licence, Visual Basic seem a very good

option.
(But you should learn how to use design patterns.)

Without knowing this language I was able to perform a graphical user 
interface to 
interact with an automat, a mySQL database and many analogical sensors
in 
less 
than 1 month. 

Cyril


On 27 Jun 2005 11:51:21 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
> 
> I'm a manager where I work(one of the cogs in a food service company).
> The boss needed one of us to become the "tech guy", and part of that
is
> writing small windows programs for the office. He wants the
development
> work done in house, and he knows I am in school for a CS minor. I know
> basic C++(Part 2 of that is in the fall), and I will be taking Java 1
> in the fall also. What is the easiest way for me to make windows
> programs that will do basic things like(Inventory, Menu Management,
> etc...)? I have heard visual basic is where it's at. I want to keep an
> open mind though, so I am wondering if python could be an option. The
> programs have
> no speed requirement. But they must be pretty, and not confuse my
> boss. Plus he wants well documented help for each function. I asked
the
> windows programming group, but I thought I would ask here also.
Thanks.
> 
> Xeys
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Re: Reading files in /var/spool/rwho/whod.*

2005-06-28 Thread Fredrik Normann
Fredrik Normann wrote:
> Hello,
> 
> I'm trying to read the binary files under /var/spool/rwho/ so I'm 
> wondering if anyone has done that before or could give me some clues on 
> how to read those files. I've tried to use the binascii module without 
> any luck.

A friend of mine made this C-program, that does the trick :)

#include 
#include 
#include 
#include 

#include 
#include 

#include 
#include 
#include 

#ifdef SOL
#include 
#else
#include 
#endif

int main (int argc, char **argv)
{

   char *filename, *binary;
   FILE *fp;
   struct whod entry;
   struct outmp who;
   size_t ret;
   size_t cnt = 0;
   char *user = (char*) malloc (8);
   char *timestr = (char*) malloc (512);
   char *hostname = (char*) malloc (512);
   int hostlen, ulen;
   size_t prefix, we_len;

   hostlen = 0;
   ulen = 0;

   struct timeval now;
   struct tm *tptr;
   time_t t;

   binary = *argv;
   ret = gettimeofday (&now, 0);
   if (ret < 0) {
 perror ("Error getting time of day");
 exit (2);
   }

   if (argc < 2) {
 printf ("%s: ERROR, no whod file specified\n", binary);
 exit (1);
   }

   filename = *(argv + 1);

   fp = fopen (filename, "r");
   if (fp == NULL) {
 perror ("Error opening file");
 exit (3);
   }

#ifdef SOL
   ret = fread (&entry, 1, sizeof (entry), fp);
#else
   ret = fread_unlocked (&entry, 1, sizeof (entry), fp);
#endif
   if (ret < 0) {
 perror ("Error reading file");
 exit (4);
   }

   prefix = offsetof (struct whod, wd_we) / sizeof (struct whoent);
   we_len = ret / sizeof (struct whoent) - prefix;

   /* Find lengths of strings */
   for (cnt = 0; cnt < we_len; cnt++) {
 who = entry.wd_we[cnt].we_utmp;
 strncpy (user, who.out_name, 8);
 if (strlen (user) > ulen)
   ulen = strlen (user);
 if ((strlen (entry.wd_hostname) + strlen (who.out_line) + 1) > hostlen)
   hostlen = strlen (entry.wd_hostname) + strlen (who.out_line) + 1;
   }

   for (cnt = 0; cnt < we_len; cnt++) {
 who = entry.wd_we[cnt].we_utmp;
 strncpy (user, who.out_name, 8);
 strncpy (hostname, entry.wd_hostname, 512);
 strcat (hostname, ":");
 strncat (hostname, who.out_line, 8);

 t = now.tv_sec - ntohl (entry.wd_we[cnt].we_idle);

 entry.wd_we[cnt].we_idle = ntohl (entry.wd_we[cnt].we_idle) / 60;

 printf ("%-*s %-*s",
ulen, user,
hostlen, hostname);
 if (entry.wd_we[cnt].we_idle >= 0) {
   tptr = localtime (&t);
   strftime (timestr, 512, "%a %b %d %H:%m", tptr);

   printf (" %s ", timestr);
   printf ("%5d:%02d",
  entry.wd_we[cnt].we_idle / 60,
  entry.wd_we[cnt].we_idle % 60);
 }
 printf ("\n");
   }

   fclose (fp);
}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Simon Brunning
On 6/26/05, John Roth <[EMAIL PROTECTED]> wrote:
> What's being ignored is that type information is useful for other things
> than compile type checking. The major case in point is the way IDEs
> such as IntelliJ and Eclipse use type information to do refactoring, code
> completion and eventually numerous other things. A Java programmer
> using IntelliJ or Eclipse can eliminate the advantage that Python
> used to have, and possibly even pull ahead.

I'm a Java programmer as my day job, most of the time, and I use
Eclipse. I'm fairly proficient with it, but nevertheless I'm more
productive with Python and SciTE than I am with Java and Eclipse.
Eclipse helps a lot, true - I certainly wouldn't want to code Java
without it or something like it - but it's not enought to pull ahead
of Python's inherent superiority.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Simon Brunning
On 6/27/05, Sakesun Roykiattisak <[EMAIL PROTECTED]> wrote:
> 1. Automatic refactoring never solve the readability issue.

Eclipse's refactorings are a great boon, I find. Refectoring is never
*fully* automatic, of course, but the ability to, for example, select
a chunk of code and have it extracted into a separate method with all
needed arguments and the return value worked out for you is very
helpful. All you have to do is give the new method a name. And this
sort of thing can certainly improve readability.

> 2. I've never been lucky enough to have enough resource for those IDE.

Eclipse is indeed a memory hog of the first order.

> 3. Python solve my problem.

Mine too - but I'm not free to choose.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Non-blocking raw_input

2005-06-28 Thread Jorge Louis de Castro
Thanks very much for you reply.

I have indeed tried the msvcrt module but none of the examples given works 
as described on a XP+SP2 box.
I have also looked at the twisted module but some functions there do not 
work on windows too, and I was told by one of the devs that it would stay 
that way for some time.

Basically, I just want to wait for user input and echo it, though while the 
user is not typing anything I'd like to have a background thread printing 
"Come on, you're taking too long" or similar stuff.
The problem is that I can only read (and in batch) the background thread 
printout messages on the console after feeding the raw_input function.

I can't find any examples or useful directions on the documentation and I've 
spent a few days googling this to no avail.
Is it not possible to have the thread print its stuff and then return to 
raw_input() ? Or use any function other than raw_input?

Any code examples, pseudo-code, or documentation directions will be highly 
appreciated!

Thanks in advance

Cheers
jorge

>From: Peter Hansen <[EMAIL PROTECTED]>
>To: python-list@python.org
>Subject: Re: Non-blocking raw_input
>Date: Mon, 27 Jun 2005 18:43:45 -0400
>
>Jorge Louis de Castro wrote:
> > Could anyone tell me whether I can find a non blocking alternative to
> > raw_input that works on windows? Is there not a python way of achieving
> > this? Can I find it somewhere in the documentation?
> > Any help will be highly appreciated
>
>Depending on what your requirements are (since you don't really say),
>the functionality in the standard msvcrt module might help.
>--
>http://mail.python.org/mailman/listinfo/python-list


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


Re: DParser binaries on Win32 with Python 2.4?

2005-06-28 Thread woodsplitter
Christopher Subich wrote:
> Compling the source on cygwin (with -mno-cygwin) succeeds in
> compilation, but then attempting to install results in:
>
> \Python24\python.exe setup.py install
> running install
> running build
> running build_py
> creating build
> creating build\lib.win32-2.4
> copying dparser.py -> build\lib.win32-2.4
> running build_ext
> building 'dparser_swigc' extension
> error: Python was built with version 7.1 of Visual Studio, and
> extensions need to be built with the same version of the compiler, but
> it isn't installed.
>
> I lack VS, and would prefer to stay using win32 Python rather than
> cygwin Python because I got twisted, which I also use, working on win32
> and not cygwin.  Any ideas?

1)  http://mingw.org
2)  python setup.py build --compiler=mingw32
3)  python setup.py install

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


Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread qwweeeit
Hi,
About the error, you already got the answer from the "experts".
Beeing almost a newbie, I tried instead an elaboration of your example,
using lists.
Furthermore I timed the two methods and to my surprise the "list
method" takes longer:

# Head_Tail.py
import random, time
nStart= time.time()

# --
# profiling: 15.3 seconds
heads = 0
tails = 0
flips = 0
while flips < 99:
coin = random.randrange(0, 2)
if coin == 0:
heads = heads + 1
else:
tails = tails + 1
flips = flips + 1
print  "heads",heads
print  "tails",tails
print  "flips",flips
nSecondsTM=time.time()-nStart
print "seconds taken by the traditional method",nSecondsTM
#---

# profiling: 16.8 seconds
nFlips=0
lFlip=[]# list initialization
while nFlips < 99:
lFlip.append(random.randrange(0, 2)) # filling the list
nFlips += 1

print  "heads",lFlip.count(0)
print  "tails",lFlip.count(1)
print  "flips",nFlips
print "seconds taken by the list method",time.time()-nStart-nSecondsTM
# --

Perhaps there are other more clever approaches...
Bye.

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


Re: Boss wants me to program

2005-06-28 Thread Jordan Rastrick
The problem with all posts that say "Use Visual Basic, its easy for
small programs" is that small programs, seemingly inevitably, become
bigger programs (unless they become dead, unmaintained programs). If
your users - you, your boss, coworkers, whoever - find your software
useful, and you start to get even remotely enthusiastic for the
project, then you'll find yourself extending and developing new
features, as well as having to fix problems in your existing code.

And while I'm personally no expert at language design, I've noticed it
seems to be a pretty solid consensus among the actual experts that VB
is one of the most atrociously designed mass market programming
languages in existence. Fine for small programs, sure. But if you ever
want to even think about doing bigger programs, or extending those
useful smaller programs to do more, or even maintain and fix bugs in
your existing code, then VB is not going to be your friend.

The major traditional advantage of VB is that it integrates very
smoothly and easily with Windows, and it has powerful and simple GUI
building tools.

However, Microsoft have essentially displaced VB from lone occupancy of
this niche with .NET. And part of the point of .NET is that its not
forcing you into one particular choice of language. So there's no
advantage to be had from using Visual Basic;  youre better off using a
language that might give you some sort of insight into good programming
practice, not to mention one that'll allow you to develop a serious
application if you ever need to.

Ultimately, if you want a current, supported version of VB, you have to
use VB .NET anyway, and if you're going to use .NET, why use VB at all?

If you have some C++ experience, C# is probably a good bet, as has been
pointed out. You get all the advantages that VB used to provide, with
far fewer of the drawbacks, and it'll stand you in good stead to learn
Java.

Theres even a version of Python for .NET, called IronPython. The major
advantage of this is that you get to program in Python, which I can
tell you from experience is a lot more enjoyable and pain-free than C,
C++, Fortran, or Java (and, I would highly suspect, VB and C#). But
apparently the available GUI builders aren't as good for Python -
having not done a whole lot of GUI building in general, I'll leave this
for more experienced people to judge.

[EMAIL PROTECTED] wrote:
> I'm a manager where I work(one of the cogs in a food service company).
> The boss needed one of us to become the "tech guy", and part of that is
> writing small windows programs for the office. He wants the development
> work done in house, and he knows I am in school for a CS minor. I know
> basic C++(Part 2 of that is in the fall), and I will be taking Java 1
> in the fall also. What is the easiest way for me to make windows
> programs that will do basic things like(Inventory, Menu Management,
> etc...)? I have heard visual basic is where it's at. I want to keep an
> open mind though, so I am wondering if python could be an option. The
> programs have
> no speed requirement.  But they must be pretty, and not confuse my
> boss. Plus he wants well documented help for each function. I asked the
> windows programming group, but I thought I would ask here also. Thanks.
> 
> Xeys

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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Roy Smith
Ivan Van Laningham <[EMAIL PROTECTED]> wrote:
> In which case, you should start with PostScript;-)  I learned it by
> plugging a glass tty into the serial port on one of the very first
> AppleWriters and typing away.

Same here.  I had the RedBook and remember reading it and not quite 
believing it would work.  Then I plugged in a terminal, typed in the first 
example in the book, and it blew my mind when a piece of paper came out 
with a square drawn on it.

> Seriously, PostScript is a lot more fun to learn than Forth, and more
> directly useful.  Since the rewards are so immediate, a kid's attention
> could be gained and kept pretty easily.

There is something to be said for that.  On the other hand, PostScript is 
not easy to debug.  If you blow the stack, you mostly just get programs 
that mysteriously (and perhaps silently) don't work.  It was frustrating 
enough for me; it'll probably just turn a kid off from the whole idea of 
programming.  But then again, little kids seem to not have any problem 
programming VCRs, so maybe their brains just work differently :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Adriaan Renting
In addition, for and while loops are pretty universally found in all
program languages. It is therefore an essential part of material
supposed to teach programming.

Adriaan Renting| Email: [EMAIL PROTECTED]
ASTRON | Phone: +31 521 595 217
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 597 332
The Netherlands| Web: http://www.astron.nl/~renting/
>>> Daniel Dittmar <[EMAIL PROTECTED]> 06/28/05 11:39 AM >>>
[EMAIL PROTECTED] wrote:
> List comprehensions, however, *are* the basic control flow; loops are
> much more verbose and they should be used only when necessary.

List comprehensions are probably a bad idea for entry level programmers:
- for and while loops are much easier to debug as you can insert print 
statements everywhere
- list comprehensions don't allow you to break complex expressions into 
several simpler ones by using local variables, everything has to happen 
in one expression

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

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


Re: OO refactoring trial ??

2005-06-28 Thread Chinook
[[ This message was both posted and mailed: see
   the 'To' and 'Newsgroups' headers for details. ]]

Clarifications:
1) Truth test simplified after a %) by Peter Otten - thanks.  In reality the 
"testit" methods will all be quite different as you might imagine (as will 
the "doit" methods).

2) A final subclass will always return True, so there will always be a valid 
factory (?) result.


Following is a simple trial structure of a refactoring (top-down to OO) 
learning exercise I'm doing.  Whether you call it a Factory pattern, COR 
pattern, or some hinze 57, I don't know what class to use till run time and 
I'm trying to avoid a lengthy "if" sequence, the test sequence is important, 
and to avoid code duplication I'll be using code objects in the "doit" 
methods.

You've already given me many good ideas in previous threads and this is where 
it got you :~)  This works, but would you please tell me: 
1) What you don't like about the approach and/or how I might improve it
2) The implications of using this in a recursive approach (referenced from 
but outside the recursive function).  
3) Any other comments you might offer

Thank you, 
Lee C


=== ootest.py 

class MF(object):
  @staticmethod
  def findit(t):
for it in MF.__subclasses__():
  if it.testit(t):
return it().doit
  
class A(MF):
  @staticmethod
  def testit(tv):
return (tv == 'relates to A')
  
  def doit(self):
print '# did A #'

class B(MF):
  @staticmethod
  def testit(tv):
return (tv == 'relates to B')
  
  def doit(self):
print '# did B #'

mydoit = MF.findit('relates to B') 
mydoit() 

mydoit = MF.findit('relates to A') 
mydoit()

 Test run == 
Python 2.4.1 (#2, Mar 31 2005, 00:05:10) [GCC 3.3 20030304 (Apple Computer, 
Inc. build 1666)] Type "help", "copyright", "credits" or "license" for more 
information.
>>> import ootest
# did B #
# did A #
>>> 

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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Roy Smith
"Adriaan Renting" <[EMAIL PROTECTED]> wrote:
> In addition, for and while loops are pretty universally found in all
> program languages. It is therefore an essential part of material
> supposed to teach programming.

And, even if they're not called "for" or "while" (they might be "do", 
"foreach", "repeat...until", etc), the basic idea of a looping construct 
which defines how many times an enclosed group of statements will be 
executed is absolutely universal.  I can't think of a language from 
assembler to HyperCard that doesn't have a version of the "for" loop.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO refactoring trial ??

2005-06-28 Thread Chinook
Clarifications:
1) Truth test simplified after a %) by Peter Otten - thanks.  In reality the 
"testit" methods will all be quite different as you might imagine (as will 
the "doit" methods).

2) A final subclass will always return True, so there will always be a valid 
result.


Following is a simple trial structure of a refactoring (top-down to OO) 
learning exercise I'm doing.  Whether you call it a Factory pattern, COR 
pattern, or some hinze 57, I don't know what class to use till run time and 
I'm trying to avoid a lengthy "if" sequence, the test sequence is important, 
and to avoid code duplication I'll be using code objects in the "doit" 
methods.

You've already given me many good ideas in previous threads and this is where 
it got you :~)  This works, but would you please tell me: 
1) What you don't like about the approach and/or how it might be improved
2) The implications of using this in a recursive approach (referenced from 
but outside the recursive function) 
3) Any other comments you might offer

Thank you, Lee C


=== ootest.py 

class MF(object):
  @staticmethod
  def findit(t):
for it in MF.__subclasses__():
  if it.testit(t):
return it().doit
  
class A(MF):
  @staticmethod
  def testit(tv):
return (tv == 'relates to A')
  
  def doit(self):
print '# did A #'

class B(MF):
  @staticmethod
  def testit(tv):
return (tv == 'relates to B')
  
  def doit(self):
print '# did B #'

mydoit = MF.findit('relates to B') 
mydoit() 

mydoit = MF.findit('relates to A') 
mydoit()

 Test run == 
Python 2.4.1 (#2, Mar 31 2005, 00:05:10) [GCC 3.3 20030304 (Apple Computer, 
Inc. build 1666)] Type "help", "copyright", "credits" or "license" for more 
information.
>>> import ootest
# did B #
# did A #
>>> 

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


Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread bruno modulix
[EMAIL PROTECTED] wrote:
> ##Coin Flip: randomly flips 100 "coins" and prints results
> ##Original draft: june 27, 2005
> ##Chuck
> 
> import random
> heads = 0
> tails = 0
> flips = 0
> while flips < 99:
> coin = random.randrange(0, 2)
> if coin == 0:
> heads = heads + 1
heads += 1
> else:
> tails = tails + 1
idem
> flips = flips + 1
idem
> if flips >= 99:
Why do you think you need this test ?-)

> print "Heads: " + heads
print "Heads: %d" % heads
> print "Tails: " + tails
idem
> print "Total: " + flips + "flips"
idem
> raw_input("Press the enter key to exit.")

May I suggest this version ?


from random import randrange

def flip_coins(flips):
coins = [0, 0]
for i in xrange(flips):
coins[randrange(0, 2)] += 1
return coins[0], coins[1]

if __name__ == "__main__":
flips = 100
heads, tails = flip_coins(flips)
print "Heads: %d\nTails %d\nTotal: %d flips\n" % (heads, tails, flips)
#raw_input("Press the enter key to exit.")


HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO refactoring trial ??

2005-06-28 Thread Chinook
On Tue, 28 Jun 2005 07:31:43 -0400, Chinook wrote
(in article <[EMAIL PROTECTED]>):

> [[ This message was both posted and mailed: see
>the 'To' and 'Newsgroups' headers for details. ]]
> 

Sorry for the duplication.  I'm trying Hogwasher on OS X and it seems I 
better look around some more.  




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


pyqt, windows xp and systray applications.. possible?

2005-06-28 Thread bastian . salmela
hi,

I've been searching long, and found some information, but still not
enough for me to actually make it happen. so, I ask here.

is it possible, in windows, to make PyQT application hide itself into
systray area?

I read,that you might have to use winEventFilter(), and do some magic
with WM_ messages. well, I don't know enough windows API.. so if anyone
here have done this, could you please help me out and show a little
example how it's done..

thanks in advance.

.b

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


Re: How to compress a folder and all of its sub directories and filesinto a zip file?

2005-06-28 Thread Fredrik Lundh
Brian van den Broek wrote:

> So, it would appear that compression requires a 3rd party module, not
> included in Python (and not present on my Windows box).

where did you get your Windows Python?  afaik, the zlib module has been
included in all major Python binary distributions since 1.5.2 or so...

 



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


Re: pyqt, windows xp and systray applications.. possible?

2005-06-28 Thread Lee Harr
On 2005-06-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> hi,
>
> I've been searching long, and found some information, but still not
> enough for me to actually make it happen. so, I ask here.
>
> is it possible, in windows, to make PyQT application hide itself into
> systray area?
>
> I read,that you might have to use winEventFilter(), and do some magic
> with WM_ messages. well, I don't know enough windows API.. so if anyone
> here have done this, could you please help me out and show a little
> example how it's done..
>


I recommend joining the pyqt mailing list:
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Matt Feinstein
On 27 Jun 2005 20:16:12 -0700, "BORT" <[EMAIL PROTECTED]>
wrote:

>Please forgive me if this is TOO newbie-ish.
>
>I am toying with the idea of teaching my ten year old a little about
>programming.  I started my search with something like "best FREE
>programming language for kids."  After MUCH clicking and high-level
>scanning, I am looking at Python and Forth.  Both have advocates that
>say each is a great approach to learning computers.

FORTH is 'way outside the mainstream of current programming, while
Python is, if anything, excessively buzz-word compliant. If you want
to teach your kid something that will a basis for learning anything
about current practices in programming, teach him Python.
Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python/IDLE - text in different colours

2005-06-28 Thread Bill Davy
To make life easier for my users, I'd like to colour my prompt string (as 
handed to raw_input()) a different colour to that produced by print.  I'm 
using Python 2.4.1 and IDLE 1.1.1 on Windows XP.  Is it possible, and if so, 
how?
tia,
Bill 


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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Edvard Majakari
[EMAIL PROTECTED] writes:

> Ivan Van Laningham wrote:
> [...]
>>
>> Seriously, PostScript is a lot more fun to learn than Forth, and more
>> directly useful.  Since the rewards are so immediate, a kid's attention
>> could be gained and kept pretty easily.
>
> PostScript is easy, but I'm afraid some technical details could get in
> the way of enjoyable exploration, e.g. font types or scaling.
> PostScript is also a single purpose language: it can print static
> graphics and with a slightly more complex setup it can display static
> graphics on the screen, period. No interactivity, no files, no network,
> no general computation or data structures.

PostScript is _not_ limited to static stuff, and it _does_ support
interactivity. See eg. 

http://www.cs.technion.ac.il/~wagner/index_files/aaa.html

Of course, this is just academic fun(?). PostScript is mostly used for
printers, and as for yet, quite few papers support animated graphics :->

And yes, I also encourage to try Python.

> List comprehensions, however, *are* the basic control flow; loops are
> much more verbose and they should be used only when necessary.

Hm. My experience is that people find loops easier to understand - varies
somewhat, though. For some, 'more verbose' is 'more easy to understand'.

-- 
# Edvard Majakari   Software Engineer
# PGP PUBLIC KEY available  Soli Deo Gloria!

$_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n";
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.1 / 2.3: xreadlines not working with codecs.open

2005-06-28 Thread Eric Brunel
On Thu, 23 Jun 2005 14:23:34 +0200, Eric Brunel <[EMAIL PROTECTED]> wrote:

> Hi all,
>
> I just found a problem in the xreadlines method/module when used with 
> codecs.open: the codec specified in the open does not seem to be taken into 
> account by xreadlines which also returns byte-strings instead of unicode 
> strings.
>
> For example, if a file foo.txt contains some text encoded in latin1:
>
 import codecs
 f = codecs.open('foo.txt', 'r', 'utf-8', 'replace')
 [l for l in f.xreadlines()]
> ['\xe9\xe0\xe7\xf9\n']
>
> But:
>
 import codecs
 f = codecs.open('foo.txt', 'r', 'utf-8', 'replace')
 f.readlines()
> [u'\ufffd\ufffd']
>
> The characters in latin1 are correctly "dumped" with readlines, but are still 
> in latin1 encoding in byte-strings with xreadlines.

Replying to myself. One more funny thing:

>>> import codecs, xreadlines
>>> f = codecs.open('foo.txt', 'r', 'utf-8', 'replace')
>>> [l for l in xreadlines.xreadlines(f)]
[u'\ufffd\ufffd']

So f.xreadlines does not work, but xreadlines.xreadlines(f) does. And this 
happens in Python 2.3, but also in Python 2.1, where the implementation for 
f.xreadlines() calls xreadlines.xreadlines(f) (?!?). Something's escaping me 
here... Reading the source didn't help.

At least, it does provide a workaround...
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in 
'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


p

2005-06-28 Thread Mhaxx


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


Re: What is different with Python ?

2005-06-28 Thread TZOTZIOY
On Mon, 13 Jun 2005 20:27:46 -0400, rumours say that Roy Smith
<[EMAIL PROTECTED]> might have written:

>Andrea Griffini <[EMAIL PROTECTED]> wrote:
>> Hehehe... a large python string is a nice idea for modelling
>> memory.

>Actually, a Python string is only good for modelling ROM.  If you want to 
>model read-write memory, you need a Python list.

This is a misquote, since Andrea paraphrased what Peter Maas said.  It
was Peter that suggested string usage to model memory (and obviously
forgot momentarily about string immutability in python).

If you included (even better, read :) the rest of Andrea's paragraph, it
would be obvious that you actually agree with Andrea.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-28 Thread TZOTZIOY
On Thu, 16 Jun 2005 14:29:49 +0100, rumours say that Tom Anderson
<[EMAIL PROTECTED]> might have written:

>At one point, a friend and i founded a university to give our recreational 
>random hackery a bit more credibility (well, we called ourself a 
>university, anyway; it was mostly a joke). We called the programming 
>department 'Executable Poetry'.

That's a good idea for a t-shirt:

"Python: executable poetry"

(kudos to Steve Holden for
[EMAIL PROTECTED] where the term PIPO
(Poetry In, Poetry Out) could be born)

and then, apart from t-shirts, the PSF could sell Python-branded
shampoos named "poetry in lotion" etc.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Open running processes

2005-06-28 Thread DeRRudi
Hi all,

I have a programm. In this program i've made the restriction that only
one instance can run at the time. (done with mutex).
Now i'd like it to open the running (make visible) instance when
someone want's to open it a second time. 
Does anybody know how to do this? I hope you all understand what i
mean. My English isn't to good...

Greetz Rudi

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


CAB files manipulation API (again).

2005-06-28 Thread Isaac Rodriguez
Hi,

I am sorry to post this question again, but when I did it the other day, my 
news reader got stucked downloading new messages, and it has been that way 
for a few days. It still gets stucked if I try to download old messages.

Anyway, does anyone know of a Python module, API, etc. that allows to 
manipulate CAB files?

Thanks,

-- 
Isaac Rodriguez
SWE Autodesk.

There are 10 types of people.
Those who undertand binary, and those who don't 


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


RE: Open running processes

2005-06-28 Thread Tim Golden
[DeRRudi]
| I have a programm. In this program i've made the restriction that only
| one instance can run at the time. (done with mutex).
| Now i'd like it to open the running (make visible) instance when
| someone want's to open it a second time. 
| Does anybody know how to do this? I hope you all understand what i
| mean. My English isn't to good...
| 
| Greetz Rudi

Rudi; you're going to have to give some more information.
It's clear that you're on Windows (because of the Mutex) but you
don't say what form your program takes: is it a console app?
something with a visible window? something which runs in the
systray? Is it done using wxPython? PyQT? Tkinter? Something else?

Assuming it's a program with a window, there are several options
open to you (as I think I mentioned when you asked this question 
last week). Unless someone has a ready-made solution they're ready 
to post, a fair amount would depend on the nature of your program, 
and the amount you know already or are prepared to learn about how
Windows apps work.

TJG


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

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


Re: Plain text email?

2005-06-28 Thread TZOTZIOY
On 27 Jun 2005 18:56:27 -0700, rumours say that "Inkiniteo"
<[EMAIL PROTECTED]> might have written:

>I see. So... what about sending HTML email? If i send HTML tagged text,
>the client will be able to read it as HTML?

I agree with the others that HTML is part of the web, not of the e-mail
system.

I suggest you send your "info" as an attached text file; no client will
mess with it.  The email package is your friend for MIME messages.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CAB files manipulation API (again).

2005-06-28 Thread Robert Kern
Isaac Rodriguez wrote:
> Hi,
> 
> I am sorry to post this question again, but when I did it the other day, my 
> news reader got stucked downloading new messages, and it has been that way 
> for a few days. It still gets stucked if I try to download old messages.

Google is your friend.

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e9a2237d820a4964

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: Better console for Windows?

2005-06-28 Thread TZOTZIOY
On 27 Jun 2005 20:13:41 -0700, rumours say that "Brett Hoerner"
<[EMAIL PROTECTED]> might have written:

>Christ, thanks.  When you install Windows it should pop up first thing
>and ask if you want to be annoyed, Y/N.

When you agree to the EULA of Windows, you implicitly say yes to "do you
want to be annoyed"?

>Well, that solves my sound problem (thanks again), now if only I could
>stretch the window horizontally.  Thats much less of a problem though,
>this is at least usable now.

Hm... right-click the cmd.exe window's title bar (or click on the
top-left icon, or press Alt-Space), go to Properties, Layout tab, Window
Size, Width.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: windows/distutils question

2005-06-28 Thread pyguy2
If the environment variable:

os.environ['APPDATA']

is present on non-English Windows, you may be able to use that to get
what you need.

john

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


Re: Python 2.1 / 2.3: xreadlines not working with codecs.open

2005-06-28 Thread Peter Otten
Eric Brunel wrote:

> I just found a problem in the xreadlines method/module when used with
> codecs.open: the codec specified in the open does not seem to be taken
> into account by xreadlines which also returns byte-strings instead of
> unicode strings.

> So f.xreadlines does not work, but xreadlines.xreadlines(f) does. And this
> happens in Python 2.3, but also in Python 2.1, where the implementation
> for f.xreadlines() calls xreadlines.xreadlines(f) (?!?). Something's
> escaping me here... Reading the source didn't help.

codecs.StreamReaderWriter seems to delegate everything it doesn't implement
itself to the underlying file instance which is ignorant of the encoding.
The culprit:

   def __getattr__(self, name,
getattr=getattr):

""" Inherit all other methods from the underlying stream.
"""
return getattr(self.stream, name)

> At least, it does provide a workaround...

Note that the xreadlines module hasn't made it into Python 2.4. 

Peter

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


benchmarking with threading module

2005-06-28 Thread Matteo Memelli
Hi, I'd like to know if it is possible to use the threading module to
benchmark a web server.
I'd like to write a python script which connect to a web server asking
for a page (like a php page querying a mysql db).
The script should launch many different queries to the web page at the
same time.
The plotting the time VS number of queries I'd like to understand which
would be the critical number of simultaneous connection to the web
server.
Do you think that using the Threading module would be a good idea?
Any other suggestion?
Thank you very much

Matteo Memelli

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


Re: Getting binary data out of a postgre database

2005-06-28 Thread projecktzero
whew!

tempFile.write(str(rec[0])) works!

printing rec[0].__class__ puts out pyPgSQL.PgSQL.PgBytea

Thanks for the help!

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


Re: Better console for Windows?

2005-06-28 Thread Thorsten Kampe
* Brett Hoerner (2005-06-28 03:44 +0100)
> Is there a different shell I can use (other than cmd.com) to run Python
> in [...]

Holy snake, are you running command.com?! Throw away your Windows 3.11
computer and start using cmd.exe.
 
> Another problem with cmd.com is when I run IPython, if I have an error,
> or tab or anything, I get the speaker beep (ala linux) but I can't find
> a way to turn it off.

Use rxvt (Cygwin).


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


re:Open running processes

2005-06-28 Thread DeRRudi
It is a wxWindow app. It is a kind of datamanager. it is possible to
minimize it to the systray.

hmm.. i've thought of an solution using memorymapping. see if it
works.. don't know if it is the 'best' or 'safest' way.. but ok.

Greetz.

ps. I'm always willing to learn! :D

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


Re: Python 2.1 / 2.3: xreadlines not working with codecs.open

2005-06-28 Thread Richard Brodie

"Eric Brunel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
>
> Replying to myself. One more funny thing:
>
> >>> import codecs, xreadlines
> >>> f = codecs.open('foo.txt', 'r', 'utf-8', 'replace')
> >>> [l for l in xreadlines.xreadlines(f)]
> [u'\ufffd\ufffd']

You've specified utf-8 as the encoding instead of iso8859-1,
by the way.


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


[OT] Re: What is different with Python ? (OT I guess)

2005-06-28 Thread Peter Otten
Christos TZOTZIOY Georgiou wrote:

> and then, apart from t-shirts, the PSF could sell Python-branded
> shampoos named "poetry in lotion" etc.

Which will once and for all solve the dandruffs problem prevalent among the 
snake community these days.

Not funny? know then that German has one term for both 'dandruff' and
'scale' (Schuppe).

Still not funny? at least you have learned some German.

Peter

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


Re: [Twisted-Python] Limiting number of concurrent client connections

2005-06-28 Thread Jp Calderone
On Tue, 28 Jun 2005 10:47:04 +0100, Toby Dickenson <[EMAIL PROTECTED]> wrote:
>Im finding that Win32Reactor raises an exception on every iteration of the
>main loop if I exceed the limit of 64 WaitForMultipleObjects.
>
>I would prefer to avoid this fairly obvious denial-of-service problem by
>limiting the number of concurrent client connections. Is there a standard
>solution for this?
>

Count the number of connections you have accepted.  When you get up to 62 or 63 
or so, stop accepting new ones.  If ServerFactory.buildProtocol() returns None, 
Twisted immediately closes the accepted connection.  If you do this (perhaps in 
conjunction with calling stopListening() on the port returned by listenXYZ()), 
you'll never overrun the 64 object limit.

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


Re: Non-blocking raw_input

2005-06-28 Thread Fredrik Lundh
Jorge Louis de Castro wrote:

> I have indeed tried the msvcrt module but none of the examples given works
> as described on a XP+SP2 box.

what examples?  how did you run the examples?

(the keyboard interface functions in msvcrt only work if the program's attached 
to
a Windows console.  if you run the program under an IDE, that may not be true).

 



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


Re: Modules for inclusion in standard library?

2005-06-28 Thread projecktzero
I'll 2nd the vote for Pychecker.

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


Re: OO refactoring trial ??

2005-06-28 Thread Paul McGuire
Lee,

Interesting idea, but I think the technique of "inherit from MF to
automatically add class to the test chain" is a gimmick that wont
scale.

Here are some things to consider:

- I'm not keen on the coupling of forcing your A,B,etc. classes to
inherit from MF.  Especially in a duck-typing language like Python, it
adds no value, the subclasses receive no default behavior from their
superclass, and I'm not keen on using the inheritance hierarchy to
register test classes.  What is the order of classes returned from
__subclasses__()?  Will you always want this order?  Will you always
want all subclasses?  If this is part of a library that others will
use, you may not be able to anticipate what subclasses someone else may
stick on to your MF class.

- The list of items should be dynamic in the calling code, not built
statically by your class structure.  There's no way to anticipate what
various sequences you will want to evaluate.

- Let's call the MF class "MultiEvaluator".  There are several ways to
evaluate among several alternatives:
  . short-circuit, take first match
  . best-fit, evaluate all and take best score (assuming the testit
routines return a double or int, as opposed to a bool)

For short-circuiting, say you have a case that will match A, you want
to avoid any processing related to B,C,etc. as possible at test/do
runtime.  You *might* be able to do extra work at list construction
time.  Consider these two alternative designs:

class MultiEvaluator(object):
def __init__(self, *classes):
self.testClasses = classes[:]

def findit(self, *args):
for C in self.testClasses:
testobj = C()
if testobj.testit(args[0]):
testobj.doit()

MultiEvaluator(A,B).findit("relates to A")

vs.

class MultiEvaluator(object):
def __init__(self, *classes):
self.testClasses = [ C() for C in classes ]

def findit(self, *args):
for testobj in self.testClasses:
if testobj.testit(args[0]):
testobj.doit()

MultiEvaluator(A,B).findit("relates to B")

In the first case, no B class is ever constructed, so if test object
construction is expensive, you might go this route.  In the second, A()
and B() are built ahead of time, so the run-time processing is the
fastest - you might choose this if the construction time can be done up
front.  The second option may cause problems for multi-threadedness or
re-entrancy with a shared MultiEvaluator, though.

This style of constructing the MultiEvaluator also makes more explicit
(which I hear is better than implicit) what classes you are testing
when creating your MultiEvaluator.

- To make your testit() and doit() code more flexible and more
powerful, I'd pass (*args) to each, as in:

class MultiEvaluator(object):
def __init__(self, *classes):
self.testClasses = classes[:]

def findit(self, *args):
for C in self.testClasses:
testobj = C()
if testobj.testit(args):
testobj.doit(args)

- In the interests of flogging OO-ness, you could make MultiEvaluator
into a function object, by changing "findit" to "__call__".  Then your
invocation of it would change from:

getObj = MultiEvaluator(A,B)
getObj.findit("relates to B")

to:

getObj = MultiEvaluator(A,B)
getObj("relates to B")

Although some might claim this is *less* explicit.  The purpose of this
is that you could then pass getObj to functional routines like map
(although you could also pass getObj.findit).



Those are my comments off the top of my head.  Let us know what you
come up with.

-- Paul

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


mod_python and Internal Server Error ...

2005-06-28 Thread Julien Cigar
Hello,

I'm using mod_python 3.1.3 with Apache 2.0.54 on a Debian box with the
publisher handler and the Clearsilver template engine, and from time to
time apache returns an 500 error code (Internal Server Error). 
Apache errog.log file looks like :

[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher: Traceback (most recent call last):
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher:   File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch\nresult = object(req)
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher:   File
"/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 98, in
handler\npath=[path])
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher:   File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 454, in
import_module\nf, p, d = imp.find_module(parts[i], path)
[Tue Jun 28 14:42:12 2005] [error] [client 164.x.x.x] PythonHandler
mod_python.publisher: ImportError: No module named taxal

...

What is strange is that when I reload the page, it's displayed fine, but
from time to time I get 500 error code ... which is quite annoying ...

As I'm using the publisher handler, my index.py looks like :

import sys
import os.path
import neo_cgi
import neo_util
import neo_cs

from mod_python import util, apache
from psycopg import QuotedString

config = apache.import_module('config', autoreload = 0, log = 0)
utils = apache.import_module('utils', autoreload = 0, log = 0)
specimen = apache.import_module('specimen', autoreload = 0, log = 0)
taxon = apache.import_module('taxon', autoreload = 0, log = 0)
fulltextsearch = apache.import_module('fulltextsearch', autoreload = 0,
log = 0)

template_directory  = config.getTemplateDirectory()
template_main   = config.getTemplateMain()
template_menu   = config.getTemplateMenu()

def index(req):
return home(req)

def home(req):
return _render(req, 'home')

def links(req):
return _render(req, 'links')

def contact(req):
return _render(req, 'contact')

def taxal(req):
sort= req.form.getfirst('sort')
order   = req.form.getfirst('order')

tl = taxon.taxon()
tl.getTaxaList(sort, order)
hdf = tl.getHDF()
return _render(req, 'taxalist', hdf)

(...)

So for the above example if I GET http://b.abc.be/birds/taxal it should
run the "def taxal(req)" function ... I don't understand why I get a
"mod_python.publisher: ImportError: No module named taxal" error message
in the apache logfile.

We have several virtualhosts : a.abc.be, b.abc.be, c.abc.be, ...
(fictive addresses). Our www directory is organized like this :
/var/www/vhosts/a.abc.be/ 
/var/www/vhosts/b.abc.be/
/var/www/vhosts/b.abc.be/enbi/
/var/www/vhosts/b.abc.be/enbi/projects/birds/
/var/www/vhosts/b.abc.be/enbi/projects/butterfly/
/var/www/vhosts/b.abc.be/enbi/projects/rubiaceae/
/var/www/vhosts/c.abc.be/blah/

I've tried with "PythonInterpPerDirectory on" in my .htaccess, but
without success ...

In advance thanks for your support


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


whois like functionality on Windows?

2005-06-28 Thread Gerrit Muller
I am migrating a website from a UNIX based machine to an Windows 
machine. In the logfiles I got from the old machine I mostly got domain 
names and sometimes only IP addresses. The Windows machine seems to 
produce only IP addresses.

Somehow I cannot find a windows solution to translate an IP address back 
into a domain-name. Searching with Google shows that more people have 
been wrestling with this problem.

I did find working whois scripts, but unfortunately:
- the verbose whois registrar information often forbids automated access
- the information is rather distributed, so you have to somehow access 
sufficient servers
- you still have to find the domain name in the sea of details returned

I also found socket based solutions, but these solutions crash with the 
message "host not found" :-(

Anyone suggestions?

kind regards, Gerrit

-- 
Gaudi systems architecting:

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


Dictionary to tuple

2005-06-28 Thread Odd-R.
I have a dictionary, and I want to convert it to a tuple,
that is, I want each key - value pair in the dictionary
to be a tuple in a tuple.

If this is the dictionary {1:'one',2:'two',3:'three'},
then I want this to be the resulting tuple:
((1,'one'),(2,'two'),(3,'three')).

I have been trying for quite some time now, but I do not
get the result as I want it. Can this be done, or is it not
possible?


I must also add that I'm new to Python.

Thanks in advance.



-- 
Har du et kjøleskap, har du en TV
så har du alt du trenger for å leve

-Jokke & Valentinerne
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionary to tuple

2005-06-28 Thread bruno modulix
Odd-R. wrote:
> I have a dictionary, and I want to convert it to a tuple,
> that is, I want each key - value pair in the dictionary
> to be a tuple in a tuple.
> 
> If this is the dictionary {1:'one',2:'two',3:'three'},
> then I want this to be the resulting tuple:
> ((1,'one'),(2,'two'),(3,'three')).
> 
> I have been trying for quite some time now, but I do not
> get the result as I want it. Can this be done, or is it not
> possible?

It's of course possible, and even a no-brainer:

dic = {1:'one',2:'two',3:'three'}
tup = tuple(dic.items())

The bad news is that dict are *not* ordered, so you'll have to sort the
result yourself if needed :(

The good news is that sorting a sequence is a no-brainer too !-)

> I must also add that I'm new to Python.
Welcome on board.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionary to tuple

2005-06-28 Thread Jeff Epler
It looks like you want tuple(d.iteritems())

>>> d = {1: 'one', 2: 'two', 3: 'three'}
>>> tuple(d.iteritems())
((1, 'one'), (2, 'two'), (3, 'three'))

You could also use tuple(d.items()).  The result is essentially the
same.  Only if the dictionary is extremely large does the difference
matter. (or if you're using an older version of Python without the
iteritems method)

Jeff


pgpegdipnTdVc.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary to tuple

2005-06-28 Thread Tim Williams (gmail)
On 28 Jun 2005 14:45:19 GMT, Odd-R. <[EMAIL PROTECTED]> wrote:
> I have a dictionary, and I want to convert it to a tuple,
> that is, I want each key - value pair in the dictionary
> to be a tuple in a tuple.
> 
> If this is the dictionary {1:'one',2:'two',3:'three'},
> then I want this to be the resulting tuple:
> ((1,'one'),(2,'two'),(3,'three')).
> 
>>> d =  {1:'one',2:'two',3:'three'}
>>> t = tuple([(k,v) for k,v in d.iteritems()])
>>> t
((1, 'one'), (2, 'two'), (3, 'three'))
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-28 Thread bruno modulix
George Sakkis wrote:
> I'd love to see IPython replace the standard interpreter. 
I dont.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: whois like functionality on Windows?

2005-06-28 Thread Thomas Heller
Gerrit Muller <[EMAIL PROTECTED]> writes:

> I am migrating a website from a UNIX based machine to an Windows
> machine. In the logfiles I got from the old machine I mostly got
> domain names and sometimes only IP addresses. The Windows machine
> seems to produce only IP addresses.
>
> Somehow I cannot find a windows solution to translate an IP address
> back into a domain-name. Searching with Google shows that more people
> have been wrestling with this problem.
>
> I did find working whois scripts, but unfortunately:
> - the verbose whois registrar information often forbids automated access
> - the information is rather distributed, so you have to somehow access
> sufficient servers
> - you still have to find the domain name in the sea of details returned
>
> I also found socket based solutions, but these solutions crash with
> the message "host not found" :-(
>
> Anyone suggestions?

This?

C:\>py23
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyaddr("194.109.137.226")
('fang.python.org', [], ['194.109.137.226'])
>>>

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


Re: Dictionary to tuple

2005-06-28 Thread bruno modulix
Tim Williams (gmail) wrote:
(snip)
d =  {1:'one',2:'two',3:'three'}
t = tuple([(k,v) for k,v in d.iteritems()])

Err... don't you spot any useless code here ?-)

(tip: dict.items() already returns a list of (k,v) tuples...)

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noob question

2005-06-28 Thread Marco
Steven D'Aprano <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...

> Can anyone think of some good, easy to understand examples of where
> Python's name/object model differs from the variable/value model?

a = b = [ 1 ]

a and b are _not_ two variables, each with [ 1 ] as value, but just two
names for the same object (a list). In other variable-based languages,
the above is equivalent to:

a = [ 1 ]
b = [ 1 ]

in Python it is not.

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


Re: How to compress a folder and all of its sub directories and filesinto a zip file?

2005-06-28 Thread Brian van den Broek
Fredrik Lundh said unto the world upon 28/06/2005 08:04:
> Brian van den Broek wrote:
> 
> 
>>So, it would appear that compression requires a 3rd party module, not
>>included in Python (and not present on my Windows box).
> 
> 
> where did you get your Windows Python?  afaik, the zlib module has been
> included in all major Python binary distributions since 1.5.2 or so...
> 
>  

This is embarrassing :-[

I felt quite certain that I'd correctly typed 'import zlib' and 
received an import error. I'm going to have to plead a bad case of 3am 
goggles.

Off to retract a spurious bug I filed ...

Thanks Fredrik.

Brian vdB


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


Re: DParser binaries on Win32 with Python 2.4?

2005-06-28 Thread Christopher Subich
[EMAIL PROTECTED] wrote:
> 1)  http://mingw.org
> 2)  python setup.py build --compiler=mingw32
> 3)  python setup.py install

Thank you very much, it looks like this worked perfectly; it even picked 
up on the cygwin-mingw32 libraries and compiled with the cygwin compiler 
and -mno-cygwin.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionary to tuple

2005-06-28 Thread Erik Max Francis
bruno modulix wrote:

> Err... don't you spot any useless code here ?-)
> 
> (tip: dict.items() already returns a list of (k,v) tuples...)

But it doesn't return a tuple of them.  Which is what the tuple call 
there does.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   But when I reached the finished line / Young black male
   -- Ice Cube
-- 
http://mail.python.org/mailman/listinfo/python-list


building python 2.4.1

2005-06-28 Thread Andreas Heiss
Hi !
I am trying to build python 2.4.1 from source on a Linux system.
Everything seems fine, but tkinter seems not to work.
The file _tkinter.pyd is missing.
How can  tell configure to build all necessary components ?

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


Re: building python 2.4.1

2005-06-28 Thread John Abel
Andreas Heiss wrote:

>Hi !
>I am trying to build python 2.4.1 from source on a Linux system.
>Everything seems fine, but tkinter seems not to work.
>The file _tkinter.pyd is missing.
>How can  tell configure to build all necessary components ?
>
>Thanks
>Andreas
>  
>
It looks to like Tcl/Tk is not installed on your system.  You will need 
to have them installed for Tkinter to build.

HTH

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


Re: Dictionary to tuple

2005-06-28 Thread Robert Kern
Erik Max Francis wrote:
> bruno modulix wrote:
> 
>>Err... don't you spot any useless code here ?-)
>>
>>(tip: dict.items() already returns a list of (k,v) tuples...)
> 
> But it doesn't return a tuple of them.  Which is what the tuple call 
> there does.

The useless code referred to was the list comprehension.

 >>> t = tuple([(k,v) for k,v in d.iteritems()])

versus

 >>> t = tuple(d.items())

or even

 >>> t = tuple(d.iteritems())

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: tkinter radiobutton

2005-06-28 Thread William Gill
 > or use a custom subclass ...

I had considered extending radiobutton to add whatever properties 
needed, but the net/net is the same, that property must be set using 
methods that trigger on the rb command procedure, or an external (to the 
rb) control variable value.

The radiobutton widget knows if it is selected or unselected, or it 
wouldn't be able to display correctly, but based on what I'm seeing, 
that information is inaccessable to the app.  Instead the app must 
evaluate an associated control variable.  That doesn't make sence to me, 
but even trying to look at the code for the radiobutton class didn't help.

I guess I need to set up an observer on the control variable, or a 
command procedure on the radiobutton (effectively to create my own 
control variable).

I know I can 'slice' my original 4 X 4 matrix vertically, by associating 
a different intVar to each 'column', but I can't figure out how to 
'slice' them horizontally w/o breaking their vertical relationships.


Bill

Peter Otten wrote:
> William Gill wrote:
> 
> 
>>I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep
>>references to them in a 2 dimensional list ( rBtns[r][c] ).  It works
>>fine, and I can even make it so only one button per column can be
>>selected, by assigning each column to an intVar.  In many languages a
>>radiobutton has a property that can be directly read to see if it is
>>selected on unselected.  Tkinter radiobuttons don't seem to have any
>>such property.  Is there any way to look (via the script not the screen)
>>to determine if it is selected?, or can this only be achieved via
>>control variables?
> 
> 
> You can either write a little helper function
> 
> def selected(rbn):
> return rbn.getvar(rbn["variable"]) == rbn["value"]
> 
> or use a custom subclass of Tkinter.Radiobutton with a 'selected' attribute:
> 
> class Radiobutton(Tkinter.Radiobutton):
> def __getattr__(self, name):
> if name == "selected":
> return self.getvar(self["variable"]) == self["value"]
> raise AttributeError
> 
> 
> Peter
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: building python 2.4.1

2005-06-28 Thread Andreas Heiss
John Abel wrote:

> Andreas Heiss wrote:
> 
>>Hi !
>>I am trying to build python 2.4.1 from source on a Linux system.
>>Everything seems fine, but tkinter seems not to work.
>>The file _tkinter.pyd is missing.
>>How can  tell configure to build all necessary components ?
>>
>>Thanks
>>Andreas
>>  
>>
> It looks to like Tcl/Tk is not installed on your system.  You will need
> to have them installed for Tkinter to build.

Actually, tk and tcl 8.4 are installed. 
However, there are no tcl.h and tk.h header files. I haven't ssen those
files since Tcl/Tk8.0


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


Re: Dictionary to tuple

2005-06-28 Thread Jeremy Sanders
Erik Max Francis wrote:

> But it doesn't return a tuple of them.  Which is what the tuple call
> there does.

Yes, but I think he meant:

t = tuple(d.items())

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: building python 2.4.1

2005-06-28 Thread John Abel
Andreas Heiss wrote:

>John Abel wrote:
>
>  
>
>>Andreas Heiss wrote:
>>
>>
>>
>>>Hi !
>>>I am trying to build python 2.4.1 from source on a Linux system.
>>>Everything seems fine, but tkinter seems not to work.
>>>The file _tkinter.pyd is missing.
>>>How can  tell configure to build all necessary components ?
>>>
>>>Thanks
>>>Andreas
>>> 
>>>
>>>  
>>>
>>It looks to like Tcl/Tk is not installed on your system.  You will need
>>to have them installed for Tkinter to build.
>>
>>
>
>Actually, tk and tcl 8.4 are installed. 
>However, there are no tcl.h and tk.h header files. I haven't ssen those
>files since Tcl/Tk8.0
>
>
>  
>
Hmmm, where they a pre/package install?  I'm sure I had to build Tcl/Tk 
from source on my Debian install.

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


Re: building python 2.4.1

2005-06-28 Thread Peter Otten
Andreas Heiss wrote:

> However, there are no tcl.h and tk.h header files. I haven't ssen those
> files since Tcl/Tk8.0

You may also need to install the development packages (tk-devel and
tcl-devel on Suse)

Peter

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


Re: Thoughts on Guido's ITC audio interview

2005-06-28 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, Simon 
Brunning <[EMAIL PROTECTED]> writes
>Eclipse's refactorings are a great boon, I find. Refectoring is never
>*fully* automatic, of course, but the ability to, for example, select
>a chunk of code and have it extracted into a separate method with all
>needed arguments and the return value worked out for you is very
>helpful. All you have to do is give the new method a name. And this
>sort of thing can certainly improve readability.

This is not an attach on you Simon, but if people are relying on that 
type of thing for increases in software productivity they are hiring the 
wrong people.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-28 Thread TZOTZIOY
On Tue, 28 Jun 2005 15:46:01 +0300, rumours say that Christos "TZOTZIOY"
Georgiou <[EMAIL PROTECTED]> might have written:

>(kudos to Steve Holden for
>[EMAIL PROTECTED] where the term PIPO
>(Poetry In, Poetry Out) could be born)

oops! kudos to Michael Spencer (I never saw Michael's message on my
newsserver, so I archived Steve's).
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Re: What is different with Python ? (OT I guess)

2005-06-28 Thread Scott David Daniels
Peter Otten wrote:
> Christos TZOTZIOY Georgiou wrote:
> 
>>and then, apart from t-shirts, the PSF could sell Python-branded
>>shampoos named "poetry in lotion" etc.
> 
> Which will once and for all solve the dandruffs problem prevalent among the 
> snake community these days.

And once again the Pythonistas will be known as snake-oil salesmen.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Text() tags and delete()

2005-06-28 Thread Bob Greschke
"Christopher Subich" <[EMAIL PROTECTED]> wrote in 
message news:[EMAIL PROTECTED]
> Bob Greschke wrote:
>> Does Text.delete(0.0, END) delete all of the tags too?  Everything says 
>> it does not delete marks, but nothing about tags.
>
> Note to everyone else: this is a TKinter question.

Oops.  I meant to put that in the subject.

> Tags are attached to text ranges, in the Text widget.  If you delete all 
> of the text in the widget, all of the text ranges will go poof, so 
> therefore all of the tag attachments will likewise go poof.

That's what I thought, and that was what it looked like was happening (but 
just because you can't find something doesn't mean it hasn't been taken to 
the garbage :)

> This will not delete any tags that have been defined for the widget, 
> though, although why you'd want to do that is an open question.

We have all kinds. :)

Thanks, Christopher!


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


ANN: PyDev 0.9.5 released

2005-06-28 Thread Fabio Zadrozny
Hi All,

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

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

Release Highlights:

- File encodings now follow the python convention
- Overview ruler now works
- Editor is synchronized when working in multiple windows with the same file
- Code folding improved
- Syntax highlighting is not confused by escaped quote + triple quote 
anymore
- Insertion of parentheses now replaces selected text
- Some more bugs...

Regards,

-- 
Fabio Zadrozny
--
Software Developer

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

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


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


Re: ANN: PyDev 0.9.5 released

2005-06-28 Thread Philippe C. Martin
Thanks Fabio,

I take this opportunity to ask what I could be doing wrong with pylint: my
PYTHONPATH is good (I think), my code compiles and passes pylint when I run
it by hand. Yet pylint in pydev does not seem to think the modules I
include and usually derive from exist.

Any clue ?

Regards,

Philippe


Fabio Zadrozny wrote:

> Hi All,
> 
> PyDev - Python IDE (Python Development Enviroment for Eclipse) version
> 0.9.5 has just been released.
> 
> Check the homepage (http://pydev.sourceforge.net/) for more details.
> 
> Release Highlights:
> 
> - File encodings now follow the python convention
> - Overview ruler now works
> - Editor is synchronized when working in multiple windows with the same
> file - Code folding improved
> - Syntax highlighting is not confused by escaped quote + triple quote
> anymore
> - Insertion of parentheses now replaces selected text
> - Some more bugs...
> 
> Regards,
> 

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


Re: Boss wants me to program

2005-06-28 Thread phil

> 
> Theres even a version of Python for .NET, called IronPython. The major
> advantage of this is that you get to program in Python, which I can
> tell you from experience is a lot more enjoyable and pain-free than C,
> C++, Fortran, or Java (and, I would highly suspect, VB and C#). But
> apparently the available GUI builders aren't as good for Python -
> having not done a whole lot of GUI building in general, I'll leave this
> for more experienced people to judge.
> 

 From 30 years of application development experience I will tell you
NOT HUMBLY, that Python is easily the most productive, the most 
read-write and the most elegant of any of the above.  Handsdown
better than Java, the runner up in that group.

Now let me explain somthing about "GUI buiders" or IDE's, from some
experience, Visual Studio being the worst.

The IDE takes a picture of what they think you want to do, they then ask
you some questions about the components, and they afford you the
opportunity to modify the properties of the objects.
Then they store all this info in tables and build code at
buildtime.  The tables are rarely documented well and sometimes
have very confusing layouts.  So you usually go back to the
IDE to make changes and if the changes are compilcated and there
are interconnected events to consider, you better know what you are
doing.

I consider it a nightmare of hiding code from the programmer.
The IDE is taking on the burden of a couple layers of abstraction
and the IDE ain't that smart.

You would be wise, if you choose Python to choose Tkinter or WxWindows
and learn the properties of a radio button and how to trigger events.
Writing simple GUIs is not that hard.  Then after you know what is
going on behind the scenes, a BOA Constructor will not be as
mysterious or dangerous.

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


Re: tkinter radiobutton

2005-06-28 Thread Peter Otten
William Gill wrote:

> The radiobutton widget knows if it is selected or unselected, or it
> wouldn't be able to display correctly, but based on what I'm seeing,
> that information is inaccessable to the app.  Instead the app must
> evaluate an associated control variable.  That doesn't make sence to me,
> but even trying to look at the code for the radiobutton class didn't help.

I guessed you wanted to solve a practical problem, but the thoughts
expressed above suggest, err, philosophical qualms. So, for the sake of the
argument and since we both don't know the implementation details, be it in
C or TCL, let's assume that the individual radiobuttons do *not* /know/
whether they are selected or not but instead compare their associated
'variable' with their 'value' every time they are /asked/ to draw
themselves. That would avoid duplicate state and require only log N instead
of N bits. Wouldn't that be an elegant implementation, at least in theory?

So why bother about the layers below when you have all the information to
write code that works?

Peter


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


Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Scott David Daniels
Philippe C. Martin wrote:
> Hi,
> 
> A couple links ...
> 
> 
> http://www.summerland.uku.co.uk/
> http://pylogo.org/
> http://www.python.org/sigs/edu-sig/
> 
> 
> BORT wrote:
> 
> 
>>Please forgive me if this is TOO newbie-ish.
>>
>>I am toying with the idea of teaching my ten year old a little about
>>programming.  I started my search with something like "best FREE
>>programming language for kids."  After MUCH clicking and high-level
>>scanning, I am looking at Python and Forth.  Both have advocates that
>>say each is a great approach to learning computers.
>>
>>My programming classes were a long, long time ago in a land far, far
>>away.  My programming muscles, which were never truly developed, have
>>atrophied even so.  That said, I want to learn this as we go.  The
>>PROCESS of research and using net resources for a self-learning
>>adventure is almost as much of the goal as learning a programming
>>skill.
>>
>>That said, a good learning goal for my kid would be to create a
>>spelling tutor for his little brother.  My (simple) vision would be:
>>
>>1.  an input file of this week's word list
>>2.  use a free text-to-speech engine to call out one word at a time
>>3.  in turn, monitor each key press as a particular word is being
>>typed, beeping on an incorrect keystroke and going to the next word if
>>correct
>>
>>I don't care if it takes a year or two to get to this level, I just
>>want a vehicle that will take us there.
>>
>>I told my son, who wants to learn how to compute probabilities, that we
>>have to start with some boring stuff so we can learn how to do the cool
>>stuff.  Adding and subtracting aren't really fun, but figuring odds on
>>rolling dice IS fun.  Learning to program will be kind of like that.
>>He accepted that explantion.
>>
>>So, that said...   In ~simplest~ terms for the stated goal -- Forth or
>>Python?
>>...the goal is NOT the spelling tutor... it is learning how to use a
>>tool to solve a problem.  I am asking which tool is more suited to an
>>otherwise arbitrary direction of "spelling tutor program."
>>
>>[NOTE: This is not a troll.  I'm geting ready to bark up a tree and I
>>prefer to avoid the wrong one. I am cross-posting.]
>>
>>Thanks
> 
> 
Over on comp.python.education, David Handy recently announced his book
with a fairly long message (excerpted here):
 ...
 Written by a homeschooling Dad and professional software developer,
 "Computer Programming is Fun!" fills a need for a book that teaches
 computer programming to teenage youth.
 ...
 208 pages, $29.95 plus taxes and shipping if applicable
 Order from the author's web site:
 http://www.handysoftware.com/cpif/
 ...
 "Why teach computer programming to teenagers? For the same reason
 you would teach them piano or any other musical instrument. Consider
 the computer an instrument for the mind."

I've not seen the book myself, but it seems like it is targeted
to very nearly your situation, so I'd investigate it.

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


Re: COM problem .py versus .exe

2005-06-28 Thread Greg Miller
Hello again, I put the executable on the "virgin" PC today.  I am using
the wmi(b) that you gave me.  The error that I am receiving now is:

File "autoStart.pyc", line 241, in test
File "wmib.pyc", line 157, in ?
File "win32com\client\__init__.pyc", line 73, in GetObject
File "win32com\client\__init__.pyc", line 88, in Moniker
com_error: (-2147221020, 'Invalid syntax', None, None)

any thoughts on this error?  Thanks again for the help.

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


Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Scott David Daniels
db wrote:
> On Tue, 28 Jun 2005 00:23:30 -0700, ChuckDubya wrote:
>>... if flips >= 99:
>>print "Heads: " + heads
>>print "Tails: " + tails
>>print "Total: " + flips + "flips"
>>raw_input("Press the enter key to exit.")...
> 
> Your programm gives an error. You are trying to concatenate strings with  
> integers.
> 
Might I suggest you were looking for this:
 ...
 print "Heads: ", heads
 print "Tails: ", tails
 print "Total: ", flips, "flips"
 ...

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


Re: Modules for inclusion in standard library?

2005-06-28 Thread George Sakkis
> "bruno modulix" <[EMAIL PROTECTED]> wrote:

> George Sakkis wrote:
> > I'd love to see IPython replace the standard interpreter.
> I dont.

Care to say why ?

George

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


Re: Better console for Windows?

2005-06-28 Thread Brian
The alt-enter tip is handy, although I must say on multiple monitors
it's not so helpful.  It full screens all of them (cloned across
screens), at least on my nVidia card.  I'm sure you're all sympathizing
with my multiple monitor problem ;-)

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


Re: Boss wants me to program

2005-06-28 Thread Max M
phil wrote:

> You would be wise, if you choose Python to choose Tkinter or WxWindows
> and learn the properties of a radio button and how to trigger events.
> Writing simple GUIs is not that hard.  Then after you know what is
> going on behind the scenes, a BOA Constructor will not be as
> mysterious or dangerous.

I agree. The language is more important than the gui. It is not very 
hard to make good applikations in eg. Tkinter, and you will understand 
evey part of it.


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-28 Thread Thomas Bartkus
"phil" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> >
> > Theres even a version of Python for .NET, called IronPython. The major
> > advantage of this is that you get to program in Python, which I can
> > tell you from experience is a lot more enjoyable and pain-free than C,
> > C++, Fortran, or Java (and, I would highly suspect, VB and C#). But
> > apparently the available GUI builders aren't as good for Python -
> > having not done a whole lot of GUI building in general, I'll leave this
> > for more experienced people to judge.
> >
>
>  From 30 years of application development experience I will tell you
> NOT HUMBLY, that Python is easily the most productive, the most
> read-write and the most elegant of any of the above.  Handsdown
> better than Java, the runner up in that group.

Agreed!

> Now let me explain somthing about "GUI buiders" or IDE's, from some
> experience, Visual Studio being the worst.
>
> The IDE takes a picture of what they think you want to do, they then ask
> you some questions about the components, and they afford you the
> opportunity to modify the properties of the objects.
> Then they store all this info in tables and build code at
> buildtime.  The tables are rarely documented well and sometimes
> have very confusing layouts.  So you usually go back to the
> IDE to make changes and if the changes are compilcated and there
> are interconnected events to consider, you better know what you are
> doing.
>
> I consider it a nightmare of hiding code from the programmer.
> The IDE is taking on the burden of a couple layers of abstraction
> and the IDE ain't that smart.

"A nightmare of hiding code from the programmer"  Hmmhh!

Well, it certainly does hide a lot of code!
More precisely, it removes the need for a lot of hand coding work that
should be automated.

Do I want to spend 95% of my coding/debugging efforts on a consistent user
interface or would I rather spend the bulk of my efforts on the business
problem that needs solving and just *have* an attractive and consistent user
interface.

> You would be wise, if you choose Python to choose Tkinter or WxWindows
> and learn the properties of a radio button and how to trigger events.
> Writing simple GUIs is not that hard.  Then after you know what is
> going on behind the scenes, a BOA Constructor will not be as
> mysterious or dangerous.

Writing simple user interfaces may not be hard but "simple" user interfaces
rarely serve well.  More to the point is that programs are much better when
they have idiot proof (and idiot easy!) user interfaces where the programmer
hasn't the need to cope with the 1001 ways a user can louse up input or need
to write an encyclopeadia of documentation on how one interacts with his
particular program.

You are quite correct to point out how much better it is to know what is
going on behind the scenes.  But heck, once you know how to extract square
roots - you need to let the computer do it!

GUI interfaces should be the same deal!
Thomas Bartkus


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


Re: OO refactoring trial ??

2005-06-28 Thread Chinook
On Tue, 28 Jun 2005 10:22:59 -0400, Paul McGuire wrote
(in article <[EMAIL PROTECTED]>):

> Lee,
> 
> Interesting idea, but I think the technique of "inherit from MF to
> automatically add class to the test chain" is a gimmick that wont
> scale.
> 
> Here are some things to consider:
> 
> - I'm not keen on the coupling of forcing your A,B,etc. classes to
> inherit from MF.  Especially in a duck-typing language like Python, it
> adds no value, the subclasses receive no default behavior from their
> superclass, and I'm not keen on using the inheritance hierarchy to
> register test classes.  What is the order of classes returned from
> __subclasses__()?  Will you always want this order?  Will you always
> want all subclasses?  If this is part of a library that others will
> use, you may not be able to anticipate what subclasses someone else may
> stick on to your MF class.

Even though this is an exercise, it is a learning exercise and your points 
are taken as pertinent considerations in "real-world" adaptation.  

So basically I'm coming from a if:elif:...else: test sequence where the order 
of the tests is critical (could be multiple hits and the first should be 
taken).  My first trial was just to move the "if" sequence to a factory 
method.  My second trial was to initially create an ordered list of classes 
to be tested as in:

>>> class A(object):
...   def foo(self):
... print "I'm A.foo"
... 
>>> class B(object):
...   def foo(self):
... print "I'm B.foo"
... 
>>> co = [A(), B()]
>>> co[1].foo()
I'm B.foo
>>> 

My third trial is what you are responding to.  So in the "real-world" I could 
only suggest how someone else might add a test, but just as in the top-down 
"if" sequence I could impose no discipline.  Even adding a weighting/priority 
to test cases (and going through all) is a halfway measure (though possibly a 
more explicit one).  I think that the consideration of how a test case might 
be added in the future is very important - having dug my way through many 
other programs.  

BTW: Is duck-typing a variation on duct-taping?  

> 
> - The list of items should be dynamic in the calling code, not built
> statically by your class structure.  There's no way to anticipate what
> various sequences you will want to evaluate.

I was also playing with another exercise involving dynamic test cases where I 
thought the ordered list (second trial) would be a potential approach?

> 
> - Let's call the MF class "MultiEvaluator".  There are several ways to
> evaluate among several alternatives:
>   . short-circuit, take first match

what I was shooting for in this exercise

>   . best-fit, evaluate all and take best score (assuming the testit
> routines return a double or int, as opposed to a bool)

like my weighted/priority thought?

> 
> For short-circuiting, say you have a case that will match A, you want
> to avoid any processing related to B,C,etc. as possible at test/do
> runtime.  You *might* be able to do extra work at list construction
> time.  Consider these two alternative designs:
> 
> class MultiEvaluator(object):
> def __init__(self, *classes):
> self.testClasses = classes[:]
> 
> def findit(self, *args):
> for C in self.testClasses:
> testobj = C()
> if testobj.testit(args[0]):
> testobj.doit()
> 
> MultiEvaluator(A,B).findit("relates to A")  

my only drawback on such would be ME(A,B,...Z).findit(test_data) 
Explicit but cumbersome maybe, though no where near as cumbersome as a 
lengthy "if" sequence.

> 
> vs.
> 
> class MultiEvaluator(object):
> def __init__(self, *classes):
> self.testClasses = [ C() for C in classes ]
> 
> def findit(self, *args):
> for testobj in self.testClasses:
> if testobj.testit(args[0]):
> testobj.doit()
> 
> MultiEvaluator(A,B).findit("relates to B")
> 
> In the first case, no B class is ever constructed, so if test object
> construction is expensive, you might go this route.  In the second, A()
> and B() are built ahead of time, so the run-time processing is the
> fastest - you might choose this if the construction time can be done up
> front.  The second option may cause problems for multi-threadedness or
> re-entrancy with a shared MultiEvaluator, though.
> 
> This style of constructing the MultiEvaluator also makes more explicit
> (which I hear is better than implicit) what classes you are testing
> when creating your MultiEvaluator.
> 
> - To make your testit() and doit() code more flexible and more
> powerful, I'd pass (*args) to each, as in:

The testit() methods do in the full-fledged exercise. The doit() methods 
return code objects (but I'm rethinking that).

> 
> class MultiEvaluator(object):
> def __init__(self, *classes):
> self.testClasses = classes[:]
> 
> def findit(self, *args):
> for C in self.testClasses:
> testobj = C()
> if testobj.testit(args):
> test

Re: Better console for Windows?

2005-06-28 Thread Tom Anderson
On Tue, 27 Jun 2005, Brett Hoerner wrote:

> Rune Strand wrote:
>
> Christ, thanks.  When you install Windows it should pop up first thing 
> and ask if you want to be annoyed, Y/N.

What, and not install if you say no?

Perhaps your best way to get a proper shell on windows is just to install 
a proper shell; Cygwin () has bash, but it also 
installs a bunch of other unixish stuff you might or might not want. This:

http://www.steve.org.uk/Software/bash/

looks like a standalone bash, plus ls, mv, cp rm, chmod and less. Here:

http://gnuwin32.sourceforge.net/packages.html

you can get various further bits of free software compiled for windows, 
including:

http://gnuwin32.sourceforge.net/packages/coreutils.htm

the GNU coreutils, which is the 1% of commands you use 99% of the time. 
bash + coreutils should do nicely. For a mostly complete GNU development 
toolchain, check out MinGW:

http://www.mingw.org/

Which, IMHO, is a better solution than Cygwin for general programming.

tom

-- 
i'm prepared to do anything as long as someone else works out how to do it and 
gives me simple instructions... -- Sean
-- 
http://mail.python.org/mailman/listinfo/python-list


Embedding python in C

2005-06-28 Thread Philippe C. Martin
Hi,

Is there a program out there that would generate the C code to instantiate
objects and call them:

ex: miracle.exe -i mymodule.py -o module_internface.c ?

I seem to recall a _yes_ to that but I got a memory overflow :-)

Thanks,

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


regulars expressions ?

2005-06-28 Thread scott
hi people !


i got some trouble with regular expressions
i need to split a string like this on the ',' character :

mystring = ""\test1, test2\", test, 42"

i wanna get something (a list) like this (3 elements) :
"test1, test2"
test
42

but the only thing i get is a list like this (4 elements) :
"test1"
"test2"
test
42

each element is separated by ',' but 1st element which is delimited by 
'"' may contain ',' character inside.

so the regular expression i need is something like :
split each element using ',' delimiter but if ',' delimiter is included 
between '"' please do not split


1st question is : does someone has understood the question ?
2nd question is : does someone has an answer ?

thanks people

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


Re: regulars expressions ?

2005-06-28 Thread Jaime Wyant
Maybe, you need the csv module:

import csv
mystring = "\"test1, test2\", test, 42"

# The one argument to csv.reader is an iterable object
# You could use a file here...
csv_reader = csv.reader([mystring])

for line in csv_reader:
print line

['test1, test2', ' test', ' 42']

hth,
jw

On 6/28/05, scott <[EMAIL PROTECTED]> wrote:
> hi people !
> 
> 
> i got some trouble with regular expressions
> i need to split a string like this on the ',' character :
> 
> mystring = ""\test1, test2\", test, 42"
> 
> i wanna get something (a list) like this (3 elements) :
> "test1, test2"
> test
> 42
> 
> but the only thing i get is a list like this (4 elements) :
> "test1"
> "test2"
> test
> 42
> 
> each element is separated by ',' but 1st element which is delimited by
> '"' may contain ',' character inside.
> 
> so the regular expression i need is something like :
> split each element using ',' delimiter but if ',' delimiter is included
> between '"' please do not split
> 
> 
> 1st question is : does someone has understood the question ?
> 2nd question is : does someone has an answer ?
> 
> thanks people
> 
> scott
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regulars expressions ?

2005-06-28 Thread Jaime Wyant
Doh - please note that csv.reader takes more than one argument - the
FIRST one is an iterable object.

jw

On 6/28/05, Jaime Wyant <[EMAIL PROTECTED]> wrote:
> Maybe, you need the csv module:
> 
> import csv
> mystring = "\"test1, test2\", test, 42"
> 
> # The one argument to csv.reader is an iterable object
> # You could use a file here...
> csv_reader = csv.reader([mystring])
> 
> for line in csv_reader:
> print line
> 
> ['test1, test2', ' test', ' 42']
> 
> hth,
> jw
> 
> On 6/28/05, scott <[EMAIL PROTECTED]> wrote:
> > hi people !
> >
> > 
> > i got some trouble with regular expressions
> > i need to split a string like this on the ',' character :
> >
> > mystring = ""\test1, test2\", test, 42"
> >
> > i wanna get something (a list) like this (3 elements) :
> > "test1, test2"
> > test
> > 42
> >
> > but the only thing i get is a list like this (4 elements) :
> > "test1"
> > "test2"
> > test
> > 42
> >
> > each element is separated by ',' but 1st element which is delimited by
> > '"' may contain ',' character inside.
> >
> > so the regular expression i need is something like :
> > split each element using ',' delimiter but if ',' delimiter is included
> > between '"' please do not split
> > 
> >
> > 1st question is : does someone has understood the question ?
> > 2nd question is : does someone has an answer ?
> >
> > thanks people
> >
> > scott
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-28 Thread phil
> 
> You are quite correct to point out how much better it is to know what is
> going on behind the scenes.  But heck, once you know how to extract square
> roots - you need to let the computer do it!
> 
> GUI interfaces should be the same deal!
> Thomas Bartkus
> 
I think I pretty much agree. I essentially code my own gui builder

but in text files.

I just think it is really important to emphasise the operative
"but once you know how" in your comments.

Then some would counter with "oh, so we should code everthing
in assembler?"  Ouch. No, I will admit there is judgement
required.  Everything should be done the easiest way, with the
qualification that you need to understand how using someone
else's shortcut leaves you vulnerable.

This guy is trying to get started and looking for our advice and
I saw most of the advice leaning towrd VB (aarrgh!) and I thought
I should give him other food for thought.

I'm going to take this opportunity for a short rant.

I believe our society ( I'm an old fart) is drifting toward
a VERY small percentage of people knowing, caring or even
being curious about "how stuff works".  I teach high school
geometry and am APPALLED at the apathy.  I am concerned about
the future of this nation, economically, but spirtually as well.
So, this influences my advice.  Know how your stuff works if
it is reasonable.
Tom Wolfe talked in a book about two kinds of kids.
Those that play video games and those that make video games,
and the numbers of the latter is shrinking.






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


  1   2   3   >