Re: Why Python has no equivalent of JDBC of Java?

2019-05-21 Thread Adriaan Renting


I think it's partially a design philosophy difference.

Java was meant to be generic, run anywhere and abstract and hide
differences in its underlying infrastructure. This has led to the Java
VM, and also JDBC I guess.

Python was more of a script interpreted C-derivative, much closer to
the bare metal, and thus much less effort was made to hide and
abstract.

It might also have to do with the different developer cultures. Java
was much more Cathedral, and Python much more Bazaar.
Bazaar type development seems to be much less able to come up with high
level abstraction.

At least that's my guess.

Adriaan

>>> On 19-5-2019 at 14:27, Marco Sulla via Python-list

wrote: 
> I programmed in Python 2 and 3 for many years, and I find it a
fantastic
> language.
> 
> Now I'm programming in Java by m ore than 2 years, and even if I
found its
> code much more boilerplate, I admit that JDBC is fantastic.
> 
> One example over all: Oracle. If you want to access an Oracle DB
from
> Python, you have to:
> 
> 1. download the Oracle instantclient and install/unzip it
> 2. on Linux, you have also to install/unzip Development and Runtime
package
> 3. on windows, you have to add the instantclient to PATH
> 4. on Linux, you have to create a script to source that sets PATH,
> ORACLE_HOME and LD_LIBRARY_PATH
> 
> Finally, you can use cx_Oracle.
> 
> Java? You have only to download ojdbcN.jar and add it to
Maven/Gradle.
> 
> Why Python has no equivalent to JDBC?

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


Re: Loop with else clause

2019-02-08 Thread Adriaan Renting


Wow, you dug deep.

My example was the reverse of the "toy example"'s you mention as I find
that often code becomes much clearer if you order it such that
specific cases, sanity checking and exceptions go first, and then the
default case at the end.

So my general suggestion would be to handle your empty list/no valid
candidates cases first,
and then do the for loop at the end.

If you style this with if/elif/else, or put return statements in
certain places, I have no opinion about and will depend on the specific
problem.

Cheers,

Adriaan Renting.

>>> On 7-2-2019 at 9:42, DL Neil 
wrote: 
> Further to our discussion of how to improve a code review's discovery
of 
> the mistaken handling of a for...else... construct:-
> 
> 
> Yesterday was a national holiday, but today gave some opportunity to

> research. Way back in 2009 there was spirited discussion over on the

> Python Ideas list (warning, even the mailing list's index covers 
> multiple screen-lengths):
> 
> - this confusion is not new by any measure, herewith a list of
previous 
> occasions "fists were raised concerning for..else."
>
https://mail.python.org/pipermail/python-ideas/2009-October/006164.html
> 
> - an excellent summary of the 2009 debate which offers no less than
six 
> ways to 'improve' for... else...
>
https://mail.python.org/pipermail/python-ideas/2009-October/006155.html
> 
> - (as mentioned earlier) the BDFL weighed-in a couple of times. His 
> regret is: "That's a flaw, and I don't quite know what to do about
it. 
> It's about 20 years too late to remove or rename it. But we probably

> should not do more of these. That's a lesson."
> (OK, so make that thirty years - older than the coder who the 
> code-review noticed falling into this coding 'gotcha'!)
>
https://mail.python.org/pipermail/python-ideas/2009-October/006083.html
> 
> - herewith a (rather complicated) suggestion, and critique
>
https://mail.python.org/pipermail/python-ideas/2009-October/006054.html
> 
> - one rather hopeful option (actual words to be used
notwithstanding)
>   for i in SEQ:
> A
>   except:
> B
>   else:
> C
> appears here:
>
https://mail.python.org/pipermail/python-ideas/2009-October/006044.html
> 
> 
> Somewhat related, PEP 548 proposed an "More Flexible Loop Control".
This 
> was addressing the confusion caused by break within a loop. It was
rejected.
> 
> 
> Each of the above addresses issues 'within', that is to say
happenings 
> during iteration - whether the entire loop or iteration cut-short by
a 
> break (and thus the idea that "else" might be re-worded to indicate 
> 'after a break').
> 
> However, as mentioned by one contributor, the specific use-case our
team 
> faced was an issue that arises prior to the loop.
Alternately-expressed: 
> that according to Python's logic, prevents even a single iteration of

> that loop. Thus, any 'solution' would reside outside of for and while

> statements because they only consider if a loop should continue or 
> terminate - not handling the question of whether it should start at
all!
> 
> PEP 315 is the only discussion (I've found) which looks 'outside' or

> 'before' the loop itself. It proposed an "Enhanced While Loop", 
> attempting to separate 'setup' or loop control from loop content. It
was 
> rejected.
> 
> 
> So, reading-around brought nothing much useful. Back to the
code-face...
> 
> Thank you to the several folk who responded with ideas to
express/improve:
> 
>  if list:
>  process_list() #the heading and for-loop, as above
>  else:
>  print( "Sorry...
> 
> NB this is a constructed 'toy example' attempting to be the shortest

> illustration of use-cases and invented purely to communicate the need

> and structure. It was expected to be interpreted as
pseudo-python-code. 
> (you'd not use/allow "process_list" as the name of a function, would
you?)
> 
> (With apologies as necessary) one of the dangers of 'toy examples' is

> the reader taking them at face value, instead of as (over-)simplified

> illustrations. In 'real life' the loop code and the no-loop exception

> are both considerably longer than a single line. Accordingly, using a

> function would be a good way to summarise and self-document the 
> activity, ie the if statement's two code-blocks would make the whole

> statement very/too-long (readability)!
> 
> The "if list:" expression is overly-simplistic. The recommendation of

> "if len(list):" is absolutely sound, for reasons of polymorphism.
> 
> In-lieu of a Python construct, there are definitely situations when
use 
> of a sentinel makes bette

Re: Loop with else clause

2019-02-05 Thread Adriaan Renting



I don't know if it is very Pythonic, but I would do something like

if no_oscar_nominees:
print ("Sorry ...")
else:
print_list_of_oscar_nominees()

And yes, that for/else construct can be confusing.

Adriaan.


>>> On 5-2-2019 at 5:29, DL Neil 
wrote: 
> What is the pythonic way to handle the situation where if a condition

> exists the loop should be executed, but if it does not something else

> should be done?
> 
> 
> Why am I asking?
> Today's code review included a for...else structure. I've rarely seen

> such a thing, and even knowing it exists, cannot recall ever using
it! 
> The coder intended to implement the scenario (above) but did not
realise 
> that the else-clause means 'execute if the loop ended without using 
> break'. She thought it meant 'if there's nothing in the iterable, 
> execute the else clause' (per if...then...else... ie the two clauses
are 
> mutually-exclusive*) - which one assumes is the reason why the BDfL
is 
> claimed to have said it should never have been implemented (this
way). 
> She neglected to test the exception properly, and was lulled into a 
> false sense of security by the coverage reporting 100%. Oops!
> 
> *see also the more commonly-used try...except...else...[finally...]
> 
> 
> When/how does this occur?
> Our client is more than a little commercially-sensitive. So as a
really 
> simple scenario, imagine a report is required, naming people who have

> become eligible for something, eg students qualified to enter an 
> advanced class, Oscar film award nominees, entrants who have
fulfilled 
> the requirements of a competition from which a winner will be
randomly 
> selected...
> 
> The names all appear in a list, so the most frequent use-case is
trivial:
> 
>   print( "And the winners are:" )
>   for name in list:
>   print( name )
> 
> but, if no-one actually qualifies, a warning message is required, eg
> 
>   print( "Sorry, no-one is eligible" )
> 
> 
> Possible solution:
> To make anything more than the trivial case readable, I think I'd put

> the list processing into one function, and the exception into another

> (except that this case is so trivial), ie
> 
>   if list:
>   process_list() #the heading and for-loop, as above
>   else:
>   print( "Sorry...
> 
> 
> Others wanted to add a semaphore/flag inside the loop to indicate if
it 
> was executed at least once. Yes, could even use the else clause
then!
> 
> The ideas went (rapidly) down-hill from there...
> 
> 
> Is there another, more pythonic, approach to conditional (for/while)

> loop processing?

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


[OT] Re: Thank you Python community!

2018-03-20 Thread Adriaan Renting



That sounds more like a conspiracy theory than a real analysis of the
problem. 


Looking at it from here in Europe, most of the analysis I've been able
to read and watch about it, points to a different cause: 


A lack of security: People flee to drugs (alcohol, tobacco, coffee and
other (illegal) drugs) to escape stessful environments. 


- A lack of job security 
- A lack of proper healthcare 
- Broken and single parent families 
- Poor and/or expensive education 
- Mental illness 


What I learned from visiting the USA many times is: 
- Americans value the individual, not the collective. They have been
trained to distrust anything collective, even if it is the only way to
solve an issue. 
- Money has too much influence at all levels, especially in politics.
The combination of an election system that is 2 centuries behind the
times, with modern compute power, data gathering and media technology is
corrupting the system. 
- The USA always depended a lot on immigration and never had to keep
it's own working population well educated and healthy to run the
economy. This is changing and one of the big cultural wars raging
currently. 


The broken healthcare system is a symptom of these issues. 


There are other reasons people get into drugs*, but from what I've
read, my impression is that these are major causes to the current
problems in the USA. 


Successive US governments have been waging unwinnable "wars", like the
"War on Drugs" for decades, so entire industries can keep profiting.
Until you fix the problems in society the demand will not go away and
the problems will stay. 


Cheers.



*) Drug use also correlates with boredom and low amounts of sunlight
and an amount of predisposition. Correlation is not always causation,
but can be. 

>>> Larry Martell <larry.mart...@gmail.com> 19-3-2018 20:21 >>>
On Mon, Mar 19, 2018 at 12:08 PM, Etienne Robillard
<tkad...@yandex.com> wrote:
> You guys just made me realize something very obvious. :-)
>
> I'm in the process right now of watching the excellent documentary
named
> "Drugs Inc." on Netflix and I'm basically stunned and deeply
concerned about
> the major opioid epidemic in the US.

Have no clue what this has to do with python, but the opioid epidemic
was created by collision between big pharma and the government.
--
https://mail.python.org/mailman/listinfo/python-list

Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



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


[OT] multicore/cpu history Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread Adriaan Renting



Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



>>> On 17-2-2018 at 22:02, in message
<captjjmpk5iaczm+f_sjauhsq0oaqkdpcjs-zt6-acpy3kkl...@mail.gmail.com>,
Chris
Angelico <ros...@gmail.com> wrote: 
> On Sun, Feb 18, 2018 at 5:05 AM, Steven D'Aprano
> <steve+comp.lang.pyt...@pearwood.info> wrote:
>> On Sat, 17 Feb 2018 15:25:15 +1100, Chris Angelico wrote:
>>

...

>>> Totally not true. The GIL does not stop other threads from
running.
>>> Also, Python has existed for multiple CPU systems pretty much since
its
>>> inception, I believe. (Summoning the D'Aprano for history lesson?)
>>
>> If you're talking about common desktop computers, I think you're
>> forgetting how recent multicore machines actually are. I'm having
>> difficulty finding when multicore machines first hit the market, but
it
>> seems to have been well into the 21st century -- perhaps as late as
2006
>> with the AMD Athelon 64 X2:
> 
> No, I'm talking about big iron. Has Python been running on multi-CPU
> supercomputers earlier than that?
> 
>> By the way, multiple CPU machines are different from CPUs with
multiple
>> cores:
>>
>> http://smallbusiness.chron.com/multiple-cpu-vs-multicore-33195.html
> 
> Yeah, it was always "multiple CPUs", not "multiple cores" when I was
> growing up. And it was only ever in reference to the expensive
> hardware that I could never even dream of working with. I was always
> on the single-CPU home-grade systems.
> 

Multicore became a thing with the Pentium 4 hyperthreading around ~2002
for consumers, and
multi cpu was a thing much longer, even with "consumer grade"
hardware:

I remember running 2 Mendocino 300 MHz Celerons on a Pentium II Xeon
motherboard to get a
multi-cpu machine for running multiple virtual machines for testing
purposes around 1998.
This was not as Intel intended, but a quite cheap consumer grade
hardware solution.

...
> 
> ChrisA

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-31 Thread Adriaan Renting



Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



>>> On 30-1-2018 at 19:22, MRAB <pyt...@mrabarnett.plus.com> wrote: 
> On 2018-01-30 15:39, Steven D'Aprano wrote:
>> On Tue, 30 Jan 2018 05:48:15 -0800, Rustom Mody wrote:
>> 
>> [...]
>>>> Ah, yes, the Dutch Reach. That would be like the French Pox
(which
>>>> isn't French), the Spanish Flu (that didn't start in Spain), the
>>>> Jerusalem artichoke (which is neither an artichoke nor from
Jerusalem),
>>>> and the turkey (the bird, which has nothing to do with Turkey,
the
>>>> country).
>>>> 
>>>> This technique is neither taught nor commonly used used by the
Dutch:
>>>> apparently some Americans decided that because the Netherlands has
a
>>>> lot of cyclists, they'll say its Dutch.
>>> 
>>> reference please
>> 
>> The onus should be on those who claim that the technique actually is
used
>> by the Dutch. Anecdotally, the Dutch people I've spoken to on the
>> Internet had no idea that this technique even existed.
>> 
> Do we know of anyone who's Dutch and frequents a Python newsgroup?
:-)
> 

I am Dutch and after googling the term, I can confirm that the "Dutch
Reach" is taught in driving school here.
I was taught this maneuvre when getting my licence 20 years ago.

If it is actually used by a lot of people, I can't confirm.
I use it most of the time, depending on what model car I'm driving.
(wether the door handles are easy to reach/operate).

The way I was taught, you have to check your mirrors and then use it to
force you to check your blind spot, mostly to avoid cars hitting
you/your door on the drivers side.
I don't remember any specific mention of bicycles or use by passengers
of this maneuvre.

I think in general cars are a much larger danger than bicycles:
- Faster: More likely have not been seen by you or not see you.
- More mass: Damage much bigger. (yes also depends on the square of the
velocity).
- Worse perception. A Bicyclist usually has unrestricted hearing and
vision around themselves, and is much more likely to have noticed the
person in the car.
- Bicyclists will understand they are vulnerable and be more careful.

Motorbikes and mopeds are the hardest for me, as they are more likely
to be missed due to their speed.

And in the Netherlands, we largely solve this problem by just having
everyone on a bike. ;-)
(We do ride cars as well)

If you want to know more about how the Dutch go about their cycling and
images of Dutch infrastructure, then I suggest the BicycleDutch Youtube
channel, for example this video:
https://www.youtube.com/watch?v=swqaAIkGtpA

The difference with a lot of other places, is that we use bicycles as a
means of transport, not as an excercise/sports device.
In general for distances < 15km (10 miles) and anything up to about the
size of a couch.

> [snip]

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


Re: Syntax error for simple script

2017-06-28 Thread Adriaan Renting



Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



>>> On 27-6-2017 at 21:38, Erik <pyt...@lucidity.plus.com> wrote: 
[snip]
> 
> One other possibility is that a beginner fires up Py3 and gets that 
> "weird" (to them) error when they tried their tutorial or SO code and

> then finds out that if they fire up Py2 instead it just works. Now
they 
> might continue to use Py2 because it's "the one that works" for
them.
> 
> I would suggest that making the error dissuade them from doing that
(for 
> the cost of a few tens of bytes) is a good thing.
> 
>>> I think the suggestion above is a bit wordy, but even if it was
>>> something like "Missing parentheses in call to the 'print'
function"
>> 
>> I think this is a good example of "the curse of knowledge". Its hard
for 
> expert > to think like a non-expert.
> 
> [snip]
> 
>> But to the beginner, adding "function" at the error might as well
be
>> 
>> Missing parentheses in call to the 'print' wharrgarbl.
> 
> You are concentrating on the detail of what I wrote. I don't care
what 
> the eventual wording is (and for sure, someone else is far more 
> qualified than me to suggest wording that is better for a beginner).
My 
> point is simply that the error _could_ contain _some_ more
information 
> that addresses this issue for a beginner who may be typing in Py2 
> examples that encourages them to seek out Py3 tutorials instead.
> 
>> That's why I asked Ben if there was something we
>> could do to make the sentence clearer.
> 
> Exactly. Ben is an example of someone more qualified than me to
suggest 
> the correct words.
> 
>>> Either that or just make it "SyntaxError: invalid syntax" like all
the
>>> others.
>> 
>> We've been there: adding the specific print message is new to Python
3.5 (or
>> maybe 3.4, I forget which). Python 3.3 gives just "SyntaxError:
invalid
>> syntax".
> 
> That surprises me, to be honest. I had presumed that the parser had
just 
> had the machinery for that message placed where the 'print' keyword
used 
> to be handled rather than ripping the whole thing out when it became
a 
> function. Interesting that it's a retrospective special case.
> 
> E.

I agree in general with Erik. I don't like the general SyntaxError. I
like more specific errors that you can at least google for.
I don't think you need the whole history in the error, but it would be
nice if it was specific enough that if you put it in a search engine you
get relevant results explaining things.

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


Re: [OT] How to improve my programming skills?

2017-06-02 Thread Adriaan Renting



Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



>>> On 1-6-2017 at 17:26, Mirko via Python-list
<python-list@python.org> wrote: 

> Hello everybody!
> 
> TLDR: Sorry for OT. Long-time Linux geek and hobby programmer wants 
> to improve his coding skills. What's most important: project 
> planing, algorithms and data structures, contributing to FOSS, web 
> development, learning other languages or something else?
>
Learning languages is something that sort of happens by itself as times
change.
 
> 
> Sorry for posting such a (long) off-topic question, which even is 
> partly even more about psychology, than about technology. But I'm 
> mostly using Python and Bash for programming and am reading this 
> mailing list/newsgroup for many years now, and hope it's Ok (feel 
> free to direct me somewhere more appropriate, as long it's an 
> equally helpful and friendly place).
> 
> I'm looking for a way (*the* way, ie. the "BEST(tm)" way) to improve

> my coding skills. While I'm a quite hard-core computer geek since 25

> years and a really good (hobbyist) Linux-SOHO-Admin, my programming 
> skills are less than sub-par. I wish to change that and become at 
> least am average hobby-programmer. I'm an excellent autodidact and 
> in fact, all what I know about computers is completely self-taught.
> 

The problem with being an autodidact is that you usually have big gaps
in your knowledge that you're not aware of.
The first question is if you want to be a better programmer or better
software engineer?
What I mean with that is do you want to make your code more robust and
efficient or do you want to learn how to design better code? The first
is very much about algorithms and the math behind them, while the second
is more about tools and methods to help you design.

> Now, the problem is, that I'm 41 years old now, have a day job 
> (which hasn't much to do with advanced computing stuff), friends and

> all that. There is little time left for this undertaking (something 
> like 5 - 10 hours per week), so I'm looking for the most efficient 
> ways to do this.
>

If you have little time, it will take a longer time to get better.
 
> I identify the following problems which could be worth improving:
> 
> - I never sit down and plan anything with pencil and paper, 
> flowcharts, UML or anything else. I just fire up Vim and start 
> typing. That works (albeit slowly) for simple programs, but as soon 
> as the project becomes a little more complex the parts and 
> components don't match well and I need to botch something together 
> to somehow make it work. And in the resulting mess I lose the
interest.
>
Any hour designing usually saves you many hours in coding.
UML is popular, but I'm a fan of Yourdon as well.
Design really starts with writing down what you're trying to do (use
cases),
why, how and within what limits. You get better through experience,
especially
when doing it for the first time, people often forget a lot of the
limits they have.

Part of it is also software management, in this case mostly on
yourself.
One of the books that's the foundation there is "The Mythical Man
Month".
It's old but it would help the industry if everyone had read it.
 
> - I never learned algorithms and data structures. I know *what* 
> (linked) lists, dicts, arrays, structs, and trees are; what binary 
> search or bubble-sort is, but I never really studied them, let alone

> implemented them for educative purposes.
>
You're touching on the difference between information and knowledge.
You know they exist, but they're not really part of your knowledge.
If you want to get better at programming, you need to learn more about
algorithms,
making excercises and actually implementing these will make them part
of your knowledge.
Some general math will also help, it really helps if you can analyse if
the code you're writing 
uses a linear or quadratic solution to your problem, and how it could
be rewritten.
At a higher level, there are also things like design patterns.
A standard book on that would be Design Patterns by Erich Gamma,
Richard Helm, Ralph Johnson en John Vlissides.
 
> - When it comes to coding, I'm heavily shy and unsure. I really know

> my stuff when it's about Linux-SOHO-Administration, but when trying 
> to contribute to FOSS projects I always hesitate for several reasons

> (somehow I never find those low-hanging fruits that everybody talks 
> about; either it's super-easy or to difficult.)
>
Sounds like you have typical sysadmin skills, but not really
programming or software engineering

RE: Swiss Ephemeris

2017-04-10 Thread Adriaan Renting

There are at least two other packages with Python bindings that allow
ephimerides calculations.

1) PyEphem http://rhodesmill.org/pyephem/
2) Pyraphttp://www.astron.nl/casacore/trunk/pyrap/docs/ (This needs a
very big casacore c++ library and thus a pain to compile, but can give
second level accuracy if you use updated IERS tables).

As to the ancient's (Greek/Roman) nature philosophy. We still use some
of it today, especially in the fields of mathematics, mechanics and
observational astronomy, but their understanding of biology and
especially the human body was entirely incorrect.

Western/Islamic medicine largely followed Hippocrates for nearly 2000
years (although the ideas are originally from Indian Ayurveda) and some
of the methods had some merit, but overall the treatments were often
worse than the disease, for example George Washinton was almost
certainly killed by his doctors.
Only with the application of the scientific method to medicine after
the enlightenment have we started to make any real progress. The most
important of which is blind trials in which a treatment needs to show to
be better than a placebo.

One of the most important things that modern medicine has shown is that
a placebo can have a real effect and cure people. Some people do get
better after you give them a sugar pill or its equivalent.
As humans we're also very good at seeing correlation and causation when
none might exist. Matt Parker has a very entertaining talk about this
here https://www.youtube.com/watch?v=sf5OrthVRPA

Cheers,

Adriaan Renting

P.S. I had an uncle who died of cancer 2 years ago who was a firm
believer in all kinds of non-mainstream cures and tried all kinds of
alternative cures from accupuncture to yoga to Gc-MAF. In the end the
only results I saw were that these people got many 10.000s euros from
him and he died very disillusioned and poor as these were not covered by
his health insurance. I learned a lot about magazines like "What doctors
don't tell you" - which use the images of people in white labcoats to
sell you things that doctors don't tell you about because they are known
to be ineffective or even bad for you. I understand that a lot of people
have a problem with authority and/or look for alternatives if mainstream
medicine can't help them. And sometimes the methods seem to work and
those are the stories you hear, as the other people end up like my
uncle, who's not here any more to tell his story. Don't end up like my
uncle.

 >>>
> Fully recognizing that most of what you wrote was tongue-in-cheek, I
> just want to say that regardless of the wonders of modern medicine,
it's
> a pity they learn so little about successful medicines other than
their
> own. In other academic scientific disciplines such as physics and
> chemistry it's not uncommon to see history of science courses in the
> curriculum. But not in medicine. I learned what I know about ancient
> Greek science from a university physics professor, though I doubt he
> would ever have guessed that one of his students would someday
breathe
> new life into that ancient science by attempting to ressurrect it.
The
> great ancients were no less endowed with intelligence than we are,
they
> simply directed it to different ends.
> 
> 
> Rick Johnson wrote, on Sunday, April 09, 2017 9:00 PM
>> 
>> On Sunday, April 9, 2017 at 8:52:44 PM UTC-5, Deborah Swanson
wrote:
>> > PS. I've been using medical astrology to look ahead at my medical

>> > condition for years in advance. And being off by a day or 
>> so doesn't 
>> > matter that much when you're looking at trends over the course of

>> > years and decades. I also have a little software widget to 
>> look at the 
>> > planetary data in graphical chart form at any particular 
>> second, also 
>> > based on sweph, which has been quite astoundingly accurate in
>> > following the rather complex kaleidoscope of my symptoms
>> > during the course of a day. (Though it doesn't do you a bit
>> > of good if you forget to look! Which is my entire
>> > motivation to get it encoded and available with a few
>> > clicks.) And it is quite useful to know in advance what
>> > will be happening when, and most importantly when it will
>> > stop. Knowledge is power!
>> 
>> It's simply amazing what technology can do these days. And
>> with medical diagnosis now just a few clicks away, someone 
>> really should tell those medical students to stop wasting 
>> time and money at university.
>> 
>> > Caveat. This kind of precision and accuracy is only found
>> > in the specific forms of astrology which relate to pure physical 
>> > phenomena, and most of what you see these days masquerading as 
>> > astrology is pure hooey, almost entirely invent

Re: ignoring or replacing white lines in a diff

2016-01-15 Thread Adriaan Renting

Thanks for the various people that provided help.

Peter Otten provided me with a working solution:

I had to split the "-I '^[[:space:]]*$'" into two commands.

  cmd   = ["diff", "-w", "-I", r"^[[:space:]]*$", "./xml/%s.xml" %
name, "test.xml"]
  p = subprocess.Popen(cmd, stdin=open('/dev/null'),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  logs  = p.communicate()
  diffs = logs[0].splitlines() #stdout

This also works:

  cmd   = ["diff -w -I '^[[:space:]]*$' ./xml/%s.xml test.xml" %
name]
  p = subprocess.Popen(cmd, stdin=open('/dev/null'),
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  logs  = p.communicate()
  diffs = logs[0].splitlines() #stdout

As to other comments:

- I've found that stdin=open('/dev/null') is essential in
subprocess.Popen to make it work from automated (headless) scripts.
- print line, did remove the extra newlines, but didn't get rid of the
blank lines.
- making it a raw string with r"-I '^[[:space:]]*$'" made no difference
(also tried r"-I ^[[:space:]]*$")
- I didn't investigate difflib further but will keep it in mind for the
future.

Thank you for your help,

Adriaan.


Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



>>> On 14-1-2016 at 22:05, Peter Otten <__pete...@web.de> wrote: 
> Adriaan Renting wrote:
> 
>> 
>> Maybe someone here has a clue what is going wrong here? Any help is
>> appreciated.
>> 
>> I'm writing a regression test for a module that generates XML.
>> 
>> I'm using diff to compare the results with a pregenerated one from
an
>> earlier version.
>> 
>> I'm running into two problems:
>> 
>> The diff doesn't seem to behave properly with the -B option. (diff
(GNU
>> diffutils) 2.8.1 on OSX 10.9)
>> 
>> Replacing -B with -I '^[[:space:]]*$' fixes it on the command line,
>> which should be exactly the same according to:
>> 
>
http://www.gnu.org/software/diffutils/manual/html_node/Blank-Lines.html#Blank-L
> ines
>> 
>> (for Python problem continue below)
>> 
>> MacRenting 21:00-159> diff -w -B test.xml xml/Ticket_6923.xml
>> 3,5c3,5
>> <   2.15.0
>> <   > changedBy="Adriaan Renting">
>> <   XML Template generator version
2.15.0
>> ---
>>>   2.6.0
>>>   > changedBy="Alwin de Jong">
>>>   XML Template generator version
>> 2.6.0
>> 113d112
>> <
>> 163d161
>> <
>> 213d210
>> <
>> 258d254
>> <
>> 369d364
>> <
>> 419d413
>> <
>> 469d462
>> <
>> 514d506
>> <
>> 625d616
>> <
>> 675d665
>> <
>> 725d714
>> <
>> 770d758
>> <
>> 881d868
>> <
>> 931d917
>> <
>> 981d966
>> <
>> 1026d1010
>> <
>> 1137d1120
>> <
>> 1187d1169
>> <
>> 1237d1218
>> <
>> 1282d1262
>> <
>> 
>> /Users/renting/src/CEP4-DevelopClusterModel-Story-Task8432-
> SAS/XML_generator/test
>> MacRenting 21:00-160> diff -w -I '^[[:space:]]*$' test.xml
>> xml/Ticket_6923.xml
>> 3,5c3,5
>> <   2.15.0
>> <   > changedBy="Adriaan Renting">
>> <   XML Template generator version
2.15.0
>> ---
>>>   2.6.0
>>>   > changedBy="Alwin de Jong">
>>>   XML Template generator version
>> 2.6.0
>> 
>> 
>> Now I try to use this in Python:
>> 
>>   cmd   = ["diff", "-w", "-I '^[[:space:]]*$'", "./xml/%s.xml"
%
>> name, "test.xml"]
> 
> Instead of 
> 
> ..., "-I '^[[:space:]]*$'", ...
> 
> try two separate arguments
> 
> ..., "-I", "^[[:space:]]*$", ...
> 
>>   ## -w ignores differences in whitespace
>>   ## -I '^[[:space:]]*$' because -B doesn't work for blank
lines
>> (on OSX?)
>>   p = subprocess.Popen(cmd, stdin=open('/dev/null'),
>> stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> 
> I don't think you need to specify stdin.
> 
>>   logs  = p.communicate()
>>   diffs = logs[0].splitlines() #stdout
>>   print "diff reply was %i lines long" % len(diffs)
>> 
>> This doesn't work. I've tried escaping the various bits, like the *
and
>> $, even though with single quotes that should not be needed.
>> 
>> I tried first removing the blank lines from the file:
>> 
>>   import fileinput
>>   for line in fileinput.FileInput("test.xml",inplace=1):
>> if line.rstrip():
>>   print line
>> 
>> This makes it worse, as it adds and empty line for each line in the
>> file.
> 
> Add a trailing comma to suppress the newline:
> 
> print line,
> 
>> I've tried various other options. The only thing I can think of, is
>> ditching Python and trying to rewrite the whole script in Bash.
>> (It's quite complicated, as it loops over various things and does
some
>> pretty output in between and I'm not very fluent in Bash)
>> 
>> Any suggestions?
> 
> Whatever floats your boat ;)

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


ignoring or replacing white lines in a diff

2016-01-14 Thread Adriaan Renting

Maybe someone here has a clue what is going wrong here? Any help is
appreciated.

I'm writing a regression test for a module that generates XML.

I'm using diff to compare the results with a pregenerated one from an
earlier version.

I'm running into two problems:

The diff doesn't seem to behave properly with the -B option. (diff (GNU
diffutils) 2.8.1 on OSX 10.9)

Replacing -B with -I '^[[:space:]]*$' fixes it on the command line,
which should be exactly the same according to:
http://www.gnu.org/software/diffutils/manual/html_node/Blank-Lines.html#Blank-Lines

(for Python problem continue below)

MacRenting 21:00-159> diff -w -B test.xml xml/Ticket_6923.xml
3,5c3,5
<   2.15.0
<   
<   XML Template generator version 2.15.0
---
>   2.6.0
>   
>   XML Template generator version
2.6.0
113d112
<
163d161
<
213d210
<
258d254
<
369d364
<
419d413
<
469d462
<
514d506
<
625d616
<
675d665
<
725d714
<
770d758
<
881d868
<
931d917
<
981d966
<
1026d1010
<
1137d1120
<
1187d1169
<
1237d1218
<
1282d1262
<

/Users/renting/src/CEP4-DevelopClusterModel-Story-Task8432-SAS/XML_generator/test
MacRenting 21:00-160> diff -w -I '^[[:space:]]*$' test.xml
xml/Ticket_6923.xml
3,5c3,5
<   2.15.0
<   
<   XML Template generator version 2.15.0
---
>   2.6.0
>   
>   XML Template generator version
2.6.0


Now I try to use this in Python:

  cmd   = ["diff", "-w", "-I '^[[:space:]]*$'", "./xml/%s.xml" %
name, "test.xml"]
  ## -w ignores differences in whitespace
  ## -I '^[[:space:]]*$' because -B doesn't work for blank lines
(on OSX?)
  p = subprocess.Popen(cmd, stdin=open('/dev/null'),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  logs  = p.communicate()
  diffs = logs[0].splitlines() #stdout
  print "diff reply was %i lines long" % len(diffs)

This doesn't work. I've tried escaping the various bits, like the * and
$, even though with single quotes that should not be needed.

I tried first removing the blank lines from the file:

  import fileinput
  for line in fileinput.FileInput("test.xml",inplace=1):
if line.rstrip():
  print line

This makes it worse, as it adds and empty line for each line in the
file.

I've tried various other options. The only thing I can think of, is
ditching Python and trying to rewrite the whole script in Bash.
(It's quite complicated, as it loops over various things and does some
pretty output in between and I'm not very fluent in Bash)

Any suggestions?

Thanks for any help provided.

Adriaan Renting.


Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/


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


Re: Old DbaseV DOS Programmer wants to step over to new/actual modern program software

2015-08-17 Thread Adriaan Renting

For building new programs using free software, I currently like a mix
of Qt, Python, C++ and various open source SQL databases (MySQL,
PostGreSQL). I have found QtCreator an easy IDE to use in such cases, I
don't really like Eclipse.
But it requires a heavy knowledge of C++, which is not an easy
language, if you want to use Qt directly.
PyQt works for smaller projects, I've used it with
http://eric-ide.python-projects.org/ in the past.

A few things you need to ask yourself:
- How much time do I have?
- Who are my users, what OS/systems do they use? I like Qt because it
allows me to create programs for all kinds of operating systems.
- How do I want to distribute my software? Is it a problem if a user is
able to read the souce code?
- How well do I really know Dbase V? What do I want to do the same and
what differently? My dad worked with Dbase III/IV/V for years, but
learned how to program it by changing the autogenerated code, which is a
horrible way to learn programming and leads to very bad habbits.
- What kind of programs are you trying to make? There also exist a lot
of more specialized solutions, like http://www.4d.com/, which might suit
your needs, if you're looking for a dBase replacement.

Cheers



Adriaan Renting| Email: rent...@astron.nl
Software Engineer Radio Observatory
ASTRON | Phone: +31 521 595 100 (797 direct)
P.O. Box 2 | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands| Web: http://www.astron.nl/~renting/



 On 16-8-2015 at 20:40, Vladimir Ignatov kmis...@gmail.com wrote:

 On Sun, Aug 16, 2015 at 1:11 PM, Rustom Mody rustompm...@gmail.com
wrote:
 
 I have some ideas in mind like Java with (ECLIPS) because it is
very 
 popular, it is the most widely used and can get tutorials and videos
all over 
 the internet.
 I've read a lot of good things about Python, that it is much easier
but too 
 complicate to define what to choose,
 at the first place witch version 2.x or 3.x, a lot of IDE's to
choose from, 
 beside of that witch IDE with what pluggin.
 
 Hi,
 
 I am using python for years but still curious about best IDE to
suggest 
 newbies.
 IMHO - too many choices with no clear winner and each with its own
flaws.
 For me two crucial features are: good autocompletion and ability to
 step over code in debugger.
 I'd try Eclipse+PyDev first and then additionally check PyCharm
($$$)
 for comparison (to see how best free compares to good
commercial)
 
 
 Vladimir
 
 https://itunes.apple.com/us/app/python-code-samples/id1025613117

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


Re: Behaviour of subprocess.Popen, ssh and nohup I don't understand

2011-04-07 Thread Adriaan Renting

Thanks, that explains a lot.

Adriaan Renting.


 On 4/6/2011 at 07:43 PM, Dan Stromberg drsali...@gmail.com wrote:

 On Wed, Apr 6, 2011 at 12:47 AM, Adriaan Renting rent...@astron.nl
wrote:


 This solves the problem using stdin=open(os.devnull, 'rb') instead
of
 stdin=None makes it run even if there is input from stdin in the
 foreground process.

 The operating system is Ubuntu 8.04
 I understood what Suspended (tty input) means. I don't understand
why
 it waits for input if stdin=None.

 Thank you for your help.

 Adriaan Renting.
 --
 http://mail.python.org/mailman/listinfo/python-list
 
 http://docs.python.org/library/subprocess.html
 With None, no redirection will occur; the child*s file handles
will
 be inherited from the parent.
 
 When a background process reads from a tty (which is most likely
what
 its inherited stdin is connected to), it gets a SIGTTIN, suspending
 your background process.
 
 See also ssh -n.

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


Re: Behaviour of subprocess.Popen, ssh and nohup I don't understand

2011-04-06 Thread Adriaan Renting


 On 4/1/2011 at 07:33 AM, Kushal Kumaran
kushal.kumaran+pyt...@gmail.com
wrote: 
 On Fri, Apr 1, 2011 at 4:31 AM, Adriaan Renting rent...@astron.nl
wrote:
 L.S.

 I have a problem that a background process that I'm trying to start
with
 subprocess.Popen gets interrupted and starts waiting for input no
matter
 what I try to do to have it continue to run. It happens when I run
it
 with nohup in the background.
 I've tried to find a solution searching the internet, but found
none.
 I've written a small test script that reproduces the problem and
hope
 maybe here there is someone who can tell me what's going wrong. Any
 suggestions are welcome.

 (renting)myhost cat test.py
 #!/usr/bin/python
 # script to test subprocess problem
 import subprocess, sys, time

 for f in range(3):
  command = [ssh, -T, localhost, uptime]
  comm = subprocess.Popen(command, shell=False, stdin=None,
 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
  print  '1'
  if comm.returncode:
print error: %i % (comm.return_code)
  else:
print  '2'
(output, output2) = comm.communicate(input=None)
print output
print output2
  print  '3'
  time.sleep(3)

 (renting)myhost python --version
 Python 2.5.2

 (renting)myhost nohup ./test.py -O2 
 [1] 15679

 (renting)myhost 1
 2
  22:40:30 up 24 days,  7:32,  1 user,  load average: 0.00, 0.00,
0.00

 None
 3
 1
 2

 [1]  + Suspended (tty input) ./test.py -O2
 (renting)myhost fg
 ./test.py -O2

  22:40:35 up 24 days,  7:32,  1 user,  load average: 0.00, 0.00,
0.00

 None
 3
 1
 2
  22:40:56 up 24 days,  7:32,  1 user,  load average: 0.00, 0.00,
0.00

 None
 3

 (renting)myhost

 Now as you can see, it suspends on the second time through the for
loop,
 until I bring it to the foreground and hit .
 What you don't see, is that I make it do this by pushing the arrow
keys
 a couple of times. The same happens when I would exit the shell,
despite
 it running with nohup.
 I don't need to exit to make it suspend, any combination of a few
random
 keystrokes makes it do this. It seems depending on the timing
though,
 during the sleep(3) it seems to ignore me, only when subprocess is
 actually running will it suspend if I generate keystrokes.
 If the ssh command is executed without -T option it suspends
directly,
 so I think it's related to the ssh command. I log in with a
 public/private key pair to avoid having to enter a password.

 Any suggestions are welcome,

 
 What operating system is this?  Try with stdin=open(os.devnull,
'rb')
 to the Popen call instead.  Also, this seems to be similar:

http://stackoverflow.com/questions/1365653/calling-fgets-on-popen-of-ssh-is-
 flushing-the-beginning-of-stdin-of-the-cal
 
 The Suspended (tty input) message means that a background process
 tried to read from stdin, so got suspended.  This is part of the job
 control mechanism.
 
 -- 
 regards,
 kushal

This solves the problem using stdin=open(os.devnull, 'rb') instead of
stdin=None makes it run even if there is input from stdin in the
foreground process.

The operating system is Ubuntu 8.04
I understood what Suspended (tty input) means. I don't understand why
it waits for input if stdin=None.

Thank you for your help.

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


Behaviour of subprocess.Popen, ssh and nohup I don't understand

2011-03-31 Thread Adriaan Renting
L.S.

I have a problem that a background process that I'm trying to start with
subprocess.Popen gets interrupted and starts waiting for input no matter
what I try to do to have it continue to run. It happens when I run it
with nohup in the background.
I've tried to find a solution searching the internet, but found none.
I've written a small test script that reproduces the problem and hope
maybe here there is someone who can tell me what's going wrong. Any
suggestions are welcome.

(renting)myhost cat test.py
#!/usr/bin/python
# script to test subprocess problem
import subprocess, sys, time

for f in range(3):
  command = [ssh, -T, localhost, uptime]
  comm = subprocess.Popen(command, shell=False, stdin=None,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
  print  '1'
  if comm.returncode:
print error: %i % (comm.return_code)
  else:
print  '2'
(output, output2) = comm.communicate(input=None)
print output
print output2 
  print  '3'
  time.sleep(3)

(renting)myhost python --version
Python 2.5.2

(renting)myhost nohup ./test.py -O2 
[1] 15679

(renting)myhost 1
2
 22:40:30 up 24 days,  7:32,  1 user,  load average: 0.00, 0.00, 0.00

None
3
1
2

[1]  + Suspended (tty input) ./test.py -O2
(renting)myhost fg
./test.py -O2

 22:40:35 up 24 days,  7:32,  1 user,  load average: 0.00, 0.00, 0.00

None
3
1
2
 22:40:56 up 24 days,  7:32,  1 user,  load average: 0.00, 0.00, 0.00

None
3

(renting)myhost

Now as you can see, it suspends on the second time through the for loop,
until I bring it to the foreground and hit .
What you don't see, is that I make it do this by pushing the arrow keys
a couple of times. The same happens when I would exit the shell, despite
it running with nohup.
I don't need to exit to make it suspend, any combination of a few random
keystrokes makes it do this. It seems depending on the timing though,
during the sleep(3) it seems to ignore me, only when subprocess is
actually running will it suspend if I generate keystrokes.
If the ssh command is executed without -T option it suspends directly,
so I think it's related to the ssh command. I log in with a
public/private key pair to avoid having to enter a password.

Any suggestions are welcome,

thanks,

Adriaan Renting

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


Re: Redirect os.system output

2005-10-25 Thread Adriaan Renting
Maybe Pexpect can help you, I think it does what you want, I'm just not sure it 
works on windows, as I think it uses pty's.

Please read it's FAQ about stdio buffer behaviour, I think it's also valid on 
Windows. pexpect.sourceforge.net

Adriaan Renting.
 
 
jas [EMAIL PROTECTED] 10/24/05 2:33 pm  
#I see that, although I don't totall grasp the code.  However, I am 
#looking to basically emulate a command prompt.  i.e. everything u see 
#in the windows command prompt should be displayed back in python. 
# 
#How can I do it without files? 
# 
#Kent Johnson wrote: 
#jas wrote: 
#Any other ideas? or examples of using subprocess to do what I was 
#asking? 
# 
#Actually I thought I was giving an example of what you were asking: 
#- on windows 
#- send a series of commands to a command process 
#- capture the result to a variable 
# 
#The example I referenced sends a series of HELP commands to cmd.exe, captures 
the output of the commands and saves it to a #file. 
# 
#What did I miss? 
# 
#Kent 
# 
# 
# 
#Kent Johnson wrote: 
# 
#jas wrote: 
# 
#I would like to redirect the output from os.system to a variable, but 
3am having trouble.  I tried using os.popen(..).read() ...but that 
#doesn't give me exactly what i want. 
# 
#Here is an example using subprocess: 
#http://groups.google.com/group/comp.lang.python/msg/9fa3a3c287e8e2a3?hl=en; 
3 
#Kent 
# 
# 

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Adriaan Renting
David Schwartz [EMAIL PROTECTED] 10/25/05 6:06 am  
 
 Do you think it would be immoral if Microsoft said, we will only sell 
Windows wholesale to dealers who don't sell other operating systems? 
 
   DS 
7 
 
It goes one further as that, MS had the tactic of we will only sell Windows 
wholesale to dealers who do not sell computers without Windows. It's not even 
about selling an other OS, it's about selling a computer without an OS.

I realy liked the aussie toshiba example, I had read it before, but it realy 
makes it clear how firm the grip is MS has on the hardware manufacturers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-25 Thread Adriaan Renting
David Schwartz [EMAIL PROTECTED] 10/25/05 9:44 am  
% 
%Peter T. Breuer [EMAIL PROTECTED] wrote in message 
%news:[EMAIL PROTECTED] 
% 
%Essentially, Microsoft asked for exclusive arrangements. That is, 
%arrangements wherein you could not sell competing products if you wished 
%to 
%sell Microsoft products. That's not even remotely unusual. 
% 
%It soitenly is, stanley. In case you hadn't noticed, the shops sell 
%more than one kind of washing powder. 
% 
%   Your argument is nonsensical. Because you can find one category of goods 
%that don't have the property I'm talking about it follows that the property 
%is unusual?! 
% 
%   Operating systems are not like washing powder at all. Try to sell both 
%Big Macs and Whoppers in one store. Heck, try to sell Craftsman tools 
%without being a Sears. Microsoft gets to decide whether they sell their 
%operating systems software like washing powder or like burgers, not you. 
% 
The thing it, that under certain circumstances, defined by law, it becomes 
illegal to ask for exclusive arrangements. One of these is if you have a 
monopoly. Another is the way the Mob asks for protection money.
IANAL, so I don't know the exact wording, but sometime in the past the USA 
representative bodies/government decided that under certain conditions it is 
illegal. (and others like my own country) The in the 2000-2004 lawsuit it was 
proven that these conditions applied to MS. It happened before (Standard oil, 
American Tobacco Company, ATT).

I'm unsure if your point is that antitrust laws should not exist, or that they 
should not apply to MS.

If you think those laws should not exist, I suggest you investigate why they 
were created, and maybe write your representative in your government to change 
this.

If you think they should not apply to MS, but you in general agree with them, 
then I think you should investigate why the laws were found to apply to MS.

Interesting information can be found here:
http://en.wikipedia.org/wiki/Antitrust
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDE recommendation please

2005-10-24 Thread Adriaan Renting
kery [EMAIL PROTECTED] 10/23/05 9:33 am  
Alex Martelli wrote: 
microsnot [EMAIL PROTECTED] wrote: 
 
 
Any suggestions for Linux, specifically SuSE or perhaps Red Hat? 
 
Thanks in advance, 
Kery 
 

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


OT: MS litigation history, was MS FAQ

2005-10-18 Thread Adriaan Renting

 
 
David Schwartz [EMAIL PROTECTED] 10/18/05 7:21 am  
 
Roedy Green [EMAIL PROTECTED] wrote in 
message news:[EMAIL PROTECTED] 
 
On Mon, 17 Oct 2005 19:44:55 -0700, David Schwartz 
[EMAIL PROTECTED] wrote or quoted : 
 
   It is not Microsoft's obligation to be fair. It is Microsoft's 
obligation to push their vision of the future of computing, one with 
Microsoft's products at the center, using anything short of force or 
fraud. 
 
I think that what they did borders on force/fraud. 
 
   I don't think any of it bordered on force or fraud. However, their 
obligation to their shareholders requires them to do anythign that borders 
on force/fraud so long as it isn't force/fraud. However, the use of things 
too close to force/fraud often backfires. Microsoft has an obligation to be 
strategic and look nice where those things beneficially impact the bottom 
line. 
 
   It's Bill Gates' job to make his company worth as much as possible. 
 
   DS 
 


I think MS obligation to its shareholders to maximise profits, does seem to 
make them cross the line quite frequently. Because of the slow legal process it 
seems that it's more profitable to do so.
A lot of these were however settled out of court, so technically, in a lot of 
them MS was not proven to have crossed the line, it does show a certain pattern 
though, some examples for googling Microsoft lawsuit:
- 1982 Microsoft vs Seattle Computer Products, settled out of court.
- 1982 Microsoft vs Digital Research, DR won.
- 1985 Microsoft vs Apple, settled by Apple leasing MS access to the MacOS code.
- 1988-1998 Microsoft vs Apple, settled out of court, MS buys $150 mil Apple 
stock
- 1989 Microsoft vs DEC, settled out of court, MS paid $150 mil
- 1994 Microsoft vs Stac Electronics, MS lost, paid $84 mil
- 1996 Microsoft vs Novell/Caldera, settled out of court, MS paid $200 mil
- 1998-2002 Microsoft vs DOJ20 states, MS lost, MS ordered to split up 
overturned in appeal.
- 2003 Microsoft vs Time-warner, settled out of court, MS pays $750 mil
- 2004 Microsoft vs EU, MS fined $613 mil
- 2004 Microsoft vs Sun, settled out of court, MS pays $700 mil

these guys also have a list, but it contains very few details:
http://www.theinquirer.net/?article=24621
They compute a total of over 9 billion in fines/settlements over the 30 year 
history of Microsoft.
 
To me it seems that MS finds it more profitable to do cross the line, and just 
pay the fines afterwards. I find it a real flaw in the corporate legal system 
that this is a valid way of doing business. That's a whole different topic 
though.


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


Re: Hygenic Macros

2005-10-18 Thread Adriaan Renting
Using numarray/pylab there's also dot:
 from pylab import *
 A = array(range(10))
 B = array(range(10))
 A * B
[ 0, 1, 4, 9,16,25,36,49,64,81,]
 dot(A, B)
285

It might also make your code more readable. I would like A dot B, but even 
using ipython
I can only get as close as dot A, B
 
Dan Farina [EMAIL PROTECTED] 10/18/05 1:33 pm  
David Pokorny wrote: 
Hi, 
 
Just wondering if anyone has considered macros for Python. I have one 
good use case. In R, the statistical programming language, you can 
multiply matrices with A %*% B (A*B corresponds to pointwise 
multiplication). In Python, I have to type 
 
import Numeric 
matrixmultiply(A,B) 
 
which makes my code almost unreadable. 
 
Thanks, 
David 
 
The problem here is that Python's parse trees are of non-trivial ugliness. 
 
A page on the compiler.ast module: 
http://docs.python.org/lib/node792.html 
 
it is, in fact, perfectly possible to write yourself a pre-processor for 
your particular application.  You may have to fiddle with the token you 
want for notation depending on how the AST fleshes out (% is used by at 
least a couple of things, after all).  My cursory familiarity with 
python grammar suggests to me that this particular choice of token could 
be a problem. 
 
I would say try it and see.  Keep in mind though that since Python's AST 
is not a trivial matter like it is in Lisp and the like that doing 
metaprogramming of this sort probably falls into the category of black 
magic unless it turns out to be very trivial. 
 
Another option is to define your own tiny class that will override the 
__mult__ method so that you can simply do: 
 
A * B 
 
Which may not be what you want. 
 
df 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


OT: On Microsoft monopolies, was MS FAQ

2005-10-17 Thread Adriaan Renting
Jeroen Wenting jwenting athornetdotdemondotnl@bag.python.org 10/16/05 
11:49 am  
% 
%Peter T. Breuer [EMAIL PROTECTED] wrote in message 
%news:[EMAIL PROTECTED] 
%In comp.os.linux.misc Jeroen Wenting jwenting at hornet dot demon dot nl 
%wrote: 
%Without Microsoft 90% of us would never have seen a computer more 
%powerful 
%than a ZX-81 and 90% of the rest of us would never have used only dumb 
%mainframe terminals. 
% 
%Uh - when microsoft produced dos 1.0, or whatever it was, I was sitting 
%at my Sun 360 workstation (with 4M of RAM, later upgraded to 8M), 
%running SunOS 3.8 or thereabouts. 
% 
%And how many people who now have $500 PCs ($200 of which is the cost of the 
%OS) would have been able to afford those? 
% 
%My point is that Microsoft made computers that were more than glorified 
%gaming consoles affordable for the common man. 
%They are the ones who lowered the price of shrinkwrapped software for home 
%and office application from thousands or tens of thousands to hundreds of 
%dollars. 
% 
% 

Microsoft never made any computers (before Xbox that is) and never had any 
control over the hardware price. The prices of hardware have very little to do 
with the software they run, but mostly with developements in IC manufacturing 
techniques.

As for prices on software, they went down because the market expanded, because 
of cheaper hardware.

The only real technological advantage MS had over a lot of it's competitors, is 
that it tried to have it's OS run on as much hardware as possible. Not being 
tied to a single hardware vendor is what made MS big. IBM's choice not to 
create their own OS, and use of the shelve parts, has enabled all the clone 
builders (most notably Compaq) to enter the PC-compatible market easily.

I think commercial software in general is a market that tends towards creating 
monopolies, because of the network effect. MS played the right tactics to 
become the OS monopoly. It has since been using all kinds of shady, sometimes 
illegal tactics to maintain this monopoly, and leverage it to gain others.

The Car+engine analogy is flawed, another analogy could be if sandwiches were 
only sold with Heinz products, you could choose betweeen peanut butter, 
strawberry jam or sandwichspread, but if you wanted Calve peanut butter, you 
would still need to pay for a jar of Heinz peanut butter too.


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


OT: OS monopolies, was MS FAQ

2005-10-17 Thread Adriaan Renting
John Bokma [EMAIL PROTECTED] 10/17/05 5:27 am  
#Roel Schroeven [EMAIL PROTECTED] wrote: 
# 
# 
#Maybe they can force it, maybe not, but that's not the point (again). 
#The point is what their intentions are, and that is trying to lock 
#people into using their software. 
# 
#Can you name big companies that don't do this? 
# 

I know that some companies, for example Adobe with PDF and postscript, have 
been much nicer in having other software interoperate/compete with them. I 
think it's why MS is currently targetting them (Metro, Digital Image).

Don't be to surprised if Acrobat, Illustrator or Photoshop has trouble running 
on Vista.

I do agree that most companies would probably try some of the same tactics, but 
that's why it's illegal to abuse monopoly power. Some of MS faults are inherent 
to how the software market works, for example that it's pace is much higher as 
what the justice system can keep up with.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UI toolkits for Python

2005-10-14 Thread Adriaan Renting
I realy like developing PyQt applications using the Eric3 IDE. I find Qt really 
has a lot of high level functionality already available for you, I like the 
flexibility of the slot-signal system, I like that the Qt C++
maps very well into object-oriented Python though PyQt. You can just use the Qt 
C++ documentation.
Just check out Eric3 itself as an example of what you can do in PyQt. It's not 
yet ported to Qt4 AFAIK, but I suppose it will not take long. In Qt4 the 
licencing is no issue for me as I'm only writing GPL code anyway.
I don't know how it performs on OSX, I think it works fine, as Qt is available 
on OSX.

I don't know what you want in a text widget, but the kTextEdit I use comes with 
functions like checkSpelling(), undo(), copy(), paste(), setFont(). Hooking 
these up to for example a fontRequestor is no more work as adding both to the 
form in QtDesigner (integrated in Eric3), and connecting the appropriate signal 
and slot. It could be some of these are only available if you have KDE 
installed.
I realy like the Canvas allowing sprites, zooming, rotating, etc.

I've never done much with TkInter, so I can't compare. I think it's easier as 
wxwindows, it's easier as VCL/CLX and MFC. (I'm comming from the 
Windows/Borland C++/Delphi world)

The standard Python shell only has buildin support for the TkInter event loop 
AFAIK, I just heard ipython is more cross GUI toolkit in this regard.

I don't think there's any consensus. I think any of a Tk, Wxwindows, GTK or Qt 
based solution might work for you, depending on what you are used to. Tk seems 
to be most traditional Python, but I think it's ugly, and I realy like the high 
level functionality that Qt provides.

Adriaan Renting.
 
 
Kenneth McDonald [EMAIL PROTECTED] 10/13/05 10:17 pm  
Is there any emerging consensus on the best UI for toolkit.  Tk  
never quite made it but from what I can see, both qt and wxWin are  
both doing fairly well in general. I'm already aware of the licensing  
issues surrounding qt (fwiw, I think their license fee for commercial  
use is eminently reasonable), so aside from that, I was wondering if  
there was any feedback readers could provide on the following: 
 
1) Which plays best with Python? Ideally, it would already have some  
higher-level python libraries to hide the grotty stuff that is almost  
never needed when actually implementing apps. 
 
2) Reliability of each? 
 
3) Useful external libraries for each? 
 
4) Ease of installation/use on OS X? 
 
Something with a genuinely useful text widget would be nice, but I  
know that's too much to expect...ah, TkText widget, where are you  
when I need you. 
 
 
Thanks, 
Ken 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: UI toolkits for Python

2005-10-14 Thread Adriaan Renting
Mike Meyer [EMAIL PROTECTED] 10/14/05 5:39 pm  
$Adriaan Renting [EMAIL PROTECTED] writes: 
$[On Qt] 
$I don't know how it performs on OSX, I think it works fine, as Qt is 
$available on OSX. 
$ 
$Qt on OS X is halfway there. It looks - and acts - like an aqua 
$application. However, to support the Command key, they hacked things 
$so that it is reported to the upper layers as the Control key. This 
$means that there's no way to get to use the control key in the UI for 
$qt apps on OS X. 
$ 
$This really rapes apps with configurable shortcuts. For instance, LyX 
$comes with a couple of emacsish bindings. You can turn them on, but 
$you have to use Command-key instead of Control-key, which pretty 
$thoroughly defeats the purpose. 
$ 
$  mike 

I think to some extent it's a general problem with cross-platform toolkits, 
altough I agree that I think the way Trolltech solved it for OS X might be 
sub-optimal, depending on how the command key is supposed to work.

You have the problem that some keyboard layouts have OS specific keys (Windows 
key, menu key on some PCs, Command key on apples) which you can't support in a 
cross-platform way. If using Command-Letter is the standard way of having 
keyboard shortcuts in OS X, then I think I can understand why they choose this 
implementation,. I suppose the Command key is more integrated into the OS as is 
the Windows key in Windows. I think it would be nice if you could choose the 
mapping.

The basic problem is that a widget toolkit that supports 
control/shift/alt/command as meta-keys can not be cross-platform, as the 
command key has no equivalent in windows or linux. How do the other widget 
toolkits handle this, do they ignore the Command key? What does Linux 
PPC/YellowDog do with the Command key?

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


Re: UI toolkits for Python

2005-10-14 Thread Adriaan Renting

 
 
Mike Meyer [EMAIL PROTECTED] 10/14/05 5:39 pm  
#Adriaan Renting [EMAIL PROTECTED] writes: 
#[On Qt] 
#...
#[mike on qt for Mac Os X]
#...

I've looked some more into this, and it seems that the confusion is because Qt 
on Mac maps:

Command/Apple key - Qt::Key_Control
Ctrl Key  - Qt::Key_Meta
Alt/Option Key- Qt::Key_Alt

because the use of the Command/Apple key is similar to how in Windows and KDE 
the Ctrl key is used.
This results in Command-S being Save, Command-A being Select All, which seems 
to be the way it's supposed on Apple, but it creates confusion if 
cross-platform documentation would say Ctrl-A is Select All, because this isn't 
true on Apple. Maybe the Apple GUI guidelines can answer how it should be.

How do other widget sets handle this? do they use: 
Command/Apple key - Key_Meta
Ctrl Key  - Key_Control
Alt/Option Key- Key_Alt

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


Re: IDLE dedent/unindent key bindings for non-us keybord?

2005-10-12 Thread Adriaan Renting
You could try using the Qscintilla based Eric3 IDE, it uses Ctrl-i and 
Ctrl-Shift-i. 
 
[EMAIL PROTECTED] 10/02/05 5:52 pm  
|What could be wrong here, and do you have any other suggestions for a 
|dedent key binding that may work on a non-us/swedish keyboard (or 
|maybe an alternative editor for python code). 
| 
|Thanks. 
| 
|
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting C++ array into Python

2005-10-12 Thread Adriaan Renting
try using SWIG?
You give very little information about how you are trying to accomplish this. 
From your mention of C++ you seem to mean a vector, not an array, I suggest you 
read the documentation of SWIG, and maybe someone can help you if you give a 
clear example of what you are trying to accomplish, how, and why it fails.

Adriaan Renting.  
  
Deshdeep, Singh (IE10) [EMAIL PROTECTED] 10/04/05 7:33 am  

 I am extending C++ application with python. I am not able to convert a C++ 
array in Python.
 
 If anyone has the experience of the below :-   
  1)How to handle the C++ array in the Python code and how to input 
that from the script ?   
 
 Awaiting for the solution   
 
 Regards   
 DD   
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Soap Question (WSDL)

2005-09-30 Thread Adriaan Renting
You need the WSDL file if you want external probrams to be able to discover 
what WebService you are running, so it depends on your need if you need to use 
one. You can perfectly run a SOAP service without a WSDL file, using SOAPpy, 
only then external programs do not have a way to find out how to talk to you.
A WSDL file just defines what messages, operations, urls etc. you 
accept/send/offer.
If your external applications know how to talk to you, you can do without a 
WSDL file.

It contains stuff like:
   wsdl:message name=sayHelloResponse1
  wsdl:part name=sayHelloReturn type=soapenc:string/
   /wsdl:message
...
  wsdl:operation name=sayHello
 wsdlsoap:operation soapAction=/
 wsdl:input name=sayHelloRequest1
wsdlsoap:body 
encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; 
namespace=urn:something.test use=encoded/
 /wsdl:input
 wsdl:output name=sayHelloResponse1
wsdlsoap:body 
encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; 
namespace=urn:something.test use=encoded/
 /wsdl:output
  /wsdl:operation


 
 
Armin [EMAIL PROTECTED] 09/30/05 12:56 am  
Hey everyone, 
 
I am trying to write a web app. that connects to flickr using SOAP. The 
book 'Dive into python' says I need to have a WSDL file to connect, 
while the only useful soap related url flickr api 
(flickr.com/services/api) provides is the following: 
 
The SOAP Server Endpoint URL is http://www.flickr.com/services/soap/ 
 
What am I supposed to do here? Help is very much appreciated at this 
point. 
 
Thanks, 
Armin 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Ide RAD for linux?

2005-09-23 Thread Adriaan Renting
I use Eric3 as IDE on Linux.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Stampare su stampante aghi

2005-09-23 Thread Adriaan Renting
|lux [EMAIL PROTECTED] 09/22/05 4:01 pm  
|Salve a tutti, 
|sono alle prese con delle stampe su 
|stampanti ad aghi... 
| 
|Per stampare puro testo la soluzione più gettonata 
|sembra essere 
| 
|f = open(LPT1:) 
|f.write(bla bla) 
|f.close() 
| 
|devo dire che funziona benissimo, ma mi piacerebbe 
|essere slegato falla parallela (sempre meno frequente) 
|e inviare il puro testo da stampare scegliendo una delle 
|stampanti installate sulla macchina senza starmi a 
|preoccupare di come o dove sia configurata (locale, rete, usb, etc). 
| 
|Come posso fare? 

Non lo so. No comprendo su questione. Parlo solomente un piu Italiano. Puoi 
demandare su questione an Inglese per favore?
I don't know. I do not understand your question. My Italian is very limited. 
Can you ask your question in English please?

|Grazie, Luca. 
| 
|-- 
|http://mail.python.org/mailman/listinfo/python-list 

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


Re: Python and Unix Commands

2005-09-20 Thread Adriaan Renting
Adriaan Renting [EMAIL PROTECTED] 09/19/05 11:20 am  
| 
|P.S. you don't need to post your question to this list every 5 minutes. 
| 
Hmmm, somehow my reply also got posted more than once...
At least that's what it looks like in my mail viewer, I only see one post in 
Google. 
Maybe it's just Groupwise that's giving me phantom messages, I appologize for 
my remark if that's the case.
I hope Groupwise 7 will be an improvement over my current 6.5.
 
 

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


Re: Python and Unix Commands

2005-09-19 Thread Adriaan Renting
Depending on what you axactly want there are a lot of ways to do this.
There is the subProcess module, there is the pty module, there is os.system, 
there is the popen module,
and my personal favorite is Pexpect (pexpect.sourceforge.org). Read the 
documentation of these modules is my first suggestion.

Adriaan Renting.

P.S. you don't need to post your question to this list every 5 minutes.
 
 
|timdoyle05 [EMAIL PROTECTED] 09/19/05 10:46 am  
|Hi, 
| 
|  I have a question relating to how Unix commands can be issued from 
|Python programs. Im am currently writing a large test script in python 
|and I need this script to call three other separate Python scripts, 
|where each one executes in it own thread of control. I would like to 
|use a Unix command to get each script to run in its own shell. I have 
|tried using the Commands module but after I issue the 
|first command, execution blocks until I kill the called script. Is 
|there a way around this?? 
| 
|Thanks for your time, 
|I would really appreciate any assistance, 
| 
|Tim. 
| 
| 
| 
|-- 
|http://mail.python.org/mailman/listinfo/python-list 

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


Re: read stdout/stderr without blocking

2005-09-16 Thread Adriaan Renting
Great reply,

I had just mixed Pexpect and subProcess code until I'd got something that 
worked, you can actually explain my code better a I can myself. I find it quite 
cumbersome to read stdout/strerr separately, and to be able to write to stdin 
in reaction to either of them, but at least on Linux you can get it to work. My 
NON_BLOCKing command might be unnecesary, I'll try without it.

The OP seemed interested on how to do this on Windows, but I've yet to see an 
answer on that one I think.
 
Thank you for the reply.

Adriaan Renting
 
|Donn Cave [EMAIL PROTECTED] 09/15/05 6:19 pm  
|In article [EMAIL PROTECTED], 
|Peter Hansen [EMAIL PROTECTED] wrote: 
| 
|Jacek Pop³awski wrote: 
|Grant Edwards wrote: 
| 
|On 2005-09-12, Jacek Pop?awski [EMAIL PROTECTED] wrote: 
| 
|   ready = select.select(tocheck, [], [], 0.25) ##continues 
|after 0.25s 
|   for file in ready[0]: 
|   try: 
|   text = os.read(file, 1024) 
| 
| 
|How do you know here, that you should read 1024 characters? 
|What will happen when output is shorter? 
| 
|It will return however much data is available. 
| 
|My tests showed, that it will block. 
| 
|Not if you use non-blocking sockets, as I believe you are expected to 
|when using select(). 
| 
|On the contrary, you need non-blocking sockets only if 
|you don't use select.  select waits until a read [write] 
|would not block - it's like if dict.has_key(x): instead of 
|try:  val = dict[x] ; except KeyError:.  I suppose you 
|knew that, but have read some obscure line of reasoning 
|that makes non-blocking out to be necessary anyway. 
|Who knows, but it certainly isn't in this case. 
| 
|I don't recall the beginning of this thread, so I'm not sure 
|if this is the usual wretched exercise of trying to make this 
|work on both UNIX and Windows, but there are strong signs 
|of the usual confusion over os.read (a.k.a. posix.read), and 
|file object read.  Let's hopefully forget about Windows for 
|the moment. 
| 
|The above program looks fine to me, but it will not work 
|reliably if file object read() is substituted for os.read(). 
|In this case, C library buffering will read more than 1024 
|bytes if it can, and then that data will not be visible to 
|select(), so there's no guarantee it will return in a timely 
|manner even though the next read() would return right 
|away.   Reading one byte at a time won't resolve this problem, 
|obviously it will only make it worse.   The only reason to 
|read one byte at a time is for data-terminated read semantics, 
|specifically readline(), in an unbuffered file.  That's what 
|happens -- at the system call level, where it's expensive -- 
|when you turn off stdio buffering and then call readline(). 
| 
|In the C vs. Python example,  read() is os.read(), and file 
|object read() is fread();  so of course, C read() works 
|where file object read() doesn't. 
| 
|Use select, and os.read (and UNIX) and you can avoid blocking 
|on a pipe.  That's essential if as I am reading it there are supposed 
|to be two separate pipes from the same process, since if one is 
|allowed to fill up, that process will block, causing a deadlock if 
|the reading process blocks on the other pipe. 
| 
|Hope I'm not missing anything here. I just follow this group 
|to answer this question over and over, so after a while it 
|gets sort of automatic. 
| 
|  Donn Cave, [EMAIL PROTECTED] 

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


Re: IDE, widget library

2005-09-16 Thread Adriaan Renting
I find developing in Eric3 + QtDesigner to be very quick and easy. It does 
everything you want and much more,
only it uses Qt3. The new Qt4 has an official GPL version for Windows, and 
there are GPL ports versions of Qt3 as pointed out by other posters.
I am realy impressed by the elegance of Qt, and because it's all OO C++ PyQt 
mixes easily with Python.
I think your dismissal of Qt is to quick, I suggest you at least take it into 
consideration.
eric3 is a nice IDE for any kind of Python dev, but it realy shines when using 
it to develop Qt apps.
If Qt realy isn't an option I would go with wxWidgets/windows. But basically 
from my POV all the toolkits are available as GPL, so if you need it for free, 
the licencing for all is basically the same.
 
Thomas Jollans [EMAIL PROTECTED] 09/15/05 9:39 pm  
I guess questions like this come all the time here ... well: 
 
I a looking for a python IDE for gnu/linux that : 
- has decent sytax highlighting (based on scintilla would be neat) 
- has basic name completition, at least for system-wide modules 
- has an integrated debugger 
- is open source, or at least free of charge 
 
an integrated GUI designer would of course be cool, but cannot be 
counted as a requirement. 
 
With that I come to the second question: 
What cross-platform GUI libraries are there ? cross-platform meaning 
functional and free on (at least) X11 and Win32 
PyQT obviously doesn't count because qt3 is not free on windows. 
Tk is ugly. (how well) is Tile supported with python ? 
does PyGTK/Glade work on win32 ? 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: read stdout/stderr without blocking

2005-09-14 Thread Adriaan Renting

 
 
Jacek Pop*awski [EMAIL PROTECTED] 09/13/05 9:23 am  
Grant Edwards wrote: 
On 2005-09-12, Jacek Pop?awski [EMAIL PROTECTED] wrote: 
 
   ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s 
   for file in ready[0]: 
   try: 
   text = os.read(file, 1024) 
 
How do you know here, that you should read 1024 characters? 
What will happen when output is shorter? 
 
 
It will return however much data is available. 
| 
|My tests showed, that it will block. 
|

IIRC it only blocks if there's nothing to read, that's why the select.select is 
done, which has a 0.25s timeout.
Please also note the fcntl.fcntl(self._child_fd, fcntl.F_SETFL, os.O_NONBLOCK) 
I do in the beginning of my code.

I basically stole this system from subProcess and Pexpect, both use the same 
mechanic. I just mashed those two together so I can read stdout and stderr 
separately in (near) real time, and reply to questions the external process 
asks me (like password prompts). It works on Linux with Python 2.3.4, the OP 
seems to use a different platform so YMMV. You can poll instead of select I 
think, but probably also only on Unix, this is from an earlier version of my 
code:

##self.poll.register(self._child_fd)
##self.poll.register(self._errorpipe_end)
...
##if self._fd_eof and self._pipe_eof:
##return 0
##ready = self.poll.poll(250)
##for x in ready:
##text = ''
##if (x[1]  select.POLLOUT) or (x[1]  select.POLLPRI):
##try:
##text = os.read(x[0], 1024)
##except:
##if x[0] == self._child_fd:
##self._fd_eof   = 1
##elif x[0] == self._errorpipe_end:
##self._pipe_eof = 1
##if (x[1]  select.POLLNVAL) or (x[1]  select.POLLHUP) or (x[1]  
select.POLLERR) or (text == ''):
##if x[0] == self._child_fd:
##self._fd_eof   = 1
##elif x[0] == self._errorpipe_end:
##self._pipe_eof = 1
##elif text:
...
##self.poll.unregister(self._child_fd)
##self.poll.unregister(self._errorpipe_end)

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

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


Re: read stdout/stderr without blocking

2005-09-14 Thread Adriaan Renting
Please note that popen uses pipes, which are block devices, not character 
devices, so the writes will be done in blocks instead of characters/lines, (you 
can only read something _after_ the application at the other end of the pipe 
has done a flush or written 8192 bytes.

When reading from a pty like pexpect does, your read will not block until the 
stdio block buffer is filled.

Maybe using popen is your problem?  The FAQ of Pexpect explains the problem 
very clearly.
 
 
Jacek Pop*awski [EMAIL PROTECTED] 09/13/05 4:36 pm  
|Grant Edwards wrote: 
|You're right.  I must have been remembering the behavior of a 
|network socket.  Apparently, you're supposed to read a single 
|byte and then call select() again.  That seems pretty lame. 
| 
|I created another thread with single read(), it works, as long as I have 
| only one PIPE (i.e. stderr is redirected into stdout). 
|I wonder is it Python limitation or systems one (I need portable solution)? 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: An interesting python problem

2005-09-14 Thread Adriaan Renting
In my mind all Python variables are some kind of named pointers, I find that 
thinking this way helps me a lot in understanding what I'm doing. I know that 
this is not completely technically correct as in the first two examples there 
is actually a new a.i/a.arr created that shadows A.i, but thinking like this 
helps me. Are there fundamental flaws to think this way?

Example:
class A: 
i = 0  ## Class A has a pointer named i pointing to (int 0 object)
   ## A.i - (int 0 object)
a = A() ## point a.i to the same thing A.i points to
   ## A.i - (int 0 object)
   ## a.i - (int 0 object)
b = A() ## point b.i to the same thing A.i points to
   ## A.i - (int 0 object)
   ## a.i - (int 0 object)
   ## b.i - (int 0 object)
a.i = 1 ## point a.i to a new (int object)
   ## A.i - (int 0 object)
   ## b.i - (int 0 object)
   ## a.i - (int 1 object)
 
class A: 
arr = [] ## A.i - (empty list object)
a = A()  ## point a.arr to the same thing A.arr points to
## A.arr - (empty list object)
## a.arr - (empty list object)
a.arr.append(haha) ## insert (haha string object) into (empty list 
object) both a.i and A.i point to
## A.i - (list object) - (haha string object)
## a.i - (list object) - (haha string object)
a.arr = [xixi] ## point a.arr to a new (list object) pointing to a new 
(xixi string object)
## A.i - (list object) - (haha string object)
## a.i - (different list object) - (xixi string 
object)
A.arr.append(xx)   ## insert (xx string object) into (list object) A.i 
points to
## A.i - (list object) - (haha string object),(xx 
string object)
## a.i - (different list object) - (xixi string 
object)
etc. ...
 
- 
 
class X: 
def __init__(self): 
self.arr = []   ## instances of Class X have a named pointer arr 
pointing to a new (empty list object)
## X.arr does not exist!
m = X()  ## creates a new (empty list object) and has m.arr 
point to it
## m.arr - (empty list object)
n = X()  ## creates a new (empty list object) and has n.arr 
point to it
## m.arr - (empty list object)
## n.arr - (different empty list object)
m.arr.append(haha) ## insert (haha string object) into (list object) m.i 
points to
## m.i - (list object) - (haha string object)
## n.i - (different empty list object)

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

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


Re: Would you pls tell me a tool to step debug python program?

2005-09-12 Thread Adriaan Renting
try Eric3 F6-F10 will probably do exactly what you want.

www.die-offenbachs.de/detlev/eric3.html

 
Johnny Lee [EMAIL PROTECTED] 09/12/05 9:12 am  
Hi, 
  I've met a problem to understand the code at hand. And I wonder 
whether there is any useful tools to provide me a way of step debug? 
Just like the F10 in VC... 
 
Thanks for your help. 
 
Regards, 
Johnny 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: read stdout/stderr without blocking

2005-09-12 Thread Adriaan Renting
Check out the select module, for an example on how to use it:
pexpect.sourceforge.net


 
 
Jacek Pop*awski [EMAIL PROTECTED] 09/12/05 10:07 am  
Popen from subprocess module gives me access to stdout, so I can read 
it. Problem is, that I don't know how much data is available... How can 
I read it without blocking my program? 
 
example: 
 
import subprocess 
import time 
 
command=ls -l -R / 
 
p=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
 
 
while (p.poll()==None): 
print . 
r=p.stdout.read() 
 
 
when you comment out read() - you will notice that loop is working, with 
read() loop is blocked 
Of course I don't need to read() inside loop, but... if output is very 
long (like from make) and I don't read from stdout - command will 
block itself! I tried to increase bufsize, but it didn't help. 
 
Is there a way to read only available data from stdout/stderr? 
Is there a way to not block Popen command without reading stdout/stderr? 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Download Mail Via Python

2005-09-12 Thread Adriaan Renting
You could maybe give some more information about what you're doing, like if you 
use POP or IMAP, the kind of mail server used, etc. I know the at least Outpook 
used some odd MS specific formatting when sending stuff trough Exchange 
(non-HTML/RTF/plain text) for the body. This is the Rich text setting, which 
does not produce RTF, but TNEF. When using Word as the e-mail editor you also 
get funky stuff.

http://support.microsoft.com/default.aspx?scid=KB;en-us;q269186
 
Albert Leibbrandt [EMAIL PROTECTED] 09/12/05 9:14 am  

 I am busy writing a little prog to download mail and put the contents of the 
emails into a database. The problem that I am currently facing is that I can 
view the message body only if it was sent with a mail client other than MS 
outlook or outlook express. What am I missing, any reading material I can have 
a look at? Examples perhaps?   
 
 Thanks in advance.   
 Albert   
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pretty windows installer for py scripts

2005-09-08 Thread Adriaan Renting
The elegant way to do installs on Windows would be by creating an MSI. 
Microsoft provides (IIRC) a simple tool to create those (Orca), that's free. 
Without the Installshield or Wise tools I think it would take quite some effort 
though, because you need to understand all the details of how msi tables work. 
You might be able to get the idea by using orca to look at other msi installs, 
and figure out how they do things.
MSI itself isn't very difficult, but it'll take some time to understand it. If 
you do use it, do not foget to define uninstall actions.
The izfree tools and tutorials on sourceforge might do the trick for you:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/windows_installer_development_tools.asp
http://izfree.sourceforge.net/

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


Re: Job Offer in Paris, France : RD Engineer (Plone)

2005-09-07 Thread Adriaan Renting
 I'm in the US and have no EU papers.  Still feasible?

Unless you and your employer know the to talk the talk and walk the walk, it's 
probably going to be hard. I work at a place in the Netherlands where about 50% 
of the employees are from abroad, with large numbers from places like the USA, 
Canada, Russia, Australia, India etc. and from what I hear it's a lot of hoops 
you need tou jump though. Stuff like getting a house, work permit, car, drivers 
licence will be expensive and very time consuming, more so in Paris. It helps a 
lot if your employer knows to push the right buttons.

Not to discourage you, working abroad can realy be a nice thing to do, but 
expect a lot of paperwork, and a lot of contradicting answers. The basic thing 
is, that most european goventments aren't set up to deal with expats, most 
immigrants are economic and political refugees from the developing world, and 
Europe is trying to make it as hard as possible for them to get in.

And about the French language: Try to find some french radio broadcast on the 
internet or something like that, and see if you can understand it. I find 
reading/writing/speaking French is o.k., but understanding native speakers can 
be very hard. I have a lot easier time understanding for example italians 
speaking French.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-06 Thread Adriaan Renting
Terry Hancock [EMAIL PROTECTED] 08/31/05 11:59 pm  
| I have NEVER seen a closed source application or programming 
| language that came with that much documentation and support. 
| 
|I'm no fan of Microsoft, but in general, the Win32 API is far 
|better documented than is Python. (Just don't use the searching 
|facilities on the MSDev CD's to find the doc; Google it up.) 
| 
|Okay, I was being a little bit tricky here, too.  I said I'd 
|*never seen* better documentation on a closed source application. 
|It's unclear to me whether that means it doesn't exist, or I just 
|can't get hold of it, because it's closed source code. 

In my Windows days I realy liked the Borland documentation, it was way better 
as the Visual Studio/MSDev docs. Borland C++Builder used to come with a 
complete rewrite of the Win32 API docs, next to the docs of it's own API. One 
of the things I realy liked about C++Builder, and haven't found anywhere else*, 
is that if you push F1 anywhere in your code, it will pop up the help of 
whatever object/class/function/lib your cursor is sitting on. No need to hunt 
google or some awkward CD search, just press F1 when you don't remember exactly 
how to call SetModemParams().
(*I'm not current with the latest MS and Borland offerings)

I still hope Novell will be able to get borland to revive Kylix.

I still think the Python docs aren't realy bad, they could benefit from the 
addition of a functionality based index like Qt has, like in 
qt3/doc/html/groups.html. Qt's docs are quite good I think, although I don't 
have a lot of experience with them yet, I have been able to find what I needed.

Some of my colleagues are quite enthousiastic about Root's documentation: 
http://root.cern.ch/root/doc/RootDoc.html.


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


Re: pexpect.exitstatus not working?

2005-09-06 Thread Adriaan Renting
I'm doing something along these lines:

Check if the task is finished and clean up.
(pid, status) = os.waitpid(self._pid, os.WNOHANG) ## clean up the zombie
assert(pid == self._pid)
if os.WIFEXITED(status) or os.WIFSIGNALED(status):
self._pid   = 0
self.exitstatus = status
assert(self.finished())
del self._pid
os.close(self._child_fd)
os.close(self._errorpipe_end)
## Interpret the return value
if (self.exitstatus == 0 or self.exitstatus  255):
if (self.exitstatus  255):
self.exitstatus = self.exitstatus  8
else: self.exitstatus = 0

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


Re: Bicycle Repair Man usability

2005-08-31 Thread Adriaan Renting
I know the Eric3 Python IDE integrates with BRM, but I haven't had a need for 
much refactoring yet, so I haven't installed BRM. I've only used Eric3's 
build-in limited refactoring yet.

Adriaan Renting.

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


Re: Precise timings ?

2005-08-31 Thread Adriaan Renting
One of the limits of at least IBM compatible PC's is that in general they are 
not more accurate as about 1/64 th of a second if I recall correctly. I think 
this is the default tick size of the BIOS clock. Next to that the
BIOS clock itself doesn't need to be very accurate, I can easily drift like an 
hour a year.
Oh, and on top of that: If you are in a multi taksing operating system this 
complicates matters even further. Finally there's interrupts, as other posters 
pointed out.

This explains it very well:
http://www.beaglesoft.com/mainfaqclock.htm

There was a thread with the same question 'time.clock() problem under linux 
(precision=0.01s)' about a month ago.
I think it had some suggestion of using a soundcard sampling rate to get an 
accurate clock. I think that without an external calibrated device, you're not 
going to get any real accurate timing, precission isn't the same as accuracy.

Adriaan.




Adriaan Renting| Email: [EMAIL PROTECTED]
ASTRON | Phone: +31 521 595 200 (217 direct)
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/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: variable hell

2005-08-29 Thread Adriaan Renting
I'm sorry for top-posting and not marking quoted text, but my e-mail reader 
(Novell Groupwise 6 for Linux) does not mark quoted text. The only thing it 
does is the  $NAME $EMAIL $DATE  above the quoted text. Therefore I add 
my comments at the top. The only alternative I have is copying all text to an 
editor, adding quote marks by hand, then copying it back into a new e-mail 
message, but this takes to much of m time. If this is to confusing I will just 
stop posting in this list.

My original code was: exec(eval('a%s=%s' % (count, value)))
Then Rafi said: exec('a%s=%s' % (count, value))
To which I responded that his example does not work in my Python, and I think 
it's invalid.
Then Martin came with: exec 'a%s = %s' % (count, value)
This does work.
But he seems to keep telling me I'm quoting him wrong, while I'm quoting Rafi.

Furthermore I'm going with your suggestion of checking the imp, globals() and 
locals().

Adriaan Renting. 
 
Mike Meyer [EMAIL PROTECTED] 08/27/05 2:24 am  
[The context is totally hosed by top posting and failure to mark 
quoted text. I gave up on recovering it.] 
 
Adriaan Renting [EMAIL PROTECTED] writes: 
 
Not in my Python. 
 
for count in range(0, 10): 
... value = count 
... exec('a%s=%s' % (count, value)) 
 
You left in the extra set of quotes. Try this: 
 
for count in range(10): 
...  value = count 
...  exec 'a%s = %s' % (count, value) 
... 
dir() 
['__builtins__', '__doc__', '__file__', '__name__', 'a0', 'a1', 'a2', 'a3', 
'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'count', 'help', 'readline', 'rlcompleter', 
'sys', 'value'] 
 
I also removed the extraneous parens that you and Rafi both used - 
exec is a statement, not a function. 
 
Of course, your two examples are better done using imp and globals() or 
locals(). 
 
 mike 
 
dir() 
['__builtins__', '__doc__', '__name__', 'count', 'value'] 
for count in range(0, 10): 
... value = count 
... exec(eval('a%s=%s' % (count, value))) 
... 
dir() 
['__builtins__', '__doc__', '__name__', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 
'a6', 'a7', 'a8', 'a9', 'count', 'value'] 
 
 
I myself use code like this to load user defined classes. 
exec(eval('from %s import %s' % (script, script))) 
exec(eval('self.user_class = %s()' % script)) 
self.user_class.run() 
 
But this can probably be done with the imp module too. 
  
rafi [EMAIL PROTECTED] 08/25/05 6:03 pm  
Adriaan Renting wrote: 
You might be able to do something along the lines of 
 
for count in range(0,maxcount): 
 value = values[count] 
 exec(eval('a%s=%s' % (count, value))) 
  
why using the eval? 
  
exec ('a%s=%s' % (count, value)) 
  
should be fine 
  
-- 
rafi 
  
Imagination is more important than knowledge. 
   (Albert Einstein) 
-- 
http://mail.python.org/mailman/listinfo/python-list 
 
 
-- 
Mike Meyer [EMAIL PROTECTED]http://www.mired.org/home/mwm/ 
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: OpenSource documentation problems

2005-08-29 Thread Adriaan Renting
Marked -1 Flamebait, but I'll respond anyway.

I've read the documents he refers to, and although I agree that the Python docs 
aren't perfect, I do not agree with him on which points. I for example do think 
it's important to incude info on which versions of the language support a 
feature.
He seems to think the GNU man pages are nice, but I find them very awkward as 
they have no hierarchical organization, and most miss examples.

I do agree that a lot of OSS projects seem to lack somewhat in the 
documentation department, compared to a lot of commercial software. I would 
give the man page of gcc as an example, it's just one 6600 line blurb. The 
other part where a lot of OSS seems to be lacking is user interface design.

I think the cause is that the OSS movement is almost solely comprised of 
programmers, while in a commercial environment there will be a lot of 
documentation writers and interface designers (and marketing, etc...)
I know I write my own documentation for the code I create, but I know I'll not 
do as good a job as a separate good doc writer would. In general I think the 
programmers should not write the documentation, and should not be the sole 
designers of the UI either.

The good commercial docs are better because there it is understood how 
important this is. I myself have always liked the Borland documentation a lot.

The big question is: how to attract more doc writers to the OSS movement?

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


Re: variable hell

2005-08-29 Thread Adriaan Renting
Oops, you're completely right.

I'm sorry, it is indeed my mistake.
I was thinking people were telling me I was quoting Martin wrong, while I was 
quoting Rafi wrong. I'll promise not quote anybody anymore until I have an 
e-mail program that can quote/copy properly. As reading it in one window, then 
typing it in another to test it, then copying it back, obviously introduced a 
PEBKAC error.

Adriaan Renting

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


Re: variable hell

2005-08-26 Thread Adriaan Renting
Not in my Python.

 for count in range(0, 10):
... value = count
... exec('a%s=%s' % (count, value))
... 
 dir()
['__builtins__', '__doc__', '__name__', 'count', 'value']
 for count in range(0, 10):
... value = count
... exec(eval('a%s=%s' % (count, value)))
... 
 dir()
['__builtins__', '__doc__', '__name__', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 
'a6', 'a7', 'a8', 'a9', 'count', 'value']
 

I myself use code like this to load user defined classes.
exec(eval('from %s import %s' % (script, script)))
exec(eval('self.user_class = %s()' % script))
self.user_class.run()

But this can probably be done with the imp module too.
 
rafi [EMAIL PROTECTED] 08/25/05 6:03 pm  
Adriaan Renting wrote: 
You might be able to do something along the lines of 
 
for count in range(0,maxcount): 
  value = values[count] 
  exec(eval('a%s=%s' % (count, value))) 
 
why using the eval? 
 
exec ('a%s=%s' % (count, value)) 
 
should be fine 
 
-- 
rafi 
 
Imagination is more important than knowledge. 
   (Albert Einstein) 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: file access dialog

2005-08-26 Thread Adriaan Renting
Well, I only know how to do it with Qt:
Dialog = QFileDialog(self.filedir, 'Python files (*.py)', self, 'open 
file dialog') 
self.filename = str( Dialog.getOpenFileName())

I don't think PyQt is available for Qt4 on windows yet.
You might be ablt to use this:
http://www.quadgames.com/download/pythonqt/PyQtGPL10.exe

Tk or wxWindows, or the Windows API itself might also be possible, I have no 
experience with them. Using either Tk or wxWindows should give a portable 
application as well.
 
Wouter van Ooijen www.voti.nl) [EMAIL PROTECTED] 08/26/05 9:52 am  
I have a tool in Python to which I want to add a small GUI. The tools 
currently runs everywhere PySerial is supported. I need a file-access 
dialog. What is the preffered way to to this? Is there a 
platform-independent file-access dialog available, or should I use the 
windows native version when running on windows (and how do I do that)? 
 
 
Wouter van Ooijen 
 
--  
http://www.voti.nl 
Webshop for PICs and other electronics 
http://www.voti.nl/hvu 
Teacher electronics and informatics 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: variable hell

2005-08-26 Thread Adriaan Renting
I was responding to rafi's suggestion, I had not received the exec 'a%s = %s' 
% (count,count) response yet at that time. The exec 'a%s = %s' % 
(count,value) works fine.

Not in my Python.

---snip---

why using the eval? 
 
exec ('a%s=%s' % (count, value)) 
 
should be fine 
 
-- 
rafi 

--- I appologize for any top-posting, and improper inlining, I'm using 
groupwise ---
 
Martin v. Löwis [EMAIL PROTECTED] 08/26/05 10:19 am  
Adriaan Renting wrote: 
Not in my Python. 
 
 
for count in range(0, 10): 
 
... value = count 
... exec('a%s=%s' % (count, value)) 
... 
 
dir() 
 
['__builtins__', '__doc__', '__name__', 'count', 'value'] 
 
You did not copy the suggestion properly: 
 
for count in range(0, 10): 
...   exec 'a%s = %s' % (count,count) 
... 
dir() 
['__builtins__', '__doc__', '__file__', '__name__', 'a0', 'a1', 'a2', 
'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'count'] 
a5 
5 
 
(you can put additional parentheses around the string, but not 
additional quotation marks) 
 
Regards, 
Martin 
-- 
http://mail.python.org/mailman/listinfo/python-list 


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


Re: Should I move to Amsterdam?

2005-08-25 Thread Adriaan Renting
Thank you for your praise of my little country, but depending on your 
definition, the Netherlands might not be as civil as you assume. A lot of my 
foreign collegues commplain about how rude the dutch can be.
Countries like sweden or japan seem to have much better manners.
As to which countries have been civilized for the longest time, the Netherlands 
wouldn't rank very high there either, China, Greece or Egypt have been 
civilized much longer.

I do think however that New york should have it's name reverted to New 
Amsterdam ;-)

 
Tom Anderson [EMAIL PROTECTED] 08/24/05 6:49 pm  
On Wed, 24 Aug 2005, Armin Steinhoff wrote: 
 
Adriaan Renting wrote: 
 
Wade [EMAIL PROTECTED] 08/24/05 2:31 pm  
 
http://www.slate.com/id/2124561/entry/2124562/ Nice little series by 
Seth Stevenson for Americans daydreaming about emigration. Somewhere, 
anywhere ... maybe Amsterdam?  I've never been to the Netherlands 
myself, but it sounds very civilized. 
 
What a joke ... Amsterdam is 'civilized' since several hundreds of years 
:) 
 
Indeed. Perhaps we should rename it Old New York to reinforce the point :). 
 
But yes, the Netherlands is a highly civilised country - up there with 
Denmark and Canada, and above the UK, France or Germany, IMNERHO. I'm not 
going to bother comparing it to the US! 
 
tom 
 
-- 
This should be on ox.boring, shouldn't it? 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: variable hell

2005-08-25 Thread Adriaan Renting
You might be able to do something along the lines of

for count in range(0,maxcount):
  value = values[count]
  exec(eval('a%s=%s' % (count, value)))
 
But I am also wonder: why? 

Peter Maas wrote: 
 suffix = 'var' 
 vars()['a%s' % suffix] = 45 
 avar 
45 
 

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


Re: where does __class__ come from?

2005-08-24 Thread Adriaan Renting
You might find the chapter 3.3 (in my python 2.3.4, it's Special Method 
names) in the reference manual useful, it is the only place I have found sofar 
that describes most of these special methods. It does however not contain 
__class__. I don't know where in the reference manual to find it's description, 
probaly in some Special attribute names chapter I can't find.
 
 
Diez B. Roggisch [EMAIL PROTECTED] 08/23/05 11:26 pm  
Where does __class__ come from, what does it mean and what else is 
being hidden? 
 
I am used to using dir(...) to figure out what I can play with. 
Clearly that does not always work... :-( 
 
Your question has benn answered - let me just add this from the dir()-docs: 
 
Note: Because dir() is supplied primarily as a convenience  for use at 
an interactive prompt,  it tries to supply an interesting set of names 
more than it tries to  supply a rigorously or consistently defined set 
of names,  and its detailed behavior may change across releases. 
 
from 
 
http://docs.python.org/lib/built-in-funcs.html 
 
Regards, 
 
Diez 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Logging all activity on a tty/pty?

2005-08-24 Thread Adriaan Renting
I only do this on Linux, and it will probably not work on all versions of Unix, 
not even to mention Windows, but I basically have used the code of Pexpect and 
removed the part that does the expecting. ;-)
The author of the Pexpect module also has clearly documented potential pitfalls 
in his FAQ. I think you can find it on pexpect.sourceforge.org
See also the documentation of the pty module.
 
 
Dan Stromberg [EMAIL PROTECTED] 08/24/05 1:54 am  
 
Is there a way, using python, to (voluntarily) log all activity in a 
given shell, in a way that should work on pretty much all *ix's with a 
port of python? 
 
Thanks! 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: where does __class__ come from?

2005-08-24 Thread Adriaan Renting
I did mean the Language reference. chapter Special method names. It contains 
a lot of the funky stuff like __dict__ and __getattr__. There is a little info 
in chapter 3.2 about __class__ : __class__ is the instance's class.
 
 


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/

Diez B. Roggisch [EMAIL PROTECTED] 08/24/05 1:13 pm  
 
Adriaan Renting wrote: 
You might find the chapter 3.3 (in my python 2.3.4, it's Special Method 
names) in the reference manual useful, it is the only place I have found 
sofar that describes most of these special methods. It does however not 
contain __class__. I don't know where in the reference manual to find it's 
description, probaly in some Special attribute names chapter I can't find. 
 
Some of these are in the library reference, but lot's of them are also 
in the language reference - which has bitten me quite a few times, but 
by now I know where to look... 
 
Regards, 
 
Diez 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Should I move to Amsterdam?

2005-08-24 Thread Adriaan Renting
Well, I'm not sure if Amsterdam is nice, but the Netherlands is o.k., except 
for the weather.
I'd like to descripbe it as 49 weeks of autumn, 1 week of spring, 1 week of 
summer, 1 week of winter.
Currently my employer only has an opening for a Microwave Antenna designer 
though, sorry no Python coders.
http://www.astron.nl/astron/jobs/index.htm

Seems like a nice column, I'll read it completely some other time.
 
Wade [EMAIL PROTECTED] 08/24/05 2:31 pm  
http://www.slate.com/id/2124561/entry/2124562/ 
 
Nice little series by Seth Stevenson for Americans daydreaming about 
emigration. Somewhere, anywhere ... maybe Amsterdam? 
 
I've never been to the Netherlands myself, but it sounds very 
civilized. 
 
Extra Python connection, besides the obvious one: Is gezellig related 
to the Zen of Python? ( 
http://wordcraft.infopop.cc/eve/ubb.x/a/tpc/f/6351024471/m/2041067571/r/3901049571
 
) 
 
-- Wade Leftwich 
Ithaca, NY 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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



Re: Unix diff command under Window.

2005-08-24 Thread Adriaan Renting
There probably is some free version somewhere, maybe even as part of CygWin.

I've used Araxis Merge on Windows. It used to be shareware. It's nice enough 
that I bought it.
 
 
TonyHa [EMAIL PROTECTED] 08/24/05 3:50 pm  
Hello, 
 
Does any one have using Python to write a Unix diff command for 
Window? 
 
Tony Ha. 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Implementing class methods in C

2005-08-19 Thread Adriaan Renting
I think you'd need to write a C++ class that has the methods you want to 
implement in C++,
then wrap that with SWIG, then inherit from that, though multiple inheritance 
if you also need functions from a base Python class.
The PyQt people use SIP I think, instead of SWIG, might be useful to look into 
that too too.

Adriaan.
 
 
[EMAIL PROTECTED] 08/18/05 6:42 pm  
 
Nope, it still doesn't work. Anyway, that's not exactly what i want, since 
i want func2 to be accessible from all instances of Test() 
 
Naveen 
 
On Thu, 18 Aug 2005, Jeremy Moles wrote: 
 
I honestly don't know the answer to this and I am entirely guessing 
but--does it work without using the new module? That is: 
 
 
 
import _test 
 
class Foo: 
pass 
 
foo = Foo() 
 
foo.bar = _test.func2 
 
foo.bar() 
 
On Thu, 2005-08-18 at 12:09 -0400, [EMAIL PROTECTED] wrote: 
I am having a problem implementing some methods of a python class in C. 
The class is defined in python, but I would like to rewrite some methods 
in c. Here is an example of what I want to do: 
 
file _test.c: 
 
#include Python.h 
 
static PyObject 
func2(PyObject *self, PyObject *args) 
{ 
  if (self == NULL) { 
PyErr_SetString(PyExc_SystemError, self is NULL); 
return NULL; 
  } 
 
  // Parse arguments 
  if (!PyArg_ParseTuple(args, )) 
  { 
return NULL; 
  } 
 
  Py_INCREF(Py_None); 
  return Py_None; 
} 
 
static PyMethodDef TestMethods[] = { 
  {func2, func2, METH_VARARGS, func2.}, 
  {NULL, NULL, 0, NULL} /* Sentinel */ 
}; 
 
PyMODINIT_FUNC 
init_test(void) 
{ 
  (void) Py_InitModule(_test, TestMethods); 
} 
 
 
test.py: 
 
class Test: 
  def func1(self): 
print I am in func 1 
 
import _test 
import new 
Test.func2 = new.instancemethod(_test.func2, None, Test) 
del(new) 
 
t = Test() 
t.func2() 
 
 
When I run test.py, I get a SystemError exception (which is what I raise 
if self is NULL). I think my confusion lies in the use of PyObject* self 
in the function declaration. Shouldn't this be set to point to the 
instance of class Test that I am calling it from? Am I misunderstanding 
the purpose of PyObject* self? Thanks. 
 
Naveen 
 
- 
Naveen Michaud-Agrawal 
Program in Molecular Biophysics 
Johns Hopkins University 
(410) 614 4435 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: time.clock() problem under linux (precision=0.01s)

2005-08-19 Thread Adriaan Renting
One of the limits of at least IBM compatible PC's is that in general they are 
not more accurate as about 1/64 th of a second if I recall correctly. I think 
this is the default tick size of the BIOS clock. Next to that the 
BIOS clock itself doesn't need to be very accurate, I can easily drift like an 
hour a year.
Oh, and on top of that: If you are in a multi taksing operating system this 
complicates matters even further.

This explains it very well:
http://www.beaglesoft.com/mainfaqclock.htm

Adriaan.
 
Szabolcs Nagy [EMAIL PROTECTED] 08/18/05 1:07 pm  
I have to measure the time of a while loop, but with time.clock i 
always get 0.0s, although python manual sais: 
this is the function to use for benchmarking Python or timing 
algorithms 
 
So i tested timer functions capabilities with a short script: 
 
import time 
import os 
 
def test_timer_func(func): 
   print 'min time-time: %.10f'%min(abs(func()-func()) for i in 
xrange(10**5)) 
   print 'max time-time: %.10f'%max(abs(func()-func()) for i in 
xrange(10**5)) 
 
   dt = 0.0 
   loopcount = 0 
   t = func() 
 
   while dt==0.0: 
   dt = func() - t 
   loopcount += 1 
 
   print min measurable loop time : %.10f%dt 
   print 'loopcount while dt==0 :',loopcount 
 
 
print '\n time.clock()' 
test_timer_func(time.clock) 
 
print '\n time.time()' 
test_timer_func(time.time) 
 
print '\n os.times()' 
ot = os.times 
test_timer_func(lambda:ot()[4]) 
 
 
My output is: 
 
time.clock() 
min time-time: 0.00 
max time-time: 0.01 
min measurable loop time : 0.01 
loopcount while dt==0 : 2703 
 
time.time() 
min time-time: 0.019073 
max time-time: 0.460148 
min measurable loop time : 0.050068 
loopcount while dt==0 : 1 
 
os.times() 
min time-time: 0.00 
max time-time: 0.010007 
min measurable loop time : 0.009998 
loopcount while dt==0 : 2515 
 
 
So the precision of time.clock is 0.01s under my ubuntu linux system, 
which means it's not suitable for benchmarking. (i want to benchmark 
the fps in my pygame+pyode program and it needs at least 0.001s 
precision) 
 
time.time seems much better solution, but python manual sais: not all 
systems provide time with a better precision than 1 second 
 
Should i use time.clock or time.time to be more crossplatform? 
Is time.time ok for windows? (time()-time() != 0.0) 
 
nszabolcs 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: win32pipe.popen3

2005-08-18 Thread Adriaan Renting
Well, on Linux I use select first to see if there's something to read. Maybe 
this works on Windows too?

This is my code: 
fd = os.open(filename, os.O_NONBLOCK)
ready = select.select([fd], [], [], 0.25) ## timeout after 
0.25 seconds.
if fd in ready[0]:
text  = os.read(fd, 1024)
lines = text.split('\n')
for line in lines:
print line
else:
print '-'
os.close(fd)

You can maybe use select.poll too.
 
Jakob Simon-Gaarde [EMAIL PROTECTED] 08/17/05 7:51 pm  
Follow-up on a thread from 1999 (see below) 
 
Well now it is 2005 and the operating system I'm using is Windows 
Server 2003, and I can still see that the same problem persists with: 
 
win32pipe.popen2() 
win32pipe.popen3() 
win32pipe.popen4() 
 
while win32pipe.popen() does almost what you want. 
 
import win32pipe 
win32pipe.popen('cmd') 
open file 'cmd', mode 'r' at 0x009DD698 
r=win32pipe.popen('cmd') 
r.readline() 
'Microsoft Windows XP [Version 5.1.2600]\n' 
r.readline() 
'(C) Copyright 1985-2001 Microsoft Corp.\n' 
r.readline() 
'\n' 
r.readline() 
'C:\\backup\\TRPython241\\trpython' 
 
Although I think the last readline ought to return None since no 
carriage return has been issued yet, it is better than popen2,popen3 
and popen4, which all just block the parent process. 
 
The current behaviour of win32pipe.popen2(), win32pipe.popen3() and 
win32pipe.popen4() would be acceptable for me if I knew a way to test 
if there was something ready for reading, but I can't see how to do 
that test, therfore I don't know when to stop reading from output :( Is 
there a solution for this, can I poll/test for ready-read on popen3 I/O 
objects. 
 
Best regards 
Jakob Simon-Gaarde 
 
 
--- 
From a thread in 1999 
High Arpard, 
 
thanx for help but I got probs with that popen3 under Win95: 
'o.readlines()' doesn't return anymore. To find out I checked 
it line per line: 
 
Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam 
import win32pipe 
i,o,e=win32pipe.popen3('ver', 'b') 
o.readline() 
'\015\012' 
o.readline() 
 
'Windows 95. [Version 4.00.]\015\012' 
 
o.readline() 
'\015\012' 
o.readline() 
 
Don't know why, but it never;-) returns. 
Perhaps it may be a bug in win32pipe, that it doesn't return 
becourse readline couldn't find CarriageReturn/EOF? 
 
I took win32pipe.popen('ver','r') for a better solution. 
That works fine. 
 
greetings, 
Holger 
 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: up to date books?

2005-08-18 Thread Adriaan Renting
I learned Python from the Learning Python book that's first on Alessandros 
list. If you have the Second Edition, that includes coverage for Python 2.3, I 
think you have quite a nice introductory book.
As a reference book Python in a Nutshell and of course the Python 
documentation itself are quite good.

Adriaan
 
 
Alessandro Bottoni [EMAIL PROTECTED] 08/18/05 9:02 am  
John Salerno wrote: 
 
hi all. are there any recommendations for an intro book to python that 
is up-to-date for the latest version? 
 
I do not know how much up-to-date they are but I have to suggest you these 
books: 
 
- Learning Python 
By Mark Lutz and David Ascher 
published by O'Reilly 
Most likely the best introductory book on Python 
 
- Python Cookbook 
By Alex Martelli and David Ascher 
published by O'Reilly 
By far the most useful book on Python after your first week of real use of 
this language 
 
Also, the fundamental 
- Programming Python (the 2nd edition ONLY) 
By Mark Lutz 
published by O'Reilly 
Is very useful for understanding the most inner details of Python 
 
would reading a book from a year or two ago cause me to miss much? 
 
No. Python did not changed too much since rel. 1.5. You can still use a book 
published in 2001 as a introductory book (as I do). The changes are 
exhaustively described both in the official documentation and in the very 
fine what's new in... articles written by Andrew Kuchlin for every new 
release (see www.python.org). 
 
CU 
 
--- 
Alessandro Bottoni 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Read from stdouton Popen on WinXP?

2005-08-17 Thread Adriaan Renting
The only way I know how to do this is using a pseudo terminal (pty), but I 
think that only works on Unix. The problem is the way stdout in C works:
- If connected to a character device, it will flush after each line.
- If connected to a block device it will flush only after it's buffer is full. 
Any kind of pipe or file is a block device.

As this is how stdout works even your OS can't help, because as long as the 
application doesn't flush, the output doesn't even arrive at the pipe or file. 
If you have access to the source of the application you can force it to flush, 
otherwise you'll need to find out if anything similar to pty exists in Windows. 
I have 3 years of Windows programming experience, but I don't know of any 
solution.

This probably also means your solution of piping the .exe will not work.

Adriaan Renting.

 mhenry1384 [EMAIL PROTECTED] 08/16/05 11:48 PM 
I am trying to run a program and filter the output on Windows XP.
Since I want to filter the output, I'd like to read it a line at a time
and only print the lines I care about.

p = subprocess.Popen([doxygen.exe, rDoxyfile.cfg],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while 1:
 line = p.stdout.readline()
 if not line:
   break
 print line


The problem is that readline() only returns after the whole process has
completed.  I have tried various permutations such as using os.read()
and changing the bufsize parameter and using popen4.  To no avail.

Obviously, it should be possible to read stdout before the process
completes, since if I leave off the stdout= parameter, the full
output shows up in stdout in realtime as you'd expect.

About the only thing I can come up with is to pipe the .exe to another
python script which could communicate to the main script via TCP/IP,
but that seems ridiculous.  I searched the newsgroup and didn't see
anything particularly helpful.

Anyone have a non-ridiculous solution?

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



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/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SOAP and XMLRPC

2005-08-17 Thread Adriaan Renting
import SOAPpy
   client = SOAPpy.SOAPProxy('http://localhost:80/Webservice')
   server = SOAPpy.SOAPServer(('localhost', 81), )
   server.registerFunction(self.somefunction, 'urn:webservice')


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/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read from stdouton Popen on WinXP?

2005-08-17 Thread Adriaan Renting
As far as I understand it, the buffering is indeed happening in the .exe, 
depending on what it thinks it's stout is connected to. There's nothing the 
operating system, or Python can do about it, if the .exe was created using 
#include stdio.h.

This might help:
http://www.cplusplus.com/ref/cstdio/
http://htmlhelp.sunsite.dk/page.php/9/ch13s20.html
http://pexpect.sourceforge.net/

Especially read the FAQ of Pexpect, it's quite clear.

It took me some time to figure it out too, and I'm not realy happy about it, 
but I suppose that the advantage is, that it's all KR compatible in this way.

I find that as long as one of the stdin/out/err are connected to a terminal, 
stdio will use them as character devices. This is why .exe | more works I 
think: more's stdout$err are a terminal, therefore it's std is a character 
device, and then the pipe is a character device, and then the .exe will have 
stdout as a character device. 
I do not know al the intricate details, but for me Pexpect works, and it's FAQ 
is quite clear, but AFAIK there are no pseudo-terminals on Windows, so you'll 
need to find a different trick.

Adriaan.
 
Matthew Henry [EMAIL PROTECTED] 08/17/05 3:42 pm  
On 8/17/05, Adriaan Renting [EMAIL PROTECTED] wrote: 
that only works on Unix. The problem is the way stdout in C works: 
- If connected to a character device, it will flush after each line. 
- If connected to a block device it will flush only after it's buffer is full. 
Any kind of pipe or file is a block device. 
 
As this is how stdout works even your OS can't help, because as long as the 
application doesn't flush, the output doesn't even arrive at the pipe or file. 
 
Thanks for the info.  I am a longtime C++ programmer, but all GUI 
stuff so I'm afraid I don't really understand how the stdio stuff 
works. 
 
From the cmd prompt, I can pipe the output of the .exe to more and 
see it work in realtime.  Thus I presume the buffering is happening on 
the Python end (or the stdio library that Python is using).  Not in 
the .exe. 
 
So, assuming that's true, why would it help to have the created 
process flush its buffer?  Does that put some kind of special 
character in the buffer that tells Python's stdio library to clear out 
its buffer? 
 
Or is my assumption incorrect, and the buffering is happening in the 
.exe and the cmd shell is working some magic to get at the output? 
 
Know of a good (online) reference that explains how stdin, stdout, 
stderr really works under the covers?  Especially under Windows? 

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


Re: GUI tookit for science and education

2005-08-17 Thread Adriaan Renting
Well, I don't think you want to write everything in HTML, but you can
certainly have a program in Python/perl/PHP/ASP/java that outputs your
user interface in HTML on one side, and maybe talks to Matlab or Root on
the otherside to do the actual science/generate the images.
I wouldn't advice Excel+VBA, unless it's the only thing you have.

 
Thomas Bartkus [EMAIL PROTECTED] 08/17/05 4:50 pm  
Paul Rubin http://[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED] 
Mateusz £oskot [EMAIL PROTECTED] writes: 
Thank you for any piece of advice in advance. 
 
Ask yourself why you want a GUI toolkit.  Maybe you can write a web 
application instead, and use a browser as the GUI.  That's a lot 
easier to write (just use html), and makes it trivial to run the 
application and the browser on separate machines. 
 
Wow Paul! 
I just couldn't help zeroing on that comment. 
   a lot easier to write (just use html), 
 
I would have used adjectives like clunky and limited when talking
about 
using an html in a browser app.  Particularly if we are talking about
high 
powered math/graphs as we often are in the science apps indicated in the

original post. 
 
I would take MS Excel/VBA as the premier fat client prototyping tool/GUI

toolkit for science  education.  How would one go about replicating any
of 
that in an HTML/browser app?  How do we get to easier to write? 
 
   Ask yourself why you want a GUI toolkit. 
I just did.  The answer is that I don't *think* you can do much of that
with 
html. 
 
Then again - I was wrong once :-) 
-Tom 
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Point and click GUI builder for Python

2005-08-08 Thread Adriaan Renting
Use Eric3 with QtDesigner. Works like a charm.

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/
 Madhusudan Singh [EMAIL PROTECTED] 08/06/05 5:39 AM

Is there such a thing for python ? Like Qt Designer for instance ?
-- 
http://mail.python.org/mailman/listinfo/python-list

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


Re: Embedding a runtime graph in Qt3 designer generated UI

2005-08-08 Thread Adriaan Renting
I find Eric3 very easy to work with when using Qt+Python. It will
generate a Python wrapper for your Qt (Designer designed) form, that you
can the sub-class and use as if it was a Python object.
I'm hoping it will be available (together with PyQt, etc.) for Qt4 soon,
but as I'm not paying a dime for it, I can only hope...

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/
 Phil Thompson [EMAIL PROTECTED] 08/08/05 9:21 AM 
 Hi

 Two questions :

 1. Is it possible to use an import command in a qt3 designer code ? (I
 know
 that it is possible to write python inside the braces -- but is it
 possible
 to use an import command for some rather large libraries I wrote that
I
 need to access ?).

You can include import statements in Designer's comment dialog by
prefixing them with Python: . This is covered in the PyQt
documentation.

 2. In the same vein, how does one embed a runtime plot in a qt3 UI ?
It
 will
 need to be a python solution since I am using python libraries to
acquire
 the data.

Have a look at PyQwt which is a set of Python bindings for the Qt-based
Qwt plotting library.

Phil

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

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


Re: Filtering terminal commands on linux

2005-08-05 Thread Adriaan Renting
Thank you very much for you answer.
We are using gear for a couple of reasons, the most improtant being that
we use it in a production environment and it's the only package with
commercial support under Linux that supports Dual Layer DVDs. (at least
according to the person that made the decision to use it)
We've had trouble in the past with cdrecord/dvdrecord.

_I am_ using the batch mode, but still need to be able to parse the
interactive output, as it will stop and try to communicate with the
user, if it encounters a problem.
It's batch mode isn't more sophisticated as gear  batchfile.


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/
 Lonnie Princehouse [EMAIL PROTECTED] 07/29/05 9:38 PM

Firstly, there's probably a better way to do whatever you're trying to
do w.r.t cd/dvd burning.  I'm not familiar with gear, but its webpage
lists Batch file scripting capability as a feature, which suggests
that you might be able to do what you want without parsing output
intended for humans.  There are also a multitude of command-line cd
and
dvd utilities for Linux which might be better for scripting.

That said, it shouldn't be too hard to craft a regular expression that
matches ANSI control sequences. Using
http://www.dee.ufcg.edu.br/~rrbrandt/tools/ansi.html as a reference,
here's how to do this for the first few control sequences...

esc = '\x1B'
start_control_sequence = esc + '['

Pn = r'\d+' # Numeric parameter
Ps = '%s(;%s)*' % (Pn,Pn)   # Selective parameter
PL = Pn
Pc = Pn

control_sequences = [
PL + ';' + Pc + '[Hf]', # Cursor position
Pn + '[ABCD]',  # Cursor up|down|forward|backward
's',# Save cursor position
'u',# Restore cursor position
'2J',   # Erase display
'K',# Erase line
Ps + 'm',   # Set graphics mode
'=' + Pn + '[hl]',  # Set|Reset mode
# ... etc
]

match_ansi = re.compile(start_control_sequence +
'(' + '|'.join(control_sequences) + ')')

def strip_ansi(text):
return match_ansi.sub('',text)


(note: code is untested.. may contain typos)

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

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


Re: Python IDE's

2005-08-02 Thread Adriaan Renting
vi/vim is a godssend if you need a working system that needs to fit in 4
Mb or ROM, but it's an editor not an IDE. You can debate about how good
an editor it is, but that's just differences in taste I suppose.

When talking about IDE's I mean a lot more as 'just' an editor, below is
my 'wishlist', I would be very interested what solutions you use, how
much time it took you to set up this solution, and which parts of my
'wishlist' it implements. Also suggestions to add to my 'wishlist' are
welcome:

- Integrated help.
when I press help button I should get a help page that's appropriate
for the piece of code my cursor currently sits on.
- Code completion.
If I type 'os.path.', the editor should be a ble to show me a list of
all methods and attributes the module has. If I then continue with
'os.path.isfile(', it should show me the parameters for the function.
- Integrated GUI design.
The IDE should have a graphical tool for designing GUIs, and the editor
should be aware of it and propagate changes in an inobtrusive way.
- Integrated debugger.
I should be able to run my module/program from the editor, execute up to
the current cursor position, preset breakpoints (maybe with conditions).
The editor should highlight the current line being executed, and give
you the choice to: step to the next line, step into the execution of the
current line, step out to the function that called the current code, run
to the next brekpoint, etc.
When the code is running I should be able to inspect the values of all
variables currently assigned and change them on the fly.
- Code aware editor.
Syntax highlighting, syntax checking, automatic indentation, loop
folding. Functionality like refatoring, create function from selected
code, inlining current selected function, template macros, coding
mistake warnings (for if (somevar); {do something;} in C/C++ kind of
mistakes).
- Integration with version control system.
- Code documentation/inspection tools.
Ability to generate include and inheritance trees, LOC counters,
profiling what lines of you code get executed most/never, helpfile
generation from code, etc.
- Project management.
Tools for communication with coworkers, bugtracking, which targets need
which files, automatic install scripts/tools, etc.
- Accessible user interface.
All functionality should be accessible through some menu structure, so I
don't need to depend on my memory. Prefereable reprogrammable/assignable
shortcut keys for all functionality, maybe even some form of macros,
plugins, etc.
- For C/C++: 
memory leak detection

Why  I want this?
Because I want to spend my time programming my code, not my developement
environment.

I currently use Eric3+QtDesigner for Python, and while not perfect, I
realy like it. I have used Borland C++Builder for C/C++ in the past for
Windows, but I haven't found a satisfactory C/C++ solution for my
current Linux system yet.

--
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/
 [EMAIL PROTECTED] 08/02/05 4:42 AM 
On Mon, 01 Aug 2005 18:21:08 -0400
Benji York wrote:

 Jon Hewer wrote:
  But, if i use Vi, then whenever i want to test some code i have to
  open up python, import the necessary modules and run it - I like the
  idea of developing python in an IDE and just hitting a run button.
 
 map F5 :wCR:!python %CR

Or, probably even better:

map F5 :wCR:!xterm -e python -i % CRCR

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

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


Re: Opinions on KYLIX 3 (Delphi 4 Linux)

2005-07-29 Thread Adriaan Renting
I've used Kylix 3 in the past, but would not consider it nowadays,
because it's realy behind the times, it can't run on the latest linux
versions and does only support Qt 2.7, while Qt4 has just been released.
I'm a C++ programmer and loved Borland C++Builder, I was disappointed by
how buggy the C++ side of Kylix 3 was.

I think Borland is dead in the water right now, because Microsoft has
been targetting their Delphi/C++Builder succes very agressively. MS has
essentailly bought their entire developement team, and used them to
create VS.Net as an answer to both Java and the Borland developement
environment.

This is more or less fact, there have enven been lawsuits about it:
http://news.com.com/2100-1023-279561.html?legacy=cnet
http://delphi.about.com/od/delphifornet/a/conspiracydnet_2.htm

According to the article Ms is now a large shareholder in Borland, and
will probably halt any further Linux developement.

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/
 David Trudgett [EMAIL PROTECTED] 07/20/05 10:37 AM

Thomas Bartkus [EMAIL PROTECTED] writes:


 Good question!  Wither Borland?

 My impression (second hand - based on no direct experience with
 Kylix!) is that Borlands wonderful Delphi product ported to Linux
 has been a dissapointment.

   * * * Someone with real experience on Kylix - please jump in here!

It has been two or three years since I gave Kylix a try, so my memory
is a bit vague on the specifics. I was working in a Delphi shop and
wanted to port (at least some of) our apps to Linux using Kylix (I
think it was version 3). I think I ported one and a half apps and more
or less gave up or put it on the back burner. My impression was that
Kylix still wasn't ready for serious development work.

The type of application I was working on (porting) involved
client/server database access, and TCP communications with other
applications. It never really worked correctly (I forget what the
problems were just now), but probably could have been made to work
correctly. The point was, however, that porting (a relatively simple)
Delphi app to Kylix shouldn't have been that hard.


 Calling Delphi similar to Visual Basic is hurtful because I
 believe that VB is the product of looting and pillaging the talent
 that came out of Borland.  I'm guessing that Microsoft has
 successfully targeted this perceived competitor with destruction.

 If Kylix were of the quality of Delphi, it would be a killer Linux
app.

Possibly. Unfortunately, I don't believe that the whole GUI building
approach of Delphi/Kylix (or other similar tools) is much chop. It
encourages one, for instance, to just place elements on the screen in
fixed positions that make no allowance for differing fonts, screen
resolutions, etc. Java (my experience is with JBuilder) is much better
in this regard, although the different paradigm takes some getting
used to. However, all GUI builders with which I'm familiar (not many)
seem to have very real limitations when it comes to designing very
complex interfaces. Kenny Tilton's Cells project (ask on
comp.lang.lisp) has set me to thinking along these lines. In the past,
I never gave it much consideration.

Programmers who like Pascal should look at Ada as a better
alternative. If I wanted to program in a Pascal-like language on
Linux, Ada (the GNU Gnat compiler, integrated with GCC) is the one
that I would use. Ada, you could say, is like Pascal on
steroids. Caveat: I've read Ada books, but haven't programmed in it,
and my main concern is that its ultra strong typing might get in my
way -- or alternatively, force greater rigour, as the Ada folks might
say ;-).

These days, for hacking about, I prefer Common Lisp. It's faster
(sometimes approaching the speed of compiled C/Pascal) and much more
powerful than Python, but doesn't have the same library support
(smaller community), and application bundling and delivery *can* be a
potential problem, depending on various factors (such as whether you
want to license a commercial Common Lisp). Also, similar to Python,
there is no standard GUI framework defined for Common Lisp, so
choosing from the GUI frameworks available can be a challenge (I've
only programmed a simple GUI app using the great little Ltk library by
Peter Herth, which talks to Tk over a socket).

My advice would be to steer clear of Kylix and choose one of the other
environments suggested to you. If you really like Pascal, fpc may be a
possibility as someone mentioned. I haven't looked into it any time in
the last couple of years, though, so I don't know its status. I really
would suggest a serious look at Ada, though, if you want to develop
fast, industrial strength applications, or take advantage of built-in
concurrency support and lots of other goodies.

David



-- 

David Trudgett
http

Re: Filtering out non-readable characters

2005-07-29 Thread Adriaan Renting
def StripNoPrint(self, S):
from string import printable
return .join([ ch for ch in S if ch in printable ])


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/
 MKoool [EMAIL PROTECTED] 07/16/05 2:33 AM 
I have a file with binary and ascii characters in it.  I massage the
data and convert it to a more readable format, however it still comes
up with some binary characters mixed in.  I'd like to write something
to just replace all non-printable characters with '' (I want to delete
non-printable characters).

I am having trouble figuring out an easy python way to do this... is
the easiest way to just write some regular expression that does
something like replace [^\p] with ''?

Or is it better to go through every character and do ord(character),
check the ascii values?

What's the easiest way to do something like this?

thanks

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

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


Re: Rich Graphics?

2005-07-28 Thread Adriaan Renting
I realy like Qt through PyQt. The combination Eric3+Qtdesigner is quite
useful. Maybe PyQt is not yet ready for the new Qt4 I think, but it does
lot's of the graphical stuff you seem to require.

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/
 Chris Spencer [EMAIL PROTECTED] 07/28/05 1:14 AM

I'm trying to write a Gui in Python for manipulating rich graphical 
representations, similar to something like Inkscape. I've tried tkinter,

wxPython, pyGtk, and while they all do traditional widgets well enough, 
none of them really handle anti-aliased, transparent, transformed shapes

typical of vector based displays. I've noticed tkZinc, which seems to 
better handle vector graphics through the use of openGL, but it's 
traditional widget set is still limited and based on tkinter. Ideally, 
what I'm looking for is something like wxWidgets which can display SVG 
along side standard widgets and allow there manipulation through Python.

I was thinking of a web-based route, by accessing the SVG capabilities 
in Mozilla's Deer Park browser through Twisted+Livepage, but this has 
been extremely complicated and limiting. Are there any other options I 
haven't considered?

Sincerely,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list

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


Re:

2005-07-01 Thread Adriaan Renting
I'm not a very experienced Python programmer yet, so I might be
mistaken, but there are a few things that would make me prefer C++ over
Python for large (over 500.000 LOC) projects.
- namespaces
- templates
- strong type checking
- data hiding
- more available libraries and more advanced developement tools.

I'm talking about managing the code, not the programmers, the project or
schedules or what have you. Those are independent from the chosen
programming language.

 Ultimately, manageability of a project is far and away more about the
 people involved and the techniques used than it is about any single
 technology involved.

Agreed.

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/
 [EMAIL PROTECTED] 06/30/05 4:15 PM

Peter Hansen [EMAIL PROTECTED] writes:

 Harry George wrote:
  Adriaan Renting [EMAIL PROTECTED] writes:
 Both VB and Python are easier to learn as the more powerful
 languages, the price is that they lack features that make it easier
to
 manage large and complex projects.
  What is a large project, and what is Python missing that C++ and
Java
  have for such tasks?
 
 But C++ and Java have features that *management* likes, thus making it
 easier to manage large projects.  (That says nothing about whether
 or not it makes it easier to produce quality code, successful
 projects, happy customers, large profits, or any such silly
 things... just that it's easier to manage. ;-)
 
 Less facetiously: I have managed a large Python project or three, and
 several large C++ projects (and, thankfully, no large Java projects)
 and found Python quite up to the task.  In fact, if anything the C++
 projects ended up more in danger of succumbing to the sheer weight of
 the code than did the Python projects.  But I attribute this more to
 the fact that we had evolved to using agile approaches with the Python
 projects than to any of those special features either present or
 lacking in C++.
 
 Ultimately, manageability of a project is far and away more about the
 people involved and the techniques used than it is about any single
 technology involved.
 
 -Peter

That's our experience too (and the reason I asked).  I wonder if the
OP will respond.


-- 
[EMAIL PROTECTED]
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
-- 
http://mail.python.org/mailman/listinfo/python-list

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


LOC in Python and C++ in large projects

2005-07-01 Thread Adriaan Renting
I think the point you want to make is that Python needs vastly less
lines of code as a similar application written in C++. I think Python
might on average be 50-60% of comparable C++ code, but not the 1-2% you
seem to want to claim. LOC is a somewhat arbitrairy measurement, but it
gives an idea of what I'm talking about.

Your single example compares a simple use in Python with a much more
elaborate framework in one of the worst C++ IDE's I know. I can easily
give you a counter example:
If I create a simple form in Eric3 it will generate about 500-600 lines
of Python too.
When using this in actual code the difference between a piece of C++ and
Python would however be mostly cosmetic:
void MyForm::exitFile()
{ close();
}
 vs. 
def exitFile(self):
self.close()

Your example is very good at demonstrating why Python is very useful for
simple and small projects. Simple programs are simpler in Python.
All programming languages can be used to write horrible unreadable and
inefficient code. Therefore I think it's better to compare best cases as
it is to compare worst cases.

In the large projects I've worked on most of the code has nothing to do
with external libraries or IDE generated code, but only with other parts
of the project and most of the advantages Python has in small simple
projects are uninportant.
I think C++ gives a little more tools to keep large projects manageable,
mostly because you can find a lot more communication failures between
programmers at compile time.

I think the choice of a programming language is not very important in
determining the overal succes of a project. C++ and Python are however
my two favorite languages.

I think it would be interesting if any readers with more experience as I
have would comment on how Python behaves in large projects, and how much
less lines they need compared to C++ or Java.
I have worked on several C++ projects with a few million lines of code,
I would appreciate experience with comparable projects. (can you do it
in 10.000 Lines of Python?)

 Thomas Heller [EMAIL PROTECTED] 07/01/05 11:36 AM 
Thomas Heller [EMAIL PROTECTED] writes:

 Adriaan Renting [EMAIL PROTECTED] writes:

 I'm not a very experienced Python programmer yet, so I might be
 mistaken, but there are a few things that would make me prefer C++
over
 Python for large (over 500.000 LOC) projects.
 - namespaces
 - templates
 - strong type checking
 - data hiding
 - more available libraries and more advanced developement tools.

 I'm talking about managing the code, not the programmers, the project
or
 schedules or what have you. Those are independent from the chosen
 programming language.

 Just a single datapoint: Implementing a trivial COM object in Python
 requires, let's guess, about 10 or 20 lines of source code.

 When I do the same in MSVC6, the wizard creates 10 files, with nearly
 400 lines of code.  Sure, I didn't have to write these code lines, but
 I'm required to understand and manage them as well.

Sorry, I forgot to include the .dsw and .dsp files in the above figure.
Including them brings the LOC count up to 750 for the C++ project -
although, to be fair, on the Python side a setup.py script for py2exe
would also have to be written.  In simple cases, this is another 10
lines.

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

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


Re:

2005-07-01 Thread Adriaan Renting
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/
 Tom Anderson [EMAIL PROTECTED] 07/01/05 2:50 PM 
On Fri, 1 Jul 2005, Adriaan Renting wrote:
 I'm not a very experienced Python programmer yet, so I might be 
 mistaken, but there are a few things that would make me prefer C++
over 
 Python for large (over 500.000 LOC) projects.

Hmm. I don't know C++, but here goes ...

 - namespaces

Aren't namespaces basically the same as packages/modules in python?

Not in the way C++ uses them. In Python if would be something like this:
---
import os
using namespace casa
class os:
def open(self, file):
pass
a = os.open('something')
b = std::os.open('something')
using namespace std
c = casa::os.open('something')
d = os.open('something')
---
This is a realy stupid example. It's essentially an extra hierarchy
layer to avoid naming clashes. I don't know of a way to do this in
Python, how would you do this?

 - templates

These would be meaningless in python - they're part of typefulness,
which ...

 - strong type checking


Not that this is necessarily a good thing. I have to say that my Java 
roots do lead me to think that strong typing is a plus for big
projects, 
since it's a way of defining and enforcing interfaces between bits of
code 
written by different people (or by one person at different times!). 
Optional static typing in python would be nice for this.

Exactly what I my point is, see also my other post on this (the LOC
post)

 - data hiding

Surely you can hide data in python?

Again, how? Is there a way to force that an external user of my lib can
not use my internal data/methods/classes, unless he uses odd compiler
hacks?

 - more available libraries and more advanced developement tools.

True. The more advanced development tools are offset to a large degree
by 
the advanced crappiness of C++ as a language, though; i'd be surprised
if 
a C++ programmer borged up with all the latest tools was actually more 
productive than a python programmer with a syntax-colouring, 
auto-indenting text editor. It'd be very interesting to get some real 
numbers on that.

I think my point is: I would be, for large projects. Just comparing my
Borland C++Builder experience with my Eric3+QtDesigner experience. This
is not only because of differences between C++ and Python though, a good
IDE alone can make 50% difference but that's another subject.
For small simple projects where I am familiar with the libs I need, I
think I'd prefer Python.

 Ultimately, manageability of a project is far and away more about
the
 people involved and the techniques used than it is about any single
 technology involved.

 Agreed.

+1 getting to the crux of it.

Thank you

tom

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


Re: Reading output from a child process non-blockingly

2005-06-30 Thread Adriaan Renting
I use the pty module, in combination with select.select.
Search for Pexpect for an elaborate example.
It basically goes something like this:


-
import os, select, pty

pid, fd = pty.fork()
fd_eof = 0
if pid == 0:
 os.execvp('ls',['ls']) # child process
else: # parent proces
 while not fd_eof:
   ready = select.select([fd], [], [], 0.25)
   if fd in ready[0]:
 text = os.read(fd, 1024)
 if text == '':
   fd_eof = 1
 else: print text
-
In 2.3.4 this exits with an exception OSError: [Errno 5] Input/output
error after showing the 'ls' output, I have a problem that this works in
2.3.4 but in 2.3.5 this just keeps running indefinately. In my own code
I handle the OSError by setting fd_eof=1. This onyl works on Unix.


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/
 Yuan HOng [EMAIL PROTECTED] 06/29/05 10:08 AM 
In my program I have to call an external program and parse its output.
For that I use the os.popen2 function, and then read the output
stream.

But the complexity is that the external program gives back its output
in a piecemeal manner, with long delays between the outputs. In the
main program I want to therefore read the output in a non-blocking
manner, to read as many bytes as the child process is spitting out.

The question is, how can I achieve that?

I tried use select.select on the output stream returned by os.popen2,
but it returns a readable file descriptor only after the whole child
process ends.

Here is a script simulating the external program:

test.py:
import sys, time
print 'hello\n'*500
sys.stdout.flush()
time.sleep(100)
print 'world\n'*500 

And here is what I am tring to do in the main program to read its
output:

import os, select
cmd = 'python test.py'
pin, pout = os.popen2(cmd)
while not select.select([pout], [], [], some_timeout)[0]:
  pass
pout.readline()

I hope to get the first return very soon, before the external program
sleeps, but instead only after the whole program exits do I get any
output.

Can anyone give me a hint?

-- 
Hong Yuan

 
www.homemaster.cn
-- 
http://mail.python.org/mailman/listinfo/python-list

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


Re:

2005-06-30 Thread Adriaan Renting
I do fundamentally not agree with you that IDE's and GUI design tools
are a waste of time.

I think that with a good IDE (graphical or not) the synergy between
editor, debugger, documentation, refactoring,
translations/internationalization, version control, software modelling,
profiling, metrics, can be very valuable.
Example: At my first employer we could do the same projects in 60% of
the time with Borland C++Builder, compared to MS VisualC++ 6. We would
put this into offerings to customers, esp. if they had a corporate
policy prefering VS 5 or 6.
Some features I realy line about some IDE's I've used:
- Automatic generation of UML diagrams from project code.
- Runtime expression evaluation/data inspection/editing.
- Pressing F1 will bring up the documentation of the class and method
your cursor is on.
- The debugger detects if an object is never deleted in C++, and put me
on the right line in the editor where it is created.
- Include trees.
- Code completion.
- Automatic management of versions in different languages.
- Comparison with older versions of the code.
- Wizards to generate often used dialogs.

If you have never tried Java with Eclipse, C++ with C++Builder or
VisualStudio.Net 2003, or even Python with the less elaborate
Eric3+QtDesigner, then I suggest you do.
Of all the Widget sets I've used (MFC, VCL, wxWindows, TVision, Athena,
Qt) I consider Qt the easiest, it's even available for free on Windows
now!

There is one danger in using IDE's to design GUI's, which is that you do
not properly separate your GUI code from the mechanics of the program.

I think that the natural way to design a GUI is with a WYSIWYG tool.
You have a valid point that you have to conform to the IDE generated
code to some extent. A good IDE will have a nonobtrusive way of handling
this.

--- Everything below here is Harry George's mail.
--
--- No the e-mail program I am forced to use does not support
quoting. -
 [EMAIL PROTECTED] 06/28/05 9:15 PM

#! rnews 2994
Newsgroups: comp.lang.python
Path:
news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp
From: Harry George [EMAIL PROTECTED]
Subject: Re: Boss wants me to program
X-Nntp-Posting-Host: cola2.ca.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: [EMAIL PROTECTED]
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4
Lines: 57
Sender: [EMAIL PROTECTED]
Organization: The Boeing Company
References: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Mime-Version: 1.0
Date: Tue, 28 Jun 2005 18:58:08 GMT
Xref: news.xs4all.nl comp.lang.python:383798

phil [EMAIL PROTECTED] writes:

 
  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.


I agree with your comments on Python and java and IDEs.  I'd like to
expand on the code in assy complaint.

Compiled-to-assy-to-machine-to-execution is understood and
algorithmic.  Any one person may no know it al,l but every step of the
way has been thought out and optimized by someone who knew what he/she
was doing.  There are very few places where anyone has to dive down
into assy, much less microcode or VLSI layouts.

Therefore, we can trust the abstract model provided by the programming
language, and can stay in that model.

This is not the case for GUIs.  We can't safely stay in the abstract
GUI IDE.  In fact, most require you to dive into the generated code to
finish the task.  Bouncing up and down the abstraction ladder is hard
and made harder by being forced to live in the IDE's idea of generated
code.

Given that, GUI IDEs are still helpful if your base langauge is a pain
to write and debug (e.g., C++, Java).  But if your language is
actually easier to use than the GUI IDEs, then the equation shifts.
With Python, the clarity of thought and the opportunities for
higher-level programming (dynamic code genration et al) make GUI IDEs
just a waste of time or worse.

I also have moved to text-based inputs to my own GUI builders.  Maybe
there is a sourceforge project waiting to be borne here :-)

[snip]

-- 
[EMAIL PROTECTED]
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
-- 

RE: Debugger Confusion

2005-06-30 Thread Adriaan Renting
I use the debugger that comes with Eric3, but it is only free for Linux/
OS X, as it needs PyQt.
asside from setting  (conditional) breakpoints, one of it's features is
that it can show you a browsable tree of all your variables. something
like this:
class MyClass
|
L-- string 'username' - 'myuser'
|
L-- list
   L-[0] - 1
   L-[1] - 'some value'

You should know by now that I like this IDE ;-)

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/
 Robert Brewer [EMAIL PROTECTED] 06/28/05 11:02 PM 
Rex Eastbourne wrote:
 I'm a little confused about which debugging utilities do what, and
 which I should use for my Python code. I'd like to be able to step
 through my code, insert breakpoints, etc. I haven't been able to do
 this yet (I'm using Emacs on Windows). I have seen references to GDB,
 GUD, PDB, and others. Which ones do I need?

1. At the point you would like to start the debugger, insert the
following 2 lines:

import pdb
pdb.set_trace()

2. Run your script from the command line.
3. When your script executes the above lines, the pdb debugger will
start up, and give you a prompt. Type 'h' at the prompt (and hit
'enter'), and you'll be shown a list of pdb commands. 's' to step
through your code, 'c' to continue processing (and stop the debugger,
essentially). The prompt is interactive, so you can inspect program
variables as you like.

Start with that, and come back if you have any more questions. :)


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

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


Re: Boss wants me to program

2005-06-29 Thread Adriaan Renting
The question was about someone with limited programming experience
building simple easy to use programs on Windows. This is the niche where
VB and Delphi realy shine. Python with TkInter is kind of o.k., I realy
like Python+PyQt+Eric3+QtDesigner, but currently that only works with a
commercial licence of Qt on Windows, that's why, on Windows, I'd
recommend VB (maybe Delphi) for small projects.
This doesn't mean I would recommend VB for everything. For large
projects C++ or java can both be far superior, depending on needs and
available tools and libraries. I realy like Python for small projects on
Linux. Both VB and Python are easier to learn as the more powerful
languages, the price is that they lack features that make it easier to
manage large and complex projects.

If there is one thing I want to advise, is to get some education, at
least buy a few good books, but only 20+ years of experience can
sometimes substitute for a few good programming classes. If they teach
how to write maintainable code, software design, efficient sorting
algorithms, user interface design, security, etc. then you're on to
something. Courses focussing on a single language often don't teach you
these general programming proinciples.

I think it's important to know how stuff works behind the scenes to some
extent. But I realy like to use all the hard work other people have done
for me.
I prefer QPrinter.print(MyEditor.lines())
to having to push the bits out the LPT myself.

I prefer TMessageBox-Question(Do you realy want to quit)
to having to MOV the bits to my video memory myself.

I realy prefer a WYSIWYG UI design tool
to having to code BUTTON(120, 123, 123, 335, -1, NULL, doButton, Push,
push this button)

Why?
Because people already figured out a way to do that, saving me time, so
I can finish my project on schedule or spend my time on something else.

P.S. I share your worries about the dwindling number of people that
actually have the technical know-how to run our increasingly complex
society. I think it has to do with our society mainly rewarding
charismatic people, and a lack of organisation among the more technical
professions. We should have a bar exam for all programmers!
About teaching in the exact sciences: I think we need a more hands-on
applied approach, to some extent this holds for the entire school
system. I'll stop here, or this will become a long OT rant.

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/
 phil [EMAIL PROTECTED] 06/28/05 8:04 PM 
 
 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.
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.
/rant





-- 
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 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: 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:

2005-06-23 Thread Adriaan Renting
I'm using Eric3 and realy like it.
http://www.die-offenbachs.de/detlev/eric3.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/
 Doug Ly [EMAIL PROTECTED] 06/22/05 4:37 PM 
Is there a good IDE for Python? I have heard that Eclipse has a plugin
for Jython only.

Thanks

 

--Doug

 


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


pty code from 2.3.4 not working in 2.3.5

2005-06-16 Thread Adriaan Renting
I hope you might be able to help me,
as I can't find the cause of my problem.

My sysadmin has upgraded Python from 2.3.4 (SuSE 9.2) to 2.3.5 (from
python.org) Now my code for running an external program no longer works.
My code is largely based on pexcpect.py and quite complex, but the
example below reproduces my problem:

-
import os, select, pty

pid, fd = pty.fork()
fd_eof = 0
if pid == 0:
  os.execvp('ls',['ls'])
else:
  while not fd_eof:
ready = select.select([fd], [], [], 0.25)
if fd in ready[0]:
  text = os.read(fd, 1024)
  if text == '':
fd_eof = 1
  else: print text
-
In 2.3.4 this exits with an exception OSError: [Errno 5] Input/output
error 
after showing the 'ls' output, in 2.3.5 this just keeps running
indefinately. In my own code I handle the OSError by setting fd_eof=1,
after the while I do some waitpid, but this is all irrelevant to the
problem I think.

pty.py doesn't seem to have changed from 2.3.4 to 2.3.5

Do you have any idea what the cause of my program no longer finishing
can be, and what I am doing wrong?

Thank you,

Adriaan Renting.

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