Your Favorite Python Book

2009-05-11 Thread Sam Tregar
Greetings.  I'm working on learning Python and I'm looking for good books to
read.  I'm almost done with Dive into Python and I liked it a lot. I found
Programming Python a little dry the last time I looked at it, but I'm more
motivated now so I might return to it.  What's your favorite?  Why?

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


Re: New to python, can i ask for a little help?

2009-05-12 Thread Sam Tregar
On Wed, May 13, 2009 at 12:18 AM, warhammer1...@gmail.com <
warhammer1...@gmail.com> wrote:

> Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
> >>> print "hello world!"
> SyntaxError: invalid syntax (, line 1)
> >>>
>
> Can anyone tell me what is wrong? I didnt expect that error
>

Try:

  print("hello world!")

I believe Python 3 requires parenthesis for print.  Someone else can explain
why perhaps.

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


Re: Your Favorite Python Book

2009-05-15 Thread Sam Tregar
Thanks for the suggestions everyone!  I've got a copy of Core Python 2nd
Edition on the way.

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


Difference between list() and [] with dictionaries

2009-05-15 Thread Sam Tregar
Hello all.  Can anyone explain why this creates a list containing a
dictionary:

  [{'a': 'b', 'foo': 'bar'}]

But this creates a list of keys of the dictionary:

  list({ "a": "b", "foo": "bar" })

I expected them to be equivalent but clearly they're not!  I'm using Python
2.6.1 if that helps.

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


[ANN] onlinepayment v1.0.0 released

2010-03-21 Thread Sam Tregar
onlinepayment v1.0.0 - a generic Python API for making online payments

This module provides an API wrapper around a variety of payment
providers.  Using this module you can write code that will work the
same regardless of the payment provider in use.

Examples::

   from onlinepayment import OnlinePayment

   # connect to authorize.net, setup auth with login and key
   auth= { 'login': 'YOUR LOGIN HERE',
   'key':   'YOUR KEY HERE' }

   op = OnlinePayment('authnet', test_mode=True, auth=auth)

   # or for paypal, setup auth with user, pass, vendor and product:
   auth= { 'username': 'YOUR USERNAME HERE',
   'password': 'YOUR PASSWORD HERE',
   'vendor':   'YOUR VENDOR HERE',
   'product':  'YOUR PRODUCT HERE' }

   # connect to PayPal
   op = OnlinePayment('paypal', test_mode=True, auth=auth)

   # charge a card
   try:
   result = op.sale(first_name = 'Joe',
last_name  = 'Example',
address= '100 Example Ln.',
city   = 'Exampleville',
state  = 'NY',
zip= '10001',
amount = '2.00',
card_num   = '400700027',
exp_date   = '0530',
card_code  = '1234')

   except conn.TransactionDeclined:
  # do something when the transaction fails

   except conn.CardExpired:
  # tell the user their card is expired

   except conn.ProcessorException:
  # handle all other possible processor-generated exceptions generically

   # examine result, the values returned here are processor-specific
   success  = result.success
   code = result.code
   message  = result.message
   trans_id = result.trans_id

   # you can get the raw data returned by the underlying processor too
   orig = result.orig

Installation


Before you can use this module you must install one or more payment
processors.  To install the PayPal payflowpro package::

  # easy_install pytz
  # easy_install python-payflowpro

To install the zc.authorizedotnet package and the authorize package
(for recurring support)::

  # easy_install zc.authorizedotnet
  # easy_install authorize

If you want authorize.net support you'll need to install a patched
version of zc.ssl.  Hopefully someday this will be released by the
Zope devs, but so far I haven't heard anything back.  Download the
zc.ssl source package from http://pypi.python.org/pypi/zc.ssl/, then
unpack::

  # tar zxvf zc.ssl-1.1.tar.gz
  # cd zc.ssl-1.1

Now download and apply my zc-ssl-timeout.patch::

  # wget
http://python-onlinepayment.googlecode.com/svn/trunk/zc-ssl-timeout.patch
  # patch -p1 < /zc-ssl-timeout.patch

And install the patched module::

  # python setup.py install

(You may also need to edit setup.py and remove the
'ssl-for-setuptools' dependecy.  I did, although it may be a quirk of
my Python install rather than a general problem.)

Once you have a payment processor you can install this module::

  # easy_install onlinepayment

For more information see: http://pypi.python.org/pypi/onlinepayment/1.0.0
-- 
http://mail.python.org/mailman/listinfo/python-list


Online payment module

2009-08-03 Thread Sam Tregar
Hello all.  I'm considering building a module to provide a
cross-payment-gatewat API for making online payments.  In the Perl world we
have a module like this called Business::OnlinePayment (
http://search.cpan.org/~jasonk/Business-OnlinePayment-2.01/OnlinePayment.pm).


Is there anything like this in Python?  My searches so far haven't turned up
anything.  If I don't find one I'll probably build one, covering PayPal and
Authorize.net to start.  If anyone is interested in discussing the project
and/or getting involved shoot me an email.

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


Re: Online payment module

2009-08-04 Thread Sam Tregar
On Tue, Aug 4, 2009 at 4:25 PM, Kushal Kumaran <
kushal.kumaran+pyt...@gmail.com > wrote:

>
> Not really familiar with this area, but have you seen these?
>
> http://code.google.com/p/pypaypal/
> http://www.geteasyshop.com/front-page
>

Thanks, but neither of these are remotely what I'm looking for!  The first
is an API for accessing PayPal, but not the one I'll be using - this one has
only one release and hasn't been updated in over a year, looks basically
useless.  The other is a full-fledged e-commerce application, not a code
library.

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