Re: Wheel-reinvention with Python

2005-08-05 Thread Torsten Bronger
Hallöchen!

Mike Meyer <[EMAIL PROTECTED]> writes:

> Torsten Bronger <[EMAIL PROTECTED]> writes:
>
>> [...]
>
> I notice that the Wikipedia doesn't have a definition for "special
> purpose language", instead preferring the phrase "Domain Specific
> Langauge". That matches the definition that agrees with what I
> think is common usage, which is:
>
> Trade some of the flexibility of a general purpose language
> for capabilities that are more tailored to a specific task
>
> Fortran certainly meets the requirements the wikipedia has for
> being a general purpose language.

As does TeX.  I don't think that this adds anything to the
argumentation.

>>> [...] Just like some C/C++ applications are legacy code, and some
>>> aren't. Which contradicts your earlier assertion that C/C++
>>> applications were all legacy code.
>>
>> Reference?
>
> See  http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/c52d3c17f1ea9ec5/d2013c3f1eef49b9?q=wheel+reinvention&rnum=1#d2013c3f1eef49b9
>>, where you dismiss all C applications a legacy code.

This URL points to an article by Paul McNett.

Probably you mean

>>> [...]  By which measure C is still immensely popular, because of
>>> the large number of older applications that are written in it
>>> that are available - Python being one such.
>
> Legacy code is not a sign of success IMO because it implies a
> difficult future.

Calling "older applications" "legacy code" is very different from
calling C/C++ a legacy code language.

> [...]
>
>> [...]  I just want to use a popular langauge amongst the ones
>> that have free success ("free" in the sense of Free Software).
>
> These leaves me with three questions for you:
>
> Is there a free language you consider successful?

Before the quibbling starts again: What do you mean with "free
language"?  For me, that's every language that I can use using
exclusively Free Software tools.

> [...]
>
> Are there any free language that have the GUI/IDE toolkit you
> want?

I don't know.  I haven't seen it yet.  Maybe Eclipse + SWT?

> Have you noticed that languages with really cool features aren't
> very popular?

This is probably true, but "really cool features" tend to become
"exotic features".  I don't need them, neither the masses.  A good
GUI toolkit is a nice "cool thing" to have.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope'or'module' better?)

2005-08-05 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Are you sure

If I were, I would not have started the statement 'I suspect...'.  I do not 
insert such words accidentally.

TJR



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


Re: ANN : dxPython 0.3.0

2005-08-05 Thread Joseph Garvin
Atila Olah wrote:

>In my opinion, you shoud make an (100%) English version of the site, if
>you want more developers to join worldwide.
>
>  
>
Isn't there some sort of Python directx thingy already? Surprised.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread Joseph Garvin
[EMAIL PROTECTED] wrote:

>I've heard 2 people complain that word 'global' is confusing.
>
>Perhaps 'modulescope' or 'module' would be better?
>
>Am I the first peope to have thought of this and suggested it?
>
>Is this a candidate for Python 3000 yet?
>
>Chris
>
>  
>
Hmm.. instead of 'global', how about 'outside' ? It seems a bit more
intuitive to me because it suggests that you mean, "the variable defined
outside this scope" or outside any nestedness.

But then again it could be confused to mean "just one scope above this
one" which isn't necessarily module scope (nested functions, etc.)...
still, might be less confusing than 'global'.

Another alternative to having to say "global var" would be to use some
sort of indicator that you want the global with each usage, like,
"global.var" or "outside.var"

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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread Mike Meyer
"John Roth" <[EMAIL PROTECTED]> writes:
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> A much better idea would be to fix the underlying
> situation that makes the global statement necessary.

You can't "fix" this. This code (in some python-like langauge that
isn't python):

x = 23

def fun():
x = 25
# Rest of code

has two possible interpretations.

Either the occurrence of x in fun references the global, or it
references a local that shadows the global. There are reasons for
wanting both behaviors. So you have to have some way to distinguish
between the two, and you want it to happen per variable, not per
function. The method with the fewest keywords is to have one be the
default, and some keyword that triggers the other.

So the only way to remove the global statement would be to have some
way to mark the other interpretation, with say a "local"
decleration. I thik that would be much worse than "global". For one
thing, most variables would be local whether or not they are
declared. Second, having an indication that you need to check module
globals in the function is a better than not having that clue there.

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


Re: Problem with new python (2.4.1) installation

2005-08-05 Thread john . coppens
>Without the traceback for the first error

Hello Peter...

There was no traceback to the first error - in none of the cases the
error appeared was a traceback present.
I just found the error - the configuration of pygtk mentioned right in
the middle somewhere that the atk version wasn't up-to-date, but did
not signal any error at the end... Installed&compiled a newer atk and
recompiled pygtk and that part seems ok.

I'd suggest to the pygtk people to change their message at the end of
the configure to something like:

gtk  yes
atk  no
pango  yes

That way there would be a positive indication at the end that something
was amiss.

Thanks Peter!
John

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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or'module' better?)

2005-08-05 Thread [EMAIL PROTECTED]
I appreciate your comments.  You give reasons why you
think 'global' is a good idea.

Are you sure that 'global' is widely assumed to mean
global to a *file* in proper CS theory?  Coming from CI assumed
'global' meant global to ENTIRE EXECUTABLE!?!?  You
even admitted you also thought 'global' was confusing in past!
So how can you say you think CS community in general won't
have any problem like we BOTH did

Chris

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


Re: GUI programming, embedding, real time plots, etc.

2005-08-05 Thread Madhusudan Singh
[EMAIL PROTECTED] wrote:

> apt-get install python-pwm
> this will get you python mega widgets
> one of the dependencies that apt will take care of for you is the
> python2.whatever-tk.
> depending on which version of debian you are using.
> i run sarge with python 2.3

Thanks for the help.

I tried to write a piece of code to plot some simulated data from a
measurement :

from Tkinter import *
import Pmw

steps=(0,)
voltages=(0,)

master=Tk()
plot=Pmw.Blt.Graph(master)
plot.pack(expand=1,fill='both')

for i in range(1,10):
steps=steps+(i,)
setvolt=1.0*i/100
voltages=voltages+(setvolt,)
plot.line_create("Plot",xdata=steps,ydata=voltages)


master.mainloop()

This quits with :

Traceback (most recent call last):
  File "", line 15, in ?
  File "/usr/lib/python2.3/site-packages/Pmw/Pmw_1_2/lib/PmwBlt.py", line
266, in line_create
self.tk.call((self._w, 'line', 'create', name) + self._options(kw))
_tkinter.TclError: element "Plot" already exists in ".-1222950836"

Now, if I try to plot from outside the loop (move the last statement in the
loop out of it), it plots ok. I need to plot this in realtime. So, what
would be the best approach ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread [EMAIL PROTECTED]
Your solution is the best of them all.  However, I don't
have the foggiest idea how it would be accomplished.

Are you *sure* you can change design so that there
is no need for a keyword like 'global'?  Please enlighten
me.  I'd really appreciate it.

Chris

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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread [EMAIL PROTECTED]
Python 3000 is not worried about backward compatibility.
It is worried more about what is *best* and getting it done.
Trust me.

Let me ask an academic questionIs 'global' the
*best* choice of all choices in Webster's dictionary?

If it is then I'll give up and go home.  If not then well.

Chris

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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread [EMAIL PROTECTED]
I'm not saying 'modulescope' and 'module' are the only alternatives or
even
the best anyone can come up with.

'global' has the connotation of being visible *EVERYWHERE*
where in Python it is just visible in one module's space.

Can you think of a better alternative or do you believe
'global' is the best possible?

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread EP
Mike Meyer writes:

> 
> The only way ISPs will find out that Python is popular is if potential
> customers tell them they need it. So if they say no, be *sure* and
> tell them you won't be using them because of that.


I think this is an issue of critical mass, but I know minds the like of this 
group will immediate see that something as general as critical mass can be 
further reduced.

Point being, all one needs is critical mass at a given point to overcome the 
inertia at that point.

By overcoming inertia, and getting change at that point, if that point is 
visible to other major points, you can change thought on the larger scale.




Personally, my current needs are sub collocation or dedicated server.  In 
respect of a good ISP (though I may be breaking all usenet etiquette by 
mentioning a specific hosting company), I have been treated well by Zettai.net 
(Zope, Plone, Python + the usual other  languages) -- and I get a lot of value 
there.  I have no desire to move.  Good people, and nice hosting if you like 
Unix.

However, I would really like to see Python hosting part of the normal 
competitive hosting landscape, at least for the reasons mentioned --- sometimes 
we do not get to pick the host.  What percent of the commercial hosting servers 
will my (Python) code run on?  It is a small number, I think.


So, if this issue were going to get some attention from some Pythonistas, what 
are the 2,3 or 5 hosting companies we would most like to see Python hosting 
offered by?  And what are their e-mail addresses?


I would certainly nominate GoDaddy.com ([EMAIL PROTECTED]), who haves done a 
tremendous job on domain name registration, and may end up with a very large 
footprint in the (recently launched) hosting business.  Python should 
definitely run on their servers (filers?).  For the betterment of mankind.


Anyway, just a thought.

EP

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


Point and click GUI builder for Python

2005-08-05 Thread Madhusudan Singh
Is there such a thing for python ? Like Qt Designer for instance ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI programming, embedding, real time plots, etc.

2005-08-05 Thread nephish
apt-get install python-pwm
this will get you python mega widgets
one of the dependencies that apt will take care of for you is the
python2.whatever-tk.
depending on which version of debian you are using.
i run sarge with python 2.3

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


Re: Problem with new python (2.4.1) installation

2005-08-05 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
> After installing python 2.4.1 (previous version 2.3.4), and installing
> pygtk 2.6.2, I get the following error message (almost with any program
> I try to run):
> 
> ImportError: could not import atk
[snip...]
> "/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/gtklayers.py",
> line 274, in ?
> class LayerTreeModel(gtk.GenericTreeModel):
> AttributeError: 'module' object has no attribute 'GenericTreeModel'
> 
> I suspect there is a problem with paths somewhere. Can someone help me
> out here?

Without the traceback for the first error I can only suggest that you 
stick a simple print statement in the line of code just before the 
AttributeError is raised, like so:

  print gtk

The result should show you what path was used to load that particular 
module, and if it is a path problem you can probably figure it out from 
there.

You haven't created your own modules named "atk" or "gtk" by any chance, 
have you?  Or have leftover .pyc or .pyo files with those names, even 
though the .py files are no longer present?

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


Re: Making a timebomb

2005-08-05 Thread Peter Hansen
Cantankerous Old Git wrote:
> [EMAIL PROTECTED] wrote:
> 
>> I have a server that right now runs infinitely.  I'd like to make it
>> die after some amount of time.  
>
> The proper way to do it is to have the timer set a flag that the other 
> threads check regularly. The threads can then clean up and exit asap.
> 
> The dirty way, which can leave corrupt half-written files and other 
> nasties, is something like sys.exit().

sys.exit() won't help you if your server is running in the main thread, 
nor if your server thread is not marked as a daemon, but that does raise 
another possibility.  Instead of doing serve() in the main thread, spawn 
off a child thread to do the serving, and call setDaemon(True) on it. 
Then the _main_ thread can do sys.exit() and the server thread will be 
terminated (somewhat messily perhaps) -- even if it is blocked in an 
accept() call or some other external blocking call.

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Mike Meyer
"Paul McGuire" <[EMAIL PROTECTED]> writes:

> Once you find your service based on price/support/etc., send them an
> e-mail asking for Python support.  The worst they can say is "no, and
> we never will," but just as likely they might respond "yes, it's
> already there" or "yes, we can add that".

The only way ISPs will find out that Python is popular is if potential
customers tell them they need it. So if they say no, be *sure* and
tell them you won't be using them because of that.

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


Re: pain

2005-08-05 Thread Mike Meyer
Kent Johnson <[EMAIL PROTECTED]> writes:
> Mike Meyer wrote:
>> The compiled jython will pay a performance penalty for being
>> dynamic. Where Java knows the type of objects, and can deduce the
>> correct method to call at compile time (well, some of the time,
>> anyway), the jython code will have to do a method search at run time.
>
> Yes, the compiled code makes heavy use of the Jython runtime to get anything 
> done.
>
> *But* most of the hard work will probably be done by Java code in
> libraries you call. For example a Swing UI, XML parsing, database
> calls, etc all will happen in Java code.

One would hope so. That's how you get good performance out of CPython
apps - you arrange for the heavy lifting to be done by libraries
written in C.

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


Re: Wheel-reinvention with Python

2005-08-05 Thread Mike Meyer
Torsten Bronger <[EMAIL PROTECTED]> writes:
> Hallöchen!
> Mike Meyer <[EMAIL PROTECTED]> writes:
>> Torsten Bronger <[EMAIL PROTECTED]> writes:
>>> Mike Meyer <[EMAIL PROTECTED]> writes:
 Torsten Bronger <[EMAIL PROTECTED]> writes:
> Mike Meyer <[EMAIL PROTECTED]> writes:
>> Torsten Bronger <[EMAIL PROTECTED]> writes:
>> [...]  You didn't answer the question about how you define
>> agile project. Please do so if you expect a comment on this.
> Projects with a high Sourceforge activity index.
 That doesn't seem to match the common defintion of "agile" when
 it comes to programming. Then again, you have a habit of using
 words to mean whatever you want, without much reference to how
 they're used by the rest of the industry.
>>> I'm not part of the industry.
>> That's no excuse for not learning the terminology, or at least
>> avoiding using phrases which already have a common meaning.
> Granted, I didn't pay enough attention to the fact that for industry
> people "agile" has a much stronger connotation.  Nevertheless, it's
> an ordinary English word, too, so that's no excuse for not trying to
> understand what I *mean*.  Since nobody has any chance to see which
> programming strategy the projects uses, you must deliberatly
> misunderstand me for assuming that I meant "agile programming".

No, I didn't (mis)understand you to mean "agile programming." I didn't
understand what you said at all - which is why I asked how you define
an agile project.

>> [...] The difference is ther are a lot of other choices, so it
>> gets chosen less often.  But I note that at least one of the 155
>> projects on SourceForge that list FORTRAN as a language is a GUI
>> application for Windows.
> I see no difference to special-purpose language then.

Difference to what?

I notice that the Wikipedia doesn't have a definition for "special
purpose language", instead preferring the phrase "Domain Specific
Langauge". That matches the definition that agrees with what I think
is common usage, which is:

Trade some of the flexibility of a general purpose language for
capabilities that are more tailored to a specific task

Fortran certainly meets the requirements the wikipedia has for being a
general purpose language.

>> [...] Just like some C/C++ applications are legacy code, and some
>> aren't. Which contradicts your earlier assertion that C/C++
>> applications were all legacy code.
> Reference?

See http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/c52d3c17f1ea9ec5/d2013c3f1eef49b9?q=wheel+reinvention&rnum=1#d2013c3f1eef49b9
>, where you dismiss all C applications a legacy code.

>> Earlier, you said you wanted a popular language because they get
>> cool features faster. You hold up two proprietary VC++ (which is
>> just an development environment) and VB as "popular" languages. If
>> you've been watching software development long enough, you'd
>> realize that "cool things" usually come from open source projects
>> first.
> That's right (or rather, I believe you).  I just want to use a
> popular langauge amongst the ones that have free success ("free" in
> the sense of Free Software).

These leaves me with three questions for you:

Is there a free language you consider successful? I can't think of any
that are a lot more (i.e. - an order of magnitude) successful than
Python that aren't derived from C.

Are there any free language that have the GUI/IDE toolkit you want?

Have you noticed that languages with really cool features aren't very
popular? Unification, prototypes, real macros, and dataflow variables
all come to mind. Some of the languages that sport these features even
come with an integrated GUI/IDE, but they have at most 99 projects
mentioning them on sourceforge - assuming they are listed at all.

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


Problem with new python (2.4.1) installation

2005-08-05 Thread john . coppens
Hello people.

After installing python 2.4.1 (previous version 2.3.4), and installing
pygtk 2.6.2, I get the following error message (almost with any program
I try to run):

ImportError: could not import atk

Trying to start PythonCAD, I also get:

Traceback (most recent call last):
  File "/usr/local/bin/gtkpycad.py", line 52, in ?
from PythonCAD.Interface.Gtk import gtkinit
  File
"/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/gtkinit.py",
line 48, in ?
from PythonCAD.Interface.Gtk import gtkimage
  File
"/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/gtkimage.py",
line 36, in ?
from PythonCAD.Interface.Gtk import gtklayers
  File
"/usr/lib/python2.4/site-packages/PythonCAD/Interface/Gtk/gtklayers.py",
line 274, in ?
class LayerTreeModel(gtk.GenericTreeModel):
AttributeError: 'module' object has no attribute 'GenericTreeModel'

I suspect there is a problem with paths somewhere. Can someone help me
out here?

John

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


GUI programming, embedding, real time plots, etc.

2005-08-05 Thread Madhusudan Singh
Hi

I am still a rookie at python (can do some basic programming with the
language), and have been using python gpib and matplotlib to control my
instruments and do real time plots. Since I have more than one instrument
to control, I was thinking of writing a GUI using Tkinter (looked at Page,
but it not have a debian package and I saw quite a few bugs listed -
Tkinter seems mature). I have some questions :

1. In using matplotlib (my code essentially involved creating a plot and
show()'ing it inside a loop), the color of the plot changed. Is there a way
to tell matplotlib to not treat each new invocation as a new plot, but to
really overwrite the old one ?

2. Is it possible to embed the matplotlib o/p in the o/p GUI ?

3. Are there some other caveats that I should be aware of in using
matplotlib ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or'module' better?)

2005-08-05 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've heard 2 people complain that word 'global' is confusing.

I did to at first.

> Perhaps 'modulescope' or 'module' would be better?

Global is an somewhat short adjective that plausibly becomes a noun when 
pluralized.  That is hard to match.  I have thought of 'modular' as the 
actual meaning of 'global', but 'modulars' does not sound as good to me.

> Am I the first peope to have thought of this and suggested it?

You are the first people I remember making at least the 'modulescope' 
suggestion.  Searching the newsgroup archive at Google would make sure ;-).

> Is this a candidate for Python 3000 yet?

Unlikely. I suspect that global meaning global to the module (as opposed to 
the collection of modules or compilation units) is established CS usage.

Terry J. Reedy



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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread John Roth
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've heard 2 people complain that word 'global' is confusing.
>
> Perhaps 'modulescope' or 'module' would be better?
>
> Am I the first peope to have thought of this and suggested it?
>
> Is this a candidate for Python 3000 yet?
>
> Chris

A much better idea would be to fix the underlying
situation that makes the global statement necessary.

I doubt if this is going to happen either, though.

John Roth
> 

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


Re: ANN : dxPython 0.3.0

2005-08-05 Thread Atila Olah
In my opinion, you shoud make an (100%) English version of the site, if
you want more developers to join worldwide.

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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread Atila Olah
I think D H is right. Or even if you'd find out that most of the people
would better like 'modulescope' or 'module', (what is, i think,
imposible), you'd destroy the backward-compatibility with older
versions of Puthon if you implement it. But it won't be implemented.
Trust me.

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


Re: minidom xml & non ascii / unicode & files

2005-08-05 Thread Martin v. Löwis
webdev wrote:
> 1. when fetching a web page from the net, how am i supposed to know how
> it's encoded.. And can i decode it to unicode and encode it back to a
> byte string so i can use it in my code, with the charsets i want, like
> utf-8.. ?

It depends on the content type. If the HTTP header declares a charset=
attribute for content-type, then use that (beware: some web servers
report the content type incorrectly. To deal with that gracefully,
you have to implement very complex algorithms, which are part of
any recent web browser).

If there is no charset= attribute, then
- if the content type is text/html, look at a meta http-equiv tag
  in the content. If that declares a charset, use that.
- if the content type is xml (plain, or xhtml+xml), look at the
  XML declaration. Alternatively, pass it to your XML parser.

> 2. in the same idea could anyone try to post the few lines that would
> actually parse an xml file, with non ascii chars, with minidom
> (parseString i guess).

doc = xml.dom.minidom.parse("foo.xml")

> Then convert a string grabbed from the net so parts of it can be
> inserted in that dom object into new nodes or existing nodes.

doc..documentElement.setAttribute("bar", text_from_net.decode("koi-8r"))

> And finally write that dom object back to a file in a way it can be used
> again later with the same script..

open("/tmp/foo.txt","w").write(doc.toxml())

> I've been trying to do that for a few days with no luck..
> I can do each separate part of the job, not that i'm quite sure how i
> decode/encode stuff in there, but as soon as i try to do everything at
> the same time i get encoding errors thrown all the time..

It would help if you would state what precise code you are using,
and what precise error you are getting (for what precise input).

> 
> 3. in order to help me understand what's going on when doing
> encodes/decodes could you please tell me if in the following example, s
> and backToBytes are actually the same thing ??
> 
> s = "hello normal string"
> u = unicode( s, "utf-8" )
> backToBytes = u.encode( "utf-8" )
> 
> i knwo they both are bytestrings but i doubt they have actually the same
> content..

They do have the same content. There is nothing to a byte string except
for the bytes. If the byte string is meant to represent characters,
they are the same "thing" only if the assumed encoding is the same.
Since the assumed encoding is "utf-8" for both s and backToBytes,
they are the same thing.

> 4. I've also tried to set the default encoding of python for my script
> using the sys.setdefaultencoding('utf-8') but it keeps telling me that
> this module does not have that method.. i'm left no choice but to edit
> the site.py file manually to change "ascii" to "utf-8", but i won't be
> able to do that on the client computers so..

Don't do that. It's meant as a last resort for backwards compatibility,
and shouldn't be used for new code.

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


Creating a virtual file system

2005-08-05 Thread Atila Olah
I'm working on a project to implement a simple cross-platform file
sharing protocol (using Python) that is similar to HTTP, and I have to
write a GUI for Windows and Linux. But let's start with the harder one:
Windows.

My question is: How do I implement a virtual partition that acts like a
real file-system and is compleatly transparent to other programs?
Should I make a virtual file allocation table for a FAT32 partition or
simulate an NTFS? Or even further: How do I create a junction (or a
hard link) to it in "My network places" or in "Entire Network"?

If there are tools that could help me but written in C or C++, please
let me know, I'll compile them to Python modules.

Thanks forward for help.

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


Re: Making a timebomb

2005-08-05 Thread Cantankerous Old Git
[EMAIL PROTECTED] wrote:
> I have a server that right now runs infinitely.  I'd like to make it
> die after some amount of time.  I was thinking of having a timebomb
> thread that starts when the server starts.  The timebomb sits, and
> sleeps for the specified timeout period (e.g., 5 hours), then does
> something to make the main thread terminate.  But I'm too inexperienced
> to figure out what that thing is.
> 
> Any suggestions?
> 
> 
> 
> class TimeBomb( threading.Thread ):
>def run(self):
>timeout = 5 * 60 * 60 #-- 3 hours
>time.sleep( timeout )
>MakeTheRestOfTheStuffDie()
> 
> class MyServer:
>def __init__(self):
>TimeBomb().run()
>serve()
> 


The proper way to do it is to have the timer set a flag that the 
other threads check regularly. The threads can then clean up and 
exit asap.

The dirty way, which can leave corrupt half-written files and 
other nasties, is something like sys.exit().

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


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread D H
[EMAIL PROTECTED] wrote:
> I've heard 2 people complain that word 'global' is confusing.
> 
> Perhaps 'modulescope' or 'module' would be better?
> 
> Am I the first peope to have thought of this and suggested it?
> 
> Is this a candidate for Python 3000 yet?

It is likely that more people would find module or modulescope confusing.

Plus module has a different customary meaning already:

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


ANN : dxPython 0.3.0

2005-08-05 Thread Gang Seong Lee
Just opened simple webpage.

dxPython
~~
dxPython is a set of interface modules to use DirectX C++ libraries from 
standard Python programming language.

http://dxpython.pythonworld.net/

Comments, suggestions are welcome.

Gang Seong LEE

[EMAIL PROTECTED]

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


Re: socket and os.system

2005-08-05 Thread Peter Hansen
Donn Cave wrote:
> Peter Hansen <[EMAIL PROTECTED]> wrote:
>>PLEASE learn to format your questions more appropriately!  Your post is 
>>simply _awful_ to read.  ...
> 
> For heaven's sake, it wasn't that hard to read.  

My apologies to the original poster.  I did find it very hard to read 
with the very brief time I put into reading posts which don't fit Usenet 
conventions.  Upon rereading it now a third time I can parse it a little 
better, and my outburst does seem harsh.  (Normally I quickly hit "k" on 
such posts and carry on, but the apparent SO_REUSEADDR symptom caught my 
eye milliseconds before I did so.)

> The good thing is that he did provide example that clearly
> illustrates the problem.
> 
> Which is not really that he can't reuse the socket address.

So I'm doubly wrong and apologize for not having tried hard enough to 
read it to avoid giving an unhelpful answer.

-putting-ice-on-his-slapped-wrists-ly y'rs,
  Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do I need to have site.py available or not ?

2005-08-05 Thread Reinhold Birkenfeld
Terry Reedy wrote:
> <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Hi,
>> on startup my embedded python comes up with "import site failed use
>> -v". Later python crashes on Pyrun_file(). This is the first time I
>> have used python and I would like to know does it require site.py to be
>> read in, and has anyone got an idea how to pass in the -v without using
>> the python -v command, ie the embedded way. Thanks very much.
> 
> If by embedded you mean embedded in a C/C++ program, I would look to the 
> doc for the C API function that you use to start it up to see whether there 
> is a way to pass in argv flags or to have the same effect.

Also note that '-v' doesn't do what you want here, it merely activates verbose
mode so that you can find the cause for above error. You want '-S'.

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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Daniel Schüle
[...]

> I am aware of the usage of argument to mean the angle in polar 
> representation, but I don't like it.  The word argument already has two 
> other meanings, one in common English, the other in math/CS.  The latter 
> meaning is the inputs to a function, and that is how the word is used in 
> Python (though the former applies more to many c.l.p threads ;-)  To me, 
> the polar angle has no connection with either meaning and so the usage is 
> 'like Greek' to me.  Whereas angle is exactly what it is.

.angle() would be also alright, as it is easy to grasp

> As for Greek: I first learned r(adius),theta (versus x,y or real,imag) as 
> the names for polar coordinates or the polar representation for complex 
> numbers and only ran into arg much later in some contexts.  And I have seen 
> complex number implementations that use the equivalent of c.r() and 
> c.theta().  But I did not suggest that for one of the reasons I don't like 
> 'lambda': its fine if you already know it and arbitrary if you don't.  (Is 
> theta used in Germany?)

yes, of course
the entire mathematic is full of them :)
as for the complex numbers, in our lessons we used R(adius) and
Phi for the angle for polar representation
I guess it's more a question of teacher's preference than a national
norm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Daniel Schüle
[...]

 > Derive your own subclass of complex and define those methods.

I think something as basic as an angle/arg of complex number
definetly belongs to the interface, and it would not even require a
great effort to put it there

most complex formulas out there use Euler representation
it's a waste of code lines (and programmers time)
to write 3 liner functions for the transformion between
a+bj <-> (r,angle)
Python makes things covenient
so we have complex numbers in the core language
the calculations where perfectly possible without them
using (re, im) tupels and many many sin/cos in the code
but imagine how ugly it would be ..
I would like see Python as a competitor to Matlab etc

Regards

--
Daniel

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


How to get ScrollRegion to adjust w/ window-size?

2005-08-05 Thread syed_saqib_ali
Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust accordingly.

However, what I really want to happen is that the area of the canvas
that the scrollbars show (the Scrollregion) should expand as the window
grows. It doesn't currently do this. although, if the window shrinks
smaller than the original canvas-size, then the scrollregion adjusts
properly.

How can I make it such that the Scrollregion fills the entire space
avaialable to it. I tried all permutations of setting
expand=Tkinter.YES and fill=Tkinter.BOTH in the pack command??

-Saqib



import Tkinter

class testApp2:

def _setupCanvas(self):
self._canvasFrame = Tkinter.Frame(self._overallFrame, bd=1,
relief=Tkinter.SUNKEN)
self._canvasFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)

self._canvas = Tkinter.Canvas(self._canvasFrame,
background="white", width=self._canvasWidth,
height=self._canvasHeight,)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(self._canvasFrame)
hScrollbar = Tkinter.Scrollbar(self._canvasFrame)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(self._canvasFrame)
vScrollbar.pack(side=Tkinter.LEFT, expand=Tkinter.NO,
fill=Tkinter.NONE)

hScrollbar = Tkinter.Scrollbar(self._canvasFrame)
hScrollbar.pack(side=Tkinter.TOP, expand=Tkinter.NO,
fill=Tkinter.NONE)

# Configure
self._parent.rowconfigure(0, weight=1)
self._parent.columnconfigure(0, weight=1)
#self._scrollX0 = self._scrollY0 = 0
#self._scrollX1 = self._canvasWidth
#self._scrollY1 = self._canvasHeight

print "self._canvasWidth = %s" % self._canvasWidth
print "self._canvasHeight = %s" % self._canvasHeight
#print "self._scrollX1 = %s" % self._scrollX1
#print "self._scrollY1 = %s" % self._scrollY1
self._canvas.config(
width=self._canvasWidth,
height=self._canvasHeight,
scrollregion=(0,0, self._canvasWidth, self._canvasHeight),
yscrollcommand=vScrollbar.set,
xscrollcommand=hScrollbar.set,
)

vScrollbar.config(orient=Tkinter.VERTICAL,
command=self._canvas.yview)
hScrollbar.config(orient=Tkinter.HORIZONTAL,
command=self._canvas.xview)

self._canvasFrame.pack()
self._canvas.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)
vScrollbar.pack(side=Tkinter.RIGHT, expand=Tkinter.YES,
fill=Tkinter.Y)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=Tkinter.YES,
fill=Tkinter.X)

def __init__(self, parent):
self._parent = parent

self._overallFrame = Tkinter.Frame(self._parent, bd=1,
relief=Tkinter.SUNKEN)
self._overallFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)

self._canvasWidth = 300
self._canvasHeight = 250
self._setupCanvas()
self._setCallBacks()

def _setCallBacks(self):
# Function Bindings
self._canvas.bind("", self._b1PressEvt)

def _b1PressEvt(self, event):
print self._canvas.config('scrollregion')
print self._canvas.config('width')
print self._canvas.config('height')
print "=" * 50
print "\n"

root = Tkinter.Tk()
app = testApp2(root)
root.mainloop()

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


Re: Syntax error after upgrading to Python 2.4

2005-08-05 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> After upgrading to 2.4 (from 2.3), I'm getting a weird syntax error:
>
 import themes
> Traceback (most recent call last):
>  File "", line 1, in ?
>  File "themes.py", line 564
>font = self.font.makeBlackAndWhite(),
>  additive = self.additive,
> ^
> SyntaxError: invalid syntax

The location of the caret is sometimes misleading, especially with 
proportional fonts...

> The relevant code is:
>
>def makeBlackAndWhite( self ):
>
>return CharStyle( names = self.names,
>  basedOn = self.basedOn.makeBlackAndWhite(),
>  font = self.font.makeBlackAndWhite(),
>  additive = self.additive,
>  prefixText = self.prefixText )
>
> This is a method in the CharStyle class which returns a new modified
> instance of CharStyle.
>
> I'm using Windows XP and Python 2.4.1
>
> Any ideas? O:-)

I don't see the problem yet.  I certainly do not see anything that should 
have been affected by the upgrade (was it from 2.3 on XP also?)

After checking for nonprinting chars, I would shuffle the param-default 
lines to try to determine which is really at fault.  Good luck, or wait for 
a more helpful response.

Terry J. Reedy



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


Re: Do I need to have site.py available or not ?

2005-08-05 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
> on startup my embedded python comes up with "import site failed use
> -v". Later python crashes on Pyrun_file(). This is the first time I
> have used python and I would like to know does it require site.py to be
> read in, and has anyone got an idea how to pass in the -v without using
> the python -v command, ie the embedded way. Thanks very much.

If by embedded you mean embedded in a C/C++ program, I would look to the 
doc for the C API function that you use to start it up to see whether there 
is a way to pass in argv flags or to have the same effect.

TJR



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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Terry Reedy

"Daniel Schüle" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> > I agree that this is a deficiency.  I would think .angle() should be a
>
> I don't know what nomenclature is used in english speaking
> mathematical world for angle of a complex number
> I learned it in german as Arg(z) .. Arg standing for argument
> you see, we would have named it differently, hence making
> it difficult for the reader, eventually creating redundancy

I am aware of the usage of argument to mean the angle in polar 
representation, but I don't like it.  The word argument already has two 
other meanings, one in common English, the other in math/CS.  The latter 
meaning is the inputs to a function, and that is how the word is used in 
Python (though the former applies more to many c.l.p threads ;-)  To me, 
the polar angle has no connection with either meaning and so the usage is 
'like Greek' to me.  Whereas angle is exactly what it is.

As for Greek: I first learned r(adius),theta (versus x,y or real,imag) as 
the names for polar coordinates or the polar representation for complex 
numbers and only ran into arg much later in some contexts.  And I have seen 
complex number implementations that use the equivalent of c.r() and 
c.theta().  But I did not suggest that for one of the reasons I don't like 
'lambda': its fine if you already know it and arbitrary if you don't.  (Is 
theta used in Germany?)

> > It is possible that a cmath2 module, written in  Python, could be 
> > useful.
>
> I hope so
> I will google for cmath2, I never heard about it

That is because we have not written it yet.  The allroots function could be 
the first addition, if it is not present elsewhere.  The 'could be' was 
meant in the sense of 'if someone were to write it' rather than 'if you 
were to read it' ;-)

Terry J. Reedy



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

Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Reinhold Birkenfeld
Erik Max Francis wrote:
> Daniel Schüle wrote:
> 
>> maybe I confuse, in german one would say "45 Grad"
>> I took a freedom to translate it directly :)
>> well, my calculator shows a "D"
>> which most likely stands for Degree, I cannot tell for sure
> 
> Probably.  In English, you have degrees and gradians, which aren't the 
> same thing; gradians are defined so that there are 400 gradians in a 
> circle (so 100 gradians in a right angle).

In German, they're "Altgrad" (degrees) and "Neugrad" or "Gon" (gradians).

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


Re: Art of Unit Testing

2005-08-05 Thread Christoph Zwerschke
I had tested the above only with Python 2.4 but I just noticed it does 
not work with Python 2.3. The following works also with Python 2.3:

import unittest

class MyTestCase(unittest.TestCase):
 def setUp(self):
 print "setUp",
 def tearDown(self):
 print "tearDown",
 def test1(self):
 print "test1"
 def test2(self):
 print "test2"

class MyTestSuite(unittest.TestSuite):
 def setUp(self):
 print "setUpAll",
 def tearDown(self):
 print "tearDownAll",
 def __call__(self, result):
 self.setUp()
 unittest.TestSuite.__call__(self, result)
 self.tearDown()

if __name__ == '__main__':
 suite = unittest.makeSuite(MyTestCase, suiteClass=MyTestSuite)
 unittest.TextTestRunner().run(suite)
-- 
http://mail.python.org/mailman/listinfo/python-list


Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread [EMAIL PROTECTED]
I've heard 2 people complain that word 'global' is confusing.

Perhaps 'modulescope' or 'module' would be better?

Am I the first peope to have thought of this and suggested it?

Is this a candidate for Python 3000 yet?

Chris

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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Erik Max Francis
Daniel Schüle wrote:

> maybe I confuse, in german one would say "45 Grad"
> I took a freedom to translate it directly :)
> well, my calculator shows a "D"
> which most likely stands for Degree, I cannot tell for sure

Probably.  In English, you have degrees and gradians, which aren't the 
same thing; gradians are defined so that there are 400 gradians in a 
circle (so 100 gradians in a right angle).

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   I am not afraid / To be a lone Bohemian
   -- Lamya
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Erik Max Francis
Daniel Schüle wrote:

> what do you think about it?
> maybe there exists some proposals aiming this goal?

Derive your own subclass of complex and define those methods.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   I am not afraid / To be a lone Bohemian
   -- Lamya
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread stephen
Using 'plot(*args, **kwargs)' does seem to work just fine.

Thanks to all for their suggestions.

Stephen

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread D H
I would highly recommend user-mode linux (UML) hosting, like bytemark or 
Linode: http://user-mode-linux.sourceforge.net/uses.html

Starting around the same price as average shared hosting, you get your 
own virtual linux box (i recommend debian), on which you can install 
java, mod_python, php, mono, jabber, or whatever you need.  You are no 
longer subject to the whims of the hosting provider, with respect to 
things like which version of PHP they support, or how many mysql 
databases you can create.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread fuzzylollipop
lazy newbie programmers, that is what the world needs more of for sure!

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


Re: pain

2005-08-05 Thread Kent Johnson
Mike Meyer wrote:
> Grant Edwards <[EMAIL PROTECTED]> writes:
> 
> 
>>On 2005-08-03, Mage <[EMAIL PROTECTED]> wrote:
>>
>>
>>>Isn't jython slower (I mean performance) than java? As well as
>>>I understand jython code will be interpreted twice.
> 
> The compiled jython will pay a performance penalty for being
> dynamic. Where Java knows the type of objects, and can deduce the
> correct method to call at compile time (well, some of the time,
> anyway), the jython code will have to do a method search at run time.

Yes, the compiled code makes heavy use of the Jython runtime to get anything 
done.

*But* most of the hard work will probably be done by Java code in libraries you 
call. For example a Swing UI, XML parsing, database calls, etc all will happen 
in Java code. So in practice the performance penalty is not significant and is 
more than offset by the productivity benefit.

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


Re: Opinions on KYLIX 3 (Delphi 4 Linux)

2005-08-05 Thread Ruben Baumann
"windozbloz" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Bye Bye Billy Bob...
>
> I'm back with one more question, then I'll chill.  I have scoured the news
> and net for info about Borlands KYLIX 3 and have found little technical
> info about it.  Their screen shots are very impressive, similar to Visual
> Basic.  I have sent several emails to Borlands Sales and Pre-Sales
> departments.  Pre-Sales bounces and Sales won't answer.  I'm sitting here
> with money in hand ready to buy but not from a company that won't give me
> the time of day.
>
> Does anyone of you have experiance with KYLIX 3 and do you think I should
> consider buying it?  Thank You, I'll go oil my keyboard now.
>
> Doug
>
> -- 
> LINUX protects me from the GATES of hell !!!

KYLIX is currently not being developed by Borland.  I'm not even sure 
they're still supporting it OR selling it.  There is a guy that is currently 
providing patches for the product(third party), but KYLIX 3 is the last 
version so far.

I suspect that Borland is going to eventually drop KYLIX in favor of .NET 
and it's c# product.  There are strong indications that the MONO project 
will run vb.net, c#.net, etc, etc, etc, so there's no need for a delphi 
(pascal) compiler under Linux if true.

HTH
Ruben


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


Re: Suggestions for optimizing my code

2005-08-05 Thread Robert Kern
drife wrote:
> Hello,
> 
> I am looking for suggestions for how I might optimize my
> code (make it execute faster), and make it more streamlined/
> elegent. But before describing my code, I want to state that
> I am not a computer scientist (I am an atmospheric scientist),
> and have but a rudimentary understanding of OO principles.
> 
> My problem is this: I want to find the maximum off-diagonal
> element of a correlation matrix, and the -position- of that
> element within the matrix. In case you are unfamiliar with
> correlation matrices they are square and symmetric, and contain
> the mutual correlations among data collected at different
> points in space or time.

import MLab
import Numeric as N

def find_max(R):
 U = MLab.triu(R)
 n = U.shape[0]
 # set the diagonal elements to 0.0, too
 U.flat[::n+1] = 0.0
 k = N.argmax(U.flat)
 i, j = divmod(k, n)
 return i, j, R[i,j]

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: socket and os.system

2005-08-05 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Peter Hansen <[EMAIL PROTECTED]> wrote:

> mfaujour wrote:
> > I HAVE THIS PYTHON PROGRAMM:
> [snip]
> 
> > socket.error: (98, 'Address already in use')
> >  
> > DOES SOMEONE HAS AN IDEA ?
> 
> PLEASE learn to format your questions more appropriately!  Your post is 
> simply _awful_ to read.  At the very least, ALL CAPS is considered to be 
> "shouting", though I can see why you had to use them since it would have 
> been impossible to see the questions amongst all the code.
> 
> In any case, assuming I've been able to guess at the specific problem 
> based on the above lines, which isn't certain, you need to use a line 
> something like this in your code to allow your server socket to bind to 
> an address that was previously in use:
> 
> server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> 
> For more background, I suggest a Google search on "python so_reuseaddr".

For heaven's sake, it wasn't that hard to read.  Of course
the upper case text was an unpardonable violation of people's
tender sensibilities, but in this case it does have the virtue
of a strong visible distinction between his code and his comments.
The good thing is that he did provide example that clearly
illustrates the problem.

Which is not really that he can't reuse the socket address.
I mean, it's usually good to take care of that, but ordinarily
for reasons having to do with shutdown latency.  In the present
case, his application is holding the socket open from a fork
that inherited it by accident.

I think the current stock answer is "use the subprocess module."
If that's not helpful, either because it doesn't provide any
feature that allows you to close a descriptor in a fork (I seem
to recall it does), or it isn't supported in your version of
Python (< 2.4), then you have your choice of two slightly awkward
solutions:

 1. fcntl F_SETFD FD_CLOEXEC (see man 2 fcntl)
 2. implement your own spawn command (see os.py's
spawnv()) and close the socket FD in the fork.

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


Re: Suggestions for optimizing my code

2005-08-05 Thread Wojciech Mula
drife wrote:
> [...]
> for row in range(len(Y)):
> for col in range(0,row):

In this case you should use 'xrange' instead 'range'.

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


Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread Bengt Richter
On 5 Aug 2005 08:34:32 -0700, [EMAIL PROTECTED] wrote:

>Is there a better way of doing this so that I don't have to go through
>every permutation of possible arguments (the example here from the
>matplotlib 'plot' function):
>
>def makeplot(self, xvalues, yvalues, linecolor='', linewidth=''):
>if linecolor and linewidth:
>plot(xvalues, yvalues, linecolor, linewidth=linewidth)
>elif linecolor:
>plot(xvalues, yvalues, linecolor)
>elif linewidth:
>plot(xvalues, yvalues, linewidth=linewidth)
>else:
>plot(xvalues, yvalues)
>

It seems like you are not changing the order or values of arguments,
so I'm wondering if this would work for you:

 def makeplot(self, *args, **kwargs):
 plot(*args, **kwargs)

and if not, why not.

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


Re: Making a timebomb

2005-08-05 Thread Benjamin Niemann
[EMAIL PROTECTED] wrote:

> I have a server that right now runs infinitely.  I'd like to make it
> die after some amount of time.  I was thinking of having a timebomb
> thread that starts when the server starts.  The timebomb sits, and
> sleeps for the specified timeout period (e.g., 5 hours), then does
> something to make the main thread terminate.  But I'm too inexperienced
> to figure out what that thing is.
> 
> Any suggestions?
> 
> 
> 
> class TimeBomb( threading.Thread ):
>def run(self):
>timeout = 5 * 60 * 60 #-- 3 hours
>time.sleep( timeout )
>MakeTheRestOfTheStuffDie()
> 
> class MyServer:
>def __init__(self):
>TimeBomb().run()
>serve()

Unfortunately you can raise an exception in another thread. You could tell
tell main thread to terminate by setting a flag that is polled by the main
thread.
You could also try to send a signal to yourself, but I'm not sure what will
happen then...


-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: minidom xml & non ascii / unicode & files

2005-08-05 Thread Benjamin Niemann
webdev wrote:

> lo all,
> 
> some of the questions i'll ask below have most certainly been discussed
> already, i just hope someone's kind enough to answer them again to help
> me out..
> 
> so i started a python 2.3 script that grabs some web pages from the web,
> regex parse the data and stores it localy to xml file for further use..
> 
> at first i had no problem using python minidom and everything concerning
> my regex/xml processing works fine, until i tested my tool on some
> french page with "non ascii" chars and my script started to throw errors
> all over the place..
> 
> I've looked into the matter and discovered the unicode / string encoding
> processes implied when dealing with non ascii texts and i must say i
> almost lost my mind.. I'm loosing it actually..

The general idea is:
- convert everything that's coming in (from the net, database, files) into
unicode
- do all your processing with unicode strings
- encode the strings to your preferred/the required encoding when you write
it to the net/database/file

> so here are the few questions i'd like to have answers for :
> 
> 1. when fetching a web page from the net, how am i supposed to know how
> it's encoded.. And can i decode it to unicode and encode it back to a
> byte string so i can use it in my code, with the charsets i want, like
> utf-8.. ?

First look at the HTTP 'Content-Type' header. If it has a parameter
'charset', that the encoding to use, e.g.
Content-Type: text/html; charset=iso-8859-1

If there's not encoding specified in the header, look at the 
prolog, if you have a XHTML document at hand (and it's present). Look below
for the syntax.

The last fallback is the  tag.
The content attribute has the same format as the HTTP header.

But you can still run into UnicodeDecodeErrors, because many website just
don't get their encoding issues right. Browser do some (more or less)
educated guesses and often manage to display the document as intended.
You should probably use htmlData.encode(encoding, "ignore") or
htmlData.encode(encoding, "replace") to work around these problems (but
loose some characters).

And, as said above: don't encode the unicode string into bytestrings and
process the bytestrings in your program - that's a bad idea. Defer the
encoding until you absolutely necessary (usually file.write()).

> 2. in the same idea could anyone try to post the few lines that would
> actually parse an xml file, with non ascii chars, with minidom
> (parseString i guess).

The parser determines the encoding of the file from the  line. E.g.
if your file is encoded in utf-8, add the line

at the top of it, if it's not already present.
The parser will then decode everything into unicode strings - all TextNodes,
attributes etc. should be unicode strings.

When writing the manipulated DOM back to disk, use toxml() which has an
encoding argument.

> Then convert a string grabbed from the net so parts of it can be
> inserted in that dom object into new nodes or existing nodes.
> And finally write that dom object back to a file in a way it can be used
> again later with the same script..

Just insert the unicode strings.

> I've been trying to do that for a few days with no luck..
> I can do each separate part of the job, not that i'm quite sure how i
> decode/encode stuff in there, but as soon as i try to do everything at
> the same time i get encoding errors thrown all the time..
> 
> 3. in order to help me understand what's going on when doing
> encodes/decodes could you please tell me if in the following example, s
> and backToBytes are actually the same thing ??
> 
> s = "hello normal string"
> u = unicode( s, "utf-8" )
> backToBytes = u.encode( "utf-8" )
> 
> i knwo they both are bytestrings but i doubt they have actually the same
> content..

Why not try it yourself?
"hello normal string" is just US-ASCII. The utf-8 encoded version of the
unicode string u"hello normal string" will be identical to the ASCII byte
string "hello normal string".


> 
> 4. I've also tried to set the default encoding of python for my script
> using the sys.setdefaultencoding('utf-8') but it keeps telling me that
> this module does not have that method.. i'm left no choice but to edit
> the site.py file manually to change "ascii" to "utf-8", but i won't be
> able to do that on the client computers so..
> Anyways i don't know if it would help my script at all..

There was just recently a discussing on setdefaultencoding() on various
pythonistic blogs, e.g.
http://blog.ianbicking.org/python-unicode-doesnt-really-suck.html


> 
> any help will be greatly appreciated
> thx
> 
> Marc

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Paul McGuire
Just because a hosting service doesn't list Python on their web page
doesn't mean that it's not available.  My company's service
(LunarPages) supports Python, and only recently has it started
appearing on their online literature.

Once you find your service based on price/support/etc., send them an
e-mail asking for Python support.  The worst they can say is "no, and
we never will," but just as likely they might respond "yes, it's
already there" or "yes, we can add that".

-- Paul

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Martin P. Hellwig
Magnus Lycka wrote:
> Martin P. Hellwig wrote:
> 
>> Kevin wrote:
>> 
>>
>> Well, for some strange reason I have never found that to be a problem.
> 
> 
> If you develop software for an external customer, and they have
> an existing web site run by some ISP that you have no control over,
> this might well be a problem.

Yes indeed there are a *load of companies not interested in technology 
they just want a fancier web page then their rivals, for them this is 
definitely a problem well actually it's a problem for the developer.
Do you tell the client to do it your way or do you do it their way.
It all depends, I work in and for non-profit organization so I mostly I 
can do what I think is the best solution. I'll explain that and what the 
advantage or dis-advantage is of all different possibilities.

> 
> Even if the customer is in control of their web servers, it might be
> difficult to convince them to install and maintain something like
> Python on them.
> 
> I find it a bit surprising that so many people on comp.lang.python
> don't realize what kind of practical complications most commercial
> software developers have to struggle with if they don't just follow
> the mainstream and use PHP or Java for all web apps.

Yeah well, I remember that I had a hard time getting java support 
instead of cgi alone, then somewhat later I've had that with perl and 
PHP and whatever, it always feels like playing catch up.
I really had it with all that begging to get this or that supported.
I've been bitten so many times over support issues that it isn't even 
funny anymore, so in the end I realized that the only way to get it down 
in a acceptable way is to do it myself or source it to a small company 
that needs the customer.

> 
> My ISP (FS Data in Sweden) has Python installed, and always upgraded
> it when I asked them (but only then, so I suspect I'm the only user--
> and this is one of the biggest ISPs in Sweden).

As I said above, I found it more likely to get support from smaller 
companies then the bigger ones.

> 
> Even if I have access to Python, they don't allow me to have my own
> long running processes, so I'm stuck with CGI, which wouldn't work
> very well with a much higher load than my moin has. (Actually, I
> didn't really need more, so I haven't asked for mod_python support
> etc.)
> 
> Colocation is certainly getting much cheaper, my ISP charges much less
> than 95EUR/month.(295 SEK). Still, it would certainly be great if
> mod_python, twisted and zope support etc would be as common as mod_perl
> or PHP support. We can only get that if we actively ask for it, and if
> we really favour vendors that provide this support when we can.

But overall I must say the I agree with you, and that this chicken/egg 
problem can only be resolved by further popularity of python.

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


Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread John Hunter
> "stephen" == stephen  <[EMAIL PROTECTED]> writes:

stephen> Is there a better way of doing this so that I don't have
stephen> to go through every permutation of possible arguments
stephen> (the example here from the matplotlib 'plot' function):

You can make linecolor=None and linewidth=None, and then use
matplotlib's rc defaults

  from matplotlib import rcParams
  def makeplot(self, xvalues, yvalues, linecolor=None, linewidth=None):
  if linecolor is None: linecolor = rcParams['lines.color']
  if linewidth is None: linewidth = rcParams['lines.linewidth']
  plot(xvalues, yvalues, color=linecolor, linewidth=linewidth)

Then you can customize the defaults in the rc file
(http://matplotlib.sf.net/matplotlibrc) any way you want.

Alternatively, you can also set the defaults in your script

  from matplotlib import rc
  rc('lines', linewidth=1.0, color='red')

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


Suggestions for optimizing my code

2005-08-05 Thread drife
Hello,

I am looking for suggestions for how I might optimize my
code (make it execute faster), and make it more streamlined/
elegent. But before describing my code, I want to state that
I am not a computer scientist (I am an atmospheric scientist),
and have but a rudimentary understanding of OO principles.

My problem is this: I want to find the maximum off-diagonal
element of a correlation matrix, and the -position- of that
element within the matrix. In case you are unfamiliar with
correlation matrices they are square and symmetric, and contain
the mutual correlations among data collected at different
points in space or time.

I write much Python code and absolutely love the language. To
do the task outlined above I twiddled around with the "argsort"
methods available in both Numeric and numarry. In the end, I
decided to accomplish this through the following algorithm.

<

import MLab
import Numeric as N

def FindMax( R):
"""Find row (column) where max off-diagonal element
occurs in matrx [R].
"""
# First get elements in the lower triangle of [R],
# since the diagonal elements are uninformative and
# the upper triangle contains redundant information.
Y = MLab.tril(R)

offMax = -.
rowMax = 0
colMax = 0

for row in range(len(Y)):
for col in range(0,row):
if Y[row][col] > offMax:
   offMax = Y[row][col]
   rowMax = row
   colMax = col

return (rowMax, colMax, offMax)

>

Now, this algorithm will work sufficiently fast on "small" sized
matrices, but I worry that performance will not scale well when
the dimensions of the matrix grow "large" (say 1000-1500 elements
on a side, or larger).

So onto my question. Could someone please provide me with a suggestion
for making this code more efficient and elegant? Again, I have but
a rudimentary understanding of OO principles.


Thanks very much for your help,


Daran


[EMAIL PROTECTED]

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


Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread en.karpachov
On 5 Aug 2005 08:34:32 -0700
[EMAIL PROTECTED] wrote:

> Is there a better way of doing this so that I don't have to go through
> every permutation of possible arguments (the example here from the
> matplotlib 'plot' function):
> 
> def makeplot(self, xvalues, yvalues, linecolor='', linewidth=''):
> if linecolor and linewidth:
> plot(xvalues, yvalues, linecolor, linewidth=linewidth)
> elif linecolor:
> plot(xvalues, yvalues, linecolor)
> elif linewidth:
> plot(xvalues, yvalues, linewidth=linewidth)
> else:
> plot(xvalues, yvalues)

What's wrong with:

def makeplot(self, xvalues, yvalues, **kwargs):
 plot(xvalues, yvalues, **kwargs)

or even:

def makeplot(self, *a, **ka):
 plot(*a, **ka)

?

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


Re: Making a timebomb

2005-08-05 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
> I have a server that right now runs infinitely.  I'd like to make it
> die after some amount of time.  I was thinking of having a timebomb
> thread that starts when the server starts.  The timebomb sits, and
> sleeps for the specified timeout period (e.g., 5 hours), then does
> something to make the main thread terminate.  But I'm too inexperienced
> to figure out what that thing is.
> 
> Any suggestions?
...
> class MyServer:
>def __init__(self):
>serve()

The right answer depends entirely on things you don't mention, most 
specifically just what serve() is doing in the above code.

Generally speaking, long-running code is either running in a loop, 
repeating some operations -- and a polling technique (to check for 
timeout) can be used -- or it is asynchronous, such as a server 
listening on sockets -- in which case you need either to use whatever 
builtin support is in the framework you're building on (and you should 
be building on a framework, not doing this from scratch), or you need to 
use non-blocking sockets and select(), or in the worst case you need to 
have your server connect internally to itself (think "loopback") and 
send itself a message so that the blocked threads will wake up and can 
then voluntarily terminate.

Not the clearest message I've written lately... sorry, but if that's not 
enough to point you in the right direction, give more detail and you'll 
get a better answer.

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Magnus Lycka
Martin P. Hellwig wrote:
> Kevin wrote:
> 
> 
> Well, for some strange reason I have never found that to be a problem.

If you develop software for an external customer, and they have
an existing web site run by some ISP that you have no control over,
this might well be a problem.

Even if the customer is in control of their web servers, it might be
difficult to convince them to install and maintain something like
Python on them.

I find it a bit surprising that so many people on comp.lang.python
don't realize what kind of practical complications most commercial
software developers have to struggle with if they don't just follow
the mainstream and use PHP or Java for all web apps.

My ISP (FS Data in Sweden) has Python installed, and always upgraded
it when I asked them (but only then, so I suspect I'm the only user--
and this is one of the biggest ISPs in Sweden).

Even if I have access to Python, they don't allow me to have my own
long running processes, so I'm stuck with CGI, which wouldn't work
very well with a much higher load than my moin has. (Actually, I
didn't really need more, so I haven't asked for mod_python support
etc.)

Colocation is certainly getting much cheaper, my ISP charges much less
than 95EUR/month.(295 SEK). Still, it would certainly be great if
mod_python, twisted and zope support etc would be as common as mod_perl
or PHP support. We can only get that if we actively ask for it, and if
we really favour vendors that provide this support when we can.
-- 
http://mail.python.org/mailman/listinfo/python-list


Syntax error after upgrading to Python 2.4

2005-08-05 Thread frr
Hi,

After upgrading to 2.4 (from 2.3), I'm getting a weird syntax error:

>>> import themes
Traceback (most recent call last):
  File "", line 1, in ?
  File "themes.py", line 564
font = self.font.makeBlackAndWhite(),
  additive = self.additive,
 ^
SyntaxError: invalid syntax

The relevant code is:

def makeBlackAndWhite( self ):

return CharStyle( names = self.names,
  basedOn = self.basedOn.makeBlackAndWhite(),
  font = self.font.makeBlackAndWhite(),
  additive = self.additive,
  prefixText = self.prefixText )

This is a method in the CharStyle class which returns a new modified
instance of CharStyle.

I'm using Windows XP and Python 2.4.1

Any ideas? O:-)

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


Re: Oreilly CodeZoo

2005-08-05 Thread Hamish Macpherson
A sexy design?

But yes, there are quite a few out there.

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


Re: Euclid's Algorithm in Python?

2005-08-05 Thread jepler
On Thu, Aug 04, 2005 at 08:13:11PM -0700, Jordan Rastrick wrote:
> Raising an assertion error for a < b is a bit of overkill, since its
> not really a case of bad input. So normally you see Euclid done like
> this:
[snipped]

My point was not so much that this was the ultimate implementation of GCD, but
that the obvious search would have turned up many enlightening results,
including the topmost one.

Jeff


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

Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Daniel Schüle
>>c = 1+1j
>>c.arg(angle_mode = cmath.GRAD) -> 45.0
> 
> 
>   Is that right? The result looks more like Degrees...

maybe I confuse, in german one would say "45 Grad"
I took a freedom to translate it directly :)
well, my calculator shows a "D"
which most likely stands for Degree, I cannot tell for sure

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


Re: newbie question; output from simple print statement

2005-08-05 Thread epost2
thanks.

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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Daniel Schüle
Hi Terry,

 >>In my opinion it would also be nice to have the
 >>possibility to write it as
 >>c.abs()
 >>it looks more OO
 >
 >
 > Python is object based but not rigidly OO in syntax or looks.  This 
is an
 > intentional design decision.  Not being gratuitiously redundant is 
another.

I agree, redundancy confuses people

 >>unfortunately there is no arg method to get the angle
 >>of the complex number
 >
 >
 > I agree that this is a deficiency.  I would think .angle() should be a
 > no-param method like .conjugate(), though its internal implementation 
would
 > need access to the appropriate cmath functions.  I think returning 
radians
 > might be enough though.

I don't know what nomenclature is used in english speaking
mathematical world for angle of a complex number
I learned it in german as Arg(z) .. Arg standing for argument
you see, we would have named it differently, hence making
it difficult for the reader, eventually creating redundancy

 > You could submit to the SourceForge tracker a RFE
 > (Request For Enhancement) if not a patch.

I never did, but I will see

 >>> c = 1 + 1j
 >>> def arg(c, angle_mode = "RAD"):
... if angle_mode not in ("RAD", "GRAD"):
... raise ValueError
... import math
... ret = math.atan2(c.imag, c.real)
... if angle_mode == "GRAD":
... return ret / math.pi * 180
... return ret

it's pretty easy and straightforward implementation
while writing this, I was struck by an idea and
reimplemented it as following

 >>> def arg(self, angle_mode = "RAD"):
... if angle_mode not in ("RAD", "GRAD"):
... raise ValueError
... import math
... ret = math.atan2(self.imag, self.real)
... if angle_mode == "GRAD":
... return ret / math.pi * 180
... return ret
...
 >>> class Complex(complex): pass
 >>> Complex.arg = arg
 >>> c = Complex(1+1j)
 >>> c.arg(angle_mode = "GRAD")
45.0

later I realized that this represents "yet another implementation"
which could be done by someone, thus again leading to possible
redundancy and confuse people

all this would not have happened when we would have
arg or angle builtin in complex type


 >>I would also like to see some more functions to make
 >>calculations with complex number more convenient
 >>e.g.
 >>c = 27
 >>c.pow(numerator = 1, denominator = 3,
 >>  mode = cmath.EULER, angle_mode = cmath.GRAD)
 >>-> ((3,0), (3,120), (3,240))
 >
 >
 > Wanting all roots is fairly specialized.  sqrt(4) is 2, not (2, -2).

it could be named .allroots(n) -> ((), (), ())
with n whole number

indeed .pow() is not a good name for it, since z**x
always yields one complex number

if x is 2.5 or alike, it could be aproximated with n/m and use
res = []
for i in z.allroots(m):
res.append(i**n)

I am not sure, this is correct iterpretation of z**2.5
I will need to ask in math newsgroup :)
and approximation might not be good enough

 > Have you looked for complex math functions in numpy, numarray, scipy or
 > similar packages?  It is possible that a cmath2 module, written in 
Python,
 > could be useful.

I hope so
I will google for cmath2, I never heard about it
I am new to Numeric and numarray, I was playing with them and
ufunc-tionsand matplotlab, as for SciPy I couldnt find
any binary for 2.4 Python unfortunately :-/

Regards

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


Do I need to have site.py available or not ?

2005-08-05 Thread marcus . obrien
Hi,
on startup my embedded python comes up with "import site failed use
-v". Later python crashes on Pyrun_file(). This is the first time I
have used python and I would like to know does it require site.py to be
read in, and has anyone got an idea how to pass in the -v without using
the python -v command, ie the embedded way. Thanks very much.

Marcus.

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


Re: newbie question; output from simple print statement

2005-08-05 Thread Paul Watson
[EMAIL PROTECTED] wrote:
> Can someone explain to me the output of this simple script? I wonder
> why ['test1.txt'] is printed before "files in c:\", and also why None
> shows up?
> 
> 
> in file test.py:
> 
> def main():
> 
> print "files in c:\ :%s"  % ListFiles("c:\")
> 
> def ListFiles(path):
> for root,dirs,files in os.walk(path):
>print files
> 
> if __name__ == "__main__":
> main():
> 
> 
> output:
> 
> C:\> python test.py
> ['test1.txt']
> files in c:\ :None

The function ListFiles() is being called first.  This produces the 
result that will be used to replace the %s of the print statement.  In 
this case, the return value is None, so nothing is printed.

How to Think Like a Computer Scientist
http://www.ibiblio.org.obp/thinkCSpy/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> Is there a better way of doing this so that I don't have to go through
> every permutation of possible arguments (the example here from the
> matplotlib 'plot' function):

Usually, you would just make the defaults for linecolor and linewidth 
the same as the defaults for the underlying function. matplotlib.pylab 
functions, however, have too much intelligence coded in them for this to 
be easy.

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Kevin
Thank you all for the messages. I agree with Bill on that I was just
whining here.   I should do a bit more research.

I guess I am just getting accustomed to the endless supplies of asp/php
hosting services. All I need to do is shopping for the lowest
price/good service. But it's not the case for Python, so for a newbie
like me it's a little discouraging. Now I have more information I will
look into it, and hopefully can pick up Phthon again. To tell you the
truth, after perl, java, vb, and (some) php and groovy, I want to
settle down on something (along with java). That maybe the reason of my
frustration. :-)

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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Dan Bishop
Terry Reedy wrote:
> "Daniel Schüle" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
...
> > unfortunately there is no arg method to get the angle
> > of the complex number
>
> I agree that this is a deficiency.  I would think .angle() should be a
> no-param method like .conjugate(), though its internal implementation would
> need access to the appropriate cmath functions.

You need math, not cmath.

def arg(z):
   """The Argument of z, in radians."""
   z += 0j # make it work on real inputs
   return math.atan2(z.imag, z.real)

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


Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread stephen
Is there a better way of doing this so that I don't have to go through
every permutation of possible arguments (the example here from the
matplotlib 'plot' function):

def makeplot(self, xvalues, yvalues, linecolor='', linewidth=''):
if linecolor and linewidth:
plot(xvalues, yvalues, linecolor, linewidth=linewidth)
elif linecolor:
plot(xvalues, yvalues, linecolor)
elif linewidth:
plot(xvalues, yvalues, linewidth=linewidth)
else:
plot(xvalues, yvalues)

Stephen

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


minidom xml & non ascii / unicode & files

2005-08-05 Thread webdev
lo all,

some of the questions i'll ask below have most certainly been discussed 
already, i just hope someone's kind enough to answer them again to help 
me out..

so i started a python 2.3 script that grabs some web pages from the web, 
regex parse the data and stores it localy to xml file for further use..

at first i had no problem using python minidom and everything concerning 
my regex/xml processing works fine, until i tested my tool on some 
french page with "non ascii" chars and my script started to throw errors 
all over the place..

I've looked into the matter and discovered the unicode / string encoding 
processes implied when dealing with non ascii texts and i must say i 
almost lost my mind.. I'm loosing it actually..

so here are the few questions i'd like to have answers for :

1. when fetching a web page from the net, how am i supposed to know how 
it's encoded.. And can i decode it to unicode and encode it back to a 
byte string so i can use it in my code, with the charsets i want, like 
utf-8.. ?

2. in the same idea could anyone try to post the few lines that would 
actually parse an xml file, with non ascii chars, with minidom 
(parseString i guess).
Then convert a string grabbed from the net so parts of it can be 
inserted in that dom object into new nodes or existing nodes.
And finally write that dom object back to a file in a way it can be used 
again later with the same script..

I've been trying to do that for a few days with no luck..
I can do each separate part of the job, not that i'm quite sure how i 
decode/encode stuff in there, but as soon as i try to do everything at 
the same time i get encoding errors thrown all the time..

3. in order to help me understand what's going on when doing 
encodes/decodes could you please tell me if in the following example, s 
and backToBytes are actually the same thing ??

s = "hello normal string"
u = unicode( s, "utf-8" )
backToBytes = u.encode( "utf-8" )

i knwo they both are bytestrings but i doubt they have actually the same 
content..

4. I've also tried to set the default encoding of python for my script 
using the sys.setdefaultencoding('utf-8') but it keeps telling me that 
this module does not have that method.. i'm left no choice but to edit 
the site.py file manually to change "ascii" to "utf-8", but i won't be 
able to do that on the client computers so..
Anyways i don't know if it would help my script at all..

any help will be greatly appreciated
thx

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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Dan Sommers
On Fri, 05 Aug 2005 15:42:41 +0200,
Daniel Schüle <[EMAIL PROTECTED]> wrote:

> Hello all,
> I often have to deal with complex numbers
> using python iteractive as calculator

> I wonder why there are no methods like arg, abs

> well one can use
> c = 1+1j
> abs(c)

> In my opinion it would also be nice to have the
> possibility to write it as
> c.abs()
> it looks more OO

I guess it's for the same reason that we are spared
from writing things like this:

z = x.squared().added_to(y.squared()).squareroot()
E = m.multiplied_by(c.squared())

More OO, yes.  More readable, not IMO.

> I would also like to see some more functions to make
> calculations with complex number more convenient

[ ... ]

> maybe there exists some proposals aiming this goal?

SciPy or Numeric?

Regards,
Dan

-- 
Dan Sommers

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

Making a timebomb

2005-08-05 Thread callmebill
I have a server that right now runs infinitely.  I'd like to make it
die after some amount of time.  I was thinking of having a timebomb
thread that starts when the server starts.  The timebomb sits, and
sleeps for the specified timeout period (e.g., 5 hours), then does
something to make the main thread terminate.  But I'm too inexperienced
to figure out what that thing is.

Any suggestions?



class TimeBomb( threading.Thread ):
   def run(self):
   timeout = 5 * 60 * 60 #-- 3 hours
   time.sleep( timeout )
   MakeTheRestOfTheStuffDie()

class MyServer:
   def __init__(self):
   TimeBomb().run()
   serve()

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


newbie question; output from simple print statement

2005-08-05 Thread epost2
Can someone explain to me the output of this simple script? I wonder
why ['test1.txt'] is printed before "files in c:\", and also why None
shows up?


in file test.py:

def main():

print "files in c:\ :%s"  % ListFiles("c:\")

def ListFiles(path):
for root,dirs,files in os.walk(path):
   print files

if __name__ == "__main__":
main():


output:

C:\> python test.py
['test1.txt']
files in c:\ :None

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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Terry Reedy

"Daniel Schüle" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I wonder why there are no methods like arg, abs

> well one can use
> c = 1+1j
> abs(c)
>
> In my opinion it would also be nice to have the
> possibility to write it as
> c.abs()
> it looks more OO

Python is object based but not rigidly OO in syntax or looks.  This is an 
intentional design decision.  Not being gratuitiously redundant is another.

> unfortunately there is no arg method to get the angle
> of the complex number

I agree that this is a deficiency.  I would think .angle() should be a 
no-param method like .conjugate(), though its internal implementation would 
need access to the appropriate cmath functions.  I think returning radians 
might be enough though.  You could submit to the SourceForge tracker a RFE 
(Request For Enhancement) if not a patch.

> I would also like to see some more functions to make
> calculations with complex number more convenient
> e.g.
> c = 27
> c.pow(numerator = 1, denominator = 3,
>   mode = cmath.EULER, angle_mode = cmath.GRAD)
> -> ((3,0), (3,120), (3,240))

Wanting all roots is fairly specialized.  sqrt(4) is 2, not (2, -2).

> what do you think about it?
> maybe there exists some proposals aiming this goal?

Have you looked for complex math functions in numpy, numarray, scipy or 
similar packages?  It is possible that a cmath2 module, written in Python, 
could be useful.

Terry J. Reedy




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

Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Martin P. Hellwig
Kevin wrote:


Well, for some strange reason I have never found that to be a problem.
But that is perhaps because I'm an administrator and I want full root 
access, install the OS as I see fit and don't want others on the same 
(virtual)box. So hosting doesn't work for me I need colo or dedicated.

Mostly I slap DragonFlyBSD( or NetBSD if the other doesn't run smoothly) 
with PostgreSQL, Mod_python/Apache and some other handy tools like 
tripwire. The advantage is that I am the administrator, the 
dis-advantage is that I am the administrator :-).

Here in the Netherlands I can get 1HE colo for 95EUR/month, a reasonable 
price IMO.

You can always rent space at different providers (for fail-over) install 
the machines just as your like it and rerent your own shared web 
hosting. Then you can have all the goodies you want and still be in the 
price range of comparible hosters.

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Roy Smith
Kevin <[EMAIL PROTECTED]> wrote:
>The problem is that it's difficult to find hosting services with Python
>installed and supported.

I just googled for ["web hosting" python] and got 1,250,000 hits.  I
can personally recommend panix.com, but there's plenty of other
choices too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Oreilly CodeZoo

2005-08-05 Thread gene tani
http://radar.oreilly.com/archives/2005/08/codezoo_program_1.html

http://python.codezoo.com/

Nice to see that python is in-demand, but what is the rationale for
another ASPN cookbook/Parnassus / pypackage / dmoz type repository?

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Terry Reedy

"Kevin" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> The problem is that it's difficult to find hosting services with Python
> installed and supported.

The Python Wiki has lists of both free and commercial hosting services. 
The top page is http://wiki.python.org/moin/PythonHosting.  Did you look at 
these?  Are the choices inadequate?  (I have no idea, never having been 
involved with the subject.)
...
> I am sure this issue has already been raised a billion times.

Yes, that is why the wiki pages were added.  Improvements are welcome, I 
presume.

> I really wish Python could be more widely available on web server
> machines. This is just my own experience and I would like to hear your
> comments.

We all wish that.  But in my ignorance, I wonder why the few that there are 
are so insufficient that you would drop Python (for PHP, no less).  Do 
clients require that you use specific hosting services, even though they do 
not host a preferred package?  Do the few Python hosters that there are, 
knowing that they are few, exploit Python developers with high rates or 
other obnoxious policies?  This issue has been raised enough that I really 
am curious.

Terry J. Reedy



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


Re: API class creation

2005-08-05 Thread kman3048

Thanks, that helped a lot.

Anybody who wants to attempt the same might find the
source code tree of Python i.e. file src/Modules/cdmodule.c
helpful.

--Matt


Daniel Dittmar wrote:
> kman3048 wrote:
> > Hello,
> >
> > as a relative newcomer to Python API programming I've got a problem:
> >
> > To extend Python:
> > - there is an API C call to create a module
> > - there is also a API C call to create a method
> > - there is an API C call to create a Class instance
> >
> > Now, I need to create a Class and fill it with Methods and Variables.
> > There are means to create (and attache) methods and variables.
> > However, I have not found how to create a Class within a Module. Or do
> > I have to use a low level API function to allocate an Object from Heap?
>
> static PyMethodDef moduleMethods [] = {
>  ...
> };
>
> statichere PyTypeObject MyClassType = {
>  PyObject_HEAD_INIT (NULL)
>  ...
> };
>
> initmymodule ()
> {
>  PyObject* module;
>  PyObject* dict;
>
>  module = Py_InitModule4 ("mymodule", moduleMethods,
>"doc string", NULL, PYTHON_API_VERSION);
>  if (module == NULL) {
>  return;
>  }
>  dict = PyModule_GetDict (module);
>  PyDict_SetItemString (dict, "MyClass"),
>  (PyObject*) &MyClassType));
> }
> 
> Daniel

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


Re: An editable buffer for the Python shell (similar to '\e' on sql prompts)

2005-08-05 Thread Robert Kern
Steve wrote:
> Hi,
> When working in the python command shell, I often end up writing more
> than 10+ lines of indented code before making a stupid typo. This got
> irritating enough for me to do something about it. So, here's an
> 'InteractiveConsole with an editable buffer'.
> 
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438813
> 
> Just thought  some one else also would find this useful.

See also ipython and pyrepl.

   http://ipython.scipy.org
   http://codespeak.net/pyrepl/

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


An editable buffer for the Python shell (similar to '\e' on sql prompts)

2005-08-05 Thread Steve
Hi,
When working in the python command shell, I often end up writing more
than 10+ lines of indented code before making a stupid typo. This got
irritating enough for me to do something about it. So, here's an
'InteractiveConsole with an editable buffer'.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438813

Just thought  some one else also would find this useful.

Regards
Steve
-- 
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: time.clock() or time.time()

2005-08-05 Thread Magnus Lycka
Shane Hathaway wrote:
> However, isn't this thoroughly un-Pythonic?  No wonder people have to 
> ask.

Only if they've never read K&R, and I thought that was compulsory! ;^)

There are a few python libraries, such as time and math, that are
basically just thin wrappers around standard C libraries. In some
cases, they are complemented with more modern libraries, such as
datetime.

You might argue on how pythonic (or useful, or beginner friendly)
they are, but they cost very little to maintain across platforms.
It's important to keep the maintenance costs down for any project,
certainly for a project such as Python, and as far as I know, there
is no cross platform standard API to access CPU time, so a
time.cputime() function would require a lot of work to maintain,
and I don't know if anyone really had a strong need for it.

There is a benefit to maintain (standard or not) API's that
programmers have experience from when programming in other languages.
Of course, I think it's a good thing to properly adapt API's to Python
ways of working. I.e. if a C++ library returning an iterator is wrapped,
I want to be able to do...

for item in container:
print item

...rather than...

it = container.start()
while it != container.end():
 item = it.deref()
 print item

Still, it's often a Good Thing if a Python API is as similar as
possible to e.g. a C++ API that it wraps.

One of the great aspects of Python is that it's a good team player.
It doesn't try to create a world of its own, like Smalltalk and
ABC does, but blends in well in a mixed language environment.

We work extensively with a mix of C++ and Python (as well as some
other languages) here at Carmen, and it would be painful if I had
to remember two different API's for each library that I access from
both C++ and Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Help on Swig

2005-08-05 Thread Gurpreet Sachdeva

Hi,
I am facing a problem with swig while using Pointers:


#include
void Array(int *ptr)
{
        int i;
        for (i = 0; i < 6; i++)
        {
                printf("Index: %d - %d\n",i, *(ptr + i));
        }
}

%module Array
%{
extern void Array(int *ptr);
#include
%}
extern void Array(int *ptr);

While running:

>>> import Array
>>> a=[1,3,2,4,5,6,7,9]
>>> Array.Array(a)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: argument number 1: a 'int *' is expected, 'list([1, 3, 2, 4, 5, 6, 7, 9])' is received

Do I need to make some changes in Interface file?
Also I need to return that array after sorting it. How do I return it and collect the same in python.

Thanks and Regards,





Cheers!


«·´`·.(*·.¸(`·.¸ ¸.·´)¸.·*).·´`·» 

      «.[ Garry ].» 

«·´`·.(¸.·*(¸.·´ `·.¸)*·.¸).·´`·» 

Blogging at http://garrythegambler.blogspot.com/

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

Re: Python's CSV reader

2005-08-05 Thread Andrew McLean
In article <[EMAIL PROTECTED]>, 
Stephan <[EMAIL PROTECTED]> writes
>Thank you all for these interesting examples and methods!

You are welcome. One point. I think there have been at least two 
different interpretations of precisely what you task is.

I had assumed that all the different "header" lines contained data for 
the same fields in the same order, and similarly that all the "detail" 
lines contained data for the same fields in the same order.

However, I think Peter has answered on the basis that you have records 
consisting of pairs of lines, the first line being a header containing 
field names specific to that record with the second line containing the 
corresponding data.

It would help of you let us know which (if any) was correct.

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Istvan Albert
There are plenty of webhosts that offer python,  do a little research.

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Benji York
Kevin wrote:
> I have been using java (jsp/servlets), vb/asp and perl for a few years.
> Almost all my projects are web site development related, and many of my
> clients' web sites are hosted on those shared web hosting services.
> 
> The problem is that it's difficult to find hosting services with Python
> installed and supported.

See http://wiki.python.org/moin/PythonHosting and remember that Google 
is your friend.
--
Benji York


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


Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Daniel Schüle
> I would also like to see some more functions to make
> calculations with complex number more convenient
> e.g.
> c = 27

c = 27+0j
-- 
http://mail.python.org/mailman/listinfo/python-list


why no arg, abs methods for comlex type?

2005-08-05 Thread Daniel Schüle
Hello all,

I often have to deal with complex numbers
using python iteractive as calculator

I wonder why there are no methods like arg, abs

well one can use
c = 1+1j
abs(c)

In my opinion it would also be nice to have the
possibility to write it as
c.abs()
it looks more OO

unfortunately there is no arg method to get the angle
of the complex number
of course it easy to write one on your own
(that's what I have done for myself)
but differnt people will create and reinvite the wheel
over and over again
while reading alien code one will have to spend 2 seconds
remembering the function names etc

consider
c = 1+1j
c.arg(angle_mode = cmath.GRAD) -> 45.0
or
c.arg(angle_mode = cmath.RAD) -> 0.7853..

I would also like to see some more functions to make
calculations with complex number more convenient
e.g.
c = 27
c.pow(numerator = 1, denominator = 3,
   mode = cmath.EULER, angle_mode = cmath.GRAD)
-> ((3,0), (3,120), (3,240))

what do you think about it?
maybe there exists some proposals aiming this goal?

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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Bill Mill
 
> I really wish Python could be more widely available on web server
> machines. This is just my own experience and I would like to hear your
> comments.
> 

I would like a pony... no, wait, even better, a unicorn!

Peace
Bill Mill
bill.mill at gmail.com

PS (the gist is, why don't you offer some constructive comments,
instead of ones we can do nothing about?)
-- 
http://mail.python.org/mailman/listinfo/python-list


The ONLY thing that prevents me from using Python

2005-08-05 Thread Kevin
I have been using java (jsp/servlets), vb/asp and perl for a few years.
Almost all my projects are web site development related, and many of my
clients' web sites are hosted on those shared web hosting services.

The problem is that it's difficult to find hosting services with Python
installed and supported. And most hosting companies are reluctant to
install it for you because they don't want to do the extra work(they
would always say to me, why don't you use php or java or asp or per?).
I have searched and found some companies that support Python. But still
there are far few choices than other options.

I am sure this issue has already been raised a billion times. I just
feel very frustrated on this. I want to learn and use Python in my web
projects.

One day in last December I decided to learn Python, because of Bruce
Eckel's  recommendation on his web site (I started java with his book).
After writing a few scripts (each with a hundred lines or less), I
really liked Python, even though at first to me, it has a very
different style and mindset from my accustomed java approach. I enjoyed
the experience and was ready to delve into the OO and other aspect of
Python.

But because of the hosting issue, I stopped and since then have spent
more time on php, and it seems that I would soon become a full time
PHPer now.

I really wish Python could be more widely available on web server
machines. This is just my own experience and I would like to hear your
comments.

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


Re: Py: a very dangerous language

2005-08-05 Thread Michael Hudson
Benjamin Niemann <[EMAIL PROTECTED]> writes:

> Luis M. Gonzalez wrote:
>
>> This is great!
>> It's absolutely useless, like a real therapist, but it's free!
>
> Never heard of Eliza? Even Emacs has it built in (Menu Help -> Emacs
> Psychiatrist).

M-x psy return

Cheers,
mwh

-- 
  Gullible editorial staff continues to post links to any and all
  articles that vaguely criticize Linux in any way.
 -- Reason #4 for quitting slashdot today, from
http://www.cs.washington.edu/homes/klee/misc/slashdot.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Program

2005-08-05 Thread Daniel Schüle
Eric schrieb:
> I am reading a book on Python and ran across and exercise that I just
> can't seem to figure out.  Its pretty simple, but I just can't get
> past a certain point.
> 
> The task is to create a program that flips a coin 100 times and keeps
> track of the total of heads and tails which is printed to the screen.
> 
> My plan was to use import random with a range of 2 and use a
> conditional statement to count to 100. The problem I am encountering
> is how do I keep track of the totals for heads and tails?
> 
> Any suggestions would be appreciated. Keep in mind I am very new to
> Python so there may be a more sophisticated way, but I am just trying
> to use what the book has taught so far.
> 
> Thanks,
> Eric

 >>> import random
 >>> coin = ("head", "tail")
 >>> cnt = {"head":0, "tail":0}
 >>> for i in xrange(100):
... cnt[random.choice(coin)] += 1
...
 >>> cnt
{'head': 49, 'tail': 51}
 >>>

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


Re: Parallel arithmetic?

2005-08-05 Thread jburgy
Dennis Lee Bieber wrote:
> On Thu, 04 Aug 2005 20:59:33 -0500, "Terrance N. Phillip"
> <[EMAIL PROTECTED]> declaimed the following in
> comp.lang.python:
>
> > Thank-you very much for all the excellent replies. I'm thinking of using
> > this to determine if a sequence is a "run" (as in a card game). If I've
> > got a sorted hand [3, 4, 5, 6, 7], then I know I've got a 5-card run
>
>   A sorted list?
>
>   if (hand[-1] - hand[0]) == (len(hand) - 1)
>
> would seem to do it for your example.
>
>   Actually, if you KNOW the list is only 5 entries long
>
>   if (hand[4] - hand[0]) == 4
>

It's cute but wrong! How 'bout hand = [ 0, 0, 0, 4 ]? It's sorted,
passes your test and does not meet the OP's requirement :(

> would do it.
>
>   Or any equivalent... (hand[0] + 4) == hand[4]
>
>
> --
>  > == <
>  >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >  [EMAIL PROTECTED] |   Bestiaria Support Staff   <
>  > == <
>  >   Home Page: <
>  >Overflow Page: <

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


Re: Some question about setuptools module

2005-08-05 Thread limodou
2005/8/5, Robert Kern <[EMAIL PROTECTED]>:
> limodou wrote:
> 
> > I'm sorry may be this letter is not suit for this maillist.
> 
> You'll get better help on the Distutils-SIG list.
> 
> http://mail.python.org/mailman/listinfo/distutils-sig/
> 
> Phillip Eby hangs out there for the care and feeding of setuptools adopters.
> 

Thanks I'll try there.

-- 
I like python! 
My Donews Blog: http://www.donews.net/limodou
New Google Maillist: http://groups-beta.google.com/group/python-cn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing python2.4.1

2005-08-05 Thread TPJ
There are two things I don't like about messages you got.

>  checking for g++ ... no

and

>  C++ compiler cannot create executables

There are two possibilities I can think of now. The first is you have
no g++ installed. In this case you should install it (I think it would
be very easy, you could install it from the proper deb package).

The second is there is a working g++, but ./configure fails to detect
it.

BTW: Have you tried to compile a simple C program by yourself?

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


  1   2   >