Re: variable declaration

2005-02-08 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote:

> "Brian van den Broek" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > Is the right way to understand it in this vicinity:
> 
> In the vicinity, but not quite exact
> 
> >At compile time (by which I mean when the Python bytecode is built)
> 
> Compile time is when the def statement is executed

I disagree: compile time is when the compiler is running (for example,
the compiler is the component which diagnoses syntax errors, while other
errors are diagnosed ``at runtime'').

Bytecode is built before def executes -- indeed it's built whether def
executes or not.  Cfr:

>>> def f(wo):
...   if wo:
... def g(): pass
... 
>>> f.func_code.co_consts
(None, ", line 3>)

the 'def g' hasn't executed (yet?), but the bytecode is built (and
stored as the first constantvalue in f, save the ubiquitous None).

If the ``if wo: def ...'' construct was in a module being imported, the
mechanics would be similar -- although in this case I think you could
tell only if a syntax error was present in the def statement (I may be
wrong, but offhand I don't think the codeobject is saved in this case).

Or, try this one:

>>> c = compile('def x(): pass', '', 'exec')
>>> c
", line 1>
>>> c.co_consts
(", line 1>, None)
>>> 

``compile time'' here is when the 'compile' built-in runs; and we can
see the code object ``x'' is already built even though the def has not
been executed yet.


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


Re: Confused with methods

2005-02-08 Thread Antoon Pardon
Op 2005-02-07, Alex Martelli schreef <[EMAIL PROTECTED]>:
> Antoon Pardon <[EMAIL PROTECTED]> wrote:
>
>> Yes it is inconsistent with the rest of python. That you found
>> a subset in which it is consistent doesn't change that.
>> 
>> And what if you do:
>> 
>>   c = C()
>>   c.f = g
>> 
>> 
>> The fact that a function in a class performs a lot of magic if
>> it is called through an instance, that isn't performed otherwise,
>> makes python inconsistent here. You may like the arrangement
>> (and it isn't such a big deal IMO) but that doesn't make it consistent.
>
> Any descriptor (be it a function or otherwise) has its __get__ method
> called, when _accessed_ by attribute syntax, if and only if that
> descriptor is in a class.  _ALL_ of Python is perfectly consistent on
> this point, and if I didn't already know the kind of crazy and obviously
> false assertions that you post *QUITE* consistently, I would be
> astonished to see you claim otherwise.  Knowing your posts, this latest
> idiocy is perfectly "par for the course".

No python is not consistent and your continuous repetion doesn't
make it so. To illustrate, here the following code:

class A:
  l = []
  def f(): pass

a = A()
print a.l is A.l
print a.f is A.f

which produces:

True
False


>
> "A lot of magic" is simply a stupid and imprecise way to describe "the
> __get__ method gets called".

So what? That is an implementation detail. 

> Saying that any of this happens when the
> function is CALLED is a definitely more serious mistake, since it's
> absolutely obvious that the __get__ method is called when the function
> (or any other attribute) is *ACCESSED* -- the call operation (on
> whatever object __get__ returns) happens AFTERWARDS.

Fine, I was imprecise. But your harping on my impression doesn't
change the fact that python doesn't work consistent here.

> Why you, and a few other habitual trolls, keep lowering the signal to
> noise ratio of this newsgroup with your blatherings, I don't know;

Well you can think me a troll, I think you are a zealot who gets
overly defensive if the "wrong" people try to suggest python has
some failing.

> I'm
> sure this behavior must be giving you guys some kind of satisfaction.
> Whether the damage you do to the clarity of the issues, and to the
> understanding of newbies who are unfortunate enough to read and trust
> the many imprecise and/or utterly false assertions you keep making,

Look we are all people, we all are imprecise at moments, including you.
But when the "wrong" people get imprecise you get into a fit on how
these people are trolls and try to get python into a bad daylight
instead of trying to understand what they really are trying to say
and reacting to that and maybe in the mean time correcting the
imprecession.

In this case the way python accesses class functions from an instance
is not consistent with how python accesses other class attributes
from an instance. I know it is designed that way and I can understand
hwy it was done. But this inconsistency can be a stumbling block for
a newcomer and I think that explaining why the inconsistency is present
is a better option than declaring there is no inconsistency.

> with
> totally unjustified airs of competence, is part of your jollies, or just
> a side effect you don't care a whit about, I don't know either.  Guess
> I'll just killfile you for another month now -- wish MacSOUP had a
> simple way to to permanent killfiling, since it's pretty obvious by now
> that it's quite unlikely you'll even post anything worthwhile at all.

Well whether I post something that is worthwhile to you, can only be
decided by you. I sometimes have my doubts about you too.

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


python connect to server using SSH protocol

2005-02-08 Thread [EMAIL PROTECTED]
How can python connect to server which use SSH protocol?
Is it easy since my python has to run third party vendor, write data,
read data inside the server (supercomputer).

Any suggestion?

Sincerely Yours,
Pujo Aji

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


Re: Big development in the GUI realm

2005-02-08 Thread Robert Kern
Francis Girard wrote:
[I wrote:]
In any case, he may be right, and the FSF, Trolltech, and you could all
be wrong. Your intention when you use the GPL may be moot if a judge
determines that the text itself and copyright law does not support your
interpretation.

I'm sorry to jump into this thread without any knowledge of these issues. I 
was just wondering if it did happen. Did some law court, over the past 
decade, had to make a decision about GPL on some real issue ? 
Not about this issue, I don't believe. There was some flap between MySQL 
AB and NuSphere Corporation concerning *static* linking, but that case 
was settled before the judge ruled on whether static linking creates a 
derivative work[1].

Larry Rosen's book _Open Source Licensing_ covers these issues (and 
their lack of case law) pretty thoroughly[2].

[1] http://www.mysql.com/news-and-events/press-release/release_2002_14.html
[2] http://www.rosenlaw.com/oslbook.htm
--
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: Confused with methods

2005-02-08 Thread Alex Martelli
jfj <[EMAIL PROTECTED]> wrote:

> I just realized that I'm trolling.

I'm glad you're retracting your earlier assertion that "There is no
trolling involved here".  Everybody can err, but to admit and apologize
takes character: may I offer my warmest handshake.

Back when I was a Python newbie (and identified as such even in the
Subject of my early posts) I had my ideas about how Python should
change, too: it should grow a '__contains__' special method to let a
container optimize membership tests (the `in' operator); it should have
a specialized iterator protocol, rather than always relying on indexing
for iteration; it should be possible to subclass builtin types, e.g.
dictionary; ... you can read all about it on google, including my
request to """Please consider "IMHO"'s to be liberally inserted in what
follows, of course!-)."""

It turned out that __contains__ was already in the plans (which I did
not know about): I had even guessed the *name*!  The iterator protocol
and subclassing builtin types took a bit longer to appear (and the
eventual name was __iter__ while my original idea was __enum__; and it's
still not fully possible insert a subclassed dict anywhere a dict may be
used) but eventually they did.

And yet for all of this I ended up in a flamewar with the timbot
anyway... it solved itself and we made friends, but still, I'm quite
familiar with the pickles a newbie can get into;-).


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


Re: Curses on Windows

2005-02-08 Thread Josef Meile
Hi Peter,
Last November I posted a message asking for advice on using simple
screen handling techniques under Windows.  Since then I have been
occupied with family / job /Christmas /living  and trying to
understand curses under linux (it works, seems very complex, sure I'm
missing something ...).  Only now am I returning to my original query.
One reply (in fact the only reply - thanks Tim Golden) suggested I
look at http://flangy.com/dev/python/curses/
There was a similar thread last month. See my reply for more links. I
haven't tested them, but they may help.
how to ncurses on win32 platform:
http://mail.python.org/pipermail/python-list/2005-January/262511.html
Just tried that and got the message
"You don't have permission to access
/dev/python/curses/files/wcurses-0.1-py2.4.zip on this server."
Yes, I also have problems.
Regards,
Josef
--
http://mail.python.org/mailman/listinfo/python-list


Re: Subclassing cElementTree.Element

2005-02-08 Thread Fredrik Lundh
Kent Johnson wrote:

> Is it possible to subclass cElementTree.Element? I tried
>  >>> import cElementTree as et
>  >>> class Elt(et.Element):
>  ...   pass
>  ...
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: Error when calling the metaclass bases
> cannot create 'builtin_function_or_method' instances

Nope.

This is by design; Elements are intended to be contained, not subclassed. (you
cannot subclass ElementTree Elements either; Element is a factory function, not
a class).

To solve the navigation issue, you could either use a dictionary that keeps 
track
of child-parent relations, or use a proxy wrapper.  Or see if you can structure 
your
code so you always work from parents (that's usually easier than you may think).

 



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


Re: An Ode To My Two Loves

2005-02-08 Thread Peter Maas
Jorgen Grahn schrieb:
It's something that worries me frequently -- I feel guilty when I introduce
Python into ("force Python upon") an organization. Because I hate having
/other/ people's favorite toy languages forced down /my/ throat ...
The solution is a multi language glue layer. Software interfaces are
defined in a  language independent way so that they can be used by
many  languages.I wonder why COM is so dominant on Windows and most
Unixish systems don't use CORBA (with GNOME as an exception).
Microsoft's .net takes this one step further by defining a multi
language implementation layer.
I hope these ideas will become more influential in Unix like systems
as well just to stop this resource wasting source code issue.
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Fredrik Lundh
Robert Kern wrote:

> Believe me, I share your frustration every time this issue comes up. However, 
> I think it's best to 
> follow Robert Heinlein's maxim:
>
>  "Never attribute to malice what can adequately be explained by stupidity."

that's Hanlon, not Heinlein.  to be on the safe side, I won't attempt to
attribute your mistake to anything.

 



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


Re: variable declaration

2005-02-08 Thread Fredrik Lundh
Terry Reedy wrote:

>>At compile time (by which I mean when the Python bytecode is built)
>
> Compile time is when the def statement is executed

no, that's run time.  "def" is an executable statement, just like "print", 
"for",
assignments, "import", etc.

the entire module is compiled (to bytecode) before any part of it is executed.
the compiler handles "global" and "from __future__", everything else is done
at runtime.

 



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


Re: Re: Big development in the GUI realm

2005-02-08 Thread Fredrik Lundh
Tim Churches wrote:

>> and how exactly are you going to load a DLL from an EXE file with-
>> out "mixing, including, or combining" the two?
>
> You can't, but as long as that "mixing, including, or combining" only occurs 
> at runtime,
> the GPL itself specifically says that is out of scope and the GPL does not 
> apply. Their
> words, not mine - to quote (yet again):
>
> "Activities other than copying, distribution and modification are not covered 
> by this
> License; they are outside its scope. The act of running the Program is not 
> restricted,..."

except that if *you* set things up so the code is combined when run, *you* are
copying, distributing, and/or modifying the program in order to mix, include 
and/or
combine your work with the GPL:ed work.

if you leave all that to the user, you're clear.

(relying on word games is a lousy legal strategy in most parts of the world)

 



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


Re: Big development in the GUI realm

2005-02-08 Thread Robert Kern
Fredrik Lundh wrote:
Robert Kern wrote:

Believe me, I share your frustration every time this issue comes up. However, I think it's best to 
follow Robert Heinlein's maxim:

"Never attribute to malice what can adequately be explained by stupidity."

that's Hanlon, not Heinlein.  to be on the safe side, I won't attempt to
attribute your mistake to anything.
Fair enough. The only time I've seen it in dead-tree print was in 
Heinlein's _Time Enough For Love_, unattributed to anyone else. 
Googlespace seems to be not entirely sure whether "Hanlon" is real or is 
a corruption of "Heinlein". Googling for quote attributions is a tricky 
proposition at best, though.

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

2005-02-08 Thread Nick Coghlan
Antoon Pardon wrote:ons already existing.
The compilor might generate a RESTORE instruction.
Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same work 
- check the name exists in the local namespace, and throw an exception if it 
doesn't. If it the name does exist, perform a normal store operation.

but the optimiser should 
eventually be able to do something to eliminate the performance penalty due to 
the technically unnecessary LOAD. I doubt it will be able to beat a STORE_FAST 
when it comes to trying to get a performance improvement, though :)

But maybe a RESTORE_FAST could.
STORE_FAST is set up to store a local as fast as is reasonably possible. The 
space for the local is preallocated in the fast locals C array. How is an 
instruction which does that *and something else* ever meant to be faster?

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-02-08 Thread Just
In article <[EMAIL PROTECTED]>,
 Nick Coghlan <[EMAIL PROTECTED]> wrote:

> Antoon Pardon wrote:ons already existing.
> > The compilor might generate a RESTORE instruction.
> 
> Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same 
> work 
> - check the name exists in the local namespace, and throw an exception if it 
> doesn't. If it the name does exist, perform a normal store operation.

But the compiler would _know_ in which scope the variable was defined, 
no?

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


Re: variable declaration

2005-02-08 Thread Peter Otten
Fredrik Lundh wrote:

> executed. the compiler handles "global" and "from __future__", everything
> else is done at runtime.

and __debug__, too, it seems:

>>> __debug__
False
>>> def f():
... if __debug__:
... global x
... x = 42
...
>>> f()
>>> x
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'x' is not defined

Peter

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


Re: empty classes as c structs?

2005-02-08 Thread Nick Coghlan
Steven Bethard wrote:
I wonder if it would be worth adding a descriptor that gives a warning 
for usage from instances, e.g.:
Thinking about it some more, I realised that a class method approach means that 
'type(self).method(self,...)' still works as a way to spell the call in a 
polymorphism friendly way.

And if we're going to have to spell the call that way *anyway*. . .
So maybe it does make sense to simply say that all non-magic Bunch/namespace 
operations are implemented as class methods (and most magic methods are 
effectively treated as class methods when it comes to looking them).

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-02-08 Thread Duncan Booth
Brian van den Broek wrote:

> Can it then be further (truly :-) ) said that
> 
> if False:
>  # thousands of lines of code here
> 
> would effect the structure of the function object's bytecode, but not 
> its behaviour when run? Or, at most, would cause a performance effect 
> due to the bytecode being bloated by thousands of line's worth of code 
> that would never get executed?
> 

Yes, but that purely an implementation detail.

if 0:
   # thousands of lines of code here

has no effect at all on the bytecode, it it optimised out entirely. 'if 
False:' is not optimised out in Python 2.4 or earlier, but might be in 
later versions.

Now, to really get your brain hurting, see what this one does:

def hurts_my_brain(v):
if 0: # unlike Steve's eg, ensuring that the
global x  # nested block is never hit at runtime
x = v

I'll give you a clue, it's not the same as your:

def hurts_my_brain(v):
if False: # unlike Steve's eg, ensuring that the
global x  # nested block is never hit at runtime
x = v

So the global statement is a wart which isn't executed at runtime, but 
behaves differently when the bytecode it doesn't generate is optimised out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Learning Python - resources and ideas

2005-02-08 Thread [EMAIL PROTECTED] (Cody Houston)
Hi. What is the best way to learn Python? None of the local schools
near me teach any courses on the topic. Thanks.

--

Cody Houston
[EMAIL PROTECTED]

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


Re: AsciiDoc 6.0.0

2005-02-08 Thread Fuzzyman

Donnal Walter wrote:
> Stuart Rackham wrote:
> > AsciiDoc
> > 
> > AsciiDoc is an uncomplicated text document format for writing short
> > documents, articles, books and UNIX man pages.
> >
> > AsciiDoc files can be translated to HTML (with or without
> > stylesheets), DocBook (articles, books and refentry documents)
> > and LinuxDoc using the asciidoc(1) command.
>
> Lately I've been thinking about using reStructuredText for creating
> simple web pages. Should I consider AsciiDoc as an alternative, and
if
> so, what are its advantages by comparison? Thanks.
>
> Donnal Walter

I've never used AsciiDoc - I've always found reST and docutils good
though :-)

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

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


Re: Big development in the GUI realm

2005-02-08 Thread Fred Pacquier
Robert Kern <[EMAIL PROTECTED]> said :

>> that's Hanlon, not Heinlein.  to be on the safe side, I won't attempt
>> to attribute your mistake to anything.
> 
> Fair enough. The only time I've seen it in dead-tree print was in 
> Heinlein's _Time Enough For Love_, unattributed to anyone else. 
> Googlespace seems to be not entirely sure whether "Hanlon" is real or
> is a corruption of "Heinlein". Googling for quote attributions is a
> tricky proposition at best, though.
 
I don't know who Mr Hanlon is, but I've previously seen it attributed to 
Napoleon Buonaparte. Never been able to verify that either, though.

-- 
YAFAP : http://www.multimania.com/fredp/
-- 
http://mail.python.org/mailman/listinfo/python-list


Learning Python - resources and ideas

2005-02-08 Thread [EMAIL PROTECTED] (Cody Houston)
Hi. What is the best way to learn Python? None of the local schools
near me teach any courses on the topic. Thanks.

--

Cody Houston
[EMAIL PROTECTED]

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


Re: variable declaration

2005-02-08 Thread Antoon Pardon
Op 2005-02-08, Nick Coghlan schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:ons already existing.
>> The compilor might generate a RESTORE instruction.
>
> Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same 
> work 
> - check the name exists in the local namespace, and throw an exception if it 
> doesn't. If it the name does exist, perform a normal store operation.

It has to check if the name exists anyway. Because if it doesn't it has
to be created in the namespace directory and in the other case only
the value part has to be changed.

I have the impression you are looking at this too much from the view
of the current implementation where putting a an entry in
a directory is seen as an atomic operation.

So a possibility might be to augment dictionaries with a put method.
d.put(key, value) would throw an exception if the key wasn't already
in the dictionary but would otherwise behave as d[key] = value.

A STORE would then be implemented as a d[key] = value
A RESTORE would then be implemented as a d.put(key,value)

The latter wouldn't have to do more, it would just behave
different.

>>>but the optimiser should 
>>>eventually be able to do something to eliminate the performance penalty due 
>>>to 
>>>the technically unnecessary LOAD. I doubt it will be able to beat a 
>>>STORE_FAST 
>>>when it comes to trying to get a performance improvement, though :)
>> 
>> 
>> But maybe a RESTORE_FAST could.
>
> STORE_FAST is set up to store a local as fast as is reasonably possible. The 
> space for the local is preallocated in the fast locals C array. How is an 
> instruction which does that *and something else* ever meant to be faster?

I don't know enough about pythons internals to answer here. Maybe you
have a point in this case, but you already stated that a RESTORE
would need more work then a STORE where IMO that was not the case,
so I'm not convinced the same kind of solution is not applicable here.

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


Re: Big development in the GUI realm

2005-02-08 Thread Fredrik Lundh
Robert Kern wrote:

> Fair enough. The only time I've seen it in dead-tree print was in Heinlein's 
> _Time Enough For 
> Love_, unattributed to anyone else.

if that's true, it would seem that it predates the Hanlon reference by a
couple of years:

http://www.statusq.org/archives/2001/12/04

on the other hand, Google tells me that "Time Enough For Love" con-
tains a couple of other famous stupidity quotes, including:

"Never underestimate the power of human stupidity"

do you still have a copy of the book?  (preferrably a version printed
before 1980...)

 



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


how to convert 4 bytes into a float ?

2005-02-08 Thread Jean-Baptiste PERIN
I read 4 bytes from a binary file.
These bytes represent a floating point number (mantisse exponent form)
How can I get a float from these bytes ?
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-02-08 Thread Nick Coghlan
Just wrote:
In article <[EMAIL PROTECTED]>,
 Nick Coghlan <[EMAIL PROTECTED]> wrote:

Antoon Pardon wrote:ons already existing.
The compilor might generate a RESTORE instruction.
Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same 
work 
- check the name exists in the local namespace, and throw an exception if it 
doesn't. If it the name does exist, perform a normal store operation.

But the compiler would _know_ in which scope the variable was defined, 
no?
I wouldn't expect the behaviour of name rebinding to be any different from other 
forms of augmented assignment as far as the existence of the left-hand side goes.

Py> def f():
...   x += 1
...
Py> f()
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 2, in f
UnboundLocalError: local variable 'x' referenced before assignment
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Alex Martelli
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:

> hassle to code, but if your application could dynamically select from
> whatever toolkit is available on the machine, you (and I should emphasis
> that this is an impersonal/generic "you" I reference) might be able to
> argue an exemption from the QT license.

So maybe it's time to resurrect anygui, maybe in a simplified version
which can only interface to, say, PyQt or Tkinter -- 'eithergui' maybe.


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


Re: variable declaration

2005-02-08 Thread Nick Coghlan
Antoon Pardon wrote:
I have the impression you are looking at this too much from the view
of the current implementation where putting a an entry in
a directory is seen as an atomic operation.
Yes and no. I *am* looking at it from an implementation point of view, but 
dictionaries have nothing to do with the relevant part of the implementation.

The CPython *_FAST opcodes relate to functions' local variables. Behind the 
scenes they are implemented as integer indexing operations into a pre-sized C 
array. Operations don't come much faster than that :)

Could a rebinding operation *theoretically* be quicker for the other cases which 
involve a real dictionary (or something that looks like one)? Well, perhaps. 
Although I can't see how the rebinding operation would gain a benefit that a 
standard binding operation wouldn't gain if placed at the exact same point.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-02-08 Thread Fredrik Lundh
Peter Otten wrote:

>> executed. the compiler handles "global" and "from __future__", everything
>> else is done at runtime.
>
> and __debug__, too, it seems:

you left out the "python -O" line.

 __debug__
> False
 def f():
> ... if __debug__:
> ... global x
> ... x = 42
> ...
 f()
 x
> Traceback (most recent call last):
>  File "", line 1, in ?
> NameError: name 'x' is not defined

yup, but unlike the two others, that's a CPython -O implementation issue.
(I'd say bug, in this case).

neither standard CPython (without -O) nor Jython behave this way.

 



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


Re: how to convert 4 bytes into a float ?

2005-02-08 Thread Alex Martelli
Jean-Baptiste PERIN <[EMAIL PROTECTED]> wrote:

> I read 4 bytes from a binary file.
> 
> These bytes represent a floating point number (mantisse exponent form)
> 
> How can I get a float from these bytes ?

See the docs for module struct, specifically the struct.unpack function,
if the float is in the binary format your machine expects (or possibly
that but with the wrong endianity).  If the float's binary format is
different from what your machine uses, you're in for a lot of painful
bit-twiddling.


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


Re: empty classes as c structs?

2005-02-08 Thread Nick Coghlan
Michael Spencer wrote:
Nick Coghlan wrote:
The other issue is that a namespace *is* a mutable object, so the 
default behaviour should be to make a copy

I don't follow this argument.  Why does mutability demand copy?  Given 
that somedict here is either a throwaway (in the classic bunch 
application ) or a dict that must be updated (the wrap-dict case), 
copying doesn't make much sense to me.

OTOH, dict.__init__(dict) copies.  h
As you noticed, it's a precedent from the other builtins and objects in the 
standard library. The mutable ones (dict, list, set, etc) all make a copy of 
whatever you pass in.

This is to allow easy copying of 
an existing namespace - 
Can't this be spelled namespace(somenamespace).__copy__()?
Again, as Steven mentioned, this is based on precedent from other objects in the 
interpreter. To get your own copy of a mutable type, you invoke the constructor 
with the original as the sole argument.

 > for anything else, invoking vars() is easy enough.
If there is potential for confusion, I'd be tempted to disallow 
namespaces as an argument to update/__update__
Limiting confusion is why I decided to restrict the special-case of querying the 
__dict__ to instances of namespace. Again, as Steven pointed out, the semantics 
get screwed up when the object supplied is usable as a dictionary, but also has 
a __dict__ attribute.

For a namespace, the special case means that namespace(ns_obj) and 
namespace(vars(ns_obj)) have the same result. Just don't go creating a namespace 
subclass which provides a direct mapping interface to anything other than it's 
own __dict__ and expect to affect namespaces created using the normal 
constructor. I figure that limitation is obscure enough that we can live with it :)

For an arbitrary object, you can poke around in its __dict__ by doing:
  namespace.view(vars(obj))
We could use __add__, instead for combining namespaces
Update already let's us combine namespaces. To create a new object that merges 
two namespaces do:
  namespace.update(namespace(ns_1), ns_2)

Good idea.  The implementation ought to be tested against several 
plausible specializations.
One thing I'm going to drop is the ability to use an arbitrary class as a 
subrecord. I realised it screws up storage of classes and class instances which 
have a __dict__ attribute.

Instead, I'll change it so that the optional argument allows you to set some of 
the attributes.

I don't like the sound of that.  The whole point here - whether as 
Steven's nice straightforward bunch, as originally conceived, or the 
other cases you and I and others have been 'cluttering' the discussion 
with ;-)  is convenience, and readability.  If there are hoops to jump 
through to use it, then the benefit is quickly reduced to zero.
Yes, once I realised that the polymorphism friendly 'type(self).update(self, 
other)' works with a classmethod, I realised it made sense to go with Steven's 
classmethod approach.

I'll also revert to his *args based solution to the keyword argument problem, 
too.
Time to go play cricket, so I won't actually be posting any of the above changes 
tonight :)

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


re-entrancy question

2005-02-08 Thread apocalypznow
I have a program that instantiates some objects and runs a main loop. 
Before the main loop starts, I create a thread that listens to TCP 
connections on a port.  If any connections are made, and depending on 
the data, I call methods on some of those objects.

I am worried that calling methods on objects from outside the main loop, 
but that are also operated on in the main loop, could cause problems.

My questions:
1) is this safe?
2) what kind of problems could occur?
3) how do I safely handle this?
--
http://mail.python.org/mailman/listinfo/python-list


RE: re-entrancy question

2005-02-08 Thread Tim Golden
[apocalypznow]

| I have a program that instantiates some objects and runs a main loop. 
| Before the main loop starts, I create a thread that listens to TCP 
| connections on a port.  If any connections are made, and depending on 
| the data, I call methods on some of those objects.
| 
| I am worried that calling methods on objects from outside the 
| main loop, 
| but that are also operated on in the main loop, could cause problems.
| 
| My questions:
| 1) is this safe?
| 2) what kind of problems could occur?
| 3) how do I safely handle this?

No doubt there are more pertinent answers, but unless this is
a learning exercise, you'd be better off investigating Pyro:
http://pyro.sf.net

TJG

(And, thinking about it, even if this is a learning exercise)


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

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


variable declaration

2005-02-08 Thread Alexander Zatvornitskiy
Hi, Peter!

05 feb 2005 at 15:28, Peter Otten wrote:

 >> variable names. You have to move the code into a function, though: $
 >> cat epsilon.py ...skipped... $ pychecker epsilon.py epsilon.py:6:
 >> Local variable (epselon) not used Well, I can change it a little to
 >> pass this check. Just add "print epselon" line.

 PO> You are now on a slippery slope. I'd rather think of ways to write my
 PO> code in a way for it to succeed or at least fail in an obvious way.
Ok, fixed.
 PO> I don't consider a scenario likely where you both misspell a name
 PO> nearly as often as you write it correctly, and do that in a situation
 PO> where the program enters an infinite loop instead of just complaining
 PO> with an exception, which is by far the most likely reaction to a
 PO> misspelt name.
Let say, you have variable or class field 'PowerOfGenerator', or 'lambda_k'.
You decide to rename it to 'ReactivePowerOfGenerator' or 'lambda_kx'. But, for
some reasons, you forget to do it everywhere, for example in function with
first lines like this:

  PowerOfGenerator=TakeFromSensor()
  if PowerOfGenerator>xxx:

  RecalcPower(PowerOfGenerator)
  PutToTheDatabase(PowerOfGenerator)
  
Here, python will not help you. The worst thing is that in such calculations
you often receive plausible results.

Another example. Let say you have variable PowerOfGenerator in your program.
But, it is only active power, so you have to (1)rename PowerOfGenerator to
ActivePowerOfGenerator, (2)calculate ReactivePowerOfGenerator, and (3)calculate
new PowerOfGenerator by formula
  PowerOfGenerator=sqrt(ReactivePowerOfGenerator**2+ActivePowerOfGenerator**2)
With var declarations, on step (1) you just rename PowerOfGenerator to
ActivePowerOfGenerator in the place of its declaration, and compile your
program. Compiler will show you all places where you have to rename variables.
After it, on step (3) you can safely and peacefully add new PowerOfGenerator
variable.

Of course, I am trying to use more short variable names, but its just an
example.

 PO> Code not written is always errorfree, and in that spirit I'd rather
 PO> strive to write the function more concisely as

 PO> def loop2():
 PO> s = 0
 PO> for delta in range(10):
 PO> s += delta
 PO> print s

 PO> This illustrates another problem with your approach: would you have
 PO> to declare globals/builtins like range(), too?
if I understand you right, it can be done this way (with '~' instead of 'var'):
  ~s=0
  for ~delta in range(10)
s+=delta

[skip]

 PO> I suggested pychecker more as a psychological bridge while you gain
 PO> trust in the Python way of ensuring reliable programs, i. e. writing
 PO> small and readable functions/classes that do one thing well and can
 PO> easily be tested. Administrative overhead -- as well as excessive
 PO> comments -- only serve to bury what is actually going on.

Your explanation is most "non-religious" in comparison with all others I see in
this newsgroup. Thank you, now I see that lack of var declarations is not
stupid oversight, but it may have reasons.
>From the other side, I still think that optional var declaration is good idea,
for example in functions which are big and operate with tens of variables,
non-decomposable by their nature. Such functions occurs in some domains. And,
in situations like above.

 PO> I guess that means no, not a good idea.

 PO> On the other hand, taking all names used in a function and looking
 PO> for similar ones, e. g. by calculating the Levenshtein distance,
 PO> might be worthwhile...

Hmm, what is the Levenshtein distance between 'x1' and 'x2'? Or between kappa_i
and kappa_j? :)

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


Re: An Ode To My Two Loves

2005-02-08 Thread Alex Martelli
Jorgen Grahn <[EMAIL PROTECTED]> wrote:

> I also notice I forget one language after doing another for a few weeks. And
> it's not just brackets and semicolons -- I also try to use one language's
> idioms in the other. People who /claim/ they have no trouble switching
> languages seem to have the same problem.

I don't find it a problem as long as the languages are simple and
well-separated.  Python and C are a good example: each is simple, and
each is pretty well-focused -- high-level vs low-level.

It's not necessarily easy if you're continuously going back and forth
between C++ and Java, for example -- in such a case, it seems to me that
transitioning into the proper mindset for each language may well be a
nonzero effort, since the languages aren't really all that simple, and
they have quite some overlap despite all the differences.

I have no experience with such switching between (say) Ruby and Python
-- both simple but vastly overlapping in scope.


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


Re: empty classes as c structs?

2005-02-08 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote:

> > We could use __add__, instead for combining namespaces
> 
> Update already let's us combine namespaces. To create a new object that merges
> two namespaces do:
>namespace.update(namespace(ns_1), ns_2)

One thing I'd like to see in namespaces is _chaining_ -- keeping each
namespace separate but having lookups proceed along the chain.  (The
best semantics for _bindings_ as opposed to lookups isn't clear though).


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


Re: how to convert 4 bytes into a float ?

2005-02-08 Thread Jean-Baptiste PERIN
Alex Martelli a écrit :
Jean-Baptiste PERIN <[EMAIL PROTECTED]> wrote:

I read 4 bytes from a binary file.
These bytes represent a floating point number (mantisse exponent form)
How can I get a float from these bytes ?

See the docs for module struct, specifically the struct.unpack function,
if the float is in the binary format your machine expects (or possibly
that but with the wrong endianity).  If the float's binary format is
different from what your machine uses, you're in for a lot of painful
bit-twiddling.
Alex
I'll have to handle Intel-PC, DEC-VAX and MIPS-SUN/SGI numbers
So I can't escape the painful bit-twiddling
Anyway, struct.unpack will undoubtedly be an incredibly valuable help
thank you very very very much ..
JiBé
--
http://mail.python.org/mailman/listinfo/python-list


Choosing the right parser for parsing C headers

2005-02-08 Thread Jean de Largentaye
Hi,

I need to parse a subset of C (a header file), and generate some unit
tests for the functions listed in it. I thus need to parse the code,
then rewrite function calls with wrong parameters. What I call "shaking
the broken tree" :)
I chose to make my UT-generator in Python 2.4. However, I am now
encountering problems in choosing the right parser for the job. I
struggle in choosing between the inappropriate, the out-of-date, the
alpha, or the too-big-for-the task...

So far I've indentified 9(!) potential candidates (Mostly taken from
the http://www.python.org/moin/LanguageParsing page) :

- Plex:
Only a lexical analyser as far as I understand. Kinda RE++, no syntax
processing
- ply:
Lex / Yacc for python! Tackle the Beast! Syntax processing looks
complex..
- Pyggy:
Lex / Yacc -styled too. More recent, but will a 0.4 version be good
enough?
- PyLR:
fast parser with core functions in C... hasn't moved since '97
- Pyparsing:
quick and easy parser... but I don't think it does more than lexical
analysis
- spark:
Here's some wood. Now build your house.
- yapps2 :
yapps2+ (I hesitate to call it yapps3):
chosen by http://www.python.org/sigs/parser-sig/towards-standard.html.
Is the choice up-to-date?
But will it do for parsing C?
- TPG (Toy Parser Generator):
looks cool
- ANTLR (latest version from Jan 28 produces Python code) :
Seems powerful and has a lot of support, but I don't want to have to
use an exterior Java tool. Furthermore, does it let me control what
happens at each stage easily, or does it just make me a compiler?

I've omitted these: shlex, kwparsing (webpage?), PyBison, Trap
(webpage?), DParser, and SimpleParse (I don't want the extra
dependancy).

I was hoping for a quick and easy choice, but got caught in the tar pit
of Too Much Information. Parsing is a large and complex field. As an
added handicap, I'm new to the dark minefield of parsers... I've had
some experience with Lex/Yacc, and have some knowledge of parser
theory, through a course on compilators. I am thus used to EBNF-style
grammar.
I was disappointed to see that Parser-SIG has died out.
Would you have any ideas on which parser is best suited for the task?

John

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


Re: Big development in the GUI realm

2005-02-08 Thread Robert Kern
Fredrik Lundh wrote:
Robert Kern wrote:

Fair enough. The only time I've seen it in dead-tree print was in Heinlein's _Time Enough For 
Love_, unattributed to anyone else.

if that's true, it would seem that it predates the Hanlon reference by a
couple of years:
http://www.statusq.org/archives/2001/12/04
on the other hand, Google tells me that "Time Enough For Love" con-
tains a couple of other famous stupidity quotes, including:
"Never underestimate the power of human stupidity"
do you still have a copy of the book?  (preferrably a version printed
before 1980...)
Not at the moment. I'll try to hit up some used book stores or libraries.
--
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: Choosing the right parser for parsing C headers

2005-02-08 Thread Fredrik Lundh
Jean de Largentaye wrote:

> I need to parse a subset of C (a header file), and generate some unit
> tests for the functions listed in it. I thus need to parse the code,
> then rewrite function calls with wrong parameters. What I call "shaking
> the broken tree" :)
>
> I chose to make my UT-generator in Python 2.4. However, I am now
> encountering problems in choosing the right parser for the job. I
> struggle in choosing between the inappropriate, the out-of-date, the
> alpha, or the too-big-for-the task...

why not use a real compiler?

http://www.boost.org/libs/python/pyste/
http://www.gccxml.org/HTML/Index.html

 



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


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Miki Tebeka
Hello Jean,

> - ply:
> Lex / Yacc for python! Tackle the Beast! Syntax processing looks
mini_c is a C compiler written using ply. You can just use it as is.
http://people.cs.uchicago.edu/~varmaa/mini_c/

HTH.
--

Miki Tebeka <[EMAIL PROTECTED]>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Thomas Heller
"Jean  de Largentaye" <[EMAIL PROTECTED]> writes:

> Hi,
>
> I need to parse a subset of C (a header file), and generate some unit
> tests for the functions listed in it. I thus need to parse the code,
> then rewrite function calls with wrong parameters. What I call "shaking
> the broken tree" :)

IMO, for parsing 'real-world' C header files, nothing can beat gccxml.

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


Re: Big development in the GUI realm

2005-02-08 Thread Joe
On Tue, 8 Feb 2005 10:01:51 +0100, "Fredrik Lundh"
<[EMAIL PROTECTED]> wrote:
>except that if *you* set things up so the code is combined when run, *you* are
>copying, distributing, and/or modifying the program in order to mix, include 
>and/or
>combine your work with the GPL:ed work.
>
>if you leave all that to the user, you're clear.

Mmm... I'm not playing games here, no matter what some seem to think. 

It's obvious that the GPL doesn't say precisely whether it's OK to use
an _independent_ library or EXE, ie. a file that is physically
different from the calling EXE, as oppposed to either copy/pasting the
code as is into a program, or statically linking a library into an
EXE.

Until now, I understood the GPL to be a way to make sure no one stole
code (hence, no static linking or copy/pasting code), and with or
without giving back any change they made.

OTOH, I though it was OK to use the by code shipping whatever standard
binary file was downloaded from the project's site, ie. MYEXE.EXE
calling YOURCODE.DLL was OK, when this code was the standard version,
untampered, and clearly indicated as not the EXE's work (as shown by
the file name and version infos).

Hence, either the GPL was not precise enough, or TrollTech should use
a different license that specifically prohibits even using Qt through
dynamic linking.

Conclusion from what I read above: As of now, no court in any country
has settled this issue by specifying whether making use of a GPLed
program _in any way_ requires the calling program to be GPLed as well,
or if there are cases where the EXE can remain closed-source. I'm fine
with TT's intentions, though.

Joe
(no, I don't want whatever stuff I post on the Net to possibly bite me
years from now, hence the anonymous posting. Nothing personal.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Curses on Windows

2005-02-08 Thread Martin Miller
I just tried the flangy.com link and it appears to be OK now.

Martin


Peter wrote:
> ...
> One reply (in fact the only reply - thanks Tim Golden) suggested I
> look at http://flangy.com/dev/python/curses/

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


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Fredrik Lundh
Thomas Heller wrote:

> IMO, for parsing 'real-world' C header files, nothing can beat gccxml.

no free tool, at least.  if a budget is involved, I'd recommend checking
out the Edison Design Group stuff.

 



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


Re: email extraction program

2005-02-08 Thread Miki Tebeka
Hello Paul,

>Can you help me create an ebay email extraction program ?
> 
>I have some ebay scripts which worked and extracted emails from
>ebay.com but these days don't work.
http://www.catb.org/~esr/faqs/smart-questions.html

HTH.
--

Miki Tebeka <[EMAIL PROTECTED]>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
-- 
http://mail.python.org/mailman/listinfo/python-list



Re: how to convert 4 bytes into a float ?

2005-02-08 Thread Alex Martelli
Jean-Baptiste PERIN <[EMAIL PROTECTED]> wrote:

> I'll have to handle Intel-PC, DEC-VAX and MIPS-SUN/SGI numbers
> So I can't escape the painful bit-twiddling

I don't recall for sure (even though I did my thesis on a Vax, 25 years
ago!) but I think you _might_ be lucky -- VAX used the binary format
that became the IEEE standard, if I recall correctly.

Intel, MIPS, SUN and SGI surely did follow IEEE standards, endianity
apart, and you can correct for endianity with struct.unpack.

The problem would be there if you had, say, floats in old IBM 360/370
formats, or Cray's original formats, or the like...

 
> Anyway, struct.unpack will undoubtedly be an incredibly valuable help
> 
> thank you very very very much ..

You're welcome!


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


Re: variable declaration

2005-02-08 Thread Antoon Pardon
Op 2005-02-08, Nick Coghlan schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> I have the impression you are looking at this too much from the view
>> of the current implementation where putting a an entry in
>> a directory is seen as an atomic operation.
>
> Yes and no. I *am* looking at it from an implementation point of view, but 
> dictionaries have nothing to do with the relevant part of the implementation.
>
> The CPython *_FAST opcodes relate to functions' local variables. Behind the 
> scenes they are implemented as integer indexing operations into a pre-sized C 
> array. Operations don't come much faster than that :)

I don't follow. AFAIR my remark here above was about the STORE opcode.
But you seem to react to it as if I am talking about STORE_FAST.

> Could a rebinding operation *theoretically* be quicker for the other cases 
> which 
> involve a real dictionary (or something that looks like one)? Well, perhaps. 
> Although I can't see how the rebinding operation would gain a benefit that a 
> standard binding operation wouldn't gain if placed at the exact same point.

Well it probably wouldn't be quicker, but it wouldn't be slower either
as you asserted earlier.

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


Re: Problems with python and threads under Freebsd

2005-02-08 Thread Andrew MacIntyre
snacktime wrote:
After debugging this some more I narrowed it down to an encryption
function in pycrypto that is triggering the segfault.  I posted a bug
report.  Don't really know enough about threading to know whether it's
a python bug or a pycrypto bug, but I'll let someone else sort that
out now..
If you get bus errors, there's a possibility that you are running out of 
stack.

AFAIR, the default thread stack size for Posix builds is dependant on 
the threading implementation.  This can be overridden when building Python.

With each gcc version since 2.9, the size of stack frames for generated 
calls has increased.  If lowering the optimisation to -O or -Os when 
building Python improves the situation, I'd suggest pursuing this 
possibility further.

-
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: [EMAIL PROTECTED]  (pref) | Snail: PO Box 370
[EMAIL PROTECTED] (alt) |Belconnen ACT 2616
Web:http://www.andymac.org/   |Australia
--
http://mail.python.org/mailman/listinfo/python-list


Re: def __init__ question in a class definition

2005-02-08 Thread Steve Holden
M.E.Farmer wrote:
Steve Holden wrote:
M.E.Farmer wrote:

Jeffrey Borkent
Systems Specialist
Information Technology Services

With that kind of credentials, and the fact that you claim you are
a
system specialists
I don't know you have me worried already.
I guess for you I just say RTFM.
If you think that is harsh then don't ask a 2nd grade question yet
claim/pretend to be some sorta system specialists.
Hey, ease up, this is comp.lang.python, remember.

You tried searching the archives first I am sure.
Go here  http://www.python.org and *read*, come back when you are
really stuck.
M.E.Farmer
P.S. YES the __ matter, they identify special methods ! __init__ is
the
class CONSTRUCTOR.
Next time, could we try exchanging the body of the message and the
PS?
That way you could have omitted the PS when you got half way through
it
and realised you were just wasting your time and everyone else's ...
got-out-the-wrong-side-of-bed-ly y'rs  - steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005  http://www.pycon.org/
Steve Holden   http://www.holdenwewb.com
P.S. And in an effort to keep on topic...PYCON!!
steve,
I stand by what I said.
Teach a man to fish feed him for a lifetime.
Re-read it, memorize it, and keep it near.
I read comp.lang.py for 3 years before I posted anything, and then i
posted an ANSWER!
I don't go around asking dirt simple questions that would be solved
with a quick read of the docs, usenet archives , Google, books that
have been written about Python,etc He should have been *reading*
not *posting*.
I can not understand why you have a problem with me pointing out he
should read the documentation. Why do you think RTFM exist, for people
like that, they are a timesink. He can redeem himself if he just goes
and reads a little and comes back looking like he made some effort.
This guy has a 6 mile sig that says he ought to know better. Had he
come with a different sig *maybe* and a question that did not scream
'''HEY I WANT YOU TO ANSWER EVERYTHING FOR ME BECAUSE I CAN NOT EVEN
READ THE BASIC DOCUMENTATION ON MY OWN'''.

Next time, could we try exchanging the body of the message and the
PS?
That way you could have omitted the PS when you got half way through
it
and realised you were just wasting your time and everyone else's ...

I tell him where he is wrong first then I answer the question, sounds
like *YOU* Now I have your attention.
What do you think that post was meant to do? Snap him off at the root?
Make him cry? Maybe it was to nudge him to read the docs, so he can
*learn* on his own.
Next time you could just write my post for me! That way I can only
waste as much time as you deem acceptable! Now that I think about it,
if we just answer every question every poster has about any detail of
Python, then we can all sing along and hold hands, who needs to write
documentation or even books about Python look at all the time we will
save...

got-out-the-wrong-side-of-bed-ly y'rs  - steve
Which-side is-the wrong-side-ly yr's - M.E.Farmer
Well, actually my point was that if we just save time by not answering 
such questions we avoid a reputation for hostility while still 
encouraging people to use other resources. But anyway, thanks for saying 
"PyCon"!

regards
 Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005  http://www.pycon.org/
Steve Holden   http://www.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to convert 4 bytes into a float ?

2005-02-08 Thread Fredrik Lundh
Alex Martelli wrote:

> I don't recall for sure (even though I did my thesis on a Vax, 25 years
> ago!) but I think you _might_ be lucky -- VAX used the binary format
> that became the IEEE standard, if I recall correctly.

iirc, you have to swap bytes around.  the code on this page might
be helpful:

http://www.octave.org/octave-lists/archive/octave-sources.2004/msg00033.html

> The problem would be there if you had, say, floats in old IBM 360/370
> formats, or Cray's original formats, or the like...

here's a IBM 360 converter (at least that's what I think it is; the code is 
taken
from a PIL format converter for a format that uses "IBM floats"):

def ibm_f32s(c):
a = ord(c[0]) & 127
b = ord(c[3]) + (ord(c[2])<<8) + (ord(c[1])<<16)
v = pow(2.0, -24) * b * pow(16.0, a-64)
if ord(c[0]) > 127:
return -v
return v

many floating point formats are trivial variations on this theme.

 



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


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Jean de Largentaye
GCC-XML looks like a very interesting alternative, as Python includes
tools to parse XML.
The mini-C compiler looks like a step in the right direction for me.
I'm going to look into that.
I'm not comfortable with C++ yet, and am not sure how I'd use Pyste.

Thanks for the information guys, you've been quite helpful!

John

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


User Identification

2005-02-08 Thread Bob Parnes
I have a python program on a server of an all-linux network. It needs to 
record the user name running it. Is there a way for the program to extract
the name from the system without a separate log-in dialog?

Bob Parnes

-- 
Bob Parnes
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: empty classes as c structs?

2005-02-08 Thread Carlos Ribeiro
On Tue, 8 Feb 2005 12:01:23 +0100, Alex Martelli <[EMAIL PROTECTED]> wrote:
> Nick Coghlan <[EMAIL PROTECTED]> wrote:
> 
> > > We could use __add__, instead for combining namespaces
> >
> > Update already let's us combine namespaces. To create a new object that 
> > merges
> > two namespaces do:
> >namespace.update(namespace(ns_1), ns_2)
> 
> One thing I'd like to see in namespaces is _chaining_ -- keeping each
> namespace separate but having lookups proceed along the chain.  (The
> best semantics for _bindings_ as opposed to lookups isn't clear though).

Good point. The name 'namespace' kind of imples chaining, in the usual
Pythonic sense... But I feel that by splitting this into two types
(namespace & bunch) we may be making things overly complicated, and
losing some of the power of the argument. Again, just my $0.02 worth.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Fredrik Lundh
Jean de Largentaye wrote:

> GCC-XML looks like a very interesting alternative, as Python includes
> tools to parse XML.
> The mini-C compiler looks like a step in the right direction for me.
> I'm going to look into that.
> I'm not comfortable with C++ yet, and am not sure how I'd use Pyste.

to clarify, Pyste is a Python tool that uses GCCXML to generate bindings; it 
might
not be something that you can use out of the box for your project, but it's 
definitely
something you should study, and perhaps borrow implementation ideas from.

 



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


Re: User Identification

2005-02-08 Thread Fredrik Lundh
Bob Parnes wrote:

>I have a python program on a server of an all-linux network. It needs to
> record the user name running it. Is there a way for the program to extract
> the name from the system without a separate log-in dialog?

how about:

>>> import getpass
>>> getpass.getuser()
'gromit'

 



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


Re: User Identification

2005-02-08 Thread Laszlo Zsolt Nagy
Bob Parnes wrote:
I have a python program on a server of an all-linux network. It needs to 
record the user name running it. Is there a way for the program to extract
the name from the system without a separate log-in dialog?

Bob Parnes
 

What about:
import os
username = os.getlogin()
Please see other functions at:
http://docs.python.org/lib/os-procinfo.html
Best,
  Laci 2.0

--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Roman Yakovenko
try http://sourceforge.net/projects/pygccxml
There are a few examples and nice ( for me ) documentation.

Roman

On Tue, 8 Feb 2005 13:35:57 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Jean de Largentaye wrote:
> 
> > GCC-XML looks like a very interesting alternative, as Python includes
> > tools to parse XML.
> > The mini-C compiler looks like a step in the right direction for me.
> > I'm going to look into that.
> > I'm not comfortable with C++ yet, and am not sure how I'd use Pyste.
> 
> to clarify, Pyste is a Python tool that uses GCCXML to generate bindings; it 
> might
> not be something that you can use out of the box for your project, but it's 
> definitely
> something you should study, and perhaps borrow implementation ideas from.
> 
> 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


How to keep a module with the same name as a module it is importing from importing itself?

2005-02-08 Thread plb

All:

I am struggling with an import problem...

In my package, myapp, I have a module, logging.py.  That module,
naturally, imports the library module logging with an 'import logging'
statement.  However, when I use 'import myapp.logging' in my script,
the myapp.logging module tries to import itself rather than the library
logging module.

How can I prevent this from happening other than using a name that
doesn't conflict?

--PLB

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


Re: re-entrancy question

2005-02-08 Thread Valentino Volonghi aka Dialtone
Tim Golden <[EMAIL PROTECTED]> wrote:

> No doubt there are more pertinent answers, but unless this is
> a learning exercise, you'd be better off investigating Pyro:
> http://pyro.sf.net

AFAIK pyro is just a RPC implementation for python whereas Twisted is a
completely different beast that happens to have its own implementation
of RPC.

How would the OP be better investigating something different, that he
probably doesn't even need?

Your comment would be pertinent only if it considered Perspective Broker
against pyro, and I admit I don't know how they compare.

-- 
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.3.7
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: User Identification

2005-02-08 Thread Laszlo Zsolt Nagy

how about:
 

import getpass
getpass.getuser()
   

'gromit'
 

Hmm, yours is better. It also works on Windows. :-)
I wonder why os.getuser() does not work in Windows - apparently there is 
a good implementation for Windows.

--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Kent Johnson
Fredrik Lundh wrote:
Robert Kern wrote:

Fair enough. The only time I've seen it in dead-tree print was in Heinlein's _Time Enough For 
Love_, unattributed to anyone else.
Amazon.com "search inside the book" finds no hits for "malice" in this book.
http://www.amazon.com/gp/reader/0441810764/102-7636110-6481700?v=search-inside&keywords=malice

if that's true, it would seem that it predates the Hanlon reference by a
couple of years:
http://www.statusq.org/archives/2001/12/04
on the other hand, Google tells me that "Time Enough For Love" con-
tains a couple of other famous stupidity quotes, including:
"Never underestimate the power of human stupidity"
"Search inside the book" finds this *twice* in "Time Enough For Love".
Kent
--
http://mail.python.org/mailman/listinfo/python-list


RE: re-entrancy question

2005-02-08 Thread Tim Golden
| Tim Golden <[EMAIL PROTECTED]> wrote:
| 
| > No doubt there are more pertinent answers, but unless this is
| > a learning exercise, you'd be better off investigating Pyro:
| > http://pyro.sf.net
| 
| AFAIK pyro is just a RPC implementation for python whereas 
| Twisted is a
| completely different beast that happens to have its own implementation
| of RPC.
| 
| How would the OP be better investigating something different, that he
| probably doesn't even need?
| 
| Your comment would be pertinent only if it considered 
| Perspective Broker
| against pyro, and I admit I don't know how they compare.


Here's the original post, quoted in its entirety:


I have a program that instantiates some objects and runs a main loop. 
Before the main loop starts, I create a thread that listens to TCP 
connections on a port.  If any connections are made, and depending on 
the data, I call methods on some of those objects.

I am worried that calling methods on objects from outside the main loop, 
but that are also operated on in the main loop, could cause problems.

My questions:
1) is this safe?
2) what kind of problems could occur?
3) how do I safely handle this?


Now *where* is there any mention of Twisted, either in the original
post or in my reply? As I read it, the OP is doing something which
creates local objects (instances, whatever) and has them available
remotely. He's then -- justifiably -- concerned about possible
re-entrancy if more than one outside agent makes a connection on
his TCP port.

It seemed to me that this was -- approximately -- what Pyro does:
you created objects locally and listen on a TCP port for incoming
requests. Since Pyro's author has already solved a number of the
problems associated with doing this kind of thing, I thought it
might be helpful to point this out.

Tim


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

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


Re: python connect to server using SSH protocol

2005-02-08 Thread Laszlo Zsolt Nagy
[EMAIL PROTECTED] wrote:
How can python connect to server which use SSH protocol?
Is it easy since my python has to run third party vendor, write data,
read data inside the server (supercomputer).
 

In advance, I'm not sure if I understood your problem.  SSH is clearly a 
remote
shell. You will be able to execute other programs on the remote computer.
Is is suitable to use this:

child_stdin,child_stdout,child_stderr =  os.popen2('ssh -l my_username  
my_host')

On the other side, you can write an application that also uses 
stdin/stdout for communication.
Best,

  Laci 2.0
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Handling import conflicts when module has the same name as a library module that it needs to import?

2005-02-08 Thread plb
All:

I am struggling with an import problem...

In my package, myapp, there is a module called logging. This module,
naturally, imports the standard library module logging.  However, when
I try 'import myapp.logging', the 'import logging' statement appears to
be finding the myapp.logging module instead of the one in the standard
library.

How can I ensure that my logging module doesn't try to import itself?

--PLB

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


Re: Synchronizing methods of a class

2005-02-08 Thread Diez B. Roggisch
> My Question:
> 
> If I decorate these function references in __class__.__dict__, am I
> doing it only for my specific instance of that class or the base class
> as well?

A class is a class - so yes, all instances are affected. You might want to
think about metaclasses for decorating.
-- 
Regards,

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


Handling import conflicts when module has the same name as a library module that it needs to import?

2005-02-08 Thread plb
All:

I am struggling with an import problem...

In my package, myapp, there is a module called logging. This module,
naturally, imports the standard library module logging.  However, when
I try 'import myapp.logging', the 'import logging' statement appears to
be finding the myapp.logging module instead of the one in the standard
library.

How can I ensure that my logging module doesn't try to import itself?

--PLB

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


Re: python connect to server using SSH protocol

2005-02-08 Thread P
[EMAIL PROTECTED] wrote:
How can python connect to server which use SSH protocol?
Is it easy since my python has to run third party vendor, write data,
read data inside the server (supercomputer).
Any suggestion?
you can use popen around the ssh binary.
You man need the pty module if you want to deal with password prompts
If you want lower level control, use the twisted module.
--
Pádraig Brady - http://www.pixelbeat.org
--
--
http://mail.python.org/mailman/listinfo/python-list


Re: User Identification

2005-02-08 Thread Gerhard Haering
On Tue, Feb 08, 2005 at 12:29:48PM -, Bob Parnes wrote:
> I have a python program on a server of an all-linux network. It needs to 
> record the user name running it. Is there a way for the program to extract
> the name from the system without a separate log-in dialog?

os.environ["USER"] for a start?

os.getuid() will give you the user id, but I don't know if Python has
methods to look up more information from that from /etc/passwd or
whereever from.

-- Gerhard


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to keep a module with the same name as a module it is importing from importing itself?

2005-02-08 Thread Laszlo Zsolt Nagy

In my package, myapp, I have a module, logging.py.  That module,
naturally, imports the library module logging with an 'import logging'
statement.  However, when I use 'import myapp.logging' in my script,
the myapp.logging module tries to import itself rather than the library
logging module.
How can I prevent this from happening other than using a name that
doesn't conflict?
 

Did you try the built-in 'imp' module?
http://docs.python.org/lib/module-imp.html
I believe that 'load_module' is your very best friend. :-)
Another idea: rename your modules so they do not conflict with standard 
modules.
Best,

  Laci 2.0
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: python connect to server using SSH protocol

2005-02-08 Thread Simon Anders
Hi
Laszlo Zsolt Nagy wrote:
[EMAIL PROTECTED] wrote:
How can python connect to server which use SSH protocol?
Is it easy since my python has to run third party vendor, write data,
read data inside the server (supercomputer).
 

In advance, I'm not sure if I understood your problem.  SSH is clearly a 
remote
shell. You will be able to execute other programs on the remote computer.
Is is suitable to use this:

child_stdin,child_stdout,child_stderr =  os.popen2('ssh -l my_username  
my_host')
This is what I was about to reply as well. But I did a short test 
program and encountered a problem:

import os
fi, foe = os.popen4 ('ssh dopey')
print >>fi, 'ls'
fi.close ()  # <-- this is annoying
for line in foe:
   print line,
foe.close ()
The above connects to a server, passes the command 'ls', which is 
executed there, and prints the returned result.

However, reading from foe succeeds only if fin has been closed before. 
An fi.flush() seems to be not sufficient. But if one wants Python to 
interactivly communicate with some shell on a remote machine, it is 
inconvenient to have to close and reopen the connection all the time.

There should be a better way.
   Simon
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 "John M. Gabriele" <[EMAIL PROTECTED]> wrote:

> I recently posted this sort of question to the c.l.p.m but
> didn't get much of a response. I know a little Perl and a
> little Python, but master neither at the moment.
> 
> I see that Python is a general purpose OO programming language
> that finds use among some system administrators, but my guess
> is that Perl is still more common in that area than Python.
> 
> For sysadmin-related tasks, is Python as useful as Perl, or
> does it get clumsy when often dealing with the stuff admins
> deal with on a regular basis?
> 
> At some point during some dingy job in the back boiler room
> of Unix, would you find yourself saying, "geez, I'd wish I
> started this with Perl -- Python just isn't cutting it." ?
> 
> Thanks,
> ---J

Given that Perl was *designed* for sysadmin work, it's not surprising that 
there are some features of it which make it very convenient to use in that 
arena.  For executing external commands, nothing really comes close to 
Perl's back-tick syntax.  For doing things like reading a sequence a files 
and filtering the combined contents with regular expressions, Perl is 
probably the tool that lets you do that in the most compact way.

As a general-purpose programming language, it sucks.  My personal opinion 
is that the general-purpose suckitude outweighs the domain-specific 
sysadmin convenience.
-- 
http://mail.python.org/mailman/listinfo/python-list


iterators instead of callbacks.

2005-02-08 Thread Antoon Pardon
My current understanding is that callbacks are used in a number
of places because they predate iterator. But now that we have
iterators these would be better suited. I'm thinking about the
FTP-lib now where iterator equivallents of retrbinary and retrlines
methods may be more easily usable then the current versions with a
callback.

So I was wondering, are such transformations in the pipeline
somewhere?

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


Re: Big development in the GUI realm

2005-02-08 Thread Tim Churches
Fredrik Lundh wrote:
Tim Churches wrote:
 

and how exactly are you going to load a DLL from an EXE file with-
out "mixing, including, or combining" the two?
 

You can't, but as long as that "mixing, including, or combining" only occurs at 
runtime,
the GPL itself specifically says that is out of scope and the GPL does not 
apply. Their
words, not mine - to quote (yet again):
"Activities other than copying, distribution and modification are not covered by this
License; they are outside its scope. The act of running the Program is not restricted,..."
   

except that if *you* set things up so the code is combined when run, *you* 
are
copying, distributing, and/or modifying the program in order to mix, include 
and/or
combine your work with the GPL:ed work.
if you leave all that to the user, you're clear.
 

Yes, that is what I, and others, have been saying, and doing, all along. 
Our Mozilla Public Licensed Python application imports (but contains no 
code from) a GPLed third-party Python module at runtime, but we don't 
distribute that module, we just tell users to obtain it independently 
and install it on their systems.

(relying on word games is a lousy legal strategy in most parts of the world)
 

(Gee, I thought that word games were the entire basis of much legal 
endeavour in most parts of the world. Patent specifications in 
particular spring to mind.)

Less flippantly, I agree, and I find it Hanlonesque that the FSF 
continues to promote a license which is at best unclear and at worst 
completely contradictory on the issue of whether dynamic, runtime 
linking or calling does or doesn't fall under its scope. Others have 
thought the same - as we have seen, Linus Torvalds felt compelled to 
include an addition to the GPL when licensing the Linux kernel to make 
it crystal clear that making runtime system calls to the kernel did not 
fall under the scope of the kernel license.

I would urge anyone who has published a GPLed Python module to add a 
similar extension in order to clarify their use of the GPL in this regard.

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


Re: Big development in the GUI realm

2005-02-08 Thread Gabriel B.
> > users.  For example, from their FAQ, it seems that no precompiled
> > binaries will be provided.  Support for comercial compilers will not be
> > built in, only for gcc (through Cygwin?).
> 
> Isn't this just the same thing with a different spin. There was always
> an available distribution for linux for non-commercial use. Windows was
> always the problem. You still can't use it for windows without knowing
> how to compile the thing on windows.

Well, if it's GPLed, can't i simply compile it and distribute a GPLed
.DLL with the source code for everyone?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re-entrancy question

2005-02-08 Thread Valentino Volonghi aka Dialtone
Tim Golden <[EMAIL PROTECTED]> wrote:

> Now *where* is there any mention of Twisted, either in the original
> post or in my reply? As I read it, the OP is doing something which

Ya sorry. I thought this was crossposted but the OP posted 2 different
emails to both python-list and twisted-python ML. This very same message
was posted on the twisted mailing list.

The answer anyway was already given on the other list: there are no
re-entrancy problems :).

-- 
Valentino Volonghi aka Dialtone
Now Running MacOSX 10.3.7
Blog: http://vvolonghi.blogspot.com
http://weever.berlios.de
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: re-entrancy question

2005-02-08 Thread Tim Golden
[EMAIL PROTECTED]
| 
| Tim Golden <[EMAIL PROTECTED]> wrote:
| 
| > Now *where* is there any mention of Twisted, either in the original
| > post or in my reply? As I read it, the OP is doing something which
| 
| Ya sorry. I thought this was crossposted but the OP posted 2 different
| emails to both python-list and twisted-python ML. This very 
| same message
| was posted on the twisted mailing list.
| 
| The answer anyway was already given on the other list: there are no
| re-entrancy problems :).
| 
| -- 
| Valentino Volonghi aka Dialtone

Ah, OK. I thought it was a bit bizarre.

TJG


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

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


trolltech comitment (was:Big development in the GUI realm)

2005-02-08 Thread Gabriel B.
On Mon, 07 Feb 2005 20:56:44 -0800, Courageous <[EMAIL PROTECTED]> wrote:
> Follow the copyright holder's wishes.
> 
> That's fair. After all, it's free, so they're doing you a damn
> big favor.

I'm terrible sorry to extend this topic even furter, but it's silly,
not to say dull to think like that.

in the first place, it's not that they're doing charity. they have
plans. if they release Qt under GPL for non-comercial use, it's
because they want to increase the user base and so be able to earn
money with the comercial fee later.

And if i'm going to write software for it, when there's plenty of
alternative that actualy works flawless under windows, why should i
stick with an option that i don't even know to wich extends i can use
the damn thing? What it they revoke this license? what it windows
longhorn has a non-backwardcompatible GDI API and a newer version of
Qt must be used, and that newer version does not have a gpl version?

If i'm going to commit to something, i like to know the lengths the
other side gona commit also.

What you said was like "Hey! it's free food! who cares if it's
rotten?" sorry, but it's just too homer simpson for me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python connect to server using SSH protocol

2005-02-08 Thread Laszlo Zsolt Nagy

import os
fi, foe = os.popen4 ('ssh dopey')
print >>fi, 'ls'
fi.close ()  # <-- this is annoying
for line in foe:
   print line,
foe.close ()
The above connects to a server, passes the command 'ls', which is 
executed there, and prints the returned result.

However, reading from foe succeeds only if fin has been closed before. 
An fi.flush() seems to be not sufficient. 
Hmm. Is it possible to use ssh for simple port forwarding (-L option) 
and write a server program on the remote machine?


--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Big development in the GUI realm

2005-02-08 Thread Fredrik Lundh
Tim Churches wrote:

>>except that if *you* set things up so the code is combined when run, *you* are
>>copying, distributing, and/or modifying the program in order to mix, include 
>>and/or
>>combine your work with the GPL:ed work.
>>
>>if you leave all that to the user, you're clear.
>>
> Yes, that is what I, and others, have been saying, and doing, all along. Our 
> Mozilla Public 
> Licensed Python application imports (but contains no code from) a GPLed 
> third-party Python module 
> at runtime, but we don't distribute that module, we just tell users to obtain 
> it independently and 
> install it on their systems.

does your program work (in any way) without this module?

>>(relying on word games is a lousy legal strategy in most parts of the world)
>>
> (Gee, I thought that word games were the entire basis of much legal endeavour 
> in most parts of the 
> world. Patent specifications in particular spring to mind.)

yeah, but you shouldn't base your entire game on a specific word play.

 



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


Re: Big development in the GUI realm

2005-02-08 Thread Gabriel B.
> >>Considering the fact that the Qt DLL exist by themselves, that the
> >>version used is the one provided by Qt, and that the EXE uses a
> >>standard, open way to communicate with it, the above does seem to say
> >>this use would be valid.
> >>
> >>
> >
> >http://www.gnu.org/licenses/gpl-faq.html#MereAggregation
> >
> >"/.../ If modules are designed to run linked together in a shared address
> >space, that almost surely means combining them into one program.
> >
> >By contrast, pipes, sockets and command-line arguments are
> >communication mechanisms normally used between two separate
> >programs. So when they are used for communication, the modules
> >normally are separate programs. But if the semantics of the
> >communication are intimate enough, exchanging complex internal
> >data structures, that too could be a basis to consider the two parts
> >as combined into a larger program."
> >
> >

This is odd. They claim it's a GPL'ed version, but it's a trolltech
license that forces you to release your code under gpl even tought
their's not!

I'm not against a company getting it's share with their product.
that's what motivated them in the first place. but DONT LIE! don't
call it gpl when it's not.

Gpl make it very explicity it deals with the program as a whole, in
the meaning of a executable code. What they're trying to achive here
is that, by adding this paragraph, they will cover the "dll use" under
the gpl.

By that cover-all definition they came up, i can't use Internet
Explorer to see a site hosted with a gpl'ed server! i can't even use a
BSD program to grep a file!

anyway... it will only mater when people with money cares. I already
have 3 choices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PHP Embedded In Python

2005-02-08 Thread Keith

jdonnell wrote:
> I'm not sure exactly what your trying to do, but I use php and python
> together a lot. I usually call the python script from php with the
> passthru function like this:
>
>  $outputFromPy = passthru('/path/to/myScript.py');
> ?>

I need to go the other direction.  I need to call php from within
python.  Thanks.

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


Re: Choosing the right parser for parsing C headers

2005-02-08 Thread Jean de Largentaye
That looks cool Roman, however, I'm behind a Corporate Firewall, is
there any chance you could send me a cvs snapshot?

John

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


Re: Curses on Windows

2005-02-08 Thread rzed
"Martin Miller" <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

> I just tried the flangy.com link and it appears to be OK now.
> 
> Martin
> 
> 
> Peter wrote:
>> ...
>> One reply (in fact the only reply - thanks Tim Golden) suggested I
>> look at http://flangy.com/dev/python/curses/
> 

But this one is still forbidden, at least for me:
http://flangy.com/dev/python/curses/files/wcurses-0.1-py2.4.zip

-- 
rzed

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


Re: [perl-python] text pattern matching, and expressiveness

2005-02-08 Thread Daniel Fackrell
"John Bokma" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Xah Lee wrote:
>
> > Perl is a language of syntactical variegations. Python on the other
> > hand, does not even allow changes in code's indentation, but its
> > efficiency and power in expression, with respect to semantics (i.e.
> > algorithms), showcases Perl's poverty in specification.
>
> Clarify :-D.

Clarification:

He (XL) is a troll and admits it.  If only he would include that information
up-front in his (IMO worthless) [perl-python] posts, it would save a lot of
effort.

Daniel Fackrell



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


Re: [perl-python] text pattern matching, and expressiveness

2005-02-08 Thread Diez B. Roggisch
> He (XL) is a troll and admits it.  If only he would include that
> information up-front in his (IMO worthless) [perl-python] posts, it would
> save a lot of effort.

He does - all of his posts start with [perl-python]. Now the big question is
which community comes up with a better/nicer/shorter/whatever filter -
pythonistas or perljunkies.

-- 
Regards,

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


Re: ANN: Zeus Programmers Editor V3.94

2005-02-08 Thread Gabriel Cooper
Jussi Jumppanen wrote:
The latest release of the Zeus for Windows programmer's
editor is now available.
So is this mentioned here on the Python mailing list because Zeus was 
written in Python, or is this just targeted spam for a commerical product?
--
http://mail.python.org/mailman/listinfo/python-list


Loop in list.

2005-02-08 Thread Jim
Where did this type of structure come from:

mat = ['a' for i in range(3)]?

This will produce a list of three elements but
I don't see reference for it in any of the books.

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


Re: Loop in list.

2005-02-08 Thread Jeremy Jones
Jim wrote:
Where did this type of structure come from:
mat = ['a' for i in range(3)]?
This will produce a list of three elements but
I don't see reference for it in any of the books.
 

It's called a list comprehension and it appeared in Python 2.0.
http://www.amk.ca/python/2.0/index.html#SECTION00060

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


Re: Loop in list.

2005-02-08 Thread Fredrik Lundh
"Jim" <[EMAIL PROTECTED]> wrote:

> Where did this type of structure come from:
>
> mat = ['a' for i in range(3)]?
>
> This will produce a list of three elements but
> I don't see reference for it in any of the books.

it's called "list comprehension", and was added in Python 2.0.

http://www.amk.ca/python/2.0/index.html#SECTION00060
http://docs.python.org/tut/node7.html#SECTION00714
http://docs.python.org/ref/lists.html

Python 2.4 introduces a variation called "generator expressions":

http://www.python.org/doc/2.4/whatsnew/node4.html
http://www.python.org/peps/pep-0289.html
http://docs.python.org/ref/genexpr.html

 



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


Re: Basic file operation questions

2005-02-08 Thread Marc Huffnagle
When you read a file with that method, is there an implied close() call 
on the file?  I assume there is, but how is that handled?

Caleb Hattingh wrote:
Peter, that was very clear, thanks.

So not only is
for line in file(...):
  # do stuff
the most elegant, it is also the fastest. file.readlines() comes
close, but
is only viable for "small" files.

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


Re: Loop in list.

2005-02-08 Thread Diez B. Roggisch
Jim wrote:

> Where did this type of structure come from:
> 
> mat = ['a' for i in range(3)]?
> 
> This will produce a list of three elements but
> I don't see reference for it in any of the books.

Its called a list-comprehension. And as I don't know what books you mean, I
can't say if its covered there or not.

-- 
Regards,

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


Re: Loop in list.

2005-02-08 Thread Bill Mill
Jim,

That is called a "list comprehension", and it is a feature which
appeared in python 2.3 (iirc). Thus if your books are about earlier
versions of python, list comprehensions will not be covered.

Check out the section of the tutorial about them at
http://docs.python.org/tut/node7.html#SECTION00714 .

Peace
Bill Mill
bill.mill at gmail.com


On Tue, 08 Feb 2005 06:50:08 -0800 (PST), Jim <[EMAIL PROTECTED]> wrote:
> Where did this type of structure come from:
> 
> mat = ['a' for i in range(3)]?
> 
> This will produce a list of three elements but
> I don't see reference for it in any of the books.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop in list.

2005-02-08 Thread Simon Brunning
On Tue, 08 Feb 2005 06:50:31 -0800 (PST), Jim <[EMAIL PROTECTED]> wrote:
> Where did this type of structure come from:
> 
> mat = ['a' for i in range(3)]?
> 
> This will produce a list of three elements but
> I don't see reference for it in any of the books.

It's called a "List Comprehension". There's a good historical reason
for the name, but you can be excused in not having looked under that
name in the index. See

for details.

They *should* be mentioned in most books, provided that it's vaguely
recent and covers Python 2.0 or later.

List comps have a cool new little sister, generator expressions - see
.

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


Re: Synchronizing methods of a class

2005-02-08 Thread Christopher De Vries
On Mon, Feb 07, 2005 at 11:57:02AM -0800, Keith Veleba wrote:
> Background:
> I'm working on a project where I have to do some serious
> multithreading. I've worked up a decorator in Python 2.3.4 to implement
> the lock semantics required for specific functions I want to
> synchronize:

I found Chris Liechti's example very helpful when working on a similar
project. See
http://groups-beta.google.com/group/comp.lang.python/msg/d647a830de39d1db
. Also, I strongly suggest using threading.RLock() objects instead of primitive
locks. With Rlocks one thread can acquire the same lock multiple times without
blocking. This is useful if one synchronized method calls another synchronized 
method.

> Obviously, my classes have to instantiate the _lock in __init__ in
> order for this to work.

The great thing about Chris's example is that the first time a synchronized
method is called a lock is instantiated, so you don't have to worry about this
step.

> Problem:
> 
> When iterating through klass.__dict__.items() in the convenience
> method, I only get the instance variables of the class.  No functions.
> I've found a way to get the function list, by iterating through
> klass.__class__.__dict__ .

I'm not sure why klass.__dict__.items() isn't working for you. I tried a simple
example:

class simple(object):
def hello(self):
print "Hello World"

def methods(cls):
for name,value in cls.__dict__.items():
if callable(value):
print name

>>> methods(simple)
hello


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


Re: How to keep a module with the same name as a module it is importing from importing itself?

2005-02-08 Thread plb
Good call!  The following snippet solved my problems portably.

path = sys.path[1:]
file, filename, description = imp.find_module('logging', path)
logging = imp.load_module('logging', file, filename, description)

Thanks!

--Peter

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


in wxPython, how to minimize the window in absence of minimize button?

2005-02-08 Thread Erik Bethke
Hello All,

I now have a wx.NO_BORDER frame that I have written dragging code
for... I like my window this way as it looks sleeker and I am now
installing some image buttons.

Now I would like to create a new minimize button from an image, and
then capture that mouse down and cause it to minimize the window...

I can make buttons all day long, despite all of my googling I still
cannot figure out what method I should call with my minimize button...

Please help thank you,
-Erik

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


Efficient checksum calculating on lagre files

2005-02-08 Thread Ola Natvig
Hi all
Does anyone know of a fast way to calculate checksums for a large file. 
I need a way to generate ETag keys for a webserver, the ETag of large 
files are not realy nececary, but it would be nice if I could do it. I'm 
using the python hash function on the dynamic generated strings (like in 
page content) but on things like images I use the shutil's 
copyfileobject function and the hash of a fileobject's hash are it's 
handlers memmory address.

Does anyone know a python utility which is possible to use, perhaps 
something like the md5sum utility on *nix systems.

--
--
 Ola Natvig <[EMAIL PROTECTED]>
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list


Re: in wxPython, how to minimize the window in absence of minimize button?

2005-02-08 Thread Erik Bethke
Damn,

I am dumb...

self.Iconize( True )

Sorry.

But a helpful tip is that the demo code *surrounding* the wxPython demo
is VERY useful, I never looked at that before!

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


Re: Loop in list.

2005-02-08 Thread Roy Smith
Jim <[EMAIL PROTECTED]> wrote:
>Where did this type of structure come from:
>
>mat = ['a' for i in range(3)]?
>
>This will produce a list of three elements but
>I don't see reference for it in any of the books.

It's a list comprehension.  Unfortunately, this is a bad example of
one, since a much simplier way of writing the same thing would be:

mat = ['a'] * 3

After several years of them being in the language, I'm still somewhat
up in the air about the wisdom of list comprehensions.  There is no
doubt that they're convenient and compact, but I think they make code
more difficult to read.  The functional programming folks will
certainly disagree, and I realize I'm probably in the minority on
this, but that's my opinion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Zeus Programmers Editor V3.94

2005-02-08 Thread Richie Hindle

[Jussi]
> The latest release of the Zeus for Windows programmer's
> editor is now available.

[Gabriel]
> So is this mentioned here on the Python mailing list because Zeus was 
> written in Python, or is this just targeted spam for a commerical product?

>From the features page:

> o Syntax highlighting for C\C++, Clipper, Cobol, Fortran, Java, Pascal, Perl, 
> Python, PHP, SQL etc 
> o Fully Scriptable using the Python, Lua or SmallC, VB Script, Java Script, 
> Ruby Script languages 
> o Integrated debugger supports the Java, Perl, Python and C# languages 

IMHO that makes it of general interest to Python programmers.  Whether or
not it's a commercial product seems irrelevant.  For myself, announcements
of Python-related products, whether free or commercial, are welcome here
(though python-announce / c.l.p.a might be a better place, from the point
of view of both readers and announcers).

-- 
Richie Hindle
[EMAIL PROTECTED]

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


  1   2   3   >