Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread tfgordon

Consider Clojure:  http://clojure.org/

You might want to watch one of these videos for an overview:

http://clojure.blip.tv/

There is also evidence that Clojure is currently the most popular
Lisp, more "popular" than Scheme or Common Lisp, whatever that means:

http://www.google.com/trends?q=common+lisp,+scheme+language,+clojure

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Mark Lawrence

On 12/06/2010 03:34, Steven D'Aprano wrote:

On Sat, 12 Jun 2010 14:13:44 +1200, Gregory Ewing wrote:


Steven D'Aprano wrote:

This
reminds me of time-travellers suffering from "time lag" in the
wonderful novel "To Say Nothing Of The Dog" by Connie Willis.


One of the many excellent reasons why Guido keeps tight control over the
keys to his time machine. Time-lagged joyriding teenagers careening
around the space-time continuum can be quite a hazard.


Imagine the havoc if RantingRick accidentally goes back in time and
deactivates the Timbot.



Not a chance, if Dr Who can take on baddies like the daleks, yetis and 
cybermen Ranting Rick would be a piece of cake. :)  My 13 year old will 
be glued to BBC1 tonight at 18:45 BST to see his hero (Dr Who that is) 
in action.


Down with baddies.

Mark Lawrence.

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


Re: lambda question

2010-06-11 Thread Ian Kelly
On Fri, Jun 11, 2010 at 9:31 PM, Vincent Davis  wrote:
> Starting with an example.
> In [23]: x = [1,2,3,4,4,4,5,5,3,2,2,]
> In [24]: y = set(x)
> In [25]: y
> Out[25]: set([1, 2, 3, 4, 5])
> In [26]: y2 = len(set(x))
> In [27]: y2
> Out[27]: 5
>
> How would I do the above "y2 = len(set(x))" but have len(set()) in a
> dictionary. I know how to do ..
> In [30]: d = dict(s=set)
> In [32]: d['s'](x)
> Out[32]: set([1, 2, 3, 4, 5])
>
> but not sure how to add the len() and thought maybe the answer in a
> lambda function.
> I know I could def a function but would prefer to keep it all on one line.

>>> d = dict(s=lambda x: len(set(x)))
>>> d['s'](x)
5

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread Stephen Hansen
On 6/11/10 7:11 PM, Gregory Ewing wrote:
> Stephen Hansen wrote:
> 
>> There's very little you can do with pywin32 that you can't do with
>> ctypes.
> 
> Except, apparently, use it from another module in the stdlib. :-(
> 

Yeah. I get the policy in general, a proliferation of ctypes stuff could
be very bad -- but if code is very careful with type-checking and stuff,
it should be possible to get an exception, I'd hope.

Otherwise it makes certain windows-workarounds very problematic. You
basically /have/ to write a C extension :|

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



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


lambda question

2010-06-11 Thread Vincent Davis
Starting with an example.
In [23]: x = [1,2,3,4,4,4,5,5,3,2,2,]
In [24]: y = set(x)
In [25]: y
Out[25]: set([1, 2, 3, 4, 5])
In [26]: y2 = len(set(x))
In [27]: y2
Out[27]: 5

How would I do the above "y2 = len(set(x))" but have len(set()) in a
dictionary. I know how to do ..
In [30]: d = dict(s=set)
In [32]: d['s'](x)
Out[32]: set([1, 2, 3, 4, 5])

but not sure how to add the len() and thought maybe the answer in a
lambda function.
I know I could def a function but would prefer to keep it all on one line.

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Steven D'Aprano
On Sat, 12 Jun 2010 14:13:44 +1200, Gregory Ewing wrote:

> Steven D'Aprano wrote:
>> This
>> reminds me of time-travellers suffering from "time lag" in the
>> wonderful novel "To Say Nothing Of The Dog" by Connie Willis.
> 
> One of the many excellent reasons why Guido keeps tight control over the
> keys to his time machine. Time-lagged joyriding teenagers careening
> around the space-time continuum can be quite a hazard.

Imagine the havoc if RantingRick accidentally goes back in time and 
deactivates the Timbot.

-- 
Steven

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Gregory Ewing

Steven D'Aprano wrote:
This 
reminds me of time-travellers suffering from "time lag" in the wonderful 
novel "To Say Nothing Of The Dog" by Connie Willis.


One of the many excellent reasons why Guido keeps tight
control over the keys to his time machine. Time-lagged
joyriding teenagers careening around the space-time
continuum can be quite a hazard.

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Gregory Ewing

Stephen Hansen wrote:


There's very little you can do with pywin32 that you can't do with
ctypes.


Except, apparently, use it from another module in the stdlib. :-(

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


Re: KinterBasDB - how to change the mode: embedded/server

2010-06-11 Thread DarkBlue
On Jun 11, 5:07 pm, durumdara  wrote:
> Hi!
>
> I want to use KinterBasDB in mixed mode: sometimes embedded, sometimes
> real local/remote server.
> How can I set up the connection to KinterBasDB can determine, what
> mode I want to use?
>
> Thanks for your help:
>    dd

you could use 2 connection strings and make the selection yourself as
needed.



e.g.

def kbconnector(connectionmode):

 if connectionmode=='use_embedded':
 myonnectionstring=.

 elif connectionmode=='use_real':
 myconnectionstring=kinterbasdb.connect

 return myconnectionstring


#connect to the embedded server
somemode='use_embedded'
myconnector=kbconnector(somemode)
mycursor=myconnector.cursor()


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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Mark Roseman
> So let me hear of ANY improvements and/or suggestions for Tkinter/IDLE
> docs, code, or whatever.

Why don't you modify the IDLE code to use the newer ttk widget set, 
rather than what its using now?  You'd be surprised at how much 
difference you'll see.
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter Toplevel sizing issue (using a grid)

2010-06-11 Thread random joe
Hello all,

Hi this i my first post here. I would like to create a tkinter
toplevel window with a custom resize action based on a grid. From the
Tk docs it say you can do this but for the life of me i cannot figure
out how? In my app i wish for the main window to only resize in 20
pixel "jumps" (if you will). I have tried using the toplevel.grid()
and setgrid option and no luck!

## here is the tk doc page about setGrid
http://www.tcl.tk/man/tcl/TkLib/SetGrid.htm

## here is the Tkinter method from wm class
def wm_grid(self,
 baseWidth=None, baseHeight=None,
 widthInc=None, heightInc=None):
"""Instruct the window manager that this widget shall only be
resized on grid boundaries. WIDTHINC and HEIGHTINC are the
width and
height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are
the
number of grid units requested in Tk_GeometryRequest."""
return self._getints(self.tk.call(
'wm', 'grid', self._w,
baseWidth, baseHeight, widthInc, heightInc))
grid = wm_grid


## Here is my code.

from Tkinter import *

class TopWin(Tk):
def __init__(self):
Tk.__init__(self)#, setgrid=1)
#self.maxsize(width=50, height=50)
#self.minsize(width=1, height=1)
self.grid(10, 10, 20, 20)

topwin = TopWin()
topwin.mainloop()


Please help. I am going nuts trying to make this work for three hours
already :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread geremy condra
On Fri, Jun 11, 2010 at 4:19 PM, rantingrick  wrote:
> On Jun 11, 4:08 pm, Stephen Hansen  wrote:
>> On 6/11/10 1:20 PM, rantingrick wrote:
>>
>> > Run the warning. Then and *only* then can we move forward with facts.
>>
>> http://google.com/codesearch?q=%22from+Tkinter+import%22http://google.com/codesearch?q=%22import+Tkinter%22
>>
>> Compared to:
>>
>> http://google.com/codesearch?q=%22from+wx+import%22http://google.com/codesearch?q=%22import+wx%22
>>
>> and
>>
>> http://google.com/codesearch?q=%22from+PyQT4+import%22http://google.com/codesearch?q=%22import+PyQT4%22
>>
>> -1; This most trivial and unreliable of metrics is, despite its limited
>> effectiveness, enough alone to show that there is sufficient usage of
>> Tkinter to argue against removal without a compelling replacement being
>> available and a migration path available for those who used Tkinter
>> before to make use of this replacement.
>>
>> There is neither a compelling replacement ready yet (though PyGUI may
>> become one, sure) nor any migration path available ('just download
>> tkinter from pypi' is not sufficient)
>
>
> Fair enough! Although whether or not we want to remove Tkinter i think
> it would be a good idea to get some feedback. But alas i am tired of
> fighting with you guys about it.
>
> So, since we are *keeping* Tkinter i want some suggestions for
> improvement. And don't go telling me that nothing needs fixing,
> because i have documented time and again the problems in Tkinter and
> IDLE. I have already made patches/fixes for some of them but somehow i
> fear the *in crowd* will never accept my changes just from pure spite.

This is the important part of life where you find out you aren't everybody
else's boss.

> So let me hear of ANY improvements and/or suggestions for Tkinter/IDLE
> docs, code, or whatever.

If you don't know of anything wrong with it, why raise this huge stink?
If you do, why are you asking us? Just go fix it.

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread rantingrick
On Jun 11, 4:08 pm, Stephen Hansen  wrote:
> On 6/11/10 1:20 PM, rantingrick wrote:
>
> > Run the warning. Then and *only* then can we move forward with facts.
>
> http://google.com/codesearch?q=%22from+Tkinter+import%22http://google.com/codesearch?q=%22import+Tkinter%22
>
> Compared to:
>
> http://google.com/codesearch?q=%22from+wx+import%22http://google.com/codesearch?q=%22import+wx%22
>
> and
>
> http://google.com/codesearch?q=%22from+PyQT4+import%22http://google.com/codesearch?q=%22import+PyQT4%22
>
> -1; This most trivial and unreliable of metrics is, despite its limited
> effectiveness, enough alone to show that there is sufficient usage of
> Tkinter to argue against removal without a compelling replacement being
> available and a migration path available for those who used Tkinter
> before to make use of this replacement.
>
> There is neither a compelling replacement ready yet (though PyGUI may
> become one, sure) nor any migration path available ('just download
> tkinter from pypi' is not sufficient)


Fair enough! Although whether or not we want to remove Tkinter i think
it would be a good idea to get some feedback. But alas i am tired of
fighting with you guys about it.

So, since we are *keeping* Tkinter i want some suggestions for
improvement. And don't go telling me that nothing needs fixing,
because i have documented time and again the problems in Tkinter and
IDLE. I have already made patches/fixes for some of them but somehow i
fear the *in crowd* will never accept my changes just from pure spite.

So let me hear of ANY improvements and/or suggestions for Tkinter/IDLE
docs, code, or whatever.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good solutions for passing around large numbers of arguments in a layered architecture?

2010-06-11 Thread Stephen Hansen
On 6/11/10 10:00 AM, Nathan Rice wrote:
> I've tried using args/kwargs, however I found it difficult to avoid
> having arguments in my signature re-ordered, and it is also a source
> of bugs.
> 
> Has anyone come up with a good solution for dealing with arguments in
> situations like this where you'd like to encapsulate lower level stuff
> for neophyte users but make it easily available to advanced users?

I'd just use a dictionary, with some namespacey sort of names for the
arguments. Sort of like how layered WSGI apps have their 'environ' object.

Its like, environ["beaker.session.blah"] = "fubar". Though that's
something of a mix of configuration and state.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Elena
On 11 Giu, 20:03, Chris Hulan  wrote:
> Haven't used it but Racket (http://racket-lang.org/) looks to be a new
> and improved Scheme

I have checked it out and I don't recommend it to others.

Racket is not Scheme anymore (it can't use SLIB, which relies on
common Scheme facilities). Racket is a language and an environment on
their own. For instance: debugging facilities are hidden into its IDE,
therefore you'll have to leave your debugging environment of choice.
Yes, you can run a REpL outside of its IDE, but you can't do much more
than that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread Stephen Hansen
On 6/11/10 1:20 PM, rantingrick wrote:
> Run the warning. Then and *only* then can we move forward with facts.

http://google.com/codesearch?q=%22from+Tkinter+import%22
http://google.com/codesearch?q=%22import+Tkinter%22

Compared to:

http://google.com/codesearch?q=%22from+wx+import%22
http://google.com/codesearch?q=%22import+wx%22

and

http://google.com/codesearch?q=%22from+PyQT4+import%22
http://google.com/codesearch?q=%22import+PyQT4%22


-1; This most trivial and unreliable of metrics is, despite its limited
effectiveness, enough alone to show that there is sufficient usage of
Tkinter to argue against removal without a compelling replacement being
available and a migration path available for those who used Tkinter
before to make use of this replacement.

There is neither a compelling replacement ready yet (though PyGUI may
become one, sure) nor any migration path available ('just download
tkinter from pypi' is not sufficient)

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: Deformed Form

2010-06-11 Thread Stephen Hansen
On 6/11/10 1:09 PM, Dave Angel wrote:
> Your question would have been much easier to understand if you had
> referred to "form field" rather than variable, since I assumed you
> really meant Python variable.  Also, this script is a CGI script,
> written in Python.  But the other files that you import are python
> modules, not scripts.

Yeah, those exact terminology issues tripped me up very hard in
understanding what was going on.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: GUIs - A Modest Proposal

2010-06-11 Thread geremy condra
On Fri, Jun 11, 2010 at 1:20 PM, rantingrick  wrote:
> On Jun 11, 12:44 pm, Mark Lawrence  wrote:
>
>> 
>> To quote R. David Murray on the Python bug tracker earlier today.
>>
>> "Everyone who uses IDLE uses TKInter
>
> Thats a grossly general statement although it *is* a fact. Heres
> Another:  "Everyone who uses Tkinter uses Python"... and the point
> is
>
>> and a lot of people use IDLE."
>
> "A lot"? How many is "a lot" David. If you're going to present the
> group with such general ways of measuring value then at least give us
> a mapping so we can translate it into something tangible. Can you
> express "a lot" in the form of an integer? And where is the proof that
> supports this value "A Lot".
>
> Hmm, I know *I* use IDLE so thats *one* person. However blabbing hear-
> say like some old lady at a hair salon is a non starter because it has
> no fact-based-foundation in reality, and so renders the argument
> completely inadmissible and quite frankly makes you look incompetent.
> Sadly however (in this group it seems) hearsay and hyperbole run a-
> muck on a daily basis.
>
> Release the ModuleRemovalWarning and you WILL then get back reliable
> information as to who *IS* and *IS NOT* wishing Tkinter to stay. But
> you won't do this because your afraid of being proven wrong. I would
> happily love to be proven wrong, WITH FACTS AND NOT HEARSAY THAT IS!.
> If the numbers are for keeping Tkinter then I will jump full-force
> into Tkinter/IDLE development. I already have many patches and
> improvements for both Tkinter and IDLE working nicely on my machine.
>
> Run the warning. Then and *only* then can we move forward with facts.
> Or you could just keep living in your self-aggrandizing fantasy world
> of "I'm always right and everyone else is the moron".

I'm currently doing an analysis of pypi data to see what modules are being
used and how much. If you're so interested in knowing how widely used
tkinter is, please contact me- we could certainly use some additional
processor time.

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Emile van Sebille

On 6/11/2010 1:20 PM rantingrick said...

On Jun 11, 12:44 pm, Mark Lawrence  wrote:



and a lot of people use IDLE."


"A lot"? How many is "a lot"


4050 (1)

Emile  :)

---

(1) Results 1 - 10 of about 4,050 for python "in idle".

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread rantingrick
On Jun 11, 12:44 pm, Mark Lawrence  wrote:

> 
> To quote R. David Murray on the Python bug tracker earlier today.
>
> "Everyone who uses IDLE uses TKInter

Thats a grossly general statement although it *is* a fact. Heres
Another:  "Everyone who uses Tkinter uses Python"... and the point
is

> and a lot of people use IDLE."

"A lot"? How many is "a lot" David. If you're going to present the
group with such general ways of measuring value then at least give us
a mapping so we can translate it into something tangible. Can you
express "a lot" in the form of an integer? And where is the proof that
supports this value "A Lot".

Hmm, I know *I* use IDLE so thats *one* person. However blabbing hear-
say like some old lady at a hair salon is a non starter because it has
no fact-based-foundation in reality, and so renders the argument
completely inadmissible and quite frankly makes you look incompetent.
Sadly however (in this group it seems) hearsay and hyperbole run a-
muck on a daily basis.

Release the ModuleRemovalWarning and you WILL then get back reliable
information as to who *IS* and *IS NOT* wishing Tkinter to stay. But
you won't do this because your afraid of being proven wrong. I would
happily love to be proven wrong, WITH FACTS AND NOT HEARSAY THAT IS!.
If the numbers are for keeping Tkinter then I will jump full-force
into Tkinter/IDLE development. I already have many patches and
improvements for both Tkinter and IDLE working nicely on my machine.

Run the warning. Then and *only* then can we move forward with facts.
Or you could just keep living in your self-aggrandizing fantasy world
of "I'm always right and everyone else is the moron".


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


Re: function that counts...

2010-06-11 Thread Bryan
Lie Ryan wrote:
> In my original post in comp.programming, I
> used this definition of factorial:
>
> def fact(n):
>     """ factorial function (i.e. n! = n * (n-1) * ... * 2 * 1) """
>     p = 1
>     for i in range(1,n+1):
>         p *= i
>     return p

Ah, much better, but partition10(M, i) gets the wrong answer when i is
1 or 2. I think you don't want to let M go negative. With that tweak,
it seems to work in general, and fact() never gets called with a
negative number.

What I really like about your partition10() is that it's adaptable to
efficiently handle bases much larger than 10. Richard Thomas's
algorithm is poly-time and efficient as long as the base is small.

I'll take the liberty of tweaking your code to handle the 1 or 2 digit
case, and write the more general form. I'll also memoize fact(), and
add prttn() and a test.

--
--Bryan


_ft = [1]
def fact(n):
assert n >= 0 and n % 1 == 0
if len(_ft) <= n:
for i in range(len(_ft), n + 1):
_ft.append(i * _ft[-1])
return _ft[n]

def C(n, r):
""" regular Combination (nCr) """
return fact(n) // (fact(n - r) * fact(r))

def D(M, N):
""" Distribution aka Partitioning """
assert M >= 0 and N > 0
return C(M + N - 1, M)

def partition(nballs, nbins, binmax):
"""Count ways to put identical balls into distinct bounded bins.
"""
if nbins == 0:
return int(nballs == 0)
s = 0
sign = 1
for j in range(1 + min(nbins, nballs // binmax)):
s += sign * D(nballs, nbins) * C(nbins, j)

# flip the sign for inclusion-exclusion
sign *= -1
nballs -= binmax
return s

def prttn(m, n):
assert m >= 0 and n > 0
count = 0
dls = [int(c) for c in reversed(str(n))]
while dls:
msd = dls.pop()
count += sum(partition(m - d, len(dls), 10) for
d in range(min(msd, m + 1)))
m -= msd
return count


def test():
upto = 123456
counts = [0] * (len(str(upto)) * 9)
for n in range(upto):
digits = [int(c) for c in str(n)]
counts[sum(digits)] += 1
for m in range(9 * len(digits) + 2):
count = prttn(m, n + 1)
assert count == counts[m]
if count == 0:
break
assert count == 0
if n % 1000 == 0:
print('Tested to:', n)

test()




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


Re: Deformed Form

2010-06-11 Thread Dave Angel

Victor Subervi wrote:

Ok. Starting over. Here is the script that "generates" the variable
"new_passengers_curr_customers":

  



Now, here's the form that *should* be able to access that variable:

!/usr/bin/python

import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())
import MySQLdb
from login import login
import fpformat
from New_Passengers_Curr_Customers import New_Passengers_Curr_Customers
from New_Passengers_Addl_Customers import New_Passengers_Addl_Customers
from New_Passenger import New_Passenger

form = cgi.FieldStorage()


I have to guess here, since I have very limited CGI experience, and the 
FieldStorage() function/class isn't listed in my 2.6 docs.


But my guess is that you only get to parse the cgi stuff once.  So when 
you import another module that calls that same function, it clears it 
out so it's no longer accessible to you here.  Think of a file open.  
Once read, the file-ptr is at the end, and further reads won't see anything.


If I'm right, then you'd need something like "rewind".  Or if you just 
want this script to access the data, then move that line before the 
three imports.


Your question would have been much easier to understand if you had 
referred to "form field" rather than variable, since I assumed you 
really meant Python variable.  Also, this script is a CGI script, 
written in Python.  But the other files that you import are python 
modules, not scripts.


I'd also suggest you not use the same name for the module that you use 
for the function in that module.  That's the cause of another confusion 
I had with your message.


But back to your problem.

I'd suggest you do all your form interaction from a single script, and 
pass any needed data explicitly to functions in the other modules, 
rather than having them try to look it up themselves.


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


Re: Deformed Form

2010-06-11 Thread MRAB

Victor Subervi wrote:
Ok. Starting over. Here is the script that "generates" the variable 
"new_passengers_curr_customers":



[snip]

Now, here's the form that *should* be able to access that variable:

!/usr/bin/python

import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())
import MySQLdb
from login import login
import fpformat
from New_Passengers_Curr_Customers import New_Passengers_Curr_Customers


This imports from module New_Passengers_Curr_Customers, which calls:

cgi.FieldStorage()


from New_Passengers_Addl_Customers import New_Passengers_Addl_Customers
from New_Passenger import New_Passenger

form = cgi.FieldStorage()


[snip]

Another call to:

cgi.FieldStorage()



*** NOTE THIS: 
  new_passengers_curr_customers = 
New_Passengers_Curr_Customers(customers, flights)

*** THAT LINE 

  if new_passengers_curr_customers > 0:
print ""
  print '\n'
  cursor.close()

create_edit_passengers3()


See that line that I marked right at the end? So here's that script:

#!/usr/bin/python


[snip]


import cgitb; cgitb.enable()
import cgi

form = cgi.FieldStorage()

def New_Passengers_Curr_Customers(customers, flights):

*** RIGHT HERE. SEE THIS LINE? WHY DOES IT WORK HERE AND NOT IN THE 2ND 
SCRIPT IN THIS HERE EMAIL WHERE IT SHOULD WORK???***
  new_passengers_curr_customers = 
int(form.getfirst('new_passengers_curr_customers', 0))

*** THAT LINE ABOVE. RIGHT ABOVE HERE. OK?? ***


[snip]


Ok. So I think that was clear now.
TIA,
beno


The documentation for cgi.FieldStorage() says:

""To get at submitted form data, it’s best to use the FieldStorage 
class. The other classes defined in this module are provided mostly for 
backward compatibility. Instantiate it exactly once, without arguments. 
This reads the form contents from standard input or the environment 
(depending on the value of various environment variables set according 
to the CGI standard). Since it may consume standard input, it should be 
instantiated only once.""


It might be that the first call to cgi.FieldStorage() is consuming the
data, so the second call sees no data.

You could ensure that there are only 2 types of source file:

1. Script: called by CGI (not sure about the terminology here). It
fetches the values from the form using:

form = cgi.FieldStorage()

2. Module: imported to provide supporting functions. It never calls
cgi.FieldStorage(). If an imported function needs the form then it's
passed in explicitly.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Deformed Form

2010-06-11 Thread Stephen Hansen
... This is the first time you've actually clearly expressed what you're
doing.

On 6/11/10 12:11 PM, Victor Subervi wrote:

I dub thee Script1.py:
> *** RIGHT HERE! ***
> 
>   print " name='new_passengers_curr_customers' />"
>
> *** SEE IT? ***

Mmhmm.

I dub thee Script2.py:
> *** NOTE THIS: 
>   new_passengers_curr_customers = New_Passengers_Curr_Customers(customers,
> flights)
> *** THAT LINE 

Okay.

I dub thee Script3.py:
> import cgitb; cgitb.enable()
> import cgi
> 
> form = cgi.FieldStorage()
> 
> def New_Passengers_Curr_Customers(customers, flights):
> 
> *** RIGHT HERE. SEE THIS LINE? WHY DOES IT WORK HERE AND NOT IN THE 2ND
> SCRIPT IN THIS HERE EMAIL WHERE IT SHOULD WORK???***
>   new_passengers_curr_customers =
> int(form.getfirst('new_passengers_curr_customers', 0))
> *** THAT LINE ABOVE. RIGHT ABOVE HERE. OK?? ***

The only reason that moving the lines
  form = cgi.FieldStorage()
and
  blah = int(form.getfirst("blah", 0))

from Script3 to the exact place in Script2 (notwithstanding my not
wanting to type absurdly long variable names :P) wouldn't work, is if
you didn't move the lines correctly. Those will absolutely work just
fine in Script2.py. You had to have done it wrong. Maybe typo'd.

Show the traceback.

Hint: Never say it "doesn't work", or "I can't do this here", or "it
won't" or "it can't. Show the actual traceback and the actual (not
retyped) chunk of code.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


ANN: Komodo 6.0.0b1 -- adds Python 3 support

2010-06-11 Thread Trent Mick

Hello all,

We are pleased to tell you that Komodo IDE and Komodo Edit 6.0.0 Beta 1
were released today. If you're using 6.0.0 Alpha 2 then you can use
Komodo's auto-update mechanism.  Otherwise, you can get Beta 1 at:

  http://downloads.activestate.com/Komodo/releases/6.0.0b1/

For Pythonistas the most significant recent changes are the addition of 
Python 3 code intelligence support (i.e. autocomplete, calltips, Go To 
Definition, sections list, code browser)!


Komodo 5 (the current production version) already supported background 
syntax checking and debugging for Python 3. This beta release finally 
rounds out Komodo's language support for Python 3.



Test Framework Survey
=

We're running a survey on what Test Automation Frameworks people use 
(both in Python and not). We'd appreciate it if you would take the time 
to fill that out: only 4 questions. We'll post results from the survey 
on our blog (http://www.activestate.com/blog) next month. (We'll be 
giving away some t-shirts, too!)


  http://surveymonkey.com/s/june2010as

Thanks!


What else is in Komodo 6.0b1?
=


Other significant changes in Komodo 6.0.0b1 are:

 * New integrated toolbox
 * all your tools will now belong to one pane
 * faster loading and firing
 * tools are now standalone JSON files, that can be
   easily copied and exported
 * more features are planned
 * in the "renovations are underway in order to serve you
   better" department, tools in projects currently do not work.
   This should be fixed in the nightlies fairly soon.
   The toolbox main menu is also not operational.
 * UI improvements
 * goto-line is now an inline panel
 * child dialogs appear on same screen as Komodo window
 * better-looking icons
 * some menu rearrangements
 * Places File Manager
 * one-click access to all parent directories
 * it's now easier to move to recently visited directories
 * publishing (IDE only)
 * now works over slower connections
 * show diffs between local and remote files
 * numerous UI improvements
 * Rx toolkit (IDE only)
 * now supports JavaScript

For a more detailed overview, check out the Komodo 6 descriptive
features page:

 http://community.activestate.com/komodo-60-features

As well as new features, Komodo 6 comes with a whole lot of enhancements
and bug fixes. See the "Release Notes" section in Komodo's internal help
viewer for the full list of changes.

Please try it out and give us your feedback:

  emailhttp://listserv.activestate.com/mailman/listinfo/komodo-beta
  bugs http://bugs.activestate.com/enter_bug.cgi?product=Komodo
  forumhttp://community.activestate.com/products/Komodo


Cheers,
Trent

--
Trent Mick
Product Manager, Komodo and Python
ActiveState, The Dynamic Language Experts
http://www.activestate.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Deformed Form

2010-06-11 Thread Victor Subervi
Ok. Starting over. Here is the script that "generates" the variable
"new_passengers_curr_customers":

#!/usr/bin/python

import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())
import MySQLdb
from login import login
from Curr_Passengers_Table import Curr_Passengers_Table

def create_edit_passengers():
  print "Content-Type: text/html"
  print
  print '''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";>
http://www.w3.org/1999/xhtml";>


'''
  user, passwd, db, host = login()
  database = MySQLdb.connect(host, user, passwd, db)
  cursor = database.cursor()
  form = cgi.FieldStorage()
  flight = form.getfirst('flight')
  try:
cursor.execute('select c.id, p.name, p.weight, c.first_name,
c.middle_name, c.last_name, c.suffix from Passengers p join Customers c
where p.flights_id=%s;', flight)
passengers = cursor.fetchall()
  except MySQLdb.ProgrammingError:
passengers = []
  cursor.execute('select * from Flights where id=%s;', flight)
  flight_data = cursor.fetchone()
  print "You have selected flight #%s, departing %s from %s and arriving
%s at %s." % (flight_data[0], flight_data[2],
flight_data[5], flight_data[3], flight_data[6])
  if len(passengers) > 0:
print '\n'
Curr_Passengers_Table(passengers)
print "Add Passengers"
  else:
print "There are currently no passengers enrolled in this flight. Please
enter some."
print '\n'

*** RIGHT HERE! ***

  print ""
 ^
*** SEE IT? ***

  print ""
  print '\n'
  cursor.close()

create_edit_passengers()



Now, here's the form that *should* be able to access that variable:

!/usr/bin/python

import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())
import MySQLdb
from login import login
import fpformat
from New_Passengers_Curr_Customers import New_Passengers_Curr_Customers
from New_Passengers_Addl_Customers import New_Passengers_Addl_Customers
from New_Passenger import New_Passenger

form = cgi.FieldStorage()

def sortedDictValues(adict):
  items = adict.items()
  items.sort()
  return [value for key, value in items]

def create_edit_passengers3():
  print "Content-Type: text/html"
  print
  print '''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";>
http://www.w3.org/1999/xhtml";>


'''
  user, passwd, db, host = login()
  database = MySQLdb.connect(host, user, passwd, db)
  cursor = database.cursor()
  cursor.execute('select id from Flights;')
  flights = [itm[0] for itm in cursor]
  cursor.execute('select id, first_name, middle_name, last_name, suffix from
Customers;')
  customers = cursor.fetchall()
  try:
cursor.execute('select p.id, c.first_name, c.middle_name, c.last_name,
c.suffix, c.discount, p.flights_id, p.name, f.price, c.id from Customers c
join Passengers p on c.id=p.customer_id join Flights f on p.flights_id=f.id
;')
passengers = cursor.fetchall()
print '\n'
start_html = "\n  \n
Delete?\nFlight\n
Name\nDiscount\n
Price\n  \n"
passengers_html = []
ids = []
i = 0
for passenger in passengers:
  do_delete = form.getfirst('%s:delete' % passenger[0])
  passengers_html, i = New_Passenger(passengers_html, passenger,
do_delete, flights, ids, i)
printHTML = sortedDictValues(dict(zip(ids, passengers_html)))
if len(printHTML) > 0:
  print start_html
for html in printHTML:
  print html
print ""
  except MySQLdb.ProgrammingError:
pass

*** NOTE THIS: 
  new_passengers_curr_customers = New_Passengers_Curr_Customers(customers,
flights)
*** THAT LINE 

  if new_passengers_curr_customers > 0:
print ""
  print '\n'
  cursor.close()

create_edit_passengers3()


See that line that I marked right at the end? So here's that script:

#!/usr/bin/python

import cgitb; cgitb.enable()
import cgi

form = cgi.FieldStorage()

def New_Passengers_Curr_Customers(customers, flights):

*** RIGHT HERE. SEE THIS LINE? WHY DOES IT WORK HERE AND NOT IN THE 2ND
SCRIPT IN THIS HERE EMAIL WHERE IT SHOULD WORK???***
  new_passengers_curr_customers =
int(form.getfirst('new_passengers_curr_customers', 0))
*** THAT LINE ABOVE. RIGHT ABOVE HERE. OK?? ***

  print "" % new_passengers_curr_customers
  if new_passengers_curr_customers > 0:
print "\n"
print "  \nFrom Current
Customers\n  "
print "  \nFlight\n
Customer\n  "
  i = 0
  while i < new_passengers_curr_customers:
print "  "
print "" % i
for flight in flights:
  print "  %s" % flight
print ""
print "" % i
for customer in customers:
  print "  %s %s %s %s" % (customer[0],
customer[1], customer[2], customer[3], customer[4])
print ""
print "  "
i += 1
  if new_passengers_curr_customers > 0:
print ""
  return new_passengers_curr_customers

Ok. So I think that was clear now.
TIA,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple chat server

2010-06-11 Thread Burakk
Thank you for your replies...

I have overriden the error handlers
and the results:

Traceback (most recent call last):
  File "/home/burak/NetBeansProjects/intantMarkup/src/
02basicServer.py", line 65, in 
try: asyncore.loop()
  File "/usr/lib/python3.1/asyncore.py", line 206, in loop
poll_fun(timeout, map)
  File "/usr/lib/python3.1/asyncore.py", line 147, in poll
read(obj)
  File "/usr/lib/python3.1/asyncore.py", line 79, in read
obj.handle_error()
  File "/usr/lib/python3.1/asyncore.py", line 75, in read
obj.handle_read_event()
  File "/usr/lib/python3.1/asyncore.py", line 420, in
handle_read_event
self.handle_read()
  File "/usr/lib/python3.1/asynchat.py", line 170, in handle_read
index = self.ac_in_buffer.find(terminator)
TypeError: expected an object with the buffer interface


 But i want to add that i am writing the code in netbeans with python
3.1 and running the code from the programme.. Ubuntu deafult python is
2.6.5. Is this a problem. And i also want to add that i made the .py
executable and run that from terminal too with the same
results...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Benjamin Kaplan
On Fri, Jun 11, 2010 at 11:03 AM, Chris Hulan  wrote:
> Haven't used it but Racket (http://racket-lang.org/) looks to be a new
> and improved Scheme
>

The language isn't new, just the name. Racket is the language formerly
known as PLT Scheme. They decided that they made enough changes from
R5RS that they should rename it.  That way, when people ask questions,
it's clear that they're talking about the PLT variant of Scheme and
not the main standard.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deformed Form

2010-06-11 Thread Dave Angel

Victor Subervi wrote:

On Fri, Jun 11, 2010 at 12:24 PM, Stephen Hansen
wrote:

  

Sure, if you have some file that two separate scripts import, and in
said file you generate some value-- as long as that value will be the
same at all times, it'll appear that the two scripts are sharing some
state. They are not, however. The two scripts can not communicate.




I'm glad you have lots of experience and I respect that. However, I did not
say that "two separate scripts import said file." To repeat:

1) variable value generated is
create_edit_passengers2.py
2) 
create_edit_passengers2.pycalls
create_edit_passengers3.py
via a  and
passes the value of the var thereunto.
3) theoretically! Yet for some reason I can't call it in
create_edit_passengers3.py
but *can* call it in a
script that is imported by
create_edit_passengers3.py 

I think I'm being clear here, am I not? With all your knowledge and
understanding, I still fail to understand how it is you don't understand and
cannot answer my question.


You could try actually stating something approaching what your code is 
doing.


"variable value generated is create_edit_passengers2.py"   So you're generating that 
source code, and storing it in some variable called "value"?


"calls create_edit_passengers3.py"   You say you're calling
create_edit_passengers3.py

but that's not a function, it's a source file.  You can't call a source 
file.


And "passes the value of the var therunto"  is mighty roundabout.  
Assuming you meant "import" in the last part, how are you passing the 
value?  Import doesn't take any parameters.


"script that is imported by".  Nitpick:  a script cannot be imported.  
Once it is, it's a module.


"for some reason I can't call it in create_edit_passengers3.py"  No idea 
what "it" refers to, is it some mythical script that you're still trying 
to call?


Your problem could be circular imports.  If one module imports another, 
which directly or indirectly imports the first, you can get into various 
trouble.  If somebody imports the *script* you're definitely hosed, 
since there will then be two instances of that one, the script, and the 
module.



Maybe it's all clear if one looks at those files, but from here the 
links seem broken.  So I'm just going by your message, which is 
confusing.  I suggest you construct a simple example to show the 
problem, one small enough to include here in its entirety.  Then 
describe it in proper Python terminology.


DaveA

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


Re: Deformed Form

2010-06-11 Thread Stephen Hansen
[reordering the message a bit]

On 6/11/10 10:40 AM, Victor Subervi wrote:
>>> Now you guys can make fun of me all you want, but until you actually
READ
>>> and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
>>> ridiculous and make you look like fools.

> On Fri, Jun 11, 2010 at 12:24 PM, Stephen Hansen
> wrote:
>>
>> And this comment ends my attempt at assisting you, for multiple reasons
>> (from the utter absurdity of you insisting we understand you when you
>> take insultingly little care to actually express your problems clearly,
>> to your arrogant and repeated refusal to take advice that is given, to
>> your abject rudeness here, and so on).
>>
>
> That comment was not addressed to you as you didn't bother to quote the
> other part just after it, where I stated I appreciate your help and
> understand how difficult it is to not misunderstand each other. Sorry you
> misunderstood. I am not being arrogant or rude.

"I think your criticisms are ridiculous and make you look like fools" is
what I object to. I didn't quote the rest, because it doesn't matter --
once you say something like that, you become an jerk. Once you're an
jerk, you don't get to backtrack and say, 'oh, except you'. I don't
really accept the appreciation from someone being an jerk. If you're an
jerk at all, you can't really expect any sort of help at all :P

That said, I'll answer once more:

>> Sure, if you have some file that two separate scripts import, and in
>> said file you generate some value-- as long as that value will be the
>> same at all times, it'll appear that the two scripts are sharing some
>> state. They are not, however. The two scripts can not communicate.
>>
> 
> I'm glad you have lots of experience and I respect that. However, I did not
> say that "two separate scripts import said file." To repeat:
> 
> 1) variable value generated is
> create_edit_passengers2.py
> 2) 
> create_edit_passengers2.pycalls
> create_edit_passengers3.py
> via a  and
> passes the value of the var thereunto.
> 3) theoretically! Yet for some reason I can't call it in
> create_edit_passengers3.py
> but *can* call it in a
> script that is imported by
> create_edit_passengers3.py 
> 
> I think I'm being clear here, am I not? With all your knowledge and
> understanding, I still fail to understand how it is you don't understand and
> cannot answer my question.

You're not even *approaching* being clear.

"Variable value generated is" means WHAT?

What does "generated" mean?

If you have a line,

   x = MyFunction()

At the top level of some script, then everytime that script is called,
MyFunction is called, and it assigns its value to x. If MyFunction is
deterministic and doesn't rely on any sort of state, it'll be the same
value every time.

[For the rest of the analysis, I refuse to continue typing these
absurdly long names. create_edit_passengers2.py is bar1.py,
create_edit_passengers3.py is bar2.py]

Okay, at 1, you say.. you have Value generated. When you go
http://foo/bar1.py, then it will load, "generate" your value, dump the
resulting output, and then close.

And its done. That value ceases to exist.

Okay, so. Step 2. The output that bar1 returned contained a form. This
form, I assume (but you did not state), contains embedded in it the
value of "var". Yes? No? Either way

Now we're at step 2. In step 2, you have some form, and its calling back
to http://foo/bar2.py via a , passing the value of "var" in it. I
can't quite make out what all is going on here, so its all a guess, as
you have this slightly crazy bar2.py thing going on
that I can't figure out. But, I'll just handwave that, and guess.

So, bar2 receives our "var".

Then you say:

> 3) theoretically! Yet for some reason I can't call it in
> create_edit_passengers3.py
> but *can* call it in a
> script that is imported by
> create_edit_passengers3.py 

I can't even vaguely guess at what you're trying to express there, which
is why I didn't address this originally -- its utterly meaningless
gibberish to me.

"Yet for some reason I can't call it in bar2.py"

"but *can* call it in a script that is imported by
bar2.py

Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Chris Hulan
Haven't used it but Racket (http://racket-lang.org/) looks to be a new
and improved Scheme

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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Andrew Philpot

On 06/11/10 08:48, Elena wrote:

On 10 Giu, 23:33, bolega  wrote:

I mean ordinary people, who may want to do things with their computers
for scripting, tasks that python can do...


Lisp is not for ordinary people, Python is.


Python is for ordinary people.
Lisp is for extraordinary people.
I believe nearly all people have the potential to be extraordinary, but 
most choose to remain merely ordinary.

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


Re: MySQLdb problems with named pipe connection on Windows 7?

2010-06-11 Thread John Nagle

   I reconfigured MySQL to allow local network connections, and
now MySQLdb works over TCP.  It doesn't seem to be able to use
Windows 7 named pipes, although the "mysql" command line client can.
There may be a bug.  This wouldn't be noticed unless MySQL
was configured without network connections, which is rare.  I set
up MySQL that way on a development machine with a local MySQL instance.

John Nagle

On 6/11/2010 9:32 AM, John Nagle wrote:

On 6/10/2010 11:58 PM, Dennis Lee Bieber wrote:

On Thu, 10 Jun 2010 14:15:21 -0700, John Nagle
declaimed the following in gmane.comp.python.general:



MySQL is configured for connections over named pipes only; it's
not running as a TCP server. Is MySQLdb trying to use TCP for a local
connection? The MySQLdb documentation says that connections to
"localhost" on Windows will be made over named pipes. Does that
not work?


I wouldn't be a tad surprised if M$ Win7 has implemented some
security/privilege scheme on named pipes such that cross process/user
access is blocked.


The MySQL command line client can connect with the same privileges.
So that may not be the problem.

John Nagle


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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Paul Rubin
Andreas Waldenburger  writes:
> I have a strong suspicion that Tkinter may be used a lot more than is
> made public (isn't anything?). I'm especially thinking about scientists
> who write special purpose data processing or control programs with
> basic GUIs. These things don't have to be pretty or anything and it is
> a HUGE advantage if you don't have to jump through any hoops to get it
> to run on different platforms.

Yes, I don'tthink that's limited to scientists either.  One way to slap
a basic GUI on something is to embed a web server in it, or run it as a
CGI, so the user connects to it with a browser.  I think most
programmers are familiar with that idea, that GUI functionality doesn't
have to be slick in order to be useful.  Other times, you don't want a
browser involved, and tkinter works fine for that.  I've always found
tkinter adequate for the (not terribly slick) applications I've written
with guis.  I can understand it's only good for relatively rudimentary
apps, but that's sufficient for lots of things.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread Mark Lawrence

On 11/06/2010 17:17, rantingrick wrote:

On Jun 11, 9:06 am, Mark Lawrence  wrote:


"Everyone who uses IDLE uses TKInter, and a lot of people use IDLE."


That sounds like hyperbole to me. What evidence do you have to made
such a statement. What evidence do *I* have to make the opposing
statement. We don't, so add the warning and put your money where your
mouth is instead of your foot :-!


I did *NOT* make the statement as my original post clearly shows.


To quote R. David Murray on the Python bug tracker earlier today.

"Everyone who uses IDLE uses TKInter, and a lot of people use IDLE."


Looks like you're mad cos the bug tracker issue has already been closed 
as rejected.  Or is it cos you fell for my bait?  Or both?


To paraphrase Tommy Docherty, Ranting Rick is to Python what King Herod 
was to baby sitting.


Have a nice day.

Mark Lawrence.

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


Re: Deformed Form

2010-06-11 Thread Victor Subervi
On Fri, Jun 11, 2010 at 12:24 PM, Stephen Hansen
wrote:

> Sure, if you have some file that two separate scripts import, and in
> said file you generate some value-- as long as that value will be the
> same at all times, it'll appear that the two scripts are sharing some
> state. They are not, however. The two scripts can not communicate.
>

I'm glad you have lots of experience and I respect that. However, I did not
say that "two separate scripts import said file." To repeat:

1) variable value generated is
create_edit_passengers2.py
2) 
create_edit_passengers2.pycalls
create_edit_passengers3.py
via a  and
passes the value of the var thereunto.
3) theoretically! Yet for some reason I can't call it in
create_edit_passengers3.py
but *can* call it in a
script that is imported by
create_edit_passengers3.py 

I think I'm being clear here, am I not? With all your knowledge and
understanding, I still fail to understand how it is you don't understand and
cannot answer my question.

>
> > Now you guys can make fun of me all you want, but until you actually READ
> > and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
> > ridiculous and make you look like fools.
>
> And this comment ends my attempt at assisting you, for multiple reasons
> (from the utter absurdity of you insisting we understand you when you
> take insultingly little care to actually express your problems clearly,
> to your arrogant and repeated refusal to take advice that is given, to
> your abject rudeness here, and so on).
>

That comment was not addressed to you as you didn't bother to quote the
other part just after it, where I stated I appreciate your help and
understand how difficult it is to not misunderstand each other. Sorry you
misunderstood. I am not being arrogant or rude.

My scripts work. I guess I can just let them work and not bother
understanding *why* they work the way they do and not the way they *should*;
however, if anyone would like to explain, using the 3 steps above, where the
problem is, that would be nice.
Sincerely,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for very complicated gettext PO file(s) for testing

2010-06-11 Thread python
I'm looking for one or more very complicated gettext PO files for
testing. I know this sounds a bit OT, but these files will be
used to test some Python-based PO utilities we've had to write to
manage our PO files. We have our own in-house produced test
files, but its always dangerous to test against your myopic view
of the world.

By complicated I mean lots of msgids, plural forms, comments,
and/or non-standard extensions to the PO file syntax.

I would be grateful for any samples sent via email or a link to a
specific open source project with sophisticated PO files.

Thank you,
Malcolm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good solutions for passing around large numbers of arguments in a layered architecture?

2010-06-11 Thread James Mills
On Sat, Jun 12, 2010 at 3:00 AM, Nathan Rice
 wrote:
> I've tried using args/kwargs, however I found it difficult to avoid
> having arguments in my signature re-ordered, and it is also a source
> of bugs.
>
> Has anyone come up with a good solution for dealing with arguments in
> situations like this where you'd like to encapsulate lower level stuff
> for neophyte users but make it easily available to advanced users?

Use a container instead and pass this around. eg: an Environment class.

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Stephen Hansen
On 6/11/10 4:48 AM, Andreas Waldenburger wrote:
> I have a strong suspicion that Tkinter may be used a lot more than is
> made public (isn't anything?). I'm especially thinking about scientists
> who write special purpose data processing or control programs with
> basic GUIs. These things don't have to be pretty or anything and it is
> a HUGE advantage if you don't have to jump through any hoops to get it
> to run on different platforms.

This.

Its used in a lot of in-house / internal things.

Another point: there's a not insignificant minority to whom 'just
download it' simply doesn't apply.

To replace tkinter would require a clea r upgrade path. Or a really,
really, really long deprecation period.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Stephen Hansen
On 6/10/10 11:00 PM, rantingrick wrote:
> On Jun 11, 12:17 am, ant  wrote:
>> I like the points about backwards compatibility. Presumably that
>> reason alone is enough to keep Tkinter in the standard library for a
>> long while.
> 
> I don't see why that is a good reason. Download Tkinter and your
> backward compatible again. The majority don't use it anyway. I would
> bet that only myself, Kevin, and only a handful of others use Tkinter
> for anything more than education purposes. AFIK, Kevin is THE ONLY
> PYTHON programmer producing real professional GUI's with Tkinter -- i
> encourage anyone else to speak up if your out there producing real
> Tkinter GUI. (psst: i don't think we'll be seeing mobs in the streets,
> really i don't)

Hint: the world and even Python community is a lot larger then this
mailing list.

A LOT.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Stephen Hansen
On 6/10/10 10:17 PM, ant wrote:
> So would it be so awful to have Tkinter and GUI2 (whatever it is) in
> the stdlib, assuming that both had equivalent functionality? That
> would be the way to give people the choice.

There's some slight precedent, in that the stdlib does offer more then
one "xml" library -- from the suck of minidom, to sax, to elementtree.
Then again they all sort of address slightly different domains of
problems related to xml. Then there's urllib/urllib2 -- but usually, if
one library duplicates the intent of another, they only co-exist until
such time as the old one can Go Away. (Exactly how long that is,
depends: some 'to go away' libraries can survive a very long time due to
major usage).

That said, I'd be worried about--


> But it does imply that GUI2 is not too huge, to prevent excessive
> bloat (is that a tautology?).

When you factor in dependencies, it might be a lot. Then again, it might
not. Not counting dependencies, PyGUI seems reasonably sized -- the
other major GUI's? Way too big.

> Other interesting comments: licencing. Can anyone give a concise
> summary of whether the 'major' GUIs have any insuperable licencing
> problems that would rule them out anyway? Programming is hard enough
> without lawyers.

wxPython (and its dependency, wxWidgets) has a custom license, but its
very Python-like. Meaning, its essentially 'do whatever you want, open,
closed, commercial, charity, whatever'.

QT is LGPL -- and although you can technically include LGPL stuff in
non-[L]GPL libs, I don't think its policy in Python to allow it. It
creates a burden / obligation.

PyQT is GPL, so impossible to include at all. PySide, Nokia's answer to
PyQt not changing their licensing terms when Nokia acquired TrollTech,
is LGPL. Technically possible, but I don't think its allowable.

PyGTK is LGPL. Same issues: and this raises a question with regards to
PyGUI, which uses pygtk on linux to create its UI.

I don't remember what other UI libs are out there.

I might be wrong on the LGPL policy bit. But the only stuff I'm aware of
that Python bundles (i.e., zlib, sqlite) have the permissive 'do
whatever' type of license. I don't believe Python wants to create a
situation where any burden is placed on someone who embeds it.

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Good solutions for passing around large numbers of arguments in a layered architecture?

2010-06-11 Thread Nathan Rice
I've been running into a problem lately where I have an architecture like so:

Main class -> facade/configuration class -> low level logic class.

The main class is what the user interacts with.

The facade/config class is responsible for loading and managing the
lower level classes and providing a consistent interface to the main
class.  It can be hot swapped in/out to drastically change the
functionality of the main class.

The low level logic classes are responsible for dealing with domain primitives.


The issue I'm having is that I want advanced users to be able to pass
extra configuration information to the facade and low level classes if
need be, without the signature drastically changing with different
facade classes.  Currently, I explicitly state parameters as much as
possible at each level.  To deal with low level logic classes that
have a large number of possible options I allow the caller to pass a
dictionary of options for that class.  This leaves me with signatures
that are upwards of 15 arguments long in some cases, the majority of
them repeated in classes called from the main class.

I've tried using args/kwargs, however I found it difficult to avoid
having arguments in my signature re-ordered, and it is also a source
of bugs.

Has anyone come up with a good solution for dealing with arguments in
situations like this where you'd like to encapsulate lower level stuff
for neophyte users but make it easily available to advanced users?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple chat server

2010-06-11 Thread Giampaolo Rodolà
In every dispatcher instance of your application I recommend to
override handle_error as follows:

class A(asyncore.dispatcher)

 def handle_error(self):
 raise

This will print a common traceback message instead of the compact one
provided by asyncore which provides a lot less information.


--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil

2010/6/11 Burakk :
> Hi,
>
> I am using ubuntu lucid and i have started to learn python(vrs 3.1). I
> am trying to make a tutorial code(see below) work but when i run the
> code, open a terminal window and connect as client with telnet and
> type somethings and hit enter, give me error below...(the terminal
> says connection closed by foreign host)
>
> if someone can help i will be glad...
>
> thanx
>
> -- error: uncaptured python exception, closing channel
> <__main__.ChatSession connected 127.0.0.1:46654 at 0xb71cce8c> ( 'TypeError'>:expected an object with the buffer interface [/usr/lib/
> python3.1/asyncore.py|read|75] [/usr/lib/python3.1/asyncore.py|
> handle_read_event|420] [/usr/lib/python3.1/asynchat.py|handle_read|
> 170]) --
>
> code
>
> from asyncore import dispatcher
> from asynchat import async_chat
> import asyncore
> import socket
>
> PORT = 5005
> NAME = 'TestChat'
>
> class ChatSession(async_chat):
>
>     def __init__(self, sock):
>         async_chat.__init__(self, sock)
>         self.set_terminator("xx")
>         self.data = []
>
>
>     def collect_incoming_data(self, data):
>         self.data.append(data)
>
>
>     def found_terminator(self):
>         line = ''.join(self.data)
>         self.data = []
>         self.push(line)
>
> class ChatServer(dispatcher):
>      def __init__(self, port):
>          dispatcher.__init__(self)
>          self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
>          self.set_reuse_addr()
>          self.bind(('', PORT))
>          self.listen(5)
>          self.sessions = []
>
>
>      def handle_accept(self):
>          conn, addr = self.accept()
>          self.sessions.append(ChatSession(conn))
>
> if __name__== '__main__':
>    s = ChatServer(PORT)
>    try: asyncore.loop()
>    except KeyboardInterrupt : print
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb problems with named pipe connection on Windows 7?

2010-06-11 Thread John Nagle

On 6/10/2010 11:58 PM, Dennis Lee Bieber wrote:

On Thu, 10 Jun 2010 14:15:21 -0700, John Nagle
declaimed the following in gmane.comp.python.general:



MySQL is configured for connections over named pipes only; it's
not running as a TCP server.  Is MySQLdb trying to use TCP for a local
connection?  The MySQLdb documentation says that connections to
"localhost" on Windows will be made over named pipes.  Does that
not work?


I wouldn't be a tad surprised if M$ Win7 has implemented some
security/privilege scheme on named pipes such that cross process/user
access is blocked.


The MySQL command line client can connect with the same privileges.
So that may not be the problem.

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


Re: Deformed Form

2010-06-11 Thread Stephen Hansen
On 6/11/10 4:46 AM, Victor Subervi wrote:
> You know, if this were the first time I'd worked with "passing variables
> around" through cgi, I'd think you may be right. But answer me this:
if what
> you assume is correct,

I do not assume. I know.

With CGI, each web request is independent. This is simple fact.

The web server launches Python, Python runs a script, Python returns a
string containing the result, *Python closes*. The web host sends that
string to the client.

The Python application *ends*. Its memory is cleared. It is gone. This
is how CGI works (and why CGI is almost never used anymore, as it is
quite slow as a result-- most people use something like FastCGI or WSGI
either with a long-running daemon Python process or embedding Python
into Apache itself).

When the next request comes in, it all starts up again: each request has
only the information provided to it, either in cookies, the environment
variables (there's quite a few interesting ones), and the request
parameters.

This is *how it works*.

This is not some vague guess of mine. This is *years* of experience of
*actually* doing *exactly* what you're doing (while at the time actually
making an attempt to understand the actual processes going on instead of
just moving things around in files and observing the results to guess
what's going on under the covers).

Sure, if you have some file that two separate scripts import, and in
said file you generate some value-- as long as that value will be the
same at all times, it'll appear that the two scripts are sharing some
state. They are not, however. The two scripts can not communicate.

> Now you guys can make fun of me all you want, but until you actually READ
> and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
> ridiculous and make you look like fools.

And this comment ends my attempt at assisting you, for multiple reasons
(from the utter absurdity of you insisting we understand you when you
take insultingly little care to actually express your problems clearly,
to your arrogant and repeated refusal to take advice that is given, to
your abject rudeness here, and so on).

-- 

   Stephen Hansen
   ... me+list/python (AT) ixokai (DOT) io



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


Re: GUIs - A Modest Proposal

2010-06-11 Thread rantingrick
On Jun 11, 9:06 am, Mark Lawrence  wrote:

> "Everyone who uses IDLE uses TKInter, and a lot of people use IDLE."

That sounds like hyperbole to me. What evidence do you have to made
such a statement. What evidence do *I* have to make the opposing
statement. We don't, so add the warning and put your money where your
mouth is instead of your foot :-!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT]romantic poetry

2010-06-11 Thread Ethan Furman

Mark Lawrence wrote:
For a bit of light relief from those fed up of reading of the perceived 
shortcomings of tkinker thought you might like this.  Enjoy :)


http://www.cc.gatech.edu/fac/Spencer.Rugaber/poems/love.txt

Kindest regards.

Mark Lawrence


AH hahahahahahahahahahahah

Much appreciated!

~Ethan~

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


Re: simple chat server

2010-06-11 Thread Peter Pearson
On Thu, 10 Jun 2010 15:26:28 -0700 (PDT), Burakk wrote:
> Hi,
>
> I am using ubuntu lucid and i have started to learn python(vrs 3.1). I
> am trying to make a tutorial code(see below) work but when i run the
> code, open a terminal window and connect as client with telnet and
> type somethings and hit enter, give me error below...(the terminal
> says connection closed by foreign host)
>
> if someone can help i will be glad...

I know this is very little help, but your code appears to
work fine under Python 2.5.2.

-- 
To email me, substitute nowhere->spamcop, invalid->net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a +b ?

2010-06-11 Thread Steven D'Aprano
On Fri, 11 Jun 2010 22:11:26 +0800, yanhua wrote:

> hi,all!
> it's a simple question:
> input two integers A and B in a line,output A+B?
> 
> this is my program:
> s = input()
> t = s.split()
> a = int(t[0])
> b = int(t[1])
> print(a+b)
> 
> but i think it's too complex,can anybody tell to slove it with less
> code.


Why do you think it is too complex? That seems fine to me. If anything, 
it is too SIMPLE -- where is the error checking? What if the user only 
enters one number? Or three numbers? Or something that isn't a number at 
all?

You can't get much simpler than your code -- you take a string, split it, 
convert the parts into integers, and print the sum. That is very simple. 
Compare it to this solution posted earlier:

(Python 2.x code)
import operator
print reduce(operator.add, map(int, raw_input().split()))

Look at how complex that is! You need to import a module, create a list 
using map, look up the 'add' attribute on the module, then call reduce on 
the list. Try explaining that to a new programmer who isn't familiar with 
map and reduce. And can you imagine how much extra work the computer has 
to do just to save a couple of lines of code?

No, I think your code is very simple. You can save a few lines by writing 
it like this:

s = input('enter two numbers: ')
t = s.split()
print(int(t[0]) + int(t[1]))  # no need for temporary variables a and b

but this still has the problem that there is no error checking for bad 
user input. Fortunately this is Python, where bad input will just raise 
an exception instead of causing a core dump, but still, this is too 
simple for anything except quick-and-dirty scripts.



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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Elena
On 10 Giu, 23:33, bolega  wrote:
> I mean ordinary people, who may want to do things with their computers
> for scripting, tasks that python can do...

Lisp is not for ordinary people, Python is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a +b ?

2010-06-11 Thread Alain Ketterlin
yanhua  writes:

> it's a simple question:
> input two integers A and B in a line,output A+B?
>
> this is my program:
> s = input()

input() is probably not what you think it is. Check raw_input instead.

> t = s.split()
> a = int(t[0])
> b = int(t[1])
> print(a+b)
>
> but i think it's too complex,can anybody tell to slove it with less code.

print sum(map(int,raw_input().split()))

or replace sum by reduce. BTW, it works with any number of integers

You can find this by walking backwards in your code, starting at a+b,
and generalizing a little bit on your way.

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


pyjsglade: GTK-glade-like UI builder for pyjamas

2010-06-11 Thread lkcl
https://sourceforge.net/projects/pyjsglade/

kees bos, the primary programmer who added all of the incredible
python features to the pyjs compiler, such as support for yield, long
data type and much more, has just started a project "pyjsglade".  its
purpose is the same as that of GTK glade: allow developers to build
GUIs based on an XML file format.

whilst he's pretty much literally only just begun the project, it's a)
useable because he needs it to be, for a work-related project b) kees
is such a ridiculously competent programmer that by the time you read
this it'll likely be 50% functional :)

anyway, i thought i'd just let people informally know.

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


Re: a +b ?

2010-06-11 Thread Xavier Ho
2010/6/12 yanhua 

> hi,all!
> it's a simple question:
> input two integers A and B in a line,output A+B?
>
> this is my program:
> s = input()
> t = s.split()
> a = int(t[0])
> b = int(t[1])
> print(a+b)
>
> but i think it's too complex,can anybody tell to slove it with less code.
> --
>

The reason it looks complicated is because you're using one variable for
everything you do. Look at others' answers - most of them are simply
combining them into one line.

Cheers,
Xav
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deformed Form

2010-06-11 Thread Emile van Sebille

On 6/11/2010 4:46 AM Victor Subervi said...

Now you guys can make fun of me all you want, but until you actually READ
and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
ridiculous and make you look like fools.


I think the point is exactly as you state -- until you actually READ and 
UNDERSTAND what you're writing, I'm afraid your questions are ridiculous 
and make you look like a fool.


Emile

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Jean-Michel Pichavant

Andreas Waldenburger wrote:

On Thu, 10 Jun 2010 23:00:37 -0700 (PDT) rantingrick
 wrote:

  

On Jun 11, 12:17 am, ant  wrote:


I like the points about backwards compatibility. Presumably that
reason alone is enough to keep Tkinter in the standard library for a
long while.
  

I don't see why that is a good reason. Download Tkinter and your
backward compatible again. The majority don't use it anyway. I would
bet that only myself, Kevin, and only a handful of others use Tkinter
for anything more than education purposes.



I have a strong suspicion that Tkinter may be used a lot more than is
made public (isn't anything?). I'm especially thinking about scientists
who write special purpose data processing or control programs with
basic GUIs. These things don't have to be pretty or anything and it is
a HUGE advantage if you don't have to jump through any hoops to get it
to run on different platforms.

/W

  
Moreover, the majority of the python scripts/applications do not require 
any GUI, the majority of those which require a GUI don't require to be 
pretty anyway.



JM

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


Re: a +b ?

2010-06-11 Thread superpollo

Simon Brunning ha scritto:

2010/6/11 yanhua :

hi,all!
it's a simple question:
input two integers A and B in a line,output A+B?


print sum(int(i) for i in raw_input("Please enter some integers: ").split())


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


Re: a +b ?

2010-06-11 Thread Simon Brunning
2010/6/11 yanhua :
> hi,all!
> it's a simple question:
> input two integers A and B in a line,output A+B?

print sum(int(i) for i in raw_input("Please enter some integers: ").split())

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a +b ?

2010-06-11 Thread Alex Hall
On 6/11/10, yanhua  wrote:
> hi,all!
> it's a simple question:
> input two integers A and B in a line,output A+B?
>
> this is my program:
> s = input()
> t = s.split()
> a = int(t[0])
> b = int(t[1])
> print(a+b)
>
> but i think it's too complex,can anybody tell to slove it with less code.
Just a thought, but less code is not always better; more code and
comments often help others, and even yourself if you return to a
project after some time, understand what the code does and how it
works. However, you could try this:
t=input().split()
print(str(int(t[0])+int(t[1])))
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehg...@gmail.com; http://www.facebook.com/mehgcap
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a +b ?

2010-06-11 Thread Martin P. Hellwig

On 06/11/10 15:19, superpollo wrote:

yanhua ha scritto:

hi,all??



s = input()


this does not work
 Well it does if it is python 3 and not 2 as you are using 
:-)


--
mph

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


Re: a +b ?

2010-06-11 Thread superpollo

yanhua ha scritto:

hi,all??
it's a simple question:
input two integers A and B in a line,output A+B?

this is my program:
s = input()


this does not work


t = s.split()
a = int(t[0])
b = int(t[1])
print(a+b)

but i think it's too complex,can anybody tell to slove it with less code.


>>> import operator
>>> print reduce(operator.add, map(int, raw_input().split()))
124312 41242
165554
>>>

bye

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


a +b ?

2010-06-11 Thread yanhua

hi,all!
it's a simple question:
input two integers A and B in a line,output A+B?

this is my program:
s = input()
t = s.split()
a = int(t[0])
b = int(t[1])
print(a+b)

but i think it's too complex,can anybody tell to slove it with less code.
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread Mark Lawrence

On 11/06/2010 12:48, Andreas Waldenburger wrote:

On Thu, 10 Jun 2010 23:00:37 -0700 (PDT) rantingrick
  wrote:


On Jun 11, 12:17 am, ant  wrote:

I like the points about backwards compatibility. Presumably that
reason alone is enough to keep Tkinter in the standard library for a
long while.


I don't see why that is a good reason. Download Tkinter and your
backward compatible again. The majority don't use it anyway. I would
bet that only myself, Kevin, and only a handful of others use Tkinter
for anything more than education purposes.


I have a strong suspicion that Tkinter may be used a lot more than is
made public (isn't anything?). I'm especially thinking about scientists
who write special purpose data processing or control programs with
basic GUIs. These things don't have to be pretty or anything and it is
a HUGE advantage if you don't have to jump through any hoops to get it
to run on different platforms.

/W



To quote R. David Murray on the Python bug tracker earlier today.

"Everyone who uses IDLE uses TKInter, and a lot of people use IDLE."

Kindest regards.

Mark Lawrence.

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Kevin Walzer

On 6/11/10 7:48 AM, Andreas Waldenburger wrote:


I have a strong suspicion that Tkinter may be used a lot more than is
made public (isn't anything?). I'm especially thinking about scientists
who write special purpose data processing or control programs with
basic GUIs. These things don't have to be pretty or anything and it is
a HUGE advantage if you don't have to jump through any hoops to get it
to run on different platforms.

/W



Good point .Tkinter is very widely used in scientific visualization 
software:


UCSF Chimera
http://www.cgl.ucsf.edu/chimera/

PyMOL
http://www.pymol.org/

There are others, no doubt.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread superpollo

Andreas Waldenburger ha scritto:

On Thu, 10 Jun 2010 23:00:37 -0700 (PDT) rantingrick
 wrote:


On Jun 11, 12:17 am, ant  wrote:

I like the points about backwards compatibility. Presumably that
reason alone is enough to keep Tkinter in the standard library for a
long while.

I don't see why that is a good reason. Download Tkinter and your
backward compatible again. The majority don't use it anyway. I would
bet that only myself, Kevin, and only a handful of others use Tkinter
for anything more than education purposes.


I have a strong suspicion that Tkinter may be used a lot more than is
made public (isn't anything?). I'm especially thinking about scientists
who write special purpose data processing or control programs with
basic GUIs. These things don't have to be pretty or anything and it is
a HUGE advantage if you don't have to jump through any hoops to get it
to run on different platforms.

/W



e.g.:

http://heim.ifi.uio.no/~hpl/INF5660/PyBasics.pdf

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


Help with suds: HTTP Error 401

2010-06-11 Thread Eric von Horst
Hi,

I am trying to do a very simple thing with SUDS but I think I am
missing the obvious (first time I use suds)

I have small program that tries to open a wsdl. When I execute the
program I am getting 'suds.transport.TransportError: HTTP Error 401:
Unauthorized' Seems obvious but I specify username and pwd in the
code.
when use IE to go the wsdl, I get a pop-up asking me for the username
and pwd, I enter them, and the wsdl is displayed.

This is my code:
"
from suds import WebFault
from suds.client import Client
from suds.transport.http import HttpAuthenticated


t = HttpAuthenticated(username='admin', password='admin')


client = Client('http://.xxx.xx.x:8080/axis2/services/UcmdbService?
wsdl', transport=t)
"
I seems straightforward :(

Any help much appreciated.

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


Re: passing environment variable path to open command

2010-06-11 Thread Mahmood Naderan
Thanks, both of the methods work fine:

 open(os.path.expandvars("${SOMETHING}/sc_1.sh"), "r")
OR
 infile = open(os.path.join(env, 'sc_1.sh'),"r")

// Naderan *Mahmood;





From: Christian Heimes 
To: python-list@python.org
Sent: Fri, June 11, 2010 2:05:15 PM
Subject: Re: passing environment variable path to open command

Am 11.06.2010 10:39, schrieb Mahmood Naderan:
> Hi,
> I am new to python so my question may be very basic.
> Suppose I have a file (sc_1.sh) which the path to that file is in system path:
> SOMETHING=/home/mahmood/scripts
>  
> Now I want to open that file with respect to the environment variable:
>    import os
>    env = os.getenv("SOMETHING")
>    print env
>    infile = open("env/sc_1.sh","r")
>  
> But here is the error I get:
> /home/mahmood/scripts
> Traceback (most recent call last):
>  File "test.py", line 7, in 
>    infile = open("env/sc_1.sh","r")
> IOError: [Errno 2] No such file or directory: 'env/sc_1.sh'
>  
> How can I use such variable in open file command?
> Thanks,

How about:

  open(os.path.expandvars("${SOMETHING}/sc_1.sh"), "r")

See http://docs.python.org/library/os.path.html#os.path.expandvars

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



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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Andreas Waldenburger
On Thu, 10 Jun 2010 23:00:37 -0700 (PDT) rantingrick
 wrote:

> On Jun 11, 12:17 am, ant  wrote:
> > I like the points about backwards compatibility. Presumably that
> > reason alone is enough to keep Tkinter in the standard library for a
> > long while.
> 
> I don't see why that is a good reason. Download Tkinter and your
> backward compatible again. The majority don't use it anyway. I would
> bet that only myself, Kevin, and only a handful of others use Tkinter
> for anything more than education purposes.

I have a strong suspicion that Tkinter may be used a lot more than is
made public (isn't anything?). I'm especially thinking about scientists
who write special purpose data processing or control programs with
basic GUIs. These things don't have to be pretty or anything and it is
a HUGE advantage if you don't have to jump through any hoops to get it
to run on different platforms.

/W

-- 
INVALID? DE!

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


Re: Deformed Form

2010-06-11 Thread Victor Subervi
On Thu, Jun 10, 2010 at 2:07 PM, Stephen Hansen wrote:

> On 6/10/10 10:48 AM, Victor Subervi wrote:
> > Now, create_edit_passengers3() is called by the form/submit button in
> (you
> > guessed it) create_edit_passengers2.py, the latter containing a var in it
> > which *should* be accessible to create_edit_passengers3.py, one would
> think.
>
> Wait, wait, wait.
>
> If a user is browsing to, say,
> http://example.com/create_edit_passengers2.py; that script will be run,
> and once -done-, print out a form which the user sees.
>
> At that point, create_edit_passengers2.py is dead. Gone. Over.
>
> Once a person then clicks Submit, and the form is sent to
> http://example.com/create_edit_passengers3.py; its a whole new
> environment (assuming you're using CGI, which it appears you are).
>
> The *only* way for state or data to get from one script to another is
> not importing, or shared variables, or anything like that: you *have* to
> pass it into that form, and extract it from the resulting form. You can
> pass the actual variables as a , and then extract
> it like any of the user-fields. Or, you can write out your state to a
> local file with some unique ID, and just write out into the form that
> unique ID. Or use a cookie session. Etc.
>
> You *can't* pass variables around script-to-script among separate CGI
> sessions. It just totally doesn't work like that. Any success you think
> you have had is false; it works by mere accident or illusion. Each CGI
> script stands alone. It starts, runs, executes, then closes. No state is
> preserved unless you *explicitly* preserve it.
>

You know, if this were the first time I'd worked with "passing variables
around" through cgi, I'd think you may be right. But answer me this: if what
you assume is correct, how in the heck is this variable being generated (and
it is) in 
create_edit_passengers2.py(as
an ) and then being reinstantiated in another
script? That is, if what you say is true, I should not be able to access it
through ANY script whatsoever after
create_edit_passengers2.pyis
"dead", right??? Look closely:

1) variable value generated is
create_edit_passengers2.py
2) 
create_edit_passengers2.pycalls
create_edit_passengers3.py
via a  and
passes the value of the var thereunto.
3) theoretically! Yet for some reason I can't call it in
create_edit_passengers3.py
but *can* call it in a
script that is imported by
create_edit_passengers3.py 

Now you guys can make fun of me all you want, but until you actually READ
and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
ridiculous and make you look like fools. For those who don't criticize me
and are trying to help but misunderstand, hey, what can I say, who
misunderstand so much myself lol.
TIA,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread Mark Lawrence

On 11/06/2010 08:35, rantingrick wrote:

On Jun 11, 1:46 am, Mark Lawrence  wrote:


I look forward to seeing your request on the Python bug tracker.  Not
holding my breath.


Thanks Mark, its done! "Tkinter Litmus Test"



I know, saw it on the bug tracker list before I left for work this 
morning.  Spoilsport, fishing is just no fun any more, you dangle a bit 
of bait and it get's taken hook, line and sinker.


Mark Lawrence

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


Re: GUIs - A Modest Proposal

2010-06-11 Thread Arndt Roger Schneider

rantingrick schrieb:


On Jun 10, 9:38 pm, Stephen Hansen  wrote:

 


Also-- you're just starting to get wrong.

http://docs.python.org/library/tix.html

They don't -call- them the things you are, but between ComboBox, and the
flexibility of HList and TList... it actually offers quite a lot.
   



Urm, do you *know* what a Grid widget is Stephen? (hint: Excel) Do you
*know* what a ListCtrl is Stephen? (Hint: File Browser in report or
iconlabel views) Neither of those widgets exists in the Tix package.
And how do i *know* this? Well because unlike you i have actually
written code with Tix widgets, obviously you have not.

 




All this stuff is present in Tk!

OpenGL:
tkzinc, a 2D visualiation system based on OpenGL,
this one is widley used in air-traffic control...
BTW: tkinc features the best transformation system in the
IT--the author got a patent for it.

canvas3d, OpenGL-3D.

In addition there are *very very very large* visualization systems 
available in Tk:

vtk for example...


ListCtrl --besides that I truely hate this type of controls, an 
aggregation of usablility problems--

tkTreeCtrl is a true clone of MSWIN Explorer


Spreadsheet:
Well, whow doesn't exist in Tix! Are you sure? Hint: look again.
There is tktable, technically well done with on-demand data aquisition,
looks really ugly. An open field to display your artistic prowess.

Once upon a time there was a complete
spreadsheet application written in C++/Tk: abacus.


The TList only displays iconlabels in a wrapping column format, not in
any "report mode" ala: Windows Explorer("details mode"). The HList
widget is for showing a tree structure and is NOTHING like either a
ListCtrl or a Grid.

 



See above.
But notice this windows explorer type sort of thing is a major offence
on other platforms.

My own approach for such an interface function is to use seperate window
types, it reduces the maintainment cost for such an application.


HList:
Well *now* I am speachless. Did you actually even do a superfical
research on the topic?

BLT-tree
bwidget-tree
rtl_tree
hugelist
tkTreeCtrl (mentioned above)
ttk:treectrl
tablelist
tixtreecontrol


Just scanning the docs of a module (that you know jack about) and then
parroting off some baseless arguments are bound to bite you in the
@ss! *egg on face*
 



Please enjoy it.

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


Re: Deformed Form

2010-06-11 Thread Bruno Desthuilliers

Stephen Hansen a écrit :

On 6/10/10 8:35 AM, Bruno Desthuilliers wrote:

Stephen Hansen (L/P) a écrit :

On 6/10/10 7:14 AM, Victor Subervi wrote:

(snip)

+1 for "absolutely worst framed question of the day" :)

IMHO you're wasting your time. Some guys never learn, and I guess we do
have a world-class all-times champion here.




Well, he eventually learned about bare excepts and using string
formatting in SQL. It took a long time, but he finally believed us.


No ??? Incredible. Perhaps I'm being a bit too pessimistic then.


He just sort of needs to give us the benefit of the doubt when we say,
"umm, its bad to do that" :)


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


Re: passing environment variable path to open command

2010-06-11 Thread Christian Heimes
Am 11.06.2010 10:39, schrieb Mahmood Naderan:
> Hi,
> I am new to python so my question may be very basic.
> Suppose I have a file (sc_1.sh) which the path to that file is in system path:
> SOMETHING=/home/mahmood/scripts
>  
> Now I want to open that file with respect to the environment variable:
>import os
>env = os.getenv("SOMETHING")
>print env
>infile = open("env/sc_1.sh","r")
>  
> But here is the error I get:
> /home/mahmood/scripts
> Traceback (most recent call last):
>   File "test.py", line 7, in 
> infile = open("env/sc_1.sh","r")
> IOError: [Errno 2] No such file or directory: 'env/sc_1.sh'
>  
> How can I use such variable in open file command?
> Thanks,

How about:

  open(os.path.expandvars("${SOMETHING}/sc_1.sh"), "r")

See http://docs.python.org/library/os.path.html#os.path.expandvars

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


Re: passing environment variable path to open command

2010-06-11 Thread Jean-Michel Pichavant

Mahmood Naderan wrote:


Hi,
I am new to python so my question may be very basic.
Suppose I have a file (sc_1.sh) which the path to that file is in 
system path:


SOMETHING=/home/mahmood/scripts

 


Now I want to open that file with respect to the environment variable:
   import os
   env = os.getenv("SOMETHING")
   print env

   infile = open("env/sc_1.sh","r")

 


But here is the error I get:
/home/mahmood/scripts
Traceback (most recent call last):
  File "test.py", line 7, in 
infile = open("env/sc_1.sh","r")
IOError: [Errno 2] No such file or directory: 'env/sc_1.sh'

 


How can I use such variable in open file command?

Thanks,
 


*// Naderan *Mahmood;*


import os

infile = open(os.path.join(env, 'sc_1.sh'),"r")

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


KinterBasDB - how to change the mode: embedded/server

2010-06-11 Thread durumdara
Hi!

I want to use KinterBasDB in mixed mode: sometimes embedded, sometimes
real local/remote server.
How can I set up the connection to KinterBasDB can determine, what
mode I want to use?

Thanks for your help:
   dd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Tamas K Papp
On Thu, 10 Jun 2010 13:14:01 -0700, bolega wrote:

> Please compare LISP and its virtues with other languages such as
> javascript, python etc.

Generally, it is advisable to cross-post questions like this to at
least 50 other language newsgroups.  For example, you are not giving
Ruby users a fair chance to compare their language to Lisp, Java, and
Python.  Also, you missed Fortran!  The guiding principle should be to
choose a wide range of languages, the more disparate the better.

OTOH, I applaud the lack of specificity.  Lesser minds would have
asked about a specific Lisp dialect, such as CL.  Such things should
be avoided, as they focus the discussion unnecessarily.

Cheers,

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


Re: Which is the best implementation of LISP family of languages for real world programming ?

2010-06-11 Thread Espen Vestre
p...@informatimago.com (Pascal J. Bourguignon) writes:

> What applets?  Have you ever seen a java applet?  Last time I saw one
> it must have been fifteen years ago.

I see one each time I log into my internet banking
service. Unfortunately.
-- 
  (espen)
-- 
http://mail.python.org/mailman/listinfo/python-list


passing environment variable path to open command

2010-06-11 Thread Mahmood Naderan
Hi,
I am new to python so my question may be very basic.
Suppose I have a file (sc_1.sh) which the path to that file is in system path:
SOMETHING=/home/mahmood/scripts
 
Now I want to open that file with respect to the environment variable:
   import os
   env = os.getenv("SOMETHING")
   print env
   infile = open("env/sc_1.sh","r")
 
But here is the error I get:
/home/mahmood/scripts
Traceback (most recent call last):
  File "test.py", line 7, in 
    infile = open("env/sc_1.sh","r")
IOError: [Errno 2] No such file or directory: 'env/sc_1.sh'
 
How can I use such variable in open file command?
Thanks,
 
// Naderan *Mahmood;


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


Re: Decimal problem

2010-06-11 Thread durumdara
On jún. 10, 23:01, Mark Dickinson  wrote:
> On Jun 10, 8:45 pm, durumdara  wrote:
>
> > ne 91, in fixed_conv_out_precise
> >     from decimal import Decimal
> > ImportError: cannot import name Decimal
>
> Is it possible that you've got another file called decimal.py
> somewhere in Python's path?  What happens if you start Python manually
> and type 'from decimal import Decimal' at the prompt?
>
> --
> Mark

Hi!

A

I found the problem. But before this I destroyed my machine fully... :-
(

The problem is ACTUAL PATH. My script name was copy.py.
If I tried to start python here, and type "import decimal" the python
was crashed on.

Because decimal is uses copy and number modules. The decimal is
imported my module, not the system...

Ajja...

I need to reinstall all tools that was in this machine, because I
uninstalled/deleted everything to find the source of the problem -
what was next to my eyes... :-(

Thanks for your help:
   dd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-11 Thread Lee
On Jun 10, 10:26 am, Giampaolo Rodolà  wrote:
> 2010/6/10 Leon :
>
> > Hi, there,
> > I'm trying to read the source code of python.
> > I read around, and am kind of lost, so where to start?
>
> > Any comments are welcomed, thanks in advance.
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> If you're interested in understanding Python internals you might want
> to take a look at 
> this:http://tech.blog.aknin.name/category/my-projects/pythons-innards/
>
> --- Giampaolohttp://code.google.com/p/pyftpdlibhttp://code.google.com/p/psutil

Great stuff, which works for me very well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read source code of python?

2010-06-11 Thread Lee
On Jun 10, 7:53 am, Floris Bruynooghe 
wrote:
> On Jun 10, 8:55 am, Thomas Jollans  wrote:
>
> > On 06/10/2010 07:25 AM, Qijing Li wrote:
>
> > > Thanks for your reply.
> > > I'm trying to understand python language deeply and  use it efficiently.
> > > For example: How the operator "in" works on list? the running time is
> > > be O(n)?  if my list is sorted, what the running time would be?
>
> Taking this example, you know you want the "in" operator.  Which you
> somehow need to know is implemented by the "__contains__" protocol
> (you can find this in the "expressions" section of the "Language
> Reference").
>
> Now you can either know how objects look like in C (follow the
> "Extending and Embedding" tutorial, specifically the "Defining New
> Types" section) and therefore know you need to look at the sq_contains
> slot of the PySequenceMethods sturcture.  Or you could just locate the
> list object in Objects/listobjects.c (which you can easily find by
> looking at the source tree) and search for "contains".  Both ways
> will lead you pretty quickly to the list_contains() function in
> Objects/listobject.c.  And now you just need to know the C-API (again
> in the docs) to be able to read it (even if you don't that's a pretty
> straightforward function to read).
>
> Hope that helps
> Floris

It does help, thank you.
I think I know where to start, I found somethings I'm interested in in
listobject.c.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-11 Thread Steven W. Orr

On 6/10/2010 11:40 AM, Chris Seberino wrote:


Even if zombies are created, they will eventually get dealt with my OS
w/o any user intervention needed right?


Bad approach. Years ago I inherited a server that didn't do a proper cleanup pf 
its slaves. After a few days running, people discovered that the machine 
performance was seriously degrading. I was called in and found that there were 
around 10,000 defunct processes (not zombies).


Remember boys and girls. Neatness counts.

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUIs - A Modest Proposal

2010-06-11 Thread rantingrick
On Jun 11, 1:46 am, Mark Lawrence  wrote:

> I look forward to seeing your request on the Python bug tracker.  Not
> holding my breath.

Thanks Mark, its done! "Tkinter Litmus Test"

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


Re: sir

2010-06-11 Thread Gabriel Genellina
En Wed, 09 Jun 2010 05:03:36 -0300, madhuri vio   
escribió:



url[, data[, timeout])

in this format of passing arguments i dint understand d syntax...d comma  
is

coming immediately after the bracket...dint get it..


Those square brackets are not "real" brackets, you're not supposed to  
actually include them. They indicate an optional section, e.g., given this  
description:


FTP.connect(host[, port[, timeout]])

you may invoke the method as:

connect(host)
connect(host, port)
connect(host, port, timeout)

--
Gabriel Genellina

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