Re: namespace dictionaries ok?

2005-10-25 Thread Ron Adam
James Stroud wrote:
> Here it goes with a little less overhead:
> 
> 
> py> class namespace:
> ...   def __init__(self, adict):
> ... self.__dict__.update(adict)
> ...
> py> n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice':4})
> py> n.bob
> 1
> py> n.ted
> 3
> 
> James

How about...

 class namespace(dict):
 __getattr__ = dict.__getitem__
 __setattr__ = dict.__setitem__
 __delattr__ = dict.__delitem__


This seems to work, and eliminates the indirect method calls.

Cheers,
Ron

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


Re: grep

2005-10-25 Thread marduk
On Tue, 2005-10-25 at 06:45 +, David Isaac wrote:
> What's the standard replacement for the obsolete grep module?

AFAIK there never was a "grep" module.  There does, however exist a
deprecated "regex" module:

>>> import regex
__main__:1: DeprecationWarning: the regex module is deprecated; please
use the re module


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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Antoon Pardon
Op 2005-10-24, David Schwartz schreef <[EMAIL PROTECTED]>:
>
> "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>
>>> Microsoft had something you need so badly that you could not go into
>>> business without it. So they demanded from you that you pay them what 
>>> their
>>> software was actually worth to you. That is not extortion. Everyone who
>>> sells something tries to get the maximum possible value for it.
>
>> If a company wants to be paid for things it didn't deliver, then I think
>> that is extortion. Microsoft want te be paid a license on windows for
>> P.C.'s that were sold without windows.
>
> I think you need to look up "extortion" in a dictionary. I can walk up 
> to you and say "if you want me to mow your lawn, you must pay me $1 every 
> time you smoke a cigarette". So long as you can say "no" and all that 
> happens is that I don't mow your lawn (which I have no obligation to do 
> anyway), it isn't extortion.

If you would happen to have a monopoly on the mowing business, which
would make it very hard for me to have my lawn mowed unless I took
your offer, it would be.

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


Re: pickle

2005-10-25 Thread marduk
On Mon, 2005-10-24 at 23:55 -0700, Shi Mu wrote:
> I got a sample code and tested it but really can not understand the
> use of pickle and dump:
> 
> >>> import pickle
> >>> f = open("try.txt", "w")
> >>> pickle.dump(3.14, f)
> >>> pickle.dump([1,2,3,4], f)
> >>> f.close()

The pickle module "serializes" python objects.  You can "dump" a python
object that can later be loaded:

>>> x = complex(2,3.5)
>>> f = open("cnumber.pickle", "w")
>>> import pickle
>>> pickle.dump(x, f)
>>> f.close()
>>> y = pickle.load(file("cnumber.pickle", "r"))
>>> y
(2+3.5j)


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


testing for modules?

2005-10-25 Thread Ed Hotchkiss
i have a generic script that is using several modules on windows and linux boxes. i need to have the scripts test if a module is installed, and then if not - then to install the module. can anyone give me a headsup on how to test for a module, returning something to indicate whether or not it is installed, then after that executing file to install the module.? just somewhere to start would be helpful! thanks in advance.
-- edward hotchkiss 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: namespace dictionaries ok?

2005-10-25 Thread Steven D'Aprano
Simon Burton wrote:


> Yes!
> 
> I do this a lot when i have deeply nested function calls
> a->b->c->d->e
> and need to pass args  to the deep function without changing the
> middle functions.

If you find yourself passing arguments to functions 
just so they can in turn pass them on to other 
functions, you probably shouldn't be using deeply 
nested function calls and should be looking for another 
program structure.


-- 
Steven.

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


Re: Redirect os.system output

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

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

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

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


Re: pickle

2005-10-25 Thread Shi Mu
what does the following code mean?

y = pickle.load(file("cnumber.pickle", "r"))

also, I can not understand "f" in pickle.dump(x, f)

On 10/25/05, marduk <[EMAIL PROTECTED]> wrote:
> On Mon, 2005-10-24 at 23:55 -0700, Shi Mu wrote:
> > I got a sample code and tested it but really can not understand the
> > use of pickle and dump:
> >
> > >>> import pickle
> > >>> f = open("try.txt", "w")
> > >>> pickle.dump(3.14, f)
> > >>> pickle.dump([1,2,3,4], f)
> > >>> f.close()
>
> The pickle module "serializes" python objects.  You can "dump" a python
> object that can later be loaded:
>
> >>> x = complex(2,3.5)
> >>> f = open("cnumber.pickle", "w")
> >>> import pickle
> >>> pickle.dump(x, f)
> >>> f.close()
> >>> y = pickle.load(file("cnumber.pickle", "r"))
> >>> y
> (2+3.5j)
>
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-25 Thread David Schwartz

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

>> I think you need to look up "extortion" in a dictionary. I can walk 
>> up
>> to you and say "if you want me to mow your lawn, you must pay me $1 every
>> time you smoke a cigarette". So long as you can say "no" and all that
>> happens is that I don't mow your lawn (which I have no obligation to do
>> anyway), it isn't extortion.

> If you would happen to have a monopoly on the mowing business, which
> would make it very hard for me to have my lawn mowed unless I took
> your offer, it would be.

Yes, but that's the "if". I have a monopoly on *me* mowing your lawn. 
You can, of course, go to someone else to have your lawn mowed. Microsoft 
only had a monopoly on *Microsoft* operating systems. Microsoft had no 
control over OSX, Linux, FreeBSD, and so on.

Essentially, Microsoft asked for exclusive arrangements. That is, 
arrangements wherein you could not sell competing products if you wished to 
sell Microsoft products. That's not even remotely unusual.

DS


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


Hi All - Newby

2005-10-25 Thread Ask
G'day All,

Just thought I'd drop in and say hi. I'm new to Python, but old to software 
development.

Python is one of the languages used in my new job, so I've just bought a 
book, read it, and downloaded Python; It's pretty good isn't it? It's 
particularly handy being able top run the same bytecode on different 
platforms.

I found a link to this newsgroup, downloaded 1000 messages, and have only 
put one user in my twit filter so hopefully it'll be a good resource!

I must admit to much confusion regarding some of the basics, but I'm sure 
time, reading, and good advice will get rid of that. at this stage, it's 
just working through some examples and getting my head around things. As an 
example, if I create a window, I've been unable to force it to be a certain 
size, and put a button (widget) at (say) 20,40 (x & y). Is window formatting 
possible?

Thanks and I'm sure to be reading your posts soon.

Pauly





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


Re: Redirect os.system output

2005-10-25 Thread Paul Dale

You might want to try python expect which gives you a very simple and 
scriptable interface to a process.

http://pexpect.sourceforge.net/

I've been using it on windows to automate a few things.

Cheers,

Paul

jas wrote:

>Kent,
>  Yes, your example does work.  So did os.popen...however, the problem
>is specific to "cmd.exe".
>   Have you tried that yet?
>
>Thanks!
>
>Kent Johnson wrote:
>  
>
>>jas wrote:
>>
>>
>>>Ok, I tried this...
>>>
>>>C:\>python
>>>Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
>>>on win32
>>>Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>  
>>>
>>import subprocess as sp
>>p = sp.Popen("cmd", stdout=sp.PIPE)
>>
>>result = p.communicate("ipconfig")
>>
>>
>>>'result' is not recognized as an internal or external command,
>>>operable program or batch file.
>>>
>>>
>>>
>>>basically I was opening to send the "ipconfig" command to cmd.exe and
>>>store the result in the "result" variable.  But you can see there was
>>>an error with result.
>>>  
>>>
>>This works for me:
>>import subprocess as sp
>>p = sp.Popen("ipconfig", stdout=sp.PIPE)
>>result = p.communicate()[0]
>>print result
>>
>>Kent
>>
>>
>
>  
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Hatred FAQ

2005-10-25 Thread Peter T. Breuer
In comp.os.linux.misc Antoon Pardon <[EMAIL PROTECTED]> wrote:
>> I think you need to look up "extortion" in a dictionary. I can walk up 
>> to you and say "if you want me to mow your lawn, you must pay me $1 every 
>> time you smoke a cigarette". So long as you can say "no" and all that 
>> happens is that I don't mow your lawn (which I have no obligation to do 
>> anyway), it isn't extortion.

> If you would happen to have a monopoly on the mowing business, which
> would make it very hard for me to have my lawn mowed unless I took
> your offer, it would be.

In this case the extortion is over smoking a cigarette (it doesn't seem
to me to necessitate a monopoly on mowing for the threat to have been
deemed to have been made, but perhaps for it to be deemed likely for you
to believe it to have teeth) - money is being demanded with menaces for
your continued smoking of cigarettes.  The threatened menace is that
your lawn will find itself not mown.

I can certainly also envisage circumstances in which that threat would
be very real by virtue of an effective monpoloy in the garden market.

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


Re: namespace dictionaries ok?

2005-10-25 Thread Duncan Booth
Ron Adam wrote:
> James Stroud wrote:
>> Here it goes with a little less overhead:
>> 
>> 

> 
> But it's not a dictionary anymore so you can't use it in the same places 
> you would use a dictionary.
> 
>foo(**n)
> 
> Would raise an error.
> 
> So I couldn't do:
> 
> def foo(**kwds):
>kwds = namespace(kwds)
>kwds.bob = 3
>kwds.alice = 5
>...
>bar(**kwds) #<--- do something with changed items
> 
I agree with Steven D'Aprano's reply, but if you are set on it you could 
try this:

>>> class namespace(dict):
def __init__(self, *args, **kw):
dict.__init__(self, *args, **kw)
self.__dict__ = self


>>> n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice':4})
>>> n.bob
1
>>> n.bob = 3
>>> n['bob']
3

The big problem of course with this sort of approach is that you cannot 
then safely use any of the methods of the underlying dict as they could be 
masked by values.

P.S. James, *please* could you avoid top-quoting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Joerg Schuster
> Some people, when confronted with a problem, think "I know,
> I'll use regular expressions." Now they have two problems.
> --Jamie Zawinski

Thanks for the citation.

If my goal had been to redesign my program, I would not ask questions
about regular expressions. I do not have the time to redesign my
program. And knowing that my situation would be better, if I had
written other code in the past, does not help me at all.

I just want to use more than 100 capturing groups. If someone told me
that it is very unlikely for Python to get rid of the said limitation,
I would recode part of my program in C++ using pcre. But I would prefer
to be able to do everything in Python. That is why I asked.

Jörg

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Peter T. Breuer
In comp.os.linux.misc David Schwartz <[EMAIL PROTECTED]> wrote:
> Yes, but that's the "if". I have a monopoly on *me* mowing your lawn. 
> You can, of course, go to someone else to have your lawn mowed.

Of course you can't - why would anyone else be available to mow my lawn
just because I want it to be so? Mowing a lawn requires a lifetime's
investment of skill acquirement, plus a small army of lawn mower
backup fronds advancement teams sitting in cold offices setting up the
lawnmower oil. And while I was searching for somebody else to do the
work my lawn business would be losing money like a sieve.


> Microsoft 
> only had a monopoly on *Microsoft* operating systems. Microsoft had no 

Nonsense. Microsoft had an effective monopoly on *IBM PC* operating
systems, thanks to nasty illegal competition-killing tactics that in
themselves were illegal (such as making their programs not work with
ther versions of dos).

> control over OSX, Linux, FreeBSD, and so on.

They had plenty of control, thanks to their monopoly position (and
Linux didn't exist then, FreeBSD came soon but was not a client
offering).

> Essentially, Microsoft asked for exclusive arrangements. That is, 
> arrangements wherein you could not sell competing products if you wished to 
> sell Microsoft products. That's not even remotely unusual.

It soitenly is, stanley. In case you hadn't noticed, the shops sell
more than one kind of washing powder.

Please stop this shillism.

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread David Schwartz

"Peter T. Breuer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

>> Essentially, Microsoft asked for exclusive arrangements. That is,
>> arrangements wherein you could not sell competing products if you wished 
>> to
>> sell Microsoft products. That's not even remotely unusual.

> It soitenly is, stanley. In case you hadn't noticed, the shops sell
> more than one kind of washing powder.

Your argument is nonsensical. Because you can find one category of goods 
that don't have the property I'm talking about it follows that the property 
is unusual?!

Operating systems are not like washing powder at all. Try to sell both 
Big Macs and Whoppers in one store. Heck, try to sell Craftsman tools 
without being a Sears. Microsoft gets to decide whether they sell their 
operating systems software like washing powder or like burgers, not you.

> Please stop this shillism.

If you could produce a strong argument, it might make sense to accuse me 
of shilling.

DS


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


Re: Microsoft Hatred FAQ

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

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


Re: Syntax across languages

2005-10-25 Thread Duncan Booth
Tim Roberts wrote:

>>
>>- Nestable Pascal-like comments (useful): (* ... *)
> 
> That's only meaningful in languages with begin-comment AND end-comment
> delimiters.  Python has only begin-comment.  Effectively, you CAN nest
> comments in Python:

I believe that the OP is mistaken. In standard Pascal comments do not nest, 
and you can mix delimiters so, for example:

(* this is a comment }

Most Pascal implementations require the delimeters to match and allow you 
to nest comments which use different delimiters, but I'm not aware of any 
Pascal implementations which would allow you to nest comments with the same 
delimiter:

(* This is not a valid (* comment within a comment. *) *)

To this extent Python (if you consider docstrings as a type of comment) 
does exactly the same thing:

""" this is # a docstring! """

# and this is """ a comment """

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


Re: grep

2005-10-25 Thread Fredrik Lundh
"marduk" wrote:

>> What's the standard replacement for the obsolete grep module?
>
> AFAIK there never was a "grep" module.  There does, however exist a
> deprecated "regex" module:

there was a "grep" module in 1.5.2 and earlier:

http://effbot.org/librarybook/grep.htm

but it was removed in 2.0 (or somewhere around that time).

the new RE package doesn't support all the RE syntax variants used by that
module, but if you're willing to update your patterns [1] to use the new syntax,
you can replace grep with some variation of:

import re, glob

def grep(pattern, *files):
search = re.compile(pattern).search
for file in files:
for index, line in enumerate(open(file)):
if search(line):
print ":".join((file, str(index+1), line[:-1]))

grep("grep", *glob.glob("*.py"))

(tweak as necessary)



1) to some extent, the reconvert module might be able to help you with the con-
version:

http://www.python.org/dev/doc/devel/lib/module-reconvert.html
http://effbot.org/librarybook/reconvert.htm 



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


Re: pickle

2005-10-25 Thread Fredrik Lundh
Shi Mu wrote:

> what does the following code mean?
>
> y = pickle.load(file("cnumber.pickle", "r"))

open the file "cnumber.pickle" for reading, pass the file handle to
the pickle.load function, and store the result in the "y" variable.

> also, I can not understand "f" in pickle.dump(x, f)

the second argument to pickle is a file handle, opened for writing.
pickle.dump will save the "pickled data" to that file.

 



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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Peter T. Breuer
In comp.os.linux.misc David Schwartz <[EMAIL PROTECTED]> wrote:
> "Peter T. Breuer" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> [DS, MS shill, said ..]
>>> Essentially, Microsoft asked for exclusive arrangements. That is,
>>> arrangements wherein you could not sell competing products if you wished 
>>> to
>>> sell Microsoft products. That's not even remotely unusual.

>> It soitenly is, stanley. In case you hadn't noticed, the shops sell
>> more than one kind of washing powder.

> Your argument is nonsensical. Because you can find one category of goods 
> that don't have the property I'm talking about it follows that the property 
> is unusual?!

Yep. You got it.

> Operating systems are not like washing powder at all.

Really? In what way? I think you'll find that in germany at least,
Linux *IS* a brand of washing powder.

> Try to sell both 
> Big Macs and Whoppers in one store.

Looks good to me -  buy my hamburgers in a shop that sells lots of
different kinds in their freezer. I THINK you are trying to confuse 
hamburgers and restaurant chains, BTW.  Uh, uh.  Won't woik, stan.  I
know the difference.

> Heck, try to sell Craftsman tools 
> without being a Sears.

No idea what they are, but I imagine they are something you tie round
an ample midriff. Anyway, your example is the wrong way round - you
mean "try to buy a lawn mower from Sears without paying for the price
of a set of Craftsman tools". Or shumeshing.


> Microsoft gets to decide whether they sell their 
> operating systems software like washing powder or like burgers, not you.

Uh uh. No they don't.  Discriminatory trading practices are, uh,
illegal. You can't refuse to sell me something (or ratch up the price)
just because you don't like me, or even worse, because you want to
create a articial supply and demand situation.  That's called "fixing
the market".

>> Please stop this shillism.

> If you could produce a strong argument, it might make sense to accuse me 
> of shilling.

I don't have to - shilling is as as shilling looks. If YOU want to
find out what MS did wrong, read the official and legal reports, dude.
The findings are findings of fact.

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


Re: testing for modules?

2005-10-25 Thread Fredrik Lundh
Ed Hotchkiss wrote:

> i have a generic script that is using several modules on windows and linux
> boxes. i need to have the scripts test if a module is installed, and then if
> not - then to install the module. can anyone give me a headsup on how to
> test for a module, returning something to indicate whether or not it is
> installed, then after that executing file to install the module.?

if the modules behave nicely, and don't do silly stuff when first imported,
something like

try:
import mymodule
except ImportError:
install_module("mymodule")
import mymodule # retry

usually works.

if you have lots of modules, you can use something like

MODULES = "mymodule", "myothermodule", "sys"

for module in MODULES:
try:
__import__(module)
except ImportError:
install_module(module)

...

import mymodule # will fail if installation failed
import myothermodule, sys



 



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


Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Fredrik Lundh
"Joey C." wrote:

> Here is a basic overview of the variables included there.
>
> params = cgi.FieldStorage()
> I accidentally made a mistake when typing what the "thefile" variable
> is.
> thefile = params["upfile"].file
> "upfile" is the CGI field that contains the file that I'm uploading.
> As you can see, the if statement just compares two values,
> os.path.getsize(thefile) and conf["upmax"], a variable I set that is
> designated as the maximum file size allowed.
>
> I'm assuming that this is all the information you need.  I'm sorry for
> not including it earlier; I was in a bit of a rush.  ^.^

and I'm sorry for not noticing the error: os.path.getsize takes a filename,
but the file attribute contains a file handle, and that UnicodeError is what
you get if you pass the wrong thing to os.path.getsize.  e.g:

>>> os.path.getsize(None) < 1000
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python23\lib\ntpath.py", line 228, in getsize
return os.stat(filename).st_size
TypeError: coercing to Unicode: need string or buffer, NoneType found

(here, the full traceback reveals that the problem is inside getsize, and not
in the comparision.  the error message itself isn't exactly helpful, though...)

the file handle is usually a real (but temporary) file, so you should be able to
get the size by seeking to the end of the file:

file = params["upfile"].file
file.seek(0, 2)
size = file.tell()
file.seek(0) # rewind

inspecting the headers attribute might also help.

 



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


Re: Microsoft Hatred FAQ

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

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

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

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

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


Re: Hi All - Newby

2005-10-25 Thread bruno modulix
Ask wrote:
> G'day All,
> 
(snip)

Welcome here...

> I must admit to much confusion regarding some of the basics, but I'm sure 
> time, reading, and good advice will get rid of that. at this stage, it's 
> just working through some examples and getting my head around things. As an 
> example, if I create a window, I've been unable to force it to be a certain 
> size, and put a button (widget) at (say) 20,40 (x & y). Is window formatting 
> possible?

As you say, Python runs on a lot of platforms. It also allow the use of
a lot of GUI toolkits. So "windows formatting" isn't a Python problem -
it's specific to to toolkit you're using. Since we don't know which
you're using, there's no way to answer your question.

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


Re: [OT] Python vs Ruby

2005-10-25 Thread bruno modulix
Scott David Daniels wrote:
> bruno modulix wrote:
> 
>> Scott David Daniels wrote:
>>
>>> bruno modulix wrote:
>>>
 ... Another language that failed to make it to the mainstream but is
 worth giving a try is Smalltalk - the father of OOPLs (Simula being the
 GrandFather). 
>>>
>>> I would say Simula is the forefather of modern OOPLs, and Smalltalk is
>>> the toofather.
>>
>> Err... I'm afraid I don't understand this last word (and google have not
>> been of much help here)
> 
> 
> Sorry, I was being too cute by half.

tss...

>  If Simula is the fore father
> (4 away) then Smalltalk is half as far (2) away.  Hence the "toofather."
> "Toofather" by analogy with the homophones "fore" and "four" we use the
> homophones "two" and "too".

My my my...

-- 
bruno desthuilliers
ruby -e "print '[EMAIL PROTECTED]'.split('@').collect{|p|
p.split('.').collect{|w| w.reverse}.join('.')}.join('@')"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hi All - Newby

2005-10-25 Thread Fredrik Lundh
"Ask" wrote:

> As an example, if I create a window, I've been unable to force it to be a 
> certain size, and put a 
> button (widget) at (say) 20,40 (x & y). Is window formatting possible?

I'm pretty sure all GUI toolkits can do that, but the exact details depend on 
the library
you're using.

(if you're using Tkinter, see this page: 
http://effbot.org/tkinterbook/place.htm )

 



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


Re: Tricky Areas in Python

2005-10-25 Thread Peter Hansen
Tim Roberts wrote:
> "PyPK" <[EMAIL PROTECTED]> wrote:
>>What possible tricky areas/questions could be asked in Python based
>>Technical Interviews?
> 
> What's the point of asking "tricky" questions?  Aren't you really more
> interested in what applications they have worked on and whether they were
> successful?
> 
> I don't know.  I'm not sure I need a job with a company that insists on
> playing "Programming Jeopardy" during the interview.

That's okay.  Those companies don't need you either. ;-)

Seriously though, the point of asking such questions is that with 
minimal effort they _can_ (not "definitely will") quickly qualify a 
candidate's level of expertise in a language.  Novices, and those who 
while they might have programmed in a language for several years still 
don't really understand it deeply enough to be considered entirely safe 
on their own, will generally trip up on all or most such questions 
(where "trip up" means anything from giving wrong answers to giving you 
the "deer in the headlights" look).  _Anyone_ could trip up on one or 
two of them, especially given the pressure of an interview situation. 
(And even seeing an expert trip up under pressure tells you something 
useful about the candidate.)

In short, a true senior programmer will provide good correct answers to 
most such questions, while those less senior generally will not.

Asking such questions in isolation, without also delving deeply into 
other background such as what applications you've worked on, is just as 
dangerous as asking _only_ about such applications.  I've made the 
mistake of hiring people who had lengthy involvement -- apparently at a 
senior level -- in significant projects, only to discover that they 
clearly didn't understand some basic concepts of the languages 
supposedly used.  My conclusion was that they were in that class of 
people who manage to interview well yet contribute little, but have 
lucked out repeatedly by working for companies who were incompetent at 
terminating for cause (and there are _many_ such companies).  (We didn't 
make the same mistake and fired them reasonably quickly.)

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Peter Hansen
Joerg Schuster wrote:
> I just want to use more than 100 capturing groups. If someone told me
> that it is very unlikely for Python to get rid of the said limitation,
> I would recode part of my program in C++ using pcre. 

It is very unlikely for Python to get rid of the said limitation.

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


migrate from ZODB 3.3.1 --- to where, and how?

2005-10-25 Thread Harald Armin Massa
Hello,

I am using ZODB "standalone" in version 3.3.1 within some application.

Now I learn that the 3.3.x branch of ZODB is "retired". No problem so
far, everything is running fine.


BUT... "retired" gives me the hint that nothing GREAT will be done to
this branch anymore :)

Now I am questioning myself: to which branch should I migrate? Is 3.5 a
sure bet, or are uneven subversions a bad sign, making retirement
likely?

As much as my diggings showed me, the "special sign" of 3.3 was
import ZODB
from persistent import Persistent
from persistent.list import PersistentList
from persistent.mapping import PersistentMapping

that PersistentList and PersistenMapping reside within
persistent., while in the 3.2 branch they reside somewhere
else in the namespace.

I learned it the hard way that 3.3 filestores not get converted
magically or easy to 3.2 :) ...

So, my questions:
 - where should I migrate to?
 - how is migration done best (especially taking care of "old"
filestores

Harald

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


Re: Tricky Areas in Python

2005-10-25 Thread Fredrik Lundh
Alex Martelli wrote:

> No, LC goes back a long way -- I think it was in 2.0 already, 2.1 for
> sure.

$ python1.5 -c "print [x for x in 'abc']"
  File "", line 1
print [x for x in 'abc']
   ^
SyntaxError: invalid syntax
$ python2.0 -c "print [x for x in 'abc']"
['a', 'b', 'c']

I was a bit surprised to find that 2.0 had variables, though:

$ python2.0 -c "[x for x in y]"
Traceback (most recent call last):
  File "", line 1, in ?
NameError: There is no variable named 'y'
$ python2.1 -c "[x for x in y]"
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'y' is not defined

;-)

 



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


Re: XML Tree Discovery (script, tool, __?)

2005-10-25 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> The output I was contemplating was a DOM "DNA" - that is the DOM
> without the instances of the elements or their data, a bare tree, a
> prototype tree based on what is in the document (rather than what is
> legal to include in the document).
>
> Just enough data that for an arbitrary element I would know:
>
> 1) whether the element was in a document
> 2) where to find it (the chain of parents)

how to you identify the elements ?  do they have unique tags, unique 
identifiers,
or some other "globally unique" identifier (attributes or contents) ?

 



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


RE: python cgi script not understood as html

2005-10-25 Thread Iyer, Prasad C

Your python script is not getting executed.
I guess there is something wrong with the server configuration.



#-Original Message-
#From: Philippe C. Martin [mailto:[EMAIL PROTECTED]
#Sent: Tuesday, October 25, 2005 1:27 AM
#To: [email protected]
#Subject: python cgi script not understood as html
#
#Hi,
#
#The following code outputs the actual HTML text to the browser, not the
#interpreted text.
#
#Any idea ?
#
#Regards,
#
#Philippe
#import cgi
#import logging
#import auth #this is the one you must implement (or use SCF ;-)
#
#html_ok = """
#Content-Type: text/html\n
#http://www.w3.org/TR/html4/loose.dtd";>\n
#\n
#\n
#  Access Granted\n
#  \n
#  \n
#\n
#\n
#Access Granted\n
#\n
#Welcome %s \n
#\n
#\n
#\n
#"""
#
#html_nok = """
#"Content-Type: text/html\n\n"
#http://www.w3.org/TR/html4/loose.dtd";>
#
#
#
#  Access Granted
#  
#  
#
#
#Access Denied
#
#
#
#
#
#"""
## DISPLAY ACCESS DENIED PAGE
#def Failure():
#print html_nok
#
##DISPLAY ACCESS GRANTED PAGE
#def Success(p_data):
#print html_ok % (p_data)


This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.

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


cell and row

2005-10-25 Thread Shi Mu
I can not understand the use of "cell" and "row" in the code:

# convert the matrix to a 1D list
matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]]
items = [cell for row in matrix for cell in row]
print items
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tricky Areas in Python

2005-10-25 Thread Fredrik Lundh
Alex Martelli wrote:

>> my hard-won ignorance, and admit that I don't see the
>> problem with the property examples:
>>
>> > class Sic:
>> > def getFoo(self): ...
>> > def setFoo(self): ...
>> > foo = property(getFoo, setFoo)
>
> Sorry for skipping the 2nd argument to setFoo, that was accidental in my
> post.  The problem here is: class Sic is "classic" ("legacy",
> "old-style") so property won't really work for it (the setter will NOT
> trigger when you assign to s.foo and s is an instance of Sic).

what's slightly confusing is that the getter works, at least until you attempt
to use the setter:

>>> class Sic:
... def getFoo(self):
... print "GET"
... return "FOO"
... def setFoo(self, value):
... print "SET", value
... foo = property(getFoo, setFoo)
...
>>> sic = Sic()
>>> print sic.foo
GET
FOO
>>> sic.foo = 10
>>> print sic.foo
10

(a "setter isn't part of an new-style object hierarchy" exception would have
been nice, I think...)

 



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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Roedy Green
On Mon, 24 Oct 2005 21:06:36 -0700, "David Schwartz"
<[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who
said :

>Do you think it would be immoral if Microsoft said, "we will only sell 
>Windows wholesale to dealers who don't sell other operating systems?"

I had an existing independent business. I was not as though I were an
MS franchise. They imposed this extortion well into my business's
life.  My choice was comply or go out of business.

It was not as if I had a choice of sell Hondas or sell Kias if I did
like the franchise deal.

To my way of thinking what MS did was similar to a the only magasine
wholesaler in town telling retailers it had to sell kiddie porn under
the table or pay full retail for all magazines.

I broke my own ethical code rather than go out of business. I will
never forgive MS for putting me in that position. 


-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use new AST goodies

2005-10-25 Thread Fredrik Lundh
Simon Burton wrote:

> I'd like to experiment with this, does anyone know where to start ?

with the "once there is" parts, probably (see below).

> It seems that the parser module still produces the same junk as before.
> So where do we find these nice high level AST objects ?

here's a nice summary:

http://www.amk.ca/diary/2005/10/the_ast_branch_lands_1

which ends with:

"The primary benefit is that it should now be easier to write optimization
passes and tools such as PyChecker or refactoring browsers, particularly
once there's a Python interface to the AST and once everything is
documented."

 



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


Re: Python/Apache Oddness On OSX

2005-10-25 Thread John Abel
[EMAIL PROTECTED] wrote:

>John Abel wrote:
>  
>
>>Hi,
>>
>>I'm running Python 2.3.5/2.4.2 on OSX 10.4.2, and am trying to run CGI
>>scripts using the builtin Apache.  For ease, I've symlinked my custom
>>modules into the /Library/Python/2.3/site-packages directory, and they
>>import OK via command line python.  However, when I perform the import
>>from a cgi script, python fails to find the module.  It is definately
>>something to do with the symlink, as the CGI works OK if I copy the
>>directory into site-packages.  Is there some oddness with Python/Apache
>>and symlink imports?
>>
>>Any pointers would be most useful.
>>
>>
>
>If running OS supplied Apache, it runs as the user "www". Because this
>isn't you or root, check that the directory your symlink points at is
>accessible to others as well as any directories above it back up to the
>root directory. If it isn't accessible, the user Apache runs as will
>not
>be able to find and use the files. When you are copying the directory
>you are possibly giving it read access for others in  the process and
>that is why it works then.
>
>Graham
>
>  
>
Yup, that's the problem.  Just got to figure out OSX's permissions, now.

Thank you!

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Frithiof Andreas Jensen

"Joerg Schuster" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hello,

Python regular expressions must not have more than 100 capturing
groups.

Really ??

I have been waiting a long time now for Python to get rid of this
limitation.

Ahh - The "dark side" of Open Source:

If nobody cares, then you will have to do it yourself (and often people do
not care because nobody had the need to go there - for good reasons).

My question is: Does anyone know if the problem is going to be fixed in
the next few months or so? Or is there a way to circumvent it?

After a quick glean across the source code for the sre module, it appears
that the only place the code mentions a limit of 100 groups is in fact the
place that you quote.

I suspect it is there for some historic reason -  the people to ask is of
course "pythonware.com" who wrote it; there may well be a good reason for
the limitation.

What happens if you up the limit to whatever you need?


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


Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-25 Thread uid09012_ti
Hi,

unfortunately the result from py2exe won't run eventhough the original
script runs without problems. The trouble is I'm at a loss as to where
to start looking!

Martin.

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


Re: cell and row

2005-10-25 Thread Fredrik Lundh
Shi Mu wrote:

>I can not understand the use of "cell" and "row" in the code:
>
> # convert the matrix to a 1D list
> matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]]
> items = [cell for row in matrix for cell in row]
> print items

working through the Python tutorial might be a good idea.  here's the section
on list comprehensions:

http://docs.python.org/tut/node7.html#SECTION00714

and here's the section on for loops:

http://docs.python.org/tut/node6.html#SECTION00620

briefly:

items = [cell for row in matrix for cell in row]

or, slightly edited for clarity:

items = [(cell)
for row in matrix
for cell in row]

is the same thing as:

items = []
for row in matrix:
for cell in row:
items.append(cell)

except that it's a bit shorter, and a bit more efficient.

 



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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Frithiof Andreas Jensen

"Joerg Schuster" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Some people, when confronted with a problem, think "I know,
> I'll use regular expressions." Now they have two problems.
> --Jamie Zawinski

Thanks for the citation.

If my goal had been to redesign my program, I would not ask questions
about regular expressions. I do not have the time to redesign my
program. And knowing that my situation would be better, if I had
written other code in the past, does not help me at all.

Experience shows that, in any project, there is always time redo what was
not made properly the first time a deadline was dreamed up.

I just want to use more than 100 capturing groups. If someone told me
that it is very unlikely for Python to get rid of the said limitation,
I would recode part of my program in C++ using pcre.

See!? There *is* Time.



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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Joerg Schuster
> What happens if you up the limit to whatever you need?

Good idea. I just tried this. Nothing evil seems to happen. This seems
to be a solution. Thanks.

Jörg

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


Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Joey C.
I'm afraid on my interpreter, this works.

>>> if os.path.getsize("C:\\Documents and Settings\\Joey\\Desktop\\file.txt") 
>>> <= 1000:
>>> print "<= 1000."

<= 1000.

No problems there, as you can see.

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Fredrik Lundh
Joerg Schuster wrote:

> I just want to use more than 100 capturing groups.

define "more" (101, 200, 1000, 10, ... ?)

 



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


Re: cell and row

2005-10-25 Thread Shi Mu
In the follwoing code,
Why the result is "'defenestrate', 'window', 'defenestrate', " before
the original list instead of 'defenestrate', 'window', ?

>>> a = ['defenestrate', 'cat', 'window', 'defenestrate']
>>> for x in a[:]:
... if len(x) > 4: a.insert(0, x)
... 
>>> a
['defenestrate', 'window', 'defenestrate', 'defenestrate', 'cat',
'window', 'defenestrate']

On 10/25/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Shi Mu wrote:
>
> >I can not understand the use of "cell" and "row" in the code:
> >
> > # convert the matrix to a 1D list
> > matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]]
> > items = [cell for row in matrix for cell in row]
> > print items
>
> working through the Python tutorial might be a good idea.  here's the section
> on list comprehensions:
>
> http://docs.python.org/tut/node7.html#SECTION00714
>
> and here's the section on for loops:
>
> http://docs.python.org/tut/node6.html#SECTION00620
>
> briefly:
>
>items = [cell for row in matrix for cell in row]
>
> or, slightly edited for clarity:
>
>items = [(cell)
>for row in matrix
>for cell in row]
>
> is the same thing as:
>
>items = []
>for row in matrix:
>for cell in row:
>items.append(cell)
>
> except that it's a bit shorter, and a bit more efficient.
>
> 
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Fredrik Lundh
"Joey C." wrote:

> I'm afraid on my interpreter, this works.
>
 if os.path.getsize("C:\\Documents and Settings\\Joey\\Desktop\\file.txt") 
 <= 1000:
 print "<= 1000."
>
> <= 1000.
>
> No problems there, as you can see.

I'm not sure if you replied to my post, but what I tried to say is that

params["upfile"].file

doesn't return a string, it returns a file object.  and os.path.getsize
on something that's not a string gives the TypeError you're seeing.

 



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


Re: Upgrading 2.4.1 to 2.4.2

2005-10-25 Thread Vincent Gulinao
Hi, I'm new to python and just upgraded python on my system from 2.3 to
2.4. My platform is Linux-2.6.9-1.667smp-i686-with-redhat-3-Heidelberg.

Is there any way to inherit (share?) all extensions and additional
modules the my 2.3 have? (of course, beside re-installing everything)
On 19 Oct 2005 02:03:56 -0700, Ben Sizer <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:> Not sure that is a good idea on a linux system. MS should be fine, but> I actually tried that on linux. Didn't realize how much on a linux
> system depends on Python.I had that problem once, although to be fair it really does depend onwhich distribution you use as to how many problems you're going tohave.Perhaps the way to do it is to install the new Python version in
/usr/local/ (alongside the distro's version is in /usr/ ), then whenyou're sure your new version is installed and working, change thereferences over - perhaps it's possible to do this with just 1 symboliclink somewhere.
--Ben Sizer--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-25 Thread Joey C.
Oh, I'm sorry, I didn't understand what you meant at first.
Then I read your reply over again and noticed that you said that the
problem lied in os.path.getsize() when I tried to run it on the
contents of an open file.

I'll try the method you outlined now.

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


Re: python gc performance in large apps

2005-10-25 Thread Fredrik Lundh
Robby Dermody wrote:

> In the diagrams above, one can see the night-day separation clearly. At
> night, the memory usage growth seemed to all but stop, but with the
> increased call volume of the day, it started shooting off again. When I
> first started gathering this data, I was hoping for a logarithmic curve,
> but at least after 48 hours, it looks like the usage increase is almost
> linear. (Although logarithmic may still be the case after it exceeds a
> gig or two of used memory. :) I'm not sure if this is something that I
> should expect from the current gc, and when it would stop.

I don't think the GC has much to do with this; it's a lot more likely that you
have growing memory structures (in-memory logs, memo caches, etc) some-
where in your application.

adding some code that calls gc.get_objects() and dumps the N largest lists
and dictionaries might help.  something like (untested):

import gc, repr, sys

def gc_check(objects):

def check(objects):
lists = []
dicts = []
for i in objects:
if isinstance(i, list): lists.append((len(i), i))
elif isinstance(i, dict): dicts.append((len(i), i))
lists.sort(); lists.reverse()
for n, i in lists[:20]:
print "LIST", n, repr.repr(i)
dicts.sort(); dicts.reverse()
for i in dicts[:20]:
print "DICT", n, repr.repr(i)

try:
check(objects)
except:
print "error in gc_check", sys.exc_info()
try:
# clear exception state (even if exc_clear doesn't exist ;-)
sys.exc_clear()
except AttributeError:
pass

(tweak as necessary)

and call this like

gc_check(gc.get_objects())

at regular intervals.  if you have any constantly growing containers in your
application, they will most likely appear in the output rather quickly.

 



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


Re: A macro editor

2005-10-25 Thread Fabio Zadrozny
Hi Jaume,

Pydev (http://pydev.sf.net) is an eclipse plugin that does 
code-completion for jython, so, it might be worth taking a look at it...

Cheers,

Fabio


jau wrote:

>Hello mates.
>
>I'm part of a big project's developer team. We are writting an 
>application in Java and we are planning to add scripting functionality 
>to it. What we exactly are planning is to give a kind of tool that would 
>allow our users to write their own scripts to perform their special 
>operations. Something like VBA does in several comercial applications. 
>But, as we are GPL we have to use a close to GPL licensed-like language.
>
>My teammates and I were talking about to use one of Python, Ruby or 
>Groovy. But, we haven't decided which to use.
>
>What seems to be easier is to use Python, you know.. because of the 
>Jython thing. But, it is probably a mistake to take Jython without a 
>extensive analysis of the all possibilities.
>
> From my point of view, the best choice will be those that allow the 
>average user getting results as fast as possible rather than the power 
>of the language itself. At the end, what we will write is a gateway to 
>access to our application's Java API through the scripts written by our 
>users.
>
>In this sense, I'd like to ask if someone knows if any of these 
>languages have a Java implementation that supports code auto-complete 
>and class navigation or any kind of functionality that would ease and 
>speed up the user's learning curve and productivity.
>
>In other words, is it possible to have a small and lightly intelligent 
>workbench window (a mini-Eclipse for example) for our future "macro 
>editor" within our application?
>
>I promise that if get some info I'll publish it here as soon I have it.
>
>Thanks for your time!
>Jaume
>  
>


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


Re: Upgrading 2.4.1 to 2.4.2

2005-10-25 Thread Fredrik Lundh
Vincent Gulinao wrote:

> Hi, I'm new to python and just upgraded python on my system from 2.3 to 2.4.
> My platform is Linux-2.6.9-1.667smp-i686-with-redhat-3-Heidelberg.
>
> Is there any way to inherit (share?) all extensions and additional modules
> the my 2.3 have? (of course, beside re-installing everything)

binary extensions should, in general, be recompiled for each new X.Y release,
so it's usually best to reinstall them.

(under Unix, you can often use older extensions, but you may get warnings, and
some extensions may not work properly.  if you feel adventurous, you can simply
copy the old Lib/site-packages directory to the corresponding location in the 
new
install, and see what happens.  no guarantees, though...)

 



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


Reminder: PyCon proposals due in a week

2005-10-25 Thread A.M. Kuchling
The deadline for PyCon 2006 submissions is now only a week away.  
If you've been procrastinating about putting your outline together, 
now's the time to get going...

Call for Proposals: 
http://www.python.org/pycon/2006/cfp

Proposal submission site:
http://submit.python.org/

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


Re: Upgrading 2.4.1 to 2.4.2

2005-10-25 Thread Fredrik Lundh
>> Hi, I'm new to python and just upgraded python on my system from 2.3 to 2.4.
>> My platform is Linux-2.6.9-1.667smp-i686-with-redhat-3-Heidelberg.
>>
>> Is there any way to inherit (share?) all extensions and additional modules
>> the my 2.3 have? (of course, beside re-installing everything)
>
> binary extensions should, in general, be recompiled for each new X.Y release,
> so it's usually best to reinstall them.

just noted that your subject doesn't match the rest of your message; if you're 
doing
a minor upgrade (X.Y.Z), it should be safe to install the new version over the 
old one,
and all existing extensions should continue to work.

(I say "should", but 2.4 => 2.4.1 did break a lot of things for me; 2.3 => 2.4 
was a
much cleaner upgrade.  most of the 2.4.1 issues are fixed in 2.4.2, so it was 
probably
just a temporary glitch)

 



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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Joerg Schuster
No limitation at all would be best. If a limitation is necessary, then
the more capturing groups, the better. At the time being, I would be
really happy about having the possibility to use 1 capturing
groups.

Jörg

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


Re: pickle

2005-10-25 Thread Steve Holden
Shi Mu wrote:
> what does the following code mean?
> 
> y = pickle.load(file("cnumber.pickle", "r"))
> 
Take it by parts:

 file("cnumber.pickle", "r")

returns a file object as a result of opening the "cnumber.pickle" file, 
which is presumably a pickle someone wrote earlier.

So

 pickle.load(file("cnumber.pickle", "r"))

returns the first object stored in that pickle file.


> also, I can not understand "f" in pickle.dump(x, f)
> 
The beginning of the docs on pickle usage says:

"""dump( obj, file[, protocol[, bin]])

Write a pickled representation of obj to the open file object file."""

Isn't this reasopnably self-explanatory?

regards
  Steve

>[...]

-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread David Schwartz

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

> On Mon, 24 Oct 2005 21:06:36 -0700, "David Schwartz"
> <[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who
> said :

>>Do you think it would be immoral if Microsoft said, "we will only sell
>>Windows wholesale to dealers who don't sell other operating systems?"

> I had an existing independent business. I was not as though I were an
> MS franchise. They imposed this extortion well into my business's
> life.  My choice was comply or go out of business.

> It was not as if I had a choice of sell Hondas or sell Kias if I did
> like the franchise deal.

Okay, I give up. As far as I can see it, there are only two realistic 
possibilties:

1) There is no other operating system worth selling. In this case, you 
are right, you have no choice but to sell the Microsoft OS, but the deal 
they're offering you harms you in no way. (Unless you intended to sell PCs 
with no OS at all.)

2) There are other realistic competing operating systems. In this case, 
you were foolish to agree to Microsoft's deal. You lost out on the realistic 
competing markets. That is, unless Windows only really was a better deal, in 
which case you were wise to take the deal and have no reason to be upset.

> To my way of thinking what MS did was similar to a the only magasine
> wholesaler in town telling retailers it had to sell kiddie porn under
> the table or pay full retail for all magazines.

Of course you pick an analogy where MS analogically peddles kiddie porn. 
I can play the same game, watch this: What MS did was similar to the major 
magazine wholesaler in a town telling retailers they must carry gay and 
lesbian publications if they want to carry its mainstream magazines.

> I broke my own ethical code rather than go out of business. I will
> never forgive MS for putting me in that position.

You certainly have a legitimate personal grudge against MS.

DS


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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Jorge Godoy
"Joerg Schuster" <[EMAIL PROTECTED]> writes:

> No limitation at all would be best. If a limitation is necessary, then
> the more capturing groups, the better. At the time being, I would be
> really happy about having the possibility to use 1 capturing
> groups.

I'm sorry, I missed the beginning of this thread and it has already expired on
my news server, but what is the reason for so much capturing groups?  I
imagine that coding this and keeping code maintenable is a huge effort.  Oh,
and I came from Perl, where I used to think in regexps...  In Python I almost
never use them. 

-- 
Jorge Godoy  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cell and row

2005-10-25 Thread Steve Holden
Shi Mu wrote:
> In the follwoing code,
> Why the result is "'defenestrate', 'window', 'defenestrate', " before
> the original list instead of 'defenestrate', 'window', ?
> 
> 
a = ['defenestrate', 'cat', 'window', 'defenestrate']
for x in a[:]:
> 
> ...   if len(x) > 4: a.insert(0, x)
> ...   
> 
a
> 
> ['defenestrate', 'window', 'defenestrate', 'defenestrate', 'cat',
> 'window', 'defenestrate']
> 
The loop cycles over a *copy* of the list (that's what a[:] is, though 
list(a) would also work), and adds any items it finds whose length is 
greater that 4 at the start of the list, which starts out with four 
elements in it.

So it adds "defenestrate" the first time through the loop, nothing the 
second ("cat" is only three characters long), "window" the third and 
"defenestrate" the fourth.

You can do a lot of this kind of playing at the interactive prompt, 
which will answer your questions much more quickly!

For example, run the code with a could of print statements inserted:

  >>> a = ['one111', 'two', 'three', 'four']
  >>> for x in a[:]:
  ...   print "x:", x
  ...   if len(x) > 4: a.insert(0, x)
  ...   print a
  ...
x: one111
['one111', 'one111', 'two', 'three', 'four']
x: two
['one111', 'one111', 'two', 'three', 'four']
x: three
['three', 'one111', 'one111', 'two', 'three', 'four']
x: four
['three', 'one111', 'one111', 'two', 'three', 'four']
  >>>

regards
  Steve

> On 10/25/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> 
>>Shi Mu wrote:
>>
[about list comprehensions, explained by Fredrik]
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Redirect os.system output

2005-10-25 Thread jas
Paul,
   I did ceck out the PExpect, however, I thought it was not ported for
Windows.  Did you find a ported version?  If not, what did you have to
do to be able to use it?

Thanks

Paul Dale wrote:
> You might want to try python expect which gives you a very simple and
> scriptable interface to a process.
>
> http://pexpect.sourceforge.net/
>
> I've been using it on windows to automate a few things.
>
> Cheers,
>
> Paul
>
> jas wrote:
>
> >Kent,
> >  Yes, your example does work.  So did os.popen...however, the problem
> >is specific to "cmd.exe".
> >   Have you tried that yet?
> >
> >Thanks!
> >
> >Kent Johnson wrote:
> >
> >
> >>jas wrote:
> >>
> >>
> >>>Ok, I tried this...
> >>>
> >>>C:\>python
> >>>Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
> >>>on win32
> >>>Type "help", "copyright", "credits" or "license" for more information.
> >>>
> >>>
> >>>
> >>import subprocess as sp
> >>p = sp.Popen("cmd", stdout=sp.PIPE)
> >>
> >>result = p.communicate("ipconfig")
> >>
> >>
> >>>'result' is not recognized as an internal or external command,
> >>>operable program or batch file.
> >>>
> >>>
> >>>
> >>>basically I was opening to send the "ipconfig" command to cmd.exe and
> >>>store the result in the "result" variable.  But you can see there was
> >>>an error with result.
> >>>
> >>>
> >>This works for me:
> >>import subprocess as sp
> >>p = sp.Popen("ipconfig", stdout=sp.PIPE)
> >>result = p.communicate()[0]
> >>print result
> >>
> >>Kent
> >>
> >>
> >
> >  
> >

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Steve Holden
Joerg Schuster wrote:
>>What happens if you up the limit to whatever you need?
> 
> 
> Good idea. I just tried this. Nothing evil seems to happen. This seems
> to be a solution. Thanks.
> 
> Jörg
> 
The joys of open source. Just remember you have now made your program 
non-portable. Hope this isn't an issue.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Peter T. Breuer
In comp.os.linux.misc David Schwartz <[EMAIL PROTECTED]> wrote:
> 1) There is no other operating system worth selling. In this case, you 
> are right, you have no choice but to sell the Microsoft OS, but the deal 
> they're offering you harms you in no way. (Unless you intended to sell PCs 
> with no OS at all.)

> 2) There are other realistic competing operating systems. In this case, 
> you were foolish to agree to Microsoft's deal. You lost out on the realistic 
> competing markets. That is, unless Windows only really was a better deal, in 
> which case you were wise to take the deal and have no reason to be upset.

3) there are plenty of other OSs that are developed or could be
developed but which cannot get a foothold or even manage to be put on
the shelves because the majority product producer insists on charging
hardware manufacturers for every box produced, whether or not it carries
their o/s, and does other nasty things like sabotaging their own
products so they won't work with a clone o/s.

Sorry - that's not legal, fair, just, or good for the market. It means
that anybody with a 51% share of the market automatically gets 100%.

Stop this apologism now.

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


Re: cell and row

2005-10-25 Thread Jan Niestadt
Because you're inserting items into your existing list instead of a new
list. What you probably mean is:

  b = []
  for x in a:
  b.append(x)

which creates a new list b that contains all elements whose length is
greater than four.
A better way to write this would be:

  b = [x for x in a if len(x) > 4]

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


PDO and database abstraction

2005-10-25 Thread Luiz Geron
Hi all,
I'm testing the PDO wrapper to database modules [1] and I'm wondering
how few things like this there are around. My problem, actually, is the
paramstyle of modules. I want to use kinterbasdb in the same code I use
cx_oracle, for example, but paramstyle changes from one to other, than
I searched for things like this and found nothing really usefull. The
problem with PDO is that it was so dificult to find, since a few people
seems to use it, and I haven't yet figured how to change the paramstyle
on it, so I want to ask: Do you use a thing like this that you would
recommend to me?

Thanks,
Luiz Carlos Geron

[1] http://pdo.neurokode.com

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread David Schwartz

"Peter T. Breuer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> 3) there are plenty of other OSs that are developed or could be
> developed but which cannot get a foothold or even manage to be put on
> the shelves because the majority product producer insists on charging
> hardware manufacturers for every box produced, whether or not it carries
> their o/s, and does other nasty things like sabotaging their own
> products so they won't work with a clone o/s.

How could he resell an OS that "could be developed"? If nobody wants 
these operating systems, then it doesn't hurt him not to be able to sell 
them. If people want them, then he could have shown Microsoft the door.

You are responding to an argument that was specifically about the effect 
of this particular arrangement on this particular business. This third case 
was not one that he could find himself in. In fact, it's case 1 for him.

> Sorry - that's not legal, fair, just, or good for the market. It means
> that anybody with a 51% share of the market automatically gets 100%.

That's just absolutely absurd. If some OS had 51% of the market, plenty 
of other distributors and manufacturers would gladly take other 49%.

> Stop this apologism now.

"Apologism"?

Merriam-Webster says: "The word you've entered isn't in the dictionary. 
Click on a spelling suggestion below or try again using the search box to 
the right."

Dictionary.com says: "No entry found for apologism."

Fortunately I finally found what you mean, from 
http://www.absoluteastronomy.com/encyclopedia/a/ap/apologism.htm which says:

Apologism is the metaphysical philosophy that argues that it is wrong for 
humans to attempt to alter the conditions of life in the mortal sphere of 
influence. It is opposed to the idea that absolute "progress" is a desirable 
goal for the pursuit of human endeavors.

I'm not sure how I've said it's wrong for people to try to alter the 
conditions of life. I strongly believe that progress is a desirable goal. In 
fact, thanks to you, I now know that I am a meliorist. Never knew there was 
a word for it and never knew there were people who weren't.

But then I found what I think you meant, "Apologetics is the field of 
study concerned with the systematic defense of a position. Someone who 
engages in apologetics is called an apologist." So perhaps you are asking me 
to stop systematically defending my position. Don't worry, my defense is not 
and has not been systematic.

DS


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


overiding assignment in module

2005-10-25 Thread Viktor Marohnic
Hello.
I would to do something like this.

container = []

p1 = point()
l1 = line()

and i would like to override = method of the module so that its puts
all objects into container.
how i can do something like that.
thanks for help,
viktor.

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Eike Preuss
David Schwartz wrote:
> "Peter T. Breuer" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
> 
>>3) there are plenty of other OSs that are developed or could be
>>developed but which cannot get a foothold or even manage to be put on
>>the shelves because the majority product producer insists on charging
>>hardware manufacturers for every box produced, whether or not it carries
>>their o/s, and does other nasty things like sabotaging their own
>>products so they won't work with a clone o/s.
> 
> 
> How could he resell an OS that "could be developed"? If nobody wants 
> these operating systems, then it doesn't hurt him not to be able to sell 
> them. If people want them, then he could have shown Microsoft the door.
Shouldn't it be my right as a seller, to decide that I want to sell an
operating system 'that nobody wants' _as well as_ operating systems that
'everybody wants'? So it *hurts* me if I am not able to sell these. That
it doesn't hurt me financially doesn't mean that it doesn't hurt me
(e.g. my freedom, ideas of morality, whatever).

[big snip]

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Roedy Green
On Tue, 25 Oct 2005 04:21:45 -0700, "David Schwartz"
<[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who
said :

>2) There are other realistic competing operating systems. In this case, 
>you were foolish to agree to Microsoft's deal. You lost out on the realistic 
>competing markets. That is, unless Windows only really was a better deal, in 
>which case you were wise to take the deal and have no reason to be upset. 

The actuality at the time was the vast majority of my business was
Windows.  People would ask about OS/2 and when they asked around town
and discovered because of the MS dirty deal it cost way more, they
lost interest.

I could not have made a living selling only OS/2.  It is was a very
difficult business to survive in as it was and I was already at a
disadvantage because of my insistence on not cutting corners the way
my competitors did.  Every once in a while I run into one of my
machines I built back in the early 90s still going without a hitch
over a decade later.

I don't think I could make it clearer.  What MS did was wrong and I
will to my dying day curse them for it.  If I were a Christian, I
would put it this way. The pressured me into selling my soul.

They did not tempt me into it. They threatened to destroy my business
and my livelihood if I did not knuckle under. That is extortion.





-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Joerg Schuster
> but what is the reason for so much capturing groups?  I
> imagine that coding this and keeping code maintenable is a huge effort.

User input is compiled to regular expressions. The user does not have
to worry about those groups.

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


Re: PDO and database abstraction

2005-10-25 Thread Gerhard Häring
Luiz Geron wrote:
> Hi all,
> I'm testing the PDO wrapper to database modules [1] and I'm wondering
> how few things like this there are around. 

Actually there are several Object-Relation Mappers (ORM) for Python, and 
also a few other attempts to provide a more convenient layer on top of 
DB-API modules.

This wiki page has links: 
http://wiki.python.org/moin/HigherLevelDatabaseProgramming

> My problem, actually, is the paramstyle of modules.

That problem exactly what these solutions try to solve, this and 
multiple SQL dialects and handling types like date etc. for multiple 
backends.

> I want to use kinterbasdb in the same code I use
> cx_oracle, for example, but paramstyle changes from one to other, than
> I searched for things like this and found nothing really usefull. The
> problem with PDO is that it was so dificult to find, since a few people
> seems to use it,  and I haven't yet figured how to change the paramstyle
> on it, so I want to ask: Do you use a thing like this that you would
> recommend to me?

I always wrote my own thin layer on top of DB-API modules and used it to 
implement a *specific* database interface for my applications. This 
would then have one or more database backends. Actually never more than 
two so far.

If you want to go for a more popular ORM, you can try out SqlObject. But 
  it doesn't have Oracle support, yet. There were patches and there are 
apparently again new attempts to integrate Oracle support, but nothing 
official/finished yet apparently.

Personally, I recently checked out different ORMs for Python one 
afternoon. Only superficially, but here's my biased uninformed opinion.

- SqlObject (1) has an active community, and its use in Subway and
TurboGears will create even more momentum for it. By looking at its code
(for hacking in Oracle support, which I managed to do for a one-table
test case), I found it to have *a lot* features, including caching and
others. I don't particularly like that, I'd prefer a thin-to-medium
layer myself.

- There was something to Modeling (2) I didn't like. It's just a gut 
feeling that it tries to do too much for my taste.

- PyDO2 did work with Oracle out of the box, the SQLite and PostgreSQL 
adapters looked reasonable too from a quick code inspection. It does 
seem to do one thing and do it right, which is a philosophy I like in 
libraries and wrappers. If I'm to use a ORM for a future project, I'd 
first go with PyDO2.

HTH,

-- Gehard

(1) http://sqlobject.org/
(2) http://modeling.sourceforge.net/
(3) http://skunkweb.sourceforge.net/PyDO2/manual.html

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


Re: overiding assignment in module

2005-10-25 Thread Fredrik Lundh
Viktor Marohnic wrote:

> I would to do something like this.
>
> container = []
>
> p1 = point()
> l1 = line()
>
> and i would like to override = method of the module so that its puts
> all objects into container.
> how i can do something like that.

you cannot, at least not as you've described the problem.  assignment is not
an operator in Python; it's a statement that modifies the current namespace.

things you can do include

- use an explicit target object

x.p1 = point()
x.l1 = line()

- execute the script in a controlled fashion, and inspect the resulting 
namespace:

myscript = """
p1 = point()
l1 = line()
"""

# create a new namespace, and add "built-in" functions to it
namespace = {}
namespace["point"] = point
namespace["line"] = line

# execute the script in this namespace
exec myscript in namespace

for key, item in namespace.iteritems():
...

 



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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Steven D'Aprano
On Tue, 25 Oct 2005 03:55:17 -0700, Joerg Schuster wrote:

> No limitation at all would be best. If a limitation is necessary, then
> the more capturing groups, the better. At the time being, I would be
> really happy about having the possibility to use 1 capturing
> groups.

Do you really think that the regular expression needed to do that would be
maintainable?

I'm also curious, what sort of usage case would need ten thousand
capturing groups? I'd love to see the performance, especially if all ten
thousand of them do backtracking.

-- 
Steven.

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Joerg Schuster
> The joys of open source. Just remember you have now
> made your program
> non-portable. Hope this isn't an issue.

Of course portability is an issue -- on the long run. But on the short
run I am really glad to be able to do a 1 second demo run on my
notebook instead of a 20 seconds demo run. And I am especially glad to
get this 1 second demo by doing a 30-minute hack. (Hopefully ...)

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread David Schwartz

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

> Shouldn't it be my right as a seller, to decide that I want to sell an
> operating system 'that nobody wants' _as well as_ operating systems that
> 'everybody wants'?

Yes, it certainly is. However, it is also Microsoft's right as a seller 
to refuse discounts to those who also sell competing products. You may not 
particularly what operating systems your customers use, but Microsoft does.

> So it *hurts* me if I am not able to sell these. That
> it doesn't hurt me financially doesn't mean that it doesn't hurt me
> (e.g. my freedom, ideas of morality, whatever).

You may want to start a restaurant that sells both Big Macs and 
Whoppers. But I don't think you'll get either McDonald's or Burger King to 
let you. Perhaps this hurts your freedom, your ideas of morality, or 
whatever, but the reality is that these companys don't want you selling both 
their products and competing products.

It is McDonald's position that a Big Mac is superior to a Whopper and 
there is no reason to pick a Whopper over a Big Mac. To them, a store that 
sells both makes no sense.

Microsoft's corporate view at the time was that an x86 desktop without 
Windows was a brick. And if you want to sell bricks, they don't want their 
customers dealing with you.

When you sell a product, you also mention that product in your 
advertising. When you sell competing products, you take some customers who 
want the product you advertised. That is why a lot of products are only sold 
through exclusive dealerships.

Microsoft, like any other company, has the right to set the conditions 
under which its product is sold. Prohibiting the distrubution of competing 
products is not really all that unusal, and the agreement Microsoft actually 
insisted on was much less restrictive than that.

Is it fair to Microsoft if the big "Windows" sign on your store and in 
your advertising brings in customers looking for Windows and you then sell 
them OS2?

DS


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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Iain King

Fredrik Lundh wrote:
> Joerg Schuster wrote:
>
> > I just want to use more than 100 capturing groups.
>
> define "more" (101, 200, 1000, 10, ... ?)
>
> 

The Zero-One-Infinity Rule:

http://www.catb.org/~esr/jargon/html/Z/Zero-One-Infinity-Rule.html

Iain

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


Re: overiding assignment in module

2005-10-25 Thread Steven D'Aprano
On Tue, 25 Oct 2005 04:56:02 -0700, Viktor Marohnic wrote:

> Hello.
> I would to do something like this.
> 
> container = []
> 
> p1 = point()
> l1 = line()

Choosing names that look like numbers is terrible practice. Don't use l,
l1, O, ll, and so forth, unless you are trying to deliberately make your
code hard to read, hard to understand, and easy to miss bugs.


> and i would like to override = method of the module so that its puts
> all objects into container.

What do you mean by put all objects into container?

Do you mean:

container = []
container = point()
container = line()

Or do you mean:

container = []
container.append(point())
container.append(line())

Or even:

container = []
container.insert(0, point())
container.insert(0, line())

Or possibly even:

container = []
container.extend(point())
container.extend(line())



> how i can do something like that.

Choose a different language.

There is no assignment method in Python.


-- 
Steven.

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


Re: Read/Write from/to a process

2005-10-25 Thread jas
So it seems there is no good way to handle "interactive" processes on
windows using python.  By interactive I mean processes/commands that
require user interaction, such as telnet or del (to delete a file or
directory sometimes you need to confirm with a yes or no), date, etc.

os.system gives the exact behavior, but you can't redirec the output.
pexpect isn't supported on windows.  Even with subprocess you can't
handle all/most cases..since you have to do things like look for he
prompt.

I modified the original suggestion so it would update the prompt, in
case the user did a "cd.." ..which works fine now.  However, if a user
tries to do, "del tmp123" ...windows prompts for a "are you sure you
want to delete... Y/N?" ...so the code hangs.

I can't believe no one else has done this yet..or if they have, it
hasn't been widely discussed.

Any other suggestions?

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


Re: Microsoft Hatred FAQ

2005-10-25 Thread Peter T. Breuer
In comp.os.linux.misc David Schwartz <[EMAIL PROTECTED]> wrote:
> "Peter T. Breuer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

>> 3) there are plenty of other OSs that are developed or could be
>> developed but which cannot get a foothold or even manage to be put on
>> the shelves because the majority product producer insists on charging
>> hardware manufacturers for every box produced, whether or not it carries
>> their o/s, and does other nasty things like sabotaging their own
>> products so they won't work with a clone o/s.

> How could he resell an OS that "could be developed"?

Is it relevant? Why? Can you sell a voip solution that could be
developed? Is that relevant? No. No. No. No.

> If nobody wants 
> these operating systems,

False premise, indeed, irrelevant premise, therefore rest of statememt
junked.  No dumb client cares what o/s they are running.  Do you care if
your mobile phone runs symbios of javalite?  That's simply not the point
- the point is that the makers of symbios don't charge your mobile phone
manufacturer for every phone sold, whether symbios is on there or
not. Doing so is "restraint of trade", because, uh, it restrains the
manufactrers of mobile phones from exercising their market choices.


> then it doesn't hurt him not to be able to sell 

Who cares? It's to the advantage of sellers to create a monopoly! It's
not in YOUR, the customer's, advantage to have one, which is why there
are laws against it!

Go away!

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


Security on XML-RPC

2005-10-25 Thread dcrespo
Hi all,

Anyone knows a simpler but stronger control access to XML-RPC functions
than the one I comment here?

My actual system works like this:

I have a TCP Server and an XML-RPC Server. Both of them verify if the
IP address is allowed.

The TCP Server works for validate and register an IP address if it
wasn't validated previously, while the XML-RPC Server works only if the
requester IP address was allowed through the mentioned TCP Server. This
means, anyone who wants to connect to the XML-RPC Server has to pass
the TCP Server.

How a client connects to the TCP Server and authenticate his IP?

Well, there is an interchange of encrypted data between the Client and
the TCP Server, where, in few words, the client sends a UserName and a
Password, all this through the send() function of the Socket
connection. If the TCP Server authenticate an IP address, then that
Client will be able to connect to the XML-RPC Server and use its
defined functions.

The problem I see here is that if I want someone to taking advantage of
my XML-RPC functions, I have to tell him all these. I would like to get
a strong but simpler way of doing all these.

Thank you for reading and thinking.

Daniel

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Jorge Godoy
"Joerg Schuster" <[EMAIL PROTECTED]> writes:

>> but what is the reason for so much capturing groups?  I
>> imagine that coding this and keeping code maintenable is a huge effort.
>
> User input is compiled to regular expressions. The user does not have
> to worry about those groups.

And what is the problem with something like getopt, optparse, etc.? 

And 10K groups on a single input line?  

-- 
Jorge Godoy  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


swig problem

2005-10-25 Thread klemens letulé
Aloa,

I'm new to python as to swig... so my question goes here. I am using swig to
call a c function which returns a char*.

I do this:

...
i = 1
while i <= 2:
result, chainName = cgiServer.rpcGetTempParameterAttribut  
   ("//firewall-input[" + str(i) + "]")
print chainName
i = i + 1
...

output is:
gprs-in
eth0-in  
~~~

and should be:
gprs-in
eth0

.i file:
...
%cstring_bounded_output(char *result, 1024);

int rpcGetTempParameterAttribut(char *xpathUri, char *result);
...

I tried some approaches to write typemaps but failed. Could someone point me
in the right direction, so that i get two different instances for the
variable in the loop. I am sure this simple problem occured earlier, but I
could't find it in the archives!

Thanks a lot and greets, Klemens


-- 


Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Read/Write from/to a process

2005-10-25 Thread Steve Holden
jas wrote:
> So it seems there is no good way to handle "interactive" processes on
> windows using python.  By interactive I mean processes/commands that
> require user interaction, such as telnet or del (to delete a file or
> directory sometimes you need to confirm with a yes or no), date, etc.
> 
> os.system gives the exact behavior, but you can't redirec the output.
> pexpect isn't supported on windows.  Even with subprocess you can't
> handle all/most cases..since you have to do things like look for he
> prompt.
> 
> I modified the original suggestion so it would update the prompt, in
> case the user did a "cd.." ..which works fine now.  However, if a user
> tries to do, "del tmp123" ...windows prompts for a "are you sure you
> want to delete... Y/N?" ...so the code hangs.
> 
> I can't believe no one else has done this yet..or if they have, it
> hasn't been widely discussed.
> 
> Any other suggestions?
> 
Look at how you might do it in other languages. Then you'll realise this 
isn't (just) a Python problem.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Missing modules '_ssl', 'ext.IsDOMString', 'ext.SplitQName'

2005-10-25 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
> unfortunately the result from py2exe won't run eventhough the original
> script runs without problems. The trouble is I'm at a loss as to where
> to start looking!

Is there no exception traceback printed?  Or some other error when you 
run the .exe?  It would be very unusual to receive no error message of 
any kind.  If you are getting a message, please post the entire 
traceback/message here, as we can only guess what's happening.

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


Re: PDO and database abstraction

2005-10-25 Thread Luiz Geron
Excuse me if I wasn't clear. I don't want to use ORMs, since I really
have to execute arbitrary sql queries, and then I can't use this object
mapping. I'm going to write my own wrapper like you did, it is not so
difficult to do.

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


Re: Tricky Areas in Python

2005-10-25 Thread bruno modulix
beza1e1 wrote:
> let me try.
> 
> 1) ''.join(lots_of_pieces)
> 
> 2) This doesn't even work, if something is removed, the list is too
> short. So:
> [x for x in somelist if not isbad(x)]
> well, list comprehension is Python 2.4 

2.2.x IIRC

> and 2.3 is the standard in many
> OSes, so it is possibly not the most portable solution

filter(isbad, somelist)

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


Re: PDO and database abstraction

2005-10-25 Thread Steve Holden
Gerhard Häring wrote:
> Luiz Geron wrote:
> 
>>Hi all,
>>I'm testing the PDO wrapper to database modules [1] and I'm wondering
>>how few things like this there are around. 
> 
> 
> Actually there are several Object-Relation Mappers (ORM) for Python, and 
> also a few other attempts to provide a more convenient layer on top of 
> DB-API modules.
> 
> This wiki page has links: 
> http://wiki.python.org/moin/HigherLevelDatabaseProgramming
> 
> 
>>My problem, actually, is the paramstyle of modules.
> 
> 
> That problem exactly what these solutions try to solve, this and 
> multiple SQL dialects and handling types like date etc. for multiple 
> backends.
> 
> 
>>I want to use kinterbasdb in the same code I use
>>cx_oracle, for example, but paramstyle changes from one to other, than
>>I searched for things like this and found nothing really usefull. The
>>problem with PDO is that it was so dificult to find, since a few people
>>seems to use it,  and I haven't yet figured how to change the paramstyle
>>on it, so I want to ask: Do you use a thing like this that you would
>>recommend to me?
> 
> 
> I always wrote my own thin layer on top of DB-API modules and used it to 
> implement a *specific* database interface for my applications. This 
> would then have one or more database backends. Actually never more than 
> two so far.
> 
[ORM stuff ...]

Another way is to actually parameterise your queries for the paramstyle 
according to which packend module you are using. For example, in a 
current development I have queries that are generated like this:

 sql = ("SELECT %s FROM %s WHERE %s=%s" %
(",".join(f[1] for f in self.FIELDS),
  table, keyfield, db.pmark))

The "db" module imports one or other of a number of back-end modules, 
and sets "pmark" to the appropriate parameter marker ("%s" or "?" are 
the ones I have used: positionals would be a little trickier, now I 
think of it).

Of course you still have to be careful of SQL syntax variations and 
other backend differences (the usual one being "find the primary key 
value of the last-inserted row on this connection/cursor").

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Steven D'Aprano
On Tue, 25 Oct 2005 05:17:52 -0700, Iain King wrote:

> 
> Fredrik Lundh wrote:
>> Joerg Schuster wrote:
>>
>> > I just want to use more than 100 capturing groups.
>>
>> define "more" (101, 200, 1000, 10, ... ?)
>>
>> 
> 
> The Zero-One-Infinity Rule:
> 
> http://www.catb.org/~esr/jargon/html/Z/Zero-One-Infinity-Rule.html


Nice in principle, not always practical. Sometimes the choice is, "do you
want it today with arbitrary limits, or six months from now with bugs
but no limits?"

If assigning arbitrary limits prevents worse problems, well, then go for
the limit. For instance, anyone who has fought browser pops ups ("close
one window, and ten more open") may have wished that the browser
implemented an arbitrary limit of, say, ten pop ups. Or even zero :-)

Of course, having said that, in those cases, the limit isn't really
arbitrary. In cases of genuinely arbitrary limits, I agree they are
pointless and annoying (as opposed to having a point but still being
annoying).


-- 
Steven.

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


Re: Confused on Kid

2005-10-25 Thread Damjan
> I was
> investigating each subproject individually and could not, for the life
> of me figure out how Kid worked.  I understand that it takes a
> well-formed XML document and transforms it, but I could not figure out
> where it transforms it, or how to transform a document.  They have
> plenty of template examples, but I'm left say, "What do I do with this?"
> I know I can't just pop in it a browser because it has no sort of style
> sheet or anything so it would just render as an XML document.  What do
> you do after you have a kid template?

KID is a pythonic template system. The KID templates are well-formed XML
files but the generated document can be HTML or even plain text (this
should be supported in some of the latest versions).

The KID templates have some simple control structures like 'if' and 'for'
which are modeled to be similar to python. The way it works is you feed the
template some data and it generates HTML documents. The document can have a
reference to a CSS file just like any other HTML page.

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


Re: overiding assignment in module

2005-10-25 Thread Viktor Marohnic
Ok thanks a lot. I think i got the point.
I also thought that it could be possible to do something like this
globals().__setitem__ = custom_setter
but __setitem__ is readonly

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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Joerg Schuster
You did not quite understand me. I will give you some details:

My program is a compiler for a certain type of linguistic grammars.
I.e. the user gives *grammar files* to my program. When the grammar
files have been compiled, they can be applied to strings (of a certain
language, e.g. English).

In the grammar files, the user does not have to deal with "capturing
groups". He even does not have to deal with regular expressions. He
just writes a grammar of a certain type. My program then compiles the
grammar into a cascade of transducers. Each of the transducers is
internally represented as a pair (REGEX, ACTION), where REGEX is a
Python regular expression and ACTION a Python function. I.e.: The
meaning of the grammar is: For each line of the input string: if REGEX
matches the line, then apply ACTION to it.

On various levels, the user may produce *disjunctions*. At the time
being, these disjunctions are internally represented by something like:

if regex1: action1()
elif regex2: action2()
elif ...
eliif regexn: actionn()

It would be nicer (and faster) to have just one regex and run that
action A such that the *capturing group* with name A ("?P...")
matched.

Now, I could of course internally create my very own transducers. But
the re module is a module that generates fsa and fsa do part of the
work that a transducer does. So why reinvent the wheel? 


Jörg

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


Re: need some advice on x y plot

2005-10-25 Thread nephish
well, for what i tried, ticstrings just contained a list of times
formatted like
[10-21 09:15, 10-21 09:44, 10-21 09:59, and so on.]
i did write mine a little different than the example that Grant gave me
because its a little
different application of time.

i think i am having trouble knowing exactly what the set xtics line is
looking for.
thanks

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


Re: Read/Write from/to a process

2005-10-25 Thread jas
Steve Holden wrote:
> Look at how you might do it in other languages. Then you'll realise this
> isn't (just) a Python problem.

Yea your right.  However, for example, in Java, one can use the Process
class, and then read from the stream until its the end (i.e. -1 is
returned).  However, with Python when reading from
subprocess.Popen.stdout ...I don't know when to stop (except for
looking for a ">" or something).  Is there a standard, like read until
"-1" or something?

As I mentioned, os.system("cmd") gives me exactly the
output/interactivity I need...but I can't redirect the output.

Thanks.

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


Re: cell and row

2005-10-25 Thread Jan Niestadt
Doh, the first example should of cours be:

  b = []
  for x in a:
  if len(x) > 4:
  b.append(x)

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


Re: Tricky Areas in Python

2005-10-25 Thread Gerhard Häring
bruno modulix wrote:
> beza1e1 wrote:
>>well, list comprehension is Python 2.4 
> 
> 2.2.x IIRC

List comprehensions were introduced in Python 2.0, according to the 
"What's new in ..." document at 
http://www.amk.ca/python/2.0/index.html#SECTION00060

-- Gerhard

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


Re: PDO and database abstraction

2005-10-25 Thread Luiz Geron
This is one example where I need to use such abstraction:
I have a dictionary with the fields and values to be inserted into the
database, with a code like this:

dic = {'field1' : 1, 'field2' : 2} #this dict comes from a Cherrypy
request
cur.execute('update table set field_one = :value1, field2 = :value2' ,
dic)

and I want to use it even with kinterbasdb, wich does not support named
paramstyle. The problem with your use of % is that the db module does
not automatically put '' in varchar fields, and so on. This is what PDO
does, or say that does. I think that I should make a wrapper that
simply swap :var to ? when the db paramstyle is qmark, and so on. Is
this correct?

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


Your message to Veritas-bu awaits moderator approval

2005-10-25 Thread veritas-bu-admin
Your mail to 'Veritas-bu' with the subject

MAIL SYSTEM ERROR - RETURNED MAIL

Is being held until the list moderator can review it for approval.

The reason it is being held:

Post by non-member to a members-only list

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Would there be support for a more general cmp/__cmp__

2005-10-25 Thread Christopher Subich
Antoon Pardon wrote:
> It *is* a definition of an ordering.
> 
> For something to be an ordering it has to be anti symmetric and transitive.
> 
> The subset relationships on sets conform to these conditions so it is a 
> (partial)
> ordering. Check your mathematic books, Why you would think this is abuse is 
> beyond me

Which is exactly why a < b on sets returns True xor False, but cmp(a,b) 
throws an exception.

a  b is a local comparison, asking only for the relationship 
between two elements.  In some bases, like the complex numbers, some 
comparisons are ill-defined.; in others, like sets, they're well-defined 
  but don't give a total ordering.

cmp(a,b) asks for their relative rankings in some total ordering.  For a 
space that does not have a total ordering, cmp(a,b) is meaningless at 
best and dangerous at worst.  It /should/ throw an exception when the 
results of cmp aren't well-defined, consistent, antisymmetric, and 
transitive.
-- 
http://mail.python.org/mailman/listinfo/python-list


pyxpcom and firefox

2005-10-25 Thread Philippe C. Martin
Hi,

I write this post here because I do not manage to get in touch with mozilla
dev people:
***
[EVAL-IN]   irc.mozilla.org
[ERROR] ReferenceError: irc is not defined
***

I have two questions:
1) has anyone compiled/installed pyxpcom with firefox 1.5xx ?
2) is there a plan to make it a .xpi (the pyxpcom xpi for mozilla does not
install into firefox).

Regards,

Philippe



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


Re: more than 100 capturing groups in a regex

2005-10-25 Thread Iain King

Steven D'Aprano wrote:
> On Tue, 25 Oct 2005 05:17:52 -0700, Iain King wrote:
>
> >
> > Fredrik Lundh wrote:
> >> Joerg Schuster wrote:
> >>
> >> > I just want to use more than 100 capturing groups.
> >>
> >> define "more" (101, 200, 1000, 10, ... ?)
> >>
> >> 
> >
> > The Zero-One-Infinity Rule:
> >
> > http://www.catb.org/~esr/jargon/html/Z/Zero-One-Infinity-Rule.html
>
>
> Nice in principle, not always practical. Sometimes the choice is, "do you
> want it today with arbitrary limits, or six months from now with bugs
> but no limits?"
>
> If assigning arbitrary limits prevents worse problems, well, then go for
> the limit. For instance, anyone who has fought browser pops ups ("close
> one window, and ten more open") may have wished that the browser
> implemented an arbitrary limit of, say, ten pop ups. Or even zero :-)
>

Well, exactly.  Why limit to ten?  The user is either going to want to
see pop-ups, or not.  So either limit to 0, or to infinity (and indeed,
this is what most browsers do).
Note the jargon entry defines infinity in this case to me the largest
possible amount given whatever ram/disk space/processing power you have
available.

Also: These arbitrary limits tend to stem from languages which
predominantly use fixed size arrays - DIM in basic, or malloc in C.
The native python component is the list, which doesn't have a max size,
so these problems should be encountered less in python code; by it's
nature, python steers you away from this mistake.

Iain

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


security

2005-10-25 Thread Mattia Adami
Hi to all.
I'm intristing in write a plugin for browsers that can execute python
code.
I know the main problem is security. Many thread were opened about this
in the ng.
I would know if fork python rewriting some library could avoid
problems. I.e. one problem is the possibility to access files. If I
rewrite the open() function so that raises exception if the program try
to access a file out of a defined directory.
I'm sure not a security expert, so please be patient if my question is
stupid.
Thanks to all.

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


  1   2   3   >