Re: [Tutor] Python Extensions in C

2011-06-01 Thread ALAN GAULD
OK, It seems to have grown a bit! :-) Your use of static seems a little odd. In particular the definition of avg as a static double. You then never use avg except here: 1. avg = *return_avgp; 2. samp = 0; 3. return_varp = v

Re: [Tutor] __init__.py question

2011-06-01 Thread Steven D'Aprano
Marilyn Davis wrote: [...] There's something I'm missing because I think you simply can't call something string.py unless you are willing to give up the library string.py. No, you're right about that. Python's search path is "first match wins". Whether it's a package or a module, it will match

Re: [Tutor] checking if a variable is an integer?

2011-06-01 Thread Steven D'Aprano
Válas Péter wrote: Hi guys, do you think, Hans, who wants to write his first prime number program, still understands what we are talking about? :-) If not, he can google the bits he doesn't understand, or ask. We won't bite! -- Steven ___ Tutor ma

Re: [Tutor] Strategy to read a redirecting html page

2011-06-01 Thread Karim
On 06/01/2011 01:41 AM, Alexandre Conrad wrote: Hi Karim, When you hit the page and you get an HTTP redirect code back (say, 302), you will need to make another call to the URL specified in the "Location" parameter in the response headers. Then you retrieve that new page and you can check you go

Re: [Tutor] __init__.py question

2011-06-01 Thread Alexandre Conrad
2011/6/1 Marilyn Davis : > Maybe I'm getting what you say, Alexandre and Ramit. > > When you import logging, it imports string, but it won't if you have a > string of your own already imported. > > So, when logging depends on string, it'll get mine and crash. > > But __init__.py helps what in this

Re: [Tutor] Python Extensions in C

2011-06-01 Thread James Reynolds
So I've been continuing with my experiment above, and I've made some good progress and learned some new things as I've been going. I've expanded it out a little bit, and you can see the code here: http://pastebin.com/gnW4xQNv I've tried to incorporate most of your su

Re: [Tutor] __init__.py question

2011-06-01 Thread Marilyn Davis
Maybe I'm getting what you say, Alexandre and Ramit. When you import logging, it imports string, but it won't if you have a string of your own already imported. So, when logging depends on string, it'll get mine and crash. But __init__.py helps what in this scenario? The only scenario it helps,

Re: [Tutor] __init__.py question

2011-06-01 Thread Alexandre Conrad
As a side note, remember that imported modules are cached under sys.modules. If you import something, it will be looked up in sys.modules and use the one in memory if it exists. If it doesn't exist, it will iterate over sys.path and look for your module/package. If it doesn't find it, you will get

Re: [Tutor] __init__.py question

2011-06-01 Thread Alexandre Conrad
2011/5/31 Marilyn Davis : > I don't really understand why __init__.py is necessary -- except that it > makes the packaging scheme work. > > The Python Manual by Guido van Rossum and Fred L. Drake says: > > ... this is done to prevent directories with a common name, such as > string, from unintentio

Re: [Tutor] __init__.py question

2011-06-01 Thread Prasad, Ramit
I wonder if this is so that it can ignore directories on sys.path. I assume that the path passed to python can be quite verbose depending on the OS's handling of path and environment variables. This is also a way to have Python ignore Python scripts in directories on the path that are not meant

Re: [Tutor] __init__.py question

2011-06-01 Thread Marilyn Davis
Thank you Válas Péter. I still don't get it, or how __init__.py alters the scenario you describe. I know that sometimes I'm really dense so please be patient with me. If I have a string.py in my local directory, it will be imported when I "import string" because the search path, sys.path, (which

Re: [Tutor] __init__.py question

2011-06-01 Thread Válas Péter
I think it means that you may have a subdirectory named "string" in your actual directory where you store e.g. your string-related scripts, and you have a Python package named "string" _somewhere_else_, but in the module search path. The subdirectory of the actual directory will have priority bacau

Re: [Tutor] checking if a variable is an integer?

2011-06-01 Thread Válas Péter
Hi guys, do you think, Hans, who wants to write his first prime number program, still understands what we are talking about? :-) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo