Re: Links and pointers to basics of soap and suds

2010-12-15 Thread John Nagle

On 12/15/2010 5:14 AM, Steve Holden wrote:

On 12/15/2010 7:38 AM, srinivas hn wrote:

Hi All,

I am very new to the soap and its python client suds. Can anyone tell me
how the actual will happens i nthe webservices including suds and soap API.


That's a bit like saying "I need to go around the corner. Would you mind
teaching me to drive?".

Google for phrases like "web services architecture" and "SOAP WSDL" to
get some idea of how these technologies are put together. This assumes,
of course, that you already possess a fair idea of how the web is put
together.

regards
  Steve


   The "suds" module is a quite good client for well-written SOAP
servers.  Basically, it's a system for making a remote procedure call
to a service on another machine.  The "suds" module is quite easy
to use if the service you're calling already exists, has a
correct WSDL file describing the interface, and the documentation
for users of the interface is correct.  I use it to talk to
Dun and Bradstreet's business database, for which it works quite well.

   Most simpler web services today tend to just encode queries
in the URL and send back not-too-strict XML or JSON.  This is
called a "REST" interface.

John Nagle

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


Re: O'Reilly Python Certification

2010-12-15 Thread Steve Holden
On 12/15/2010 4:21 PM, Stefan Sonnenberg-Carstens wrote:
> Am 15.12.2010 22:11, schrieb Steve Holden:
>> On 12/15/2010 3:40 PM, Tim Chase wrote:
>>> On a more serious note, it would be interesting to know if it's possible
>>> to test out of the certification for those of us that have been using
>>> Python for a long time.
>> That's an interesting idea - let a bunch of experienced Python users
>> tell me what a lousy job I have done of explaining the language. :)
>>
>> Seriously, I would be interested, and it's a terrific idea. I can't do
>> anything before January, but if anyone is interested in taking part in
>> such a review of the materials I'd be grateful if they would contact me
>> privately by email on a "no promises" basis.
>>
>> regards
>>   Steve
> I think he meant: take the test without study first.
> I'd be interested in both, though.
> 
There isn't a test. The award of the certificate is based on providing
working solutions to projects at the end of each lesson.

Bear in mind I have not spoken to my O'Reilly contacts about whether
they would be OK with such a scheme, hence the "no promises".

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: How to pop the interpreter's stack?

2010-12-15 Thread Tim Arnold
"Ethan Furman"  wrote in message 
news:mailman.4.1292379995.6505.python-l...@python.org...
> kj wrote:
>> The one thing I don't like about this strategy is that the tracebacks
>> of exceptions raised during the execution of __pre_spam include one
>> unwanted stack level (namely, the one corresponding to __pre_spam
>> itself).
>>
>> __pre_spam should be completely invisible and unobtrusive
>
> I am unaware of any way to accomplish what you desire.  I also think this 
> is one of those things that's not worth fighting -- how often are you 
> going to see such a traceback?  When somebody makes a coding mistake?  I 
> would say change the name (assuming yours was a real example) to something 
> more meaningful like _spam_arg_verifier and call it good.
>
> Alternatively, perhaps you could make a more general arg_verifier that 
> could be used for all such needs, and then your traceback would have:
>
> caller
>
> spam
>
> arg_verifier
>
> and that seems useful to me (it is, in fact, how I have mine set up).
>
> Hope this helps!
>
> ~Ethan~

I thought people would advise using a decorator for this one. Wouldn't that 
work?
thanks,
--Tim 


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


Re: Calling function from another module

2010-12-15 Thread rantingrick
On Dec 15, 6:46 pm, craf  wrote:
> Hi.
>
> The query code is as follows:
>
> --
> import Tkinter
> import tkMessageBox
>
> class App:
>     def __init__(self, master):
>         master.protocol("WM_DELETE_WINDOW",quit)
>
> def quit():
>     if tkMessageBox.askyesno('','Exit'):
>         master.quit()
>
> master =Tkinter.Tk()
> app = App(master)
> master.mainloop()
> ---
>
> As you can see, when I run and close the main window displays
> a text box asking if you want to quit, if so, closes
> application.
>
> Question:
>
> Is it possible to define the quit() function in another separate
> module?.
> I tried it, but it throws the error that the global name
> 'master' is not defined.

Please explain in detail what the "other module" is doing. And as
written this class "app" looks pretty useless to me. Why subclass Tk
(well it appears you "tried" to subclass it anyway) just to override
capabilities that are already available within Tk?

Also i see many mistakes in this very small code sample. Using my
deductive logic leads me to believe that many mistakes in a small code
sample translates to enormous mistakes in a larger code base. So feel
free to ramble incessantly about the intricate workings of this jewel
of Python scripting you are soon to drop on this malnourished group of
coders.

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


Re: Help regarding pattern matching

2010-12-15 Thread Katie T
On Thu, Dec 16, 2010 at 2:34 AM, Chris Rebert  wrote:
> On Wed, Dec 15, 2010 at 6:22 PM, Katie T  wrote:
>> On Wed, Dec 15, 2010 at 9:21 PM, jupiter  wrote:
>>> Hi People,
>>>
>>> I need some ideas on how to find pattern in random data series like stock 
>>> chart.
>>>
>>> What I want is to be able to find Head & Shoulder pattern in chart.
>>
>> Have a look at the references in:
>>
>> http://www.dpem.tuc.gr/fel/fm2009/Papers/Tsinaslanidis.pdf
>

http://uom-gr.academia.edu/ProdromosTsinaslanidis/Papers/281823/An_Examination_of_the_Head_and_Shoulders_Technical_Pattern_A_Support_of_the_Technical_Analysiss_Subjective_Nature

Katie
-- 
CoderStack
http://www.coderstack.co.uk/python-jobs
The Software Developer Job Board
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Added Python, WSGI to XAMPP

2010-12-15 Thread Gerry Reno
On 12/15/2010 07:36 PM, Ian Kelly wrote:
> On Mon, Dec 13, 2010 at 5:58 PM, Gerry Reno  wrote:
>   
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser.  The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code that is then fed to the engine
>> that then creates the view.  And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>> 
> In traditional MVC, the controller is the part that receives the user
> input, decides how to react to it, and instructs the model to update
> itself accordingly.  It is not supposed to be some sort of
> intermediary between the model and the view, as many people seem to
> make it; the view is supposed to gather the data it needs to render
> itself directly from the model.  In that light, I think that this
> quote from the Django FAQ is defensible:
>
>   
>> In our interpretation of MVC, the “view” describes the data that gets 
>> presented to the user. It’s not necessarily how the data looks, but which 
>> data is presented. The view describes which data you see, not how you see 
>> it. It’s a subtle distinction.
>> 
> Traditionally, the view would describe both of these things, but since
> "how you see it" is ultimately decided by the user's browser, they are
> fundamentally separated in the context of the web.  The Django
> template-view split is in recognition of this fact.
>
> As for where the controller went, there are basically two decisions
> that need to be made when input is received: how to update the model
> as a result, and what data should be displayed next.  The former
> decision belongs to the controller, the latter to the view.  But in a
> web app, these two things tend to be highly correlated, and there
> seems to be little reason to separate them out into distinct
> components.  This part then is both controller and view, and which
> word we use for it is not terribly important.  I suppose that "view"
> tends to prevail since there are other components, such as URL
> dispatch, that are controllerish in nature.
>
> For these reasons, I find that in practice traditional MVC does not
> lend itself well to the HTTP request/response cycle, where the "view"
> as you define it has no access to the model and lacks any continuity
> whatsoever from one request to the next; but the Django MTV approach
> works just fine once you're willing to accept that it's not the same
> thing.
>
> Cheers,
> Ian
>
>   

Django can use whatever approach they like.  But don't call it an MVC
framework and that is what they did initially at least.  MTV is a
contorted MVC.  And it does not correlate very well with other MVC
documentation which is very confusing to people.

No doubt, the web is constraining.  Request/response makes it difficult
to have the Model independently notify the View that it needs to update
itself because some state in the model has changed.  That is why many of
the diagrams about MVC on the web show the Controller interceding
between the View and the Model.  That doesn't mean MVC does not work on
the web.  It just means that there is a constraint imposed by the nature
of the request/response stateless architecture. 

Maybe it's splitting hairs, but having things named 'View' on the server
implies especially to newbies that the View exists on the server.  The
View exists on the client.  And then later they discover that it's not
really View but Controller and that Templates are View.   I guess if we
were screen-scraping we could actually have a server-side View.  But
normal MVC has the View on the client, and the Model and Controller in
server capacities.  And I don't see the value in naming things View on
the server when for the most part the View (or view parts in the case of
Ajax) are merely the output of render processes.

-Gerry




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


Re: Help regarding pattern matching

2010-12-15 Thread Chris Rebert
On Wed, Dec 15, 2010 at 6:22 PM, Katie T  wrote:
> On Wed, Dec 15, 2010 at 9:21 PM, jupiter  wrote:
>> Hi People,
>>
>> I need some ideas on how to find pattern in random data series like stock 
>> chart.
>>
>> What I want is to be able to find Head & Shoulder pattern in chart.
>
> Have a look at the references in:
>
> http://www.dpem.tuc.gr/fel/fm2009/Papers/Tsinaslanidis.pdf

Dead link!

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


Re: Help regarding pattern matching

2010-12-15 Thread Katie T
On Wed, Dec 15, 2010 at 9:21 PM, jupiter  wrote:
> Hi People,
>
>
> I need some ideas on how to find pattern in random data series like stock 
> chart.
>
>
> What I want is to be able to find Head & Shoulder pattern in chart.

Have a look at the references in:

http://www.dpem.tuc.gr/fel/fm2009/Papers/Tsinaslanidis.pdf

They cover a variety of algorithms for detecting such patterns.

Katie
-- 
CoderStack
http://www.coderstack.co.uk/python-jobs
The Software Developer Job Board
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: default argument in method

2010-12-15 Thread Hans-Peter Jansen
On Thursday 16 December 2010, 00:56:31 Steven D'Aprano wrote:
> On Wed, 15 Dec 2010 21:10:05 +0100, Hans-Peter Jansen wrote:
> > Since this is a major pitfall, it might be worth mentioning, that
> > mutable default arguments are generally a bad idea, as the default
> > arguments are evaluated just once, hence e.g. using an empty list
> > might contain the items, that were appended in earlier calls of
> > this method..
>
> It's only a pitfall for users who expect that default arguments are
> re- created every time you call the function; it's only a bad idea
> for code which relies on the default arguments being re-created each
> time.
>
> If you hold misunderstandings about the behaviour of a language,
> you'll have trouble understanding what code does. Default arguments
> are no different from any other feature.
>
> > Code, that _relies_ on such behavior should be yanked instantaneous
> > and the producer of such code should be punished with coding APL¹
> > on a dubeolsik hangul keyboard² for a year at least..
>
> Python code that relies on default arguments to *not* be re-created
> on each function call is no worse than (say) Ruby code that relies on
> default arguments *to* be re-created each time.
>
> I don't mean to be elitist (ah, who am I fooling, of course I do),
> but when coders of the skill and experience of the Effbot and Guido
> use mutable defaults, who are you to say they shouldn't?
>
> http://effbot.org/zone/default-values.htm
> http://www.python.org/doc/essays/graphs/

Hmm, thanks for the pointers, Steven. I stand corrected, as I won't 
argue with taste.. I like the part about the disastrous results 
specially. 

If such code would be used in any collaborations, I would expect an 
explicit comment at least.

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


Calling function from another module

2010-12-15 Thread craf
Hi.

The query code is as follows:

--
import Tkinter
import tkMessageBox


class App:
def __init__(self, master):
master.protocol("WM_DELETE_WINDOW",quit)


def quit():
if tkMessageBox.askyesno('','Exit'):
master.quit()


master =Tkinter.Tk()
app = App(master)
master.mainloop()
---

As you can see, when I run and close the main window displays
a text box asking if you want to quit, if so, closes
application.

Question:

Is it possible to define the quit() function in another separate
module?.
I tried it, but it throws the error that the global name
'master' is not defined.

Thanks in advance.

Regards

Cristian Abarzúa




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


Re: Added Python, WSGI to XAMPP

2010-12-15 Thread Ian Kelly
On Mon, Dec 13, 2010 at 5:58 PM, Gerry Reno  wrote:
> The VIEW is the bits that stream out of the webserver back to the users
> browser.  The CONTROLLER is the code that gathers all the pieces from
> the model and constructs the python code that is then fed to the engine
> that then creates the view.  And just because the controller navigates
> the logic to dynamically contruct/render a view, that does not make 'it'
> the view.

In traditional MVC, the controller is the part that receives the user
input, decides how to react to it, and instructs the model to update
itself accordingly.  It is not supposed to be some sort of
intermediary between the model and the view, as many people seem to
make it; the view is supposed to gather the data it needs to render
itself directly from the model.  In that light, I think that this
quote from the Django FAQ is defensible:

> In our interpretation of MVC, the “view” describes the data that gets 
> presented to the user. It’s not necessarily how the data looks, but which 
> data is presented. The view describes which data you see, not how you see it. 
> It’s a subtle distinction.

Traditionally, the view would describe both of these things, but since
"how you see it" is ultimately decided by the user's browser, they are
fundamentally separated in the context of the web.  The Django
template-view split is in recognition of this fact.

As for where the controller went, there are basically two decisions
that need to be made when input is received: how to update the model
as a result, and what data should be displayed next.  The former
decision belongs to the controller, the latter to the view.  But in a
web app, these two things tend to be highly correlated, and there
seems to be little reason to separate them out into distinct
components.  This part then is both controller and view, and which
word we use for it is not terribly important.  I suppose that "view"
tends to prevail since there are other components, such as URL
dispatch, that are controllerish in nature.

For these reasons, I find that in practice traditional MVC does not
lend itself well to the HTTP request/response cycle, where the "view"
as you define it has no access to the model and lacks any continuity
whatsoever from one request to the next; but the Django MTV approach
works just fine once you're willing to accept that it's not the same
thing.

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


Re: default argument in method

2010-12-15 Thread Steven D'Aprano
On Wed, 15 Dec 2010 21:10:05 +0100, Hans-Peter Jansen wrote:

> Since this is a major pitfall, it might be worth mentioning, that
> mutable default arguments are generally a bad idea, as the default
> arguments are evaluated just once, hence e.g. using an empty list might
> contain the items, that were appended in earlier calls of this method..

It's only a pitfall for users who expect that default arguments are re-
created every time you call the function; it's only a bad idea for code 
which relies on the default arguments being re-created each time.

If you hold misunderstandings about the behaviour of a language, you'll 
have trouble understanding what code does. Default arguments are no 
different from any other feature.



> Code, that _relies_ on such behavior should be yanked instantaneous and
> the producer of such code should be punished with coding APL¹ on a
> dubeolsik hangul keyboard² for a year at least..

Python code that relies on default arguments to *not* be re-created on 
each function call is no worse than (say) Ruby code that relies on 
default arguments *to* be re-created each time.

I don't mean to be elitist (ah, who am I fooling, of course I do), but 
when coders of the skill and experience of the Effbot and Guido use 
mutable defaults, who are you to say they shouldn't?

http://effbot.org/zone/default-values.htm
http://www.python.org/doc/essays/graphs/



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


Pyramid and MVC (split from: Re: Added Python, WSGI to XAMPP)

2010-12-15 Thread Gerry Reno
On 12/15/2010 05:03 PM, Chris Withers wrote:
> On 14/12/2010 00:58, Gerry Reno wrote:
>> What I really don't like right off is that Pyramid is contorting the MVC
>> model
>
> That specific pattern, I'm afraid, is a little antiquated nowadays,
> particularly when it comes to web apps...
>
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser.
>
> Yep, and in Pyramid I guess this would be the template renderer, which
> is usually a decorator on the view function or class. The view's job
> is to process a request and turn it into a response dictionary. That
> sounds a lot like your controller to me ;-)
>
>> The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code
>
> Slightly scared as to what "constructed the python code" might mean :-S
>
>> that is then fed to the engine
>> that then creates the view.  And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>
> Well, for me, the MVC isn't really what happens anymore, here's my take:
>
> - the model nowadays has all the "business logic" in it, rather than
> just the data. The model is now a collection of objects that can be
> interacted on through many/any UIs needed, some of which may be web apps.
>
> - web apps are *always* a collection of request/response transactions.
> As such, the "control" layer does just become a "view" that does that.
>
> - singleton objects and other stuff that used to live in a "control"
> are now factored out into utilities and services (of which
> zope.component provides a pretty good abstraction, and doesn't really
> have anything to do with Zope, other than the fact that Zope makes use
> of it).
>
> Welcome to the 2nd decade in the new millenium ;-)
>
> Chris
>


It doesn't matter whether you are building a desktop app or a webapp. 
MVC still applies.  And that includes when things like Ajax are added to
the mix because Ajax just performs a mini-MVC transaction.  The problems
arise when people start rigidly thinking that M only meant database.  M
means model, model means any source that emits data.  A database,
another webapp, whatever, that is M.  The view as I said before is just
the bits streaming out of the webserver back to the client device. 
There should be NOTHING on the server call view-anything.  The view only
exists on the clients.  The view is the result of what the
controllers(servers) in conjunction with renderers emit as their work
product.

-Gerry


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


Re: Added Python, WSGI to XAMPP

2010-12-15 Thread Chris Withers

On 14/12/2010 00:58, Gerry Reno wrote:

What I really don't like right off is that Pyramid is contorting the MVC
model


That specific pattern, I'm afraid, is a little antiquated nowadays, 
particularly when it comes to web apps...



The VIEW is the bits that stream out of the webserver back to the users
browser.


Yep, and in Pyramid I guess this would be the template renderer, which 
is usually a decorator on the view function or class. The view's job is 
to process a request and turn it into a response dictionary. That sounds 
a lot like your controller to me ;-)



The CONTROLLER is the code that gathers all the pieces from
the model and constructs the python code


Slightly scared as to what "constructed the python code" might mean :-S


that is then fed to the engine
that then creates the view.  And just because the controller navigates
the logic to dynamically contruct/render a view, that does not make 'it'
the view.


Well, for me, the MVC isn't really what happens anymore, here's my take:

- the model nowadays has all the "business logic" in it, rather than 
just the data. The model is now a collection of objects that can be 
interacted on through many/any UIs needed, some of which may be web apps.


- web apps are *always* a collection of request/response transactions. 
As such, the "control" layer does just become a "view" that does that.


- singleton objects and other stuff that used to live in a "control" are 
now factored out into utilities and services (of which zope.component 
provides a pretty good abstraction, and doesn't really have anything to 
do with Zope, other than the fact that Zope makes use of it).


Welcome to the 2nd decade in the new millenium ;-)

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: O'Reilly Python Certification

2010-12-15 Thread Tim Chase

On 12/15/2010 03:11 PM, Steve Holden wrote:

On 12/15/2010 3:40 PM, Tim Chase wrote:

On a more serious note, it would be interesting to know if it's possible
to test out of the certification for those of us that have been using
Python for a long time.


That's an interesting idea - let a bunch of experienced Python users
tell me what a lousy job I have done of explaining the language. :)


Actually Stephan read what I intended -- a way to take the final 
test (and receive the cert) without belaboring the taker or you 
with the actual course-work.  I did that with several classes 
back in college where I needed a prereq. for a class but was able 
to ace the final for that prereq to show the prof(s) that I knew 
the material.  Saved me a semester-long class in each case, and 
saved the professor the time spent grading my stuff.


That said, having peer-review of your course material can (well, 
*should*) only improve it.


-tkc





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


Re: Proposed changes to logging defaults

2010-12-15 Thread Gregory Ewing

Terry Reedy wrote:

On 12/15/2010 3:46 AM, John Nagle wrote:


You're assuming that the logging package has the right to blither
on the default sys.stderr.


The Python stdlib *already* assumes that it can write to stderr.


Also ISTM that any program relying on nothing it calls ever
writing to stderr would be rather fragile.

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


Help influence which tutorials are given at PyCon 2011

2010-12-15 Thread VanL
PyCon is made up of a number of different parts, each with its own 
goals. For the talks presented during the conference portion of PyCon, 
we go for both breadth and quality. There are enough different sessions 
and different tracks that each person can customize their PyCon 
experience according to their interests.


For tutorials, the goal is slightly different. We want to present 
tutorials that help developers deal effectively with their most common 
day-to-day challenges.


We categorized the various tutorial proposals into a number of broad 
buckets. You can vote on which topics you would like to see at PyCon 
2011! We will take this information into account when deciding which 
tutorials will be presented.


You can view the poll at .

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


Help regarding pattern matching

2010-12-15 Thread jupiter
Hi People,


I need some ideas on how to find pattern in random data series like stock 
chart. 


What I want is to be able to find Head & Shoulder pattern in chart.


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


Re: O'Reilly Python Certification

2010-12-15 Thread Stefan Sonnenberg-Carstens

Am 15.12.2010 22:11, schrieb Steve Holden:

On 12/15/2010 3:40 PM, Tim Chase wrote:

On a more serious note, it would be interesting to know if it's possible
to test out of the certification for those of us that have been using
Python for a long time.

That's an interesting idea - let a bunch of experienced Python users
tell me what a lousy job I have done of explaining the language. :)

Seriously, I would be interested, and it's a terrific idea. I can't do
anything before January, but if anyone is interested in taking part in
such a review of the materials I'd be grateful if they would contact me
privately by email on a "no promises" basis.

regards
  Steve

I think he meant: take the test without study first.
I'd be interested in both, though.

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


Re: O'Reilly Python Certification

2010-12-15 Thread Steve Holden
On 12/15/2010 3:40 PM, Tim Chase wrote:
> On a more serious note, it would be interesting to know if it's possible
> to test out of the certification for those of us that have been using
> Python for a long time.

That's an interesting idea - let a bunch of experienced Python users
tell me what a lousy job I have done of explaining the language. :)

Seriously, I would be interested, and it's a terrific idea. I can't do
anything before January, but if anyone is interested in taking part in
such a review of the materials I'd be grateful if they would contact me
privately by email on a "no promises" basis.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: O'Reilly Python Certification

2010-12-15 Thread Tim Chase

On 12/15/2010 11:54 AM, Ethan Furman wrote:

So I just got an e-mail from O'Reilly and their School of Technology
about a Python Certification course...  anybody have any experience with
this?

It also says Steve Holden is involved -- is this True?


you should just test for the truthiness without comparing to True:

  if is_involved(steve_holden):
your_code()

rather than asking

  if is_involved(steve_holden) is True:
your_code()

;-)

On a more serious note, it would be interesting to know if it's 
possible to test out of the certification for those of us that 
have been using Python for a long time.


-tkc





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


Re: default argument in method

2010-12-15 Thread Hans-Peter Jansen
On Monday 13 December 2010, 18:14:27 Godson Gera wrote:
> On Sun, Dec 12, 2010 at 5:05 PM, ernest  wrote:
> > Hi,
> >
> > I'd like to have a reference to an instance attribute as
> > default argument in a method. It doesn't work because
> > "self" is not defined at the time the method signature is
> > evaluated. For example:
> >
> > class C(object):
> >def __init__(self):
> >self.foo = 5
> >def m(self, val=self.foo):
> >return val
> >
> > Raises NameError because 'self' is not defined.
>
> You can defined foo outside the __init__ and can access it inside
> methods using self.foo
>
> class C(object):
>  foo=5
>  def __init__(self):
>   print self.foo
>  def m(self,val=foo):
>   return val
>
> class attributes can be accessed with out self before them in method
> signatures. However, becareful if you change the value of foo inside
> any method, the method signature will still hold on to old value.

Since this is a major pitfall, it might be worth mentioning, that  
mutable default arguments are generally a bad idea, as the default 
arguments are evaluated just once, hence e.g. using an empty list might 
contain the items, that were appended in earlier calls of this method..

Code, that _relies_ on such behavior should be yanked instantaneous and 
the producer of such code should be punished with coding APL¹ on a  
dubeolsik hangul keyboard² for a year at least..

Pete

¹) Not, that APL is a bad language per se, but even one liners tend to
   be rather cryptic for usual brains. Let's say it with Dijkstra: 
   "APL is a mistake, carried out through perfection..."
   but given the second constraint, it's going to be a, hmm, challenge.
   http://en.wikipedia.org/wiki/APL_(programming_language)
²) http://en.wikipedia.org/wiki/Keyboard_layout#Dubeolsik
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sage's Python

2010-12-15 Thread Akand Islam
On Dec 14, 1:51 pm, Emile van Sebille  wrote:
> On 12/14/2010 10:27 AM Akand Islam said...
>
> > On Dec 13, 4:33 pm, "Rhodri James"
> > wrote:
> >> On Fri, 10 Dec 2010 17:11:55 -, Akand Islam  wrote:
> >>> In my system (Ubuntu 10.04) there are sage-4.6, python 2.6.5, tk8.5-
> >>> dev installed. When I give command from terminal "sage -f
> >>> python-2.6.5.p8" to get sage's python it shows following message:
>
> >>>   No command 'sage' found, did you mean:
>
> This means that no sage command was found on your path.  Check to be
> sure that ~/Desktop is in your path.
>
> Emile

Thanks Emile.

-- Akand.

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


Re: O'Reilly Python Certification

2010-12-15 Thread Steve Holden
On 12/15/2010 12:54 PM, Ethan Furman wrote:
> So I just got an e-mail from O'Reilly and their School of Technology
> about a Python Certification course...  anybody have any experience with
> this?
> 
> It also says Steve Holden is involved -- is this True?  (Steve?)
> 
Well, it's not not not False. You think O'Reilly would publish lies on
their web site? :-)

I am a little more that involved. In ham and eggs the chicken is
involved. I am committed, like the pig, having got three of the four
classes into production after almost two years' work. So for those of
you who may have wondered why I have been on c.l.py only sporadically
lately, now you know.

The certificate will come from the University of Illinois after
approximately 160 hours of study. By the end of the series you should
have a substantial corpus of Python code that you have typed in
yourself, understand and can discuss with potential employers and
others. You will have a fair knowledge of Python and you will be
accustomed to test-driven development.

> ~Ethan~
> 
> PS
> 
> Can you tell I've been programming?  ;)

I would really like to hear from anyone who takes the class. I would
like to ensure that it is kept up to date and relevant with continuous
improvements, and feedback will be invaluable in helping me to achieve
this goal.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


O'Reilly Python Certification

2010-12-15 Thread Ethan Furman
So I just got an e-mail from O'Reilly and their School of Technology 
about a Python Certification course...  anybody have any experience with 
this?


It also says Steve Holden is involved -- is this True?  (Steve?)

~Ethan~

PS

Can you tell I've been programming?  ;)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with pywin32 on Linux

2010-12-15 Thread Stefan Sonnenberg-Carstens

Am 15.12.2010 13:58, schrieb Benedict Verheyen:

Hi,


I'm moving my development environment (python, Django, virtualenv) from Windows
to Linux (Debian more specific). However, on one app (uses Django), i have a 
log on
module that uses AD to authenticate users.
It's based on the active_directory wrapper of Tim Golden.
That needs the win32 module but installation of pywin32 fails on importing:

import _winreg
ImportError: No module named _winreg

Kind of logical in hindsight :)

However, this makes programming and testing under Linux a bit of a pain if 
you're
dealing with Windows specific stuff.
What is the correct way to proceed (i want to keep my development environment 
in Linux)?

I could adjust my software modules to use the Linux counterparts of the AD 
functions
that i have to authenticate.
Or is there another way to deal with this?

Thanks for any insight,

Cheers,
Benedict


Just change to LDAP as authentication method.
Even Active Directory offers LDAP (w/o SSL), and there
are modules to interact with LDAP using python.
And, it is platform indipendent.

See here: http://www.python-ldap.org/

I've done this quite often to auth users in an AD with apache/ldap-auth.
--
http://mail.python.org/mailman/listinfo/python-list


New OpenOpt/FuncDesigner release 0.32

2010-12-15 Thread dmitrey
Hi all,
I'm glad to inform you about new quarterly OpenOpt/FuncDesigner
release (0.32):

OpenOpt:
* New class: LCP (and related solver)
* New QP solver: qlcp
* New NLP solver: sqlcp
* New large-scale NSP (nonsmooth) solver gsubg. Currently it still
requires lots of improvements (especially for constraints - their
handling is very premature yet and often fails), but since the solver
sometimes already works better than ipopt, algencan and other
competitors it was tried with, I decided to include the one into the
release.
* Now SOCP can handle Ax <= b constraints (and bugfix for handling lb
<= x <= ub has been committed)
* Some other fixes and improvements

FuncDesigner:
* Add new function removeAttachedConstraints
* Add new oofuns min and max (their capabilities are quite restricted
yet)
* Systems of nonlinear equations: possibility to assign personal
tolerance for an equation
* Some fixes and improvements

For more details see our forum entry
http://forum.openopt.org/viewtopic.php?id=325

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


Re: Proposed changes to logging defaults

2010-12-15 Thread Terry Reedy

On 12/15/2010 3:46 AM, John Nagle wrote:


You're assuming that the logging package has the right to blither
on the default sys.stderr.


The Python stdlib *already* assumes that it can write to stderr. Using 
logging instead will make it easier for app writers to do something else.


--
Terry Jan Reedy

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


Re: Dealing with pywin32 on Linux

2010-12-15 Thread Benedict Verheyen
On 15/12/2010 15:17, Steve Holden wrote:

>>
>> Hi,
>>
>> thanks for your answer.
>> For the moment, i only need to connect to AD to authenticate.
>> But you raise a good point that if I need more functionality, I will 
>> encounter problems.
>>
> Benedict:
> 
> Have you considered running a virtual Windows machine to handle the
> specific issues that really require a Windows environment? If the
> loading isn't at brutal levels VirtualBox is a very adequate solution,
> and of course Python user VMWare has a full range of industrial-grade
> solutions for virtualization.
> 
> regards
>  Steve

Hi Steve,

good suggestion. I use VirtualBox for other needs so it's not a lot of hassle 
to set one up.
Thanks !

Regards,
Benedict


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


Re: while True or while 1

2010-12-15 Thread Steve Holden
On 12/15/2010 8:10 AM, Hans-Peter Jansen wrote:
> On Tuesday 14 December 2010, 21:38:47 Arnaud Delobelle wrote:
>> Christian Heimes  writes:
>> [...]
>>
>>> Tres Seavers once told me a joke like this:
>>>
>>>True = not not "Who's at the door?" # say it out loud!
>>>
>>> This was back in the old days of Zope 2.5 and Python 2.1, which
>>> didn't have True and False.
>>
>> I almost used:
>>
>> True = "to be" or not "to be" # that is the question
> 
> That's wrong:
> 
 "to be" or not "to be"
> 'to be'
> 
> You need to wrap it with bool() at least (even without interpreting 
> Pythons answer to the duality contradiction of consciousness for 
> now ;-))
> 
>> but didn't dare!
> 
Yeah, if Hamlet had been a Python programmer that play would have been a
light comedy.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: Dealing with pywin32 on Linux

2010-12-15 Thread Steve Holden
On 12/15/2010 8:51 AM, Benedict Verheyen wrote:
> On 15/12/2010 14:37, Tim Golden wrote:
> 
>> Well I'm not sure how far something like WINE would take you,
>> but I suggest that trying to develop Windows-specific code in
>> a Linux Dev environment is creating a rod for your own back.
>>
>> For the specific case you mention, you should be able to switch,
>> lock, stock & barrel to python-ldap or other LDAP modules. But
>> that means a fairly major rewrite, plus that's only one issue.
>> None of the Windows-specific stuff will work: registry, win32api
>> calls, whatever you're pulling out of the pywin32 packages.
>>
>> TJG
> 
> Hi,
> 
> thanks for your answer.
> For the moment, i only need to connect to AD to authenticate.
> But you raise a good point that if I need more functionality, I will 
> encounter problems.
> 
Benedict:

Have you considered running a virtual Windows machine to handle the
specific issues that really require a Windows environment? If the
loading isn't at brutal levels VirtualBox is a very adequate solution,
and of course Python user VMWare has a full range of industrial-grade
solutions for virtualization.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: Dealing with pywin32 on Linux

2010-12-15 Thread Benedict Verheyen
On 15/12/2010 14:37, Tim Golden wrote:

> Well I'm not sure how far something like WINE would take you,
> but I suggest that trying to develop Windows-specific code in
> a Linux Dev environment is creating a rod for your own back.
> 
> For the specific case you mention, you should be able to switch,
> lock, stock & barrel to python-ldap or other LDAP modules. But
> that means a fairly major rewrite, plus that's only one issue.
> None of the Windows-specific stuff will work: registry, win32api
> calls, whatever you're pulling out of the pywin32 packages.
> 
> TJG

Hi,

thanks for your answer.
For the moment, i only need to connect to AD to authenticate.
But you raise a good point that if I need more functionality, I will encounter 
problems.

Regards,
Benedict

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


Re: Encoding trouble

2010-12-15 Thread Romaric DEFAUX



Le 15/12/2010 14:16, Benedict Verheyen a écrit :

On 15/12/2010 12:34, Romaric DEFAUX wrote:


To create these query, I do this :
query = "UPDATE website SET client_name='%s' WHERE ip='%s'" % 
(self.client_name, self.ip)
then self.cursor.execute(query)


Unicode can be tricky.
Don't you have to encode the string again?
I tested this in the interpreter:

a = ("UPDATE website SET client_name='%s'" % "Romariqué 
Admin").decode("iso-8859-15")

print "Query %s " % a.encode("iso-8859-15")
produces UPDATE website SET client_name='Romariqué Admin'

So i would try to encode the query before issuing the self.cursor.execute(query)

Cheers,
Benedict


Thanks for your answer :)

I finally found the solution, I removed the following line from my db 
connection :

#   con.cursor().execute('SET NAMES \'utf8\';')
#   con.cursor().execute('SET CHARACTER SET utf8;')
#   con.cursor().execute('SET character_set_connection=utf8;')

And now it's working fine !

Thanks for your help !

Romaric



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with pywin32 on Linux

2010-12-15 Thread Tim Golden

On 15/12/2010 12:58, Benedict Verheyen wrote:

I'm moving my development environment (python, Django, virtualenv) from Windows
to Linux (Debian more specific). However, on one app (uses Django), i have a 
log on
module that uses AD to authenticate users.
It's based on the active_directory wrapper of Tim Golden.
That needs the win32 module but installation of pywin32 fails on importing:

import _winreg
ImportError: No module named _winreg

Kind of logical in hindsight :)

However, this makes programming and testing under Linux a bit of a pain if 
you're
dealing with Windows specific stuff.
What is the correct way to proceed (i want to keep my development environment 
in Linux)?

I could adjust my software modules to use the Linux counterparts of the AD 
functions
that i have to authenticate.
Or is there another way to deal with this?


Well I'm not sure how far something like WINE would take you,
but I suggest that trying to develop Windows-specific code in
a Linux Dev environment is creating a rod for your own back.

For the specific case you mention, you should be able to switch,
lock, stock & barrel to python-ldap or other LDAP modules. But
that means a fairly major rewrite, plus that's only one issue.
None of the Windows-specific stuff will work: registry, win32api
calls, whatever you're pulling out of the pywin32 packages.

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


Re: Encoding trouble

2010-12-15 Thread Benedict Verheyen
On 15/12/2010 12:34, Romaric DEFAUX wrote:

> To create these query, I do this :
> query = "UPDATE website SET client_name='%s' WHERE ip='%s'" % 
> (self.client_name, self.ip)
> then self.cursor.execute(query)
> 

Unicode can be tricky.
Don't you have to encode the string again?
I tested this in the interpreter:

a = ("UPDATE website SET client_name='%s'" % "Romariqué 
Admin").decode("iso-8859-15")

print "Query %s " % a.encode("iso-8859-15")
produces UPDATE website SET client_name='Romariqué Admin'

So i would try to encode the query before issuing the self.cursor.execute(query)

Cheers,
Benedict

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


Re: Links and pointers to basics of soap and suds

2010-12-15 Thread Steve Holden
On 12/15/2010 7:38 AM, srinivas hn wrote:
> Hi All,
> 
> I am very new to the soap and its python client suds.Can anyone tell me
> how the actual will happens i nthe webservices including suds and soap API.
> 
That's a bit like saying "I need to go around the corner. Would you mind
teaching me to drive?".

Google for phrases like "web services architecture" and "SOAP WSDL" to
get some idea of how these technologies are put together. This assumes,
of course, that you already possess a fair idea of how the web is put
together.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: while True or while 1

2010-12-15 Thread Hans-Peter Jansen
On Tuesday 14 December 2010, 21:38:47 Arnaud Delobelle wrote:
> Christian Heimes  writes:
> [...]
>
> > Tres Seavers once told me a joke like this:
> >
> >True = not not "Who's at the door?" # say it out loud!
> >
> > This was back in the old days of Zope 2.5 and Python 2.1, which
> > didn't have True and False.
>
> I almost used:
>
> True = "to be" or not "to be" # that is the question

That's wrong:

>>> "to be" or not "to be"
'to be'

You need to wrap it with bool() at least (even without interpreting 
Pythons answer to the duality contradiction of consciousness for 
now ;-))

> but didn't dare!

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


Re: Proposed changes to logging defaults

2010-12-15 Thread Steve Holden
On 12/15/2010 5:03 AM, Vinay Sajip wrote:
> On Dec 15, 8:46 am, John Nagle  wrote:
>> You're assuming that theloggingpackage has the right to blither
>> on the default sys.stderr.  There are many cases in which it
>> should not.  The program could be running in a web server, and
>> output would end up in the output HTML.  The program could be
>> running as a subprocess, and the output could end up in the
>> pipe back to the the parent.  "sys.stderr" might be connected
>> to a dead pipe, and writing to it would then kill the program.
>>
>> So this change could break existing programs in subtle ways.
> 
> I'm not assuming anything, and the rationale for the change is
> described in detail in the linked-to post. The reason for posting the
> link on this list is to give people advance warning of the changes, so
> they can see if they're affected and take the appropriate action.
> 
> Note that since this change only affects the user who is using Python
> 3.2 and has not configured logging. Since the necessary configuration
> is easy to do, I'm assuming people who might be affected can easily
> update their code in time for the 3.2 release.
> 
I might add that any web server that sends sys.stderr to the HTTP output
stream is not likely to be professionally managed. It's far preferable,
in the general case, to ensure that logging messages do not enter the
stdout-stdin pipelines carrying information between coordinating processes.

If a current task is assuming the prior logging package's behavior and
analysing a process's stdout for messages it arguably needs fixing
anyway, though I agree that breakage of any kind is unfortunate.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Links and pointers to basics of soap and suds

2010-12-15 Thread srinivas hn
Hi All,

I am very new to the soap and its python client suds.Can anyone tell me how
the actual will happens i nthe webservices including suds and soap API.


Thanks in advance


CHEERS
CNA
9986229891
-- 
http://mail.python.org/mailman/listinfo/python-list


Dealing with pywin32 on Linux

2010-12-15 Thread Benedict Verheyen
Hi,


I'm moving my development environment (python, Django, virtualenv) from Windows
to Linux (Debian more specific). However, on one app (uses Django), i have a 
log on
module that uses AD to authenticate users.
It's based on the active_directory wrapper of Tim Golden.
That needs the win32 module but installation of pywin32 fails on importing:

import _winreg
ImportError: No module named _winreg

Kind of logical in hindsight :)

However, this makes programming and testing under Linux a bit of a pain if 
you're
dealing with Windows specific stuff.
What is the correct way to proceed (i want to keep my development environment 
in Linux)?

I could adjust my software modules to use the Linux counterparts of the AD 
functions
that i have to authenticate.
Or is there another way to deal with this?

Thanks for any insight,

Cheers,
Benedict

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


Re: Tkinter polling example: file copy with progress bar

2010-12-15 Thread Steve Holden
On 12/14/2010 11:52 PM, JohnWShipman wrote:
> you
> know how us ancient Unix weenies are.

Indeed we do ... ;-)

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Encoding trouble

2010-12-15 Thread Romaric DEFAUX

Hi all,


Since yesterday I'm working on an encoding problem, I become crazy now :)
Could you please help me ?

Here's the description of the problem :

I've got two table in a MysqlDB :
history_website and website
The important column in them are :
history_website.message (varchar(255), encoding = utf8_general_ci)
website.client_name (varchar(255), encoding = utf8_general_ci)

Why :
1° ) INSERT INTO history_website (time, ip, servername, message) VALUES 
('1292411324.22', '192.168.2.15', 'system_server_test.audaxis.com', 
'client_name UPDATED from Romariqu to Romariqué Admin\n')

is working perfectly when
2°) UPDATE website SET client_name='Romariqué Admin\n' WHERE 
ip='192.168.2.15'

is producing error :
Warning: Incorrect string value: '\xE9 Admi...' for column 'client_name' 
at row 1 ???


To create these query, I do this :
query = "UPDATE website SET client_name='%s' WHERE ip='%s'" % 
(self.client_name, self.ip)

then self.cursor.execute(query)

query = "INSERT INTO history_website (time, ip, servername, message) 
VALUES ('%s', '%s', '%s', '%s')" % (now, self.ip, self.servername, message)"
where message = "client_name UPDATED from %s to %s" % 
(old_website.client_name, self.client_name)


They're both string :
type(message) = 
type(client_name) = 

My default encoding is sys.setdefaultencoding('utf-8')

In my opinion, it should not work for both or work for both, no ? This 
is strange that it's working only for one...


Romaric



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to pop the interpreter's stack?

2010-12-15 Thread Steven D'Aprano
On Tue, 14 Dec 2010 21:14:35 +, kj wrote:

> Consider this code:
> 
> 
> def spam(*args, **kwargs):
> args, kwargs = __pre_spam(*args, **kwargs)
> 
> # args & kwargs are OK: proceed
> # ...
> 
> 
> def __pre_spam(*args, **kwargs):
> # validate args & kwargs;
> # return canonicalized versions of args & kwargs; # on failure,
> raise some *informative* exception # ...
> return canonicalized_args, canonicalized_kwargs

Double leading underscores don't have any special meaning in the global 
scope. Save yourself an underscore and call it _pre_spam instead :)

In fact, even if spam and __pre_spam are methods, it's probably a good 
idea to avoid the double-underscore name mangling. It's usually more 
trouble than it's worth.


> I write functions like __pre_spam for one reason only: to remove clutter
> from a corresponding spam function that has a particularly complex
> argument-validation/canonicalization stage.  In effect, spam
> "outsources" to __pre_spam the messy business of checking and
> conditioning its arguments.

A perfectly sensible arrangement.


> The one thing I don't like about this strategy is that the tracebacks of
> exceptions raised during the execution of __pre_spam include one
> unwanted stack level (namely, the one corresponding to __pre_spam
> itself).

But why is it unwanted? The traceback shows where the error occurs -- it 
occurs in __pre_spam, not spam, or __post_spam, or spam_caller, or 
anywhere else. Even if it's possible, having the traceback *lie* about 
where it occurs is a bad idea which will cause confusion to anyone trying 
to maintain the software in the future.

I can't think of any way to do it, but frankly I haven't thought too hard 
about it. I'm glad I can't think of any way of doing it, because the 
thought of having tracebacks lie about where they come from gives me the 
shivers. Imagine debugging when you've edited the source but are still 
running the old version, and now the reported line numbers don't match up 
with the source file -- it would be like that, only worse.



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


Re: Proposed changes to logging defaults

2010-12-15 Thread Vinay Sajip
On Dec 15, 8:46 am, John Nagle  wrote:
>     You're assuming that theloggingpackage has the right to blither
> on the default sys.stderr.  There are many cases in which it
> should not.  The program could be running in a web server, and
> output would end up in the output HTML.  The program could be
> running as a subprocess, and the output could end up in the
> pipe back to the the parent.  "sys.stderr" might be connected
> to a dead pipe, and writing to it would then kill the program.
>
>     So this change could break existing programs in subtle ways.

I'm not assuming anything, and the rationale for the change is
described in detail in the linked-to post. The reason for posting the
link on this list is to give people advance warning of the changes, so
they can see if they're affected and take the appropriate action.

Note that since this change only affects the user who is using Python
3.2 and has not configured logging. Since the necessary configuration
is easy to do, I'm assuming people who might be affected can easily
update their code in time for the 3.2 release.

Regards,

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


Re: while True or while 1

2010-12-15 Thread bruno.desthuilli...@gmail.com
On 14 déc, 21:38, Arnaud Delobelle  wrote:
> I almost used:
>
>     True = "to be" or not "to be" # that is the question

KEYBOARD !-)

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


Re: PyArg_ParseTuple question

2010-12-15 Thread Stefan Behnel

Mark Wooding, 14.12.2010 21:42:

I could have used PySequence_* functions to read the size and items, but
that makes error handling more complicated.  One could also borrow the
references from the underlying list, which would leave the underlying
storage for the vector as the only thing to free.

I ended up writing a lot of conversion functions when I was doing Python
library bindings (for a crypto library); they're generally a good thing.
I found that the trickiest thing about PyArg_ParseTuple is in making
sure that you can clean everything up even if it goes wrong half way
through.


I think it's worth mentioning here that the Cython compiler generates 
tightly tailored code for argument unpacking and type conversion. So unless 
you really want (or need) to write your code directly against Python's 
C-API, Cython will do a substantially better job with much less coding. 
Even if you have already written a major part of your code in C, it's worth 
considering to (re-)write the Python API wrapper parts in Cython if you 
need better performance.


Stefan

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


Re: Proposed changes to logging defaults

2010-12-15 Thread John Nagle

On 12/9/2010 4:12 PM, Vinay Sajip wrote:

Some changes are being proposed to how logging works in default
configurations.

Briefly - when a logging event occurs which needs to be output to some
log, the behaviour of the logging package when no explicit logging
configuration is provided will change, most likely to log those events
to sys.stderr with a default format.


   Bad idea.

   You're assuming that the logging package has the right to blither
on the default sys.stderr.  There are many cases in which it
should not.  The program could be running in a web server, and
output would end up in the output HTML.  The program could be
running as a subprocess, and the output could end up in the
pipe back to the the parent.  "sys.stderr" might be connected
to a dead pipe, and writing to it would then kill the program.

   So this change could break existing programs in subtle ways.

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


Re: Proposed changes to logging defaults

2010-12-15 Thread Vinay Sajip
On Dec 15, 3:51 am, samwyse  wrote:

> I'm in favor of this change.  I've long wished that I could just add
> lots of warning/error/infologgingto a script and have it just work
> without having to spend time configuring theloggingsystem.

Note that INFO logging will still not be sent to sys.stderr. Only
events of severity WARNING and above will be logged to sys.stderr. If
you need INFO logging as well, it's easy enough to configure for a
simple script (to get the same effect):

basicConfig(level=logging.INFO, format='%(message)s') # or whatever
level/format you need

So I'm not sure how much time you really have to spend on configuring
logging.

Regards,

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