[Tutor] First extension

2010-03-26 Thread James Reynolds
Hello All,

I'm trying to write my first extension module, and I am getting the
following error in my command prompt and I was hoping you all could help me.

I have taken the following steps already:


   1. My path is set for mingw/bin as well as python31.
   2. There is a file in my disutils folder called disutils.cfg that says
   [build] compiler = mingw32
   3. The instructions in the 3.1 documentation state the following: "These
   instructions only apply if you’re using a version of Python prior to 2.4.1
   with a MinGW prior to 3.0.0 (with binutils-2.13.90-20030111-
  1. http://docs.python.org/py3k/install/index.html
  2. I am using Python 3.1 and the latest MinGW.
   4. I tested gcc/mingw by doing C:\python31>gcc -shared pdv.c -o pdv.dll
   and the test was succesful (or at least I was not given any errors while
   doing the compile)
   5. I searched on the internet and the closest thing I can find is the
   following: http://bugs.python.org/issue4709


Below you will find the following

One, the error report
two,my setup.py file
three, the file I am trying to turn into a python extension module by
running the following two commands:

python setup.py build
python setup.py install


#1


Microsoft Windows [Version 6.1.7600]

Copyright (c) 2009 Microsoft Corporation.  All rights reserved.


> c:\Python31\Lib\finance>python setup.py build

running build

running build_ext

building 'finance' extension

creating build

creating build\temp.win-amd64-3.1

creating build\temp.win-amd64-3.1\Release

C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python31\include
> -IC:\Pytho

n31\PC -c finance.c -o build\temp.win-amd64-3.1\Release\finance.o

finance.c: In function `PyInit_finance':

finance.c:31: warning: implicit declaration of function `Py_Module_Create'

finance.c:31: warning: return makes pointer from integer without a cast

writing build\temp.win-amd64-3.1\Release\finance.def

creating build\lib.win-amd64-3.1

C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s
> build\temp.win-amd64-3.1\Release\fin

ance.o build\temp.win-amd64-3.1\Release\finance.def -LC:\Python31\libs
> -LC:\Pyth

on31\PCbuild\amd64 -lpython31 -lmsvcr90 -o
> build\lib.win-amd64-3.1\finance.pyd

build\temp.win-amd64-3.1\Release\finance.o:finance.c:(.text+0x2b): undefined
> ref

erence to `_imp__PyArg_ParseTuple'

build\temp.win-amd64-3.1\Release\finance.o:finance.c:(.text+0x5c): undefined
> ref

erence to `_imp__Py_BuildValue'

build\temp.win-amd64-3.1\Release\finance.o:finance.c:(.text+0x74): undefined
> ref

erence to `Py_Module_Create'

collect2: ld returned 1 exit status

error: command 'gcc' failed with exit status 1


> c:\Python31\Lib\finance>



#2


from distutils.core import setup, Extension


> setup(name = "finance",

  version = "1.0",

  ext_modules = [Extension("finance", ["finance.c"])])



#3

#include 

#include 


> static PyObject *

pdv(PyObject *self, PyObject *args)

{

double value, rate, timex, denom, pdvx;

if (!PyArg_ParseTuple(args, "ddd", &value, &rate, &timex))

return NULL;

denom = (double) pow ((1 + rate), (timex));

pdvx = value / denom;

return Py_BuildValue("d", pdvx);

}

PyMethodDef pdvMethods[] = {

{"pdv", pdv, METH_VARARGS, "Returns the Present Discounted Value given
> of a single future value"},

{NULL, NULL, 0, NULL}

};


> static struct PyModuleDef financemodule = {

   PyModuleDef_HEAD_INIT,

   "finance",   /* name of module */

   NULL, /* module documentation, may be NULL */

   -1,   /* size of per-interpreter state of the module,

or -1 if the module keeps state in global variables. */

   pdvMethods

};


> PyMODINIT_FUNC

PyInit_finance(void)

{

return Py_Module_Create(&financemodule);

}
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-26 Thread Lowell Tackett

>From the virtual desk of Lowell Tackett  


--- On Fri, 3/26/10, Benno Lang  wrote:

From: Benno Lang 
Subject: Re: [Tutor] python magazine
To: "Lowell Tackett" 
Cc: tutor@python.org, "Bala subramanian" 
Date: Friday, March 26, 2010, 8:38 PM

On 27 March 2010 00:33, Lowell Tackett  wrote:
> The Python Magazine people have now got a Twitter site--which includes a 
> perhaps [telling] misspelling.
Obviously that's why they're looking for a chief editor - maybe it's
even a deliberate ploy.

I'm not sure if this affects others, but to me your replies appear
inside the quoted section of your mail, rather than beneath it. Would
you mind writing plain text emails to avoid this issue?

Thanks,
benno

Like this...?



  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-26 Thread Benno Lang
On 27 March 2010 00:33, Lowell Tackett  wrote:
> The Python Magazine people have now got a Twitter site--which includes a 
> perhaps [telling] misspelling.
Obviously that's why they're looking for a chief editor - maybe it's
even a deliberate ploy.

I'm not sure if this affects others, but to me your replies appear
inside the quoted section of your mail, rather than beneath it. Would
you mind writing plain text emails to avoid this issue?

Thanks,
benno
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Why this Difference in Importing NumPy 1.2 vs 1.4?

2010-03-26 Thread Emile van Sebille

On 3/26/2010 12:44 PM Wayne Watson said...

I wrote a program in Python 2.5 under Win7 and it runs fine using Numpy 1.2 ,
but not on a colleague's machine who has a slightly newer 2.5. We both use IDLE
to execute the program. During import he gets this:

  >>>
Traceback (most recent call last):
File "C:\Documents and Settings\HP_Administrator.DavesDesktop\My
Documents\Astro\Meteors\NC-FireballReport.py", line 38, in
from scipy import stats as stats # scoreatpercentile
File "C:\Python25\lib\site-packages\scipy\stats\__init__.py", line 7, in
from stats import *
File "C:\Python25\lib\site-packages\scipy\stats\stats.py", line 191, in
import scipy.special as special
File "C:\Python25\lib\site-packages\scipy\special\__init__.py", line 22, 
in
from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest
  >>>

Comments?


Version specific variations of packages with dedicated mailing lists are 
likely beyond the scope of this group.  I'd ask on the numpy list.


See http://www.scipy.org/Mailing_Lists

Emile




--
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

   (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site:  39°  15' 7" N, 121°  2' 32" W, 2700 feet
 Poisoned Shipments. Serious illegal waste dumping may be
 occuring in the Meditrainean. Radioactive material,
 mercury, biohazards. -- Sci Am Mag, Feb., 2010, p14f.

  Web Page:



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Why this Difference in Importing NumPy 1.2 vs 1.4?

2010-03-26 Thread Wayne Watson




I wrote a program in Python 2.5 under Win7 and it runs fine using Numpy
1.2 , but not on a colleague's machine who has a slightly newer 2.5. We
both use IDLE to execute the program. During import he gets this:

>>> 
Traceback (most recent call last):
  File "C:\Documents and Settings\HP_Administrator.DavesDesktop\My
Documents\Astro\Meteors\NC-FireballReport.py", line 38, in

    from scipy import stats as stats # scoreatpercentile
  File "C:\Python25\lib\site-packages\scipy\stats\__init__.py", line 7,
in 
    from stats import *
  File "C:\Python25\lib\site-packages\scipy\stats\stats.py", line 191,
in 
    import scipy.special as special
  File "C:\Python25\lib\site-packages\scipy\special\__init__.py", line
22, in 
    from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest
>>>     

Comments?
-- 
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet  
   Poisoned Shipments. Serious illegal waste dumping may be
   occuring in the Meditrainean. Radioactive material, 
   mercury, biohazards. -- Sci Am Mag, Feb., 2010, p14f.
 
Web Page: 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-26 Thread Lowell Tackett


>From the virtual desk of Lowell Tackett  


--- On Fri, 3/26/10, John  wrote:

From: John 
Subject: Re: [Tutor] python magazine
To: tutor@python.org
Date: Friday, March 26, 2010, 2:32 PM

On Friday 26 March 2010 08:33:35 am Lowell Tackett wrote:
> >From the virtual desk of Lowell Tackett 
>
> --- On Fri, 3/26/10, Bala subramanian  wrote:
>
> From: Bala subramanian 
> Subject: [Tutor] python magazine
> To: tutor@python.org
> Date: Friday, March 26, 2010, 8:07 AM
>
> Friends,
> I am sorry if this query is not appropriate to this forum.
>
> Is there any online magazine dedicated to python especially its features
> and How-to's that i can subscribe for.
>
> Thanks,
> Bala
>
>
> -Inline Attachment Follows-
>
> http://twitter.com/pymag
>
> The Python Magazine people have now got a Twitter site--which includes a
> perhaps [telling] misspelling.

Last updated Jun 2009???
Johnf

Look again...6:32 AM   Mar16th


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-26 Thread John
On Friday 26 March 2010 08:33:35 am Lowell Tackett wrote:
> >From the virtual desk of Lowell Tackett 
>
> --- On Fri, 3/26/10, Bala subramanian  wrote:
>
> From: Bala subramanian 
> Subject: [Tutor] python magazine
> To: tutor@python.org
> Date: Friday, March 26, 2010, 8:07 AM
>
> Friends,
> I am sorry if this query is not appropriate to this forum.
>
> Is there any online magazine dedicated to python especially its features
> and How-to's that i can subscribe for.
>
> Thanks,
> Bala
>
>
> -Inline Attachment Follows-
>
> http://twitter.com/pymag
>
> The Python Magazine people have now got a Twitter site--which includes a
> perhaps [telling] misspelling.

Last updated Jun 2009???
Johnf


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-26 Thread Lowell Tackett


>From the virtual desk of Lowell Tackett  


--- On Fri, 3/26/10, Bala subramanian  wrote:

From: Bala subramanian 
Subject: [Tutor] python magazine
To: tutor@python.org
Date: Friday, March 26, 2010, 8:07 AM

Friends,
I am sorry if this query is not appropriate to this forum.

Is there any online magazine dedicated to python especially its features and 
How-to's that i can subscribe for.

Thanks,
Bala


-Inline Attachment Follows-

http://twitter.com/pymag

The Python Magazine people have now got a Twitter site--which includes a 
perhaps [telling] misspelling.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-26 Thread C.T. Matsumoto

Well there was PyMag (http://pymag.phparch.com), each issue had a
dedicated howto for a python topic.

I say 'was' because they seem to busy doing something with their site,
which says they'll be back by January 26th.

I know it was possible to order back issues as pdf's.

T

Bala subramanian wrote:

Friends,
I am sorry if this query is not appropriate to this forum.

Is there any online magazine dedicated to python especially its features and
How-to's that i can subscribe for.

Thanks,
Bala





___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sending mail

2010-03-26 Thread Shashwat Anand
I guess you can use smtplib.

On Fri, Mar 26, 2010 at 7:07 PM, Timo  wrote:

>
>
> 2010/3/25 Timo 
>
> Hello,
>>
>> I was wondering what the best way is to send an email through my program?
>> I want the user to send an email with an attachment.
>>
>> I do have a webspace, should I use the smtplib module if my webhost
>> supports it (I have to ask though), or should I put a script on my space and
>> communicate with that?
>>
>> Cheers,
>> Timo
>>
>
>
> I worked on the following code. It works, but not for attachments.
>
> On the webserver I have: http://python.pastebin.com/9m8MXxuR
>
> And inside my program I then do:
> form = urllib.urlencode([("from", send_from), ("to", send_to), ("subject",
> subject), ("body", body), ("attachment", attachment)])
> webbrowser.open(url + "?" + form)
>
>
> So, 2 questions:
>  - Is this a good way of sending mails over my webhost through my program?
>  - Attachments don't work because I'm sending the path to the file, and
> ofcourse the cgi script can't find it. How should I solve this?
>
> Cheers,
> Timo
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sending mail

2010-03-26 Thread Timo
2010/3/25 Timo 

> Hello,
>
> I was wondering what the best way is to send an email through my program? I
> want the user to send an email with an attachment.
>
> I do have a webspace, should I use the smtplib module if my webhost
> supports it (I have to ask though), or should I put a script on my space and
> communicate with that?
>
> Cheers,
> Timo
>


I worked on the following code. It works, but not for attachments.

On the webserver I have: http://python.pastebin.com/9m8MXxuR

And inside my program I then do:
form = urllib.urlencode([("from", send_from), ("to", send_to), ("subject",
subject), ("body", body), ("attachment", attachment)])
webbrowser.open(url + "?" + form)


So, 2 questions:
 - Is this a good way of sending mails over my webhost through my program?
 - Attachments don't work because I'm sending the path to the file, and
ofcourse the cgi script can't find it. How should I solve this?

Cheers,
Timo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python magazine

2010-03-26 Thread Bala subramanian
Friends,
I am sorry if this query is not appropriate to this forum.

Is there any online magazine dedicated to python especially its features and
How-to's that i can subscribe for.

Thanks,
Bala
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor