Re: python response slow when running external DLL

2015-11-27 Thread jfong
Peter Otten at 2015/11/27 UTC+8 8:20:54PM wrote:

> Quick-fix example:
> def download():
> var.set("Starting download...")
> root.update_idletasks()
> time.sleep(3)
> var.set("... done")

Thanks, Peter, The update_idletasks() works. In my trivial program it's easy to 
apply for there are only two places call the DLL function.

> A cleaner solution can indeed involve threads; you might adapt the approach 
> from  (Python 2 code).

Using thread is obviously more logical. I think my mistake was the "while busy: 
 pass" loop which makes no sense because it blocks the main thread, just as the 
time.sleep() does. That's why in your link (and Laura's too) the widget.after() 
scheduling was used for this purpose.

From what I had learned here, the other way I can do is making the codes 
modified as follows. It will get ride of the "result" and "busy" global 
variables, but it also makes the codes looks a little ugly. I think I will take 
the update_idletasks() way in this porting for it seems more simpler, and can 
be used on thread or non-thread calling. Thank you again.
.
.
#do the rest
var_status.set('Download...')
_thread.start_new_thread(td_download, ())  #must use threading

def td_download():
result = mydll.SayHello()
if result:
var_status.set("Download Fail at %s" % hex(result))
showerror('Romter', 'Download Fail')
else:
var_status.set('Download OK')
showinfo('Romter', 'Download OK')

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


Re: Faviourite improvements in Python 3.5 (was: Python 3 virtualenvs)

2015-11-27 Thread INADA Naoki
OrderedDict is now faster and efficient.

On Sat, Nov 28, 2015 at 10:42 AM, Ben Finney 
wrote:

> Laura Creighton  writes:
>
> > […] python3.5 which I infinitely prefer over 3.4.
>
> That's strong language :-)
>
> Laura – and anyone else – what in your opinion are the best improvements
> brought by Python 3.5 (over Python 3.4)?
>
> --
>  \ “DRM doesn't inconvenience [lawbreakers] — indeed, over time it |
>   `\ trains law-abiding users to become [lawbreakers] out of sheer |
> _o__)frustration.” —Charles Stross, 2010-05-09 |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
INADA Naoki  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Find relative url in mixed text/html

2015-11-27 Thread Grobu

On 28/11/15 03:35, Rob Hills wrote:

Hi,

For my sins I am migrating a volunteer association forum from one
platform (WebWiz) to another (phpBB).  I am (I hope) 95% of the way
through the process.

Posts to our original forum comprise a soup of plain text, HTML and
BBCodes.  A post */may/* include links done as either standard HTML
links ( http://blah.blah.com.au or even just
www.blah.blah.com.au ).

In my conversion process, I am trying to identify cross-links (links
from one post on the forum to another) so I can convert them to links
that will work in the new forum.

My current code uses a Regular Expression (yes, I read the recent posts
on this forum about regex and HTML!) to pull out "absolute" links (
starting with http:// ) and then I use Python to identify and convert
the specific links I am interested in.  However, the forum also contains
"cross-links" done using relative links and I'm unsure how best to
proceed with that one.  Googling so far has not been helpful, but that
might be me using the wrong search terms.

Some examples of what I am talking about are:

 Post fragment containing an "Absolute" cross-link:

 ive made a new thread:
 http://www.aeva.asn.au/forums/forum_posts.asp?TID=316&PID=1958#1958
 

 converts to:

 
 ive made a new thread:
 /viewtopic.php?t=316&p=1958#1958

 Post fragment containing a "Relative" cross-link:

 Battery Management SystemVeroboard prototype

 Needs converting to:

 Battery Management SystemVeroboard prototype

So, my question is:  What is the best way to extract a list of "relative
links" from mixed text/html that I can then walk through to identify the
specific ones I want to convert?

Note, in the beginning of this project, I looked at using "Beautiful
Soup" but my reading and limited testing lead me to believe that it is
designed for well-formed HTML/XML and therefore was unsuitable for the
text/html soup I have.  If that belief is incorrect, I'd be grateful for
general tips about using Beautiful Soup in this scenario...

TIA,



Hi Rob

Is it safe to assume that all the relative (cross) links take one of the 
following forms? :


http://www.aeva.asn.au/forums/forum_posts.asp
www.aeva.asn.au/forums/forum_posts.asp
/forums/forum_posts.asp
/forum_posts.asp (are you really sure about this one?)

If so, and if your goal boils down to converting all instances of old 
style URLs to new style ones regardless of the context where they 
appear, why would a regex fail to meet your needs?



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


Re: Find relative url in mixed text/html

2015-11-27 Thread Paul Rubin
Rob Hills  writes:
> Note, in the beginning of this project, I looked at using "Beautiful
> Soup" but my reading and limited testing lead me to believe that it is
> designed for well-formed HTML/XML and therefore was unsuitable for the
> text/html soup I have.  If that belief is incorrect, I'd be grateful for
> general tips about using Beautiful Soup in this scenario...

Beautiful Soup can deal with badly formed HTML pretty well, or at least
it could in earlier versions.  It gives you several different parsing
options to choose from now.  I think the default is lxml which is fast
but maybe more strict.  Check what the others are and see if a loose
slow one is still there.  It really is pretty slow so plan on a big
computation task if you're converting a large forum.

phpBB gets a bad rap that's maybe well-deserved but I don't know what to
suggest instead.
-- 
https://mail.python.org/mailman/listinfo/python-list


Find relative url in mixed text/html

2015-11-27 Thread Rob Hills
Hi,

For my sins I am migrating a volunteer association forum from one
platform (WebWiz) to another (phpBB).  I am (I hope) 95% of the way
through the process.

Posts to our original forum comprise a soup of plain text, HTML and
BBCodes.  A post */may/* include links done as either standard HTML
links ( http://blah.blah.com.au or even just
www.blah.blah.com.au ).

In my conversion process, I am trying to identify cross-links (links
from one post on the forum to another) so I can convert them to links
that will work in the new forum.

My current code uses a Regular Expression (yes, I read the recent posts
on this forum about regex and HTML!) to pull out "absolute" links (
starting with http:// ) and then I use Python to identify and convert
the specific links I am interested in.  However, the forum also contains
"cross-links" done using relative links and I'm unsure how best to
proceed with that one.  Googling so far has not been helpful, but that
might be me using the wrong search terms. 

Some examples of what I am talking about are:

Post fragment containing an "Absolute" cross-link:

ive made a new thread:
http://www.aeva.asn.au/forums/forum_posts.asp?TID=316&PID=1958#1958


converts to:


ive made a new thread:
/viewtopic.php?t=316&p=1958#1958

Post fragment containing a "Relative" cross-link:

Battery Management SystemVeroboard prototype

Needs converting to:

Battery Management SystemVeroboard prototype

So, my question is:  What is the best way to extract a list of "relative
links" from mixed text/html that I can then walk through to identify the
specific ones I want to convert?

Note, in the beginning of this project, I looked at using "Beautiful
Soup" but my reading and limited testing lead me to believe that it is
designed for well-formed HTML/XML and therefore was unsuitable for the
text/html soup I have.  If that belief is incorrect, I'd be grateful for
general tips about using Beautiful Soup in this scenario...

TIA,

-- 
Rob Hills
Waikiki, Western Australia

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


Re: Faviourite improvements in Python 3.5 (was: Python 3 virtualenvs)

2015-11-27 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 12:42:30 +1100, Ben Finney writes:
>Laura Creighton  writes:
>
>> […] python3.5 which I infinitely prefer over 3.4. 
>
>That's strong language :-)
>
>Laura – and anyone else – what in your opinion are the best improvements
>brought by Python 3.5 (over Python 3.4)?

The interactive console started working again.
https://bugs.python.org/issue23441

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Faviourite improvements in Python 3.5 (was: Python 3 virtualenvs)

2015-11-27 Thread Ben Finney
Laura Creighton  writes:

> […] python3.5 which I infinitely prefer over 3.4. 

That's strong language :-)

Laura – and anyone else – what in your opinion are the best improvements
brought by Python 3.5 (over Python 3.4)?

-- 
 \ “DRM doesn't inconvenience [lawbreakers] — indeed, over time it |
  `\ trains law-abiding users to become [lawbreakers] out of sheer |
_o__)frustration.” —Charles Stross, 2010-05-09 |
Ben Finney

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


Re: Python 3 virtualenvs

2015-11-27 Thread D.M. Procida
Laura Creighton  wrote:

> In a message of Sat, 28 Nov 2015 00:37:21 +, D.M. Procida writes:
> >I have a new installation of Debian Jessie, with Python 2.7 and 3.4
> >installed.
> >
> >I want to use Python 3.4 by default for most things, so I want
> >virtualenv to create Python 3.4 virtualenvs unless I ask it to
> >otherwise.
> >
> >It turns out that this seems to be inordinately complex.
> >
> >The best solution I have come up with is to alias virtualenv to
> >'virtualenv -p python3.5', which seems really ugly and clunky.
> 
> This will get you python3.5 which I infinitely prefer over 3.4. 
> But you said you wanted to use 3.4 ...

Typo!

> >Then I discover things like
> > >v-vs-virtualenv-and-python-3> and realise it's not just me, it really is
> >a nasty mess and nobody seems to understand what's going on.

> What I found out.
> https://bugs.python.org/issue25151
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732703
> https://bugs.python.org/issue25152
> https://bugs.python.org/issue25154

Good lord.

> I've long ago aliased virtualenv to v, so things aren't as clunky
> for me.

I'll stick with virtualenv as an alias to virtualenv -p python3.5.
 
Thanks,

Daniele
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 virtualenvs

2015-11-27 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 00:37:21 +, D.M. Procida writes:
>I have a new installation of Debian Jessie, with Python 2.7 and 3.4
>installed.
>
>I want to use Python 3.4 by default for most things, so I want
>virtualenv to create Python 3.4 virtualenvs unless I ask it to
>otherwise.
>
>It turns out that this seems to be inordinately complex.
>
>The best solution I have come up with is to alias virtualenv to
>'virtualenv -p python3.5', which seems really ugly and clunky.

This will get you python3.5 which I infinitely prefer over 3.4. 
But you said you wanted to use 3.4 ...

>Then I discover things like
>
>and realise it's not just me, it really is a nasty mess and nobody seems
>to understand what's going on.
>
>Daniele

What I found out.
https://bugs.python.org/issue25151
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732703
https://bugs.python.org/issue25152
https://bugs.python.org/issue25154

pyenv is going away.  use python -m venv instead, if you want a 
venv.  You will never (unless somebody does a backport, which seems
very unlikley) be able to get a venv with 2.7.

I've long ago aliased virtualenv to v, so things aren't as clunky
for me.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3 virtualenvs

2015-11-27 Thread D.M. Procida
I have a new installation of Debian Jessie, with Python 2.7 and 3.4
installed.

I want to use Python 3.4 by default for most things, so I want
virtualenv to create Python 3.4 virtualenvs unless I ask it to
otherwise.

It turns out that this seems to be inordinately complex.

The best solution I have come up with is to alias virtualenv to
'virtualenv -p python3.5', which seems really ugly and clunky.

Then I discover things like

and realise it's not just me, it really is a nasty mess and nobody seems
to understand what's going on.

Daniele
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: fexit: file transfer of ANY size

2015-11-27 Thread Ulli Horlacher
paul.hermeneu...@gmail.com wrote:

> > I am now looking for beta testers. If you are interested, send me a mail.
> 
> Can you tell us a git or svn repository from which the kit is available?

Available via email request.


> Or, is this a proprietary product?

No.

-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: fexit: file transfer of ANY size

2015-11-27 Thread paul.hermeneutic
> And what is F*EX?
> ==> Frams' Fast File EXchange, a service for transfering files of ANY size
> from any user A to any user B in the internet.
> For details see: http://fex.rus.uni-stuttgart.de/
>
> I am now looking for beta testers. If you are interested, send me a mail.

Can you tell us a git or svn repository from which the kit is available?
Or, is this a proprietary product?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a function parameter =[] for?

2015-11-27 Thread Chris Angelico
On Sat, Nov 28, 2015 at 12:24 AM, Laura Creighton  wrote:
> I think it's just another instance of Just-In-Time Manufacturing
> https://en.wikipedia.org/wiki/Just-in-time_manufacturing
>
> "As soon as you need a object, we'll have one ready". :)

Just-In-Time Quantum Manufacturing: "As soon as you need an electron,
we'll have the same one ready!"

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a function parameter =[] for?

2015-11-27 Thread Laura Creighton
In a message of Fri, 27 Nov 2015 23:57:29 +1100, "Steven D'Aprano" writes:
>On Fri, 27 Nov 2015 01:56 pm, MRAB wrote:
>
>> On 2015-11-27 02:44, Steven D'Aprano wrote:
>
>>> The PyPy implementation has to take special actions to preserve the ID
>>> across object recreations. That is what I mean by "faked".
>>>
>> You could argue that it _does_ continue to exist, it just changes its
>> form...
>
>*Something* continues to exist, but it is no longer an object.
>
>I like Chris' analogy of it being like quantum mechanics -- the *object*
>isn't guaranteed to exist except when you try to access it, until then you
>don't know what form it will take at any instance.

I think it's just another instance of Just-In-Time Manufacturing
https://en.wikipedia.org/wiki/Just-in-time_manufacturing

"As soon as you need a object, we'll have one ready". :)

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a function parameter =[] for?

2015-11-27 Thread Steven D'Aprano
On Fri, 27 Nov 2015 01:56 pm, MRAB wrote:

> On 2015-11-27 02:44, Steven D'Aprano wrote:

>> The PyPy implementation has to take special actions to preserve the ID
>> across object recreations. That is what I mean by "faked".
>>
> You could argue that it _does_ continue to exist, it just changes its
> form...

*Something* continues to exist, but it is no longer an object.

I like Chris' analogy of it being like quantum mechanics -- the *object*
isn't guaranteed to exist except when you try to access it, until then you
don't know what form it will take at any instance.



-- 
Steven

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


Re: python response slow when running external DLL

2015-11-27 Thread Laura Creighton
In a message of Fri, 27 Nov 2015 13:20:03 +0100, Peter Otten writes:

>A cleaner solution can indeed involve threads; you might adapt the approach 
>from  (Python 2 code).

But it is probably better to use threading

http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with this program???

2015-11-27 Thread Denis McMahon
On Fri, 27 Nov 2015 01:43:53 -0800, justin bloomer wrote:

> Your program should contain a function that:
> 1. Seeks input from the user (via the keyboard);
> 2. To build a list of student exam results;
> 3. For each student their name (first and last), student number, and
> mark out of 100 should be captured;
> 4. For full marks regular expressions or similar mechanisms should be
> used to ensure the data appears valid.

Try writing a function that does the following:

1. Seeks input from the user (via the keyboard);
2. Builds a list of student exam results;
3. Captures name (first and last), student number, and mark out of 100 
for each student;
4. Uses regular expressions or similar mechanisms to ensure the data 
appears valid.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python response slow when running external DLL

2015-11-27 Thread Peter Otten
jf...@ms4.hinet.net wrote:

> Peter Otten at 2015/11/27  UTC+8 5:19:17 PM wrote:
> 
> Hi! Peter, thanks for your prompt reply.
> 
>> What does var_status.set() do? If it writes to stdout you may just need
>> to flush().
> 
>var_status is a StringVar which binds to a lable's textvariable. I use
>this label as the status bar to show message.

Can I conclude from the above that you are using tkinter? Widgets can only 
update when the event loop gets a chance to run. While a quick fix is to 
invoke update_idletasks() callbacks shouldn't generally contain long-running 
code that -- as you have seen -- will block the complete user interface.
 
>> Do you see the same behaviour when you replace mydll.SayHello() with
>> something simple like time.sleep(1)?
> 
> I use time.sleep(3) to replace mydll.SayHello(), still get the same.
> 
>> As a general remark keep your test scripts as simple as possible.
>> Example: If
>> 
>> import mydll
>> print("Download...", end="")
>> mydll.SayHello()
>> print("OK")
>> 
>> showed the same behaviour it would be the ideal test script.
> 
> I run the above statements in a test file, it works as expected. I can
> see "Download..." and then "OK".
> 
> 

Quick-fix example:

#!/usr/bin/env python3
import tkinter as tk
import time

def download():
var.set("Starting download...")
root.update_idletasks()
time.sleep(3)
var.set("... done")


root = tk.Tk()
var = tk.StringVar()
label = tk.Label(root, textvariable=var)
label.pack()
button = tk.Button(root, text="Download", command=download)
button.pack()

root.mainloop()

A cleaner solution can indeed involve threads; you might adapt the approach 
from  (Python 2 code).


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


Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-27 Thread Marko Rauhamaa
BartC :

> I think [functions] are more first class in Lisp than they are in most
> other languages including Python.

Functions in Python and Lisp have the same status.

I would say that Python is one of the many modern Lisp derivatives. What
Python still lacks is:

 * A way to augment the language syntax on the fly. (How could I add an
   "until" statement to Python in my Python application?)

 * A unified syntax for code and data. (Why use braces for dictionaries
   instead of indentation?)


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python response slow when running external DLL

2015-11-27 Thread jfong
Peter Otten at 2015/11/27  UTC+8 5:19:17 PM wrote:

Hi! Peter, thanks for your prompt reply.

> What does var_status.set() do? If it writes to stdout you may just need to 
> flush().

   var_status is a StringVar which binds to a lable's textvariable. I use this 
label as the status bar to show message.

> Do you see the same behaviour when you replace mydll.SayHello() with 
> something simple like time.sleep(1)?

I use time.sleep(3) to replace mydll.SayHello(), still get the same.

> As a general remark keep your test scripts as simple as possible. Example: 
> If 
> 
> import mydll
> print("Download...", end="")
> mydll.SayHello()
> print("OK")
> 
> showed the same behaviour it would be the ideal test script.

I run the above statements in a test file, it works as expected. I can see 
"Download..." and then "OK".


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


Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-27 Thread BartC

On 27/11/2015 01:09, Steven D'Aprano wrote:

On Thu, 26 Nov 2015 12:23 pm, BartC wrote:


[First-class functions]

The names are declared, but the names are rarely bound to anything else.
Functions are just called the same boring way they are in C.

/They might as well be static definitions/.


Sure. And that's probably true for, oh, I don't know, I'll be generous, and
say that 95% of Python functions in use are of a straight-forward
pseudo-static form, using no dynamic features.

But it's the other 5% -- one in twenty -- that *shine*. They're the ones
that do things that you can't do in Pascal or C except with the greatest of
difficulty.


OK, you're worried about that 5%, I'm more concerned about the other 95%.

I'm not saying you shouldn't have dynamic functions at all, just that 
it's not necessary for 100% to be dynamic.


I understand now that they are dynamic because that is the only 
mechanism that Python has to create any function definition, even the 
boring, static ones.


Together with the ability to subsequently re-bind the function name to 
something else, that's a bit unfortunate because it makes it harder to 
identifier calls to those functions in order to streamline them, or even 
for someone to look at a bit of code and be sure whether that fn(a,b,c) 
is calling the function defined as 'fn' a few hundred lines earlier or 
something else entirely.


(MRAB mentioned Postscript, which also introduces functions using 
executable statements.


However, Postscript was designed to execute code on-the-fly being 
received a character at a time over a printer cable. It had a good excuse!)



Because Pascal doesn't have first-class functions, you couldn't pass a
function as an argument to another function. So the ODE solvers used a
hard-coded function as the equation to be solved. So if you wanted to solve
a particular equation, you had to *edit the source code of the program*,
modifying that hard-coded function to match your equation, then re-compile,
and then run the code. You couldn't just type in the equation you wanted to
solve and run the code.


Wouldn't Python have the same problem? If the equation to be solved, or 
even the actual function to be executed, is input by the user, then 
doesn't that require whichever one of exec() or eval() it is that 
processes the source code?



There's a lot to like about Pascal,


It was designed for teaching. The original language would have needed 
tweaking for use in general purpose programming.



but gosh it sure is lacking in power. C
at least has function pointers, which is a step up from Pascal, but still
pretty weak and feeble. If functions are first class values in Python,
Ruby, Lisp and others, they're second class values in C and third class in
Pascal.


I think they are more first class in Lisp than they are in most other 
languages including Python. That doesn't stop Python still being jolly 
useful though...


--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help with this program???

2015-11-27 Thread Laura Creighton
In a message of Fri, 27 Nov 2015 01:43:53 -0800, justin bloomer via Python-list
 writes:
>Your program should contain a function that:
>1. Seeks input from the user (via the keyboard);
>2. To build a list of student exam results;
>3. For each student their name (first and last), student number, and mark
>out of 100 should be captured;
>4. For full marks regular expressions or similar mechanisms should be used
>to ensure the data appears valid.

Hello.

We don't do people's assignments for them.
However, over on the tutor mailing list,
https://mail.python.org/mailman/listinfo/tutor
we do help people who are learning Python.

You will have to post your code, along with any error messages
you get and explain what you were trying to do.

Laura


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


Re: Help with this program???

2015-11-27 Thread Ben Finney
justin bloomer via Python-list  writes:

> Your program should contain a function that:

This is a homework assignment, yes?

We're not going to write the code for you. If you have a program you
already wrote, we can offer feedback on *your* code.

You should also collaborate with other classmates in the course, or look
into the course material your teacher has provided.

-- 
 \ “Why doesn't Python warn that it's not 100% perfect? Are people |
  `\ just supposed to “know” this, magically?” —Mitya Sirenef, |
_o__) comp.lang.python, 2012-12-27 |
Ben Finney

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


Re: Help with this program???

2015-11-27 Thread Chris Angelico
On Fri, Nov 27, 2015 at 8:43 PM, justin bloomer via Python-list
 wrote:
> Your program should contain a function that:
> 1. Seeks input from the user (via the keyboard);
> 2. To build a list of student exam results;
> 3. For each student their name (first and last), student number, and mark
> out of 100 should be captured;
> 4. For full marks regular expressions or similar mechanisms should be used
> to ensure the data appears valid.

I suggest you start by opening up a programmer's editor and saving an
empty file under the name "examresults.py". Then take your keyboard in
hand, and start writing code. The above text would make a good set of
"stub comments" - notes to indicate what parts of code you still need
to write - which you can progressively replace with actual code.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Help with this program???

2015-11-27 Thread justin bloomer via Python-list
Your program should contain a function that:
1. Seeks input from the user (via the keyboard);
2. To build a list of student exam results;
3. For each student their name (first and last), student number, and mark
out of 100 should be captured;
4. For full marks regular expressions or similar mechanisms should be used
to ensure the data appears valid.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python response slow when running external DLL

2015-11-27 Thread Peter Otten
jf...@ms4.hinet.net wrote:

> I am new to Python. As an exercise of it, I try to port a program which
> was written more than 10 years ago. This program use the Borland C++
> Builder as its GUI front end and a DLL does the real work(it will takes a
> few seconds to complete). I saw a strange phenomenon in the following
> codes. The "var_status.set('Download...')" statement seems was deferred
> and didn't show up until the external DLL job was finished and I can only
> saw the result of "var_status.set('Download OK')" statement which
> immediately follows. I try to do the DLL function in a thread(selected by
> using the "test" flag in codes), but it didn't help.
> 
> Can anyone tell me what's the point I was missed?

What does var_status.set() do? If it writes to stdout you may just need to 
flush().

Do you see the same behaviour when you replace mydll.SayHello() with 
something simple like time.sleep(1)?

> -
> def download():
> global iniFilename
> if test:  global result, busy
> ini = iniFilename
> iniFilename = "c:\\$$temp.in3"
> saveIniFile()
> iniFilename = ini
> #do the rest
> var_status.set('Download...')
> if not test:
> result = mydll.SayHello()
> else:
> busy = True
> _thread.start_new_thread(td_download, ())
> while busy:  pass
> if result:
> var_status.set("Download Fail at %s" % hex(result))
> showerror('Romter', 'Download Fail')
> else:
> var_status.set('Download OK')
> showinfo('Romter', 'Download OK')
> 
> if test:
> result = 0x
> busy = True
> def td_download():
> global busy, result
> result = mydll.SayHello()
> busy = False
> --

As a general remark keep your test scripts as simple as possible. Example: 
If 

import mydll
print("Download...", end="")
mydll.SayHello()
print("OK")

showed the same behaviour it would be the ideal test script.

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