Karen Tracey wrote:
> On Sat, Feb 27, 2010 at 6:31 PM, Kenneth Loafman
> <kenneth.loaf...@gmail.com <mailto:kenneth.loaf...@gmail.com>> wrote:
> 
>     Karen Tracey wrote:
>     > On Sat, Feb 27, 2010 at 4:05 PM, piz...@gmail.com
>     <mailto:piz...@gmail.com>
>     > <mailto:piz...@gmail.com <mailto:piz...@gmail.com>>
>     <piz...@gmail.com <mailto:piz...@gmail.com> <mailto:piz...@gmail.com
>     <mailto:piz...@gmail.com>>>
>     > wrote:
>     >
>     >     Did you delete the .pyc files? Python generates a compiled version
>     >     of the file, and if you don't delete it, it never get's
>     updated. At
>     >     least it's the problem I have. So  if you update views.py and
>     don't
>     >     delete the old view.pyc file, it will work as the old version.
>     >
>     >
>     > You should not have to manually delete .pyc files when you update the
>     > corresponding .py file -- Python should automatically notice the
>     > modification date/time of the files do not match and re-generate the
>     > .pyc file based on the new contents of the .py file.
>     >
>     > It's only when you flat-out delete a .py file that you need to
>     remember
>     > to delete its .pyc file as well, because in that case Python can still
>     > see the module as existing even though the .py file is gone.
> 
>     That's the way it *should* work, however, if you are running under a web
>     server (runserver, Apache, Lighttpd), you need to manually delete the
>     .pyc files and restart the server.
> 
> 
> If you are routinely needing to delete .pyc files after making code
> changes in the corresponding .py files, something is broken. The post I
> responded to stated: "Python generates a compiled version
> of the file, and if you don't delete it, it never get's updated." That
> is not commonly true. Python compares the modification date/time of the
> .pyc file to same info for the .py file and if the .pyc file is out of
> date the existing .pyc file is ignored and a new one is regenerated from
> the current source. If this mechanism is not working on some system, it
> would be a good idea to track down why, because having to remember to
> delete .pyc files when changing code is bound to lead to headaches.

Forget headaches, think full-on head-banger migraines!  ;-)

> The only times I have to manually delete .pyc files are when I have
> deleting the corresponding .py files, or done a major restructuring and
> moved things around. I've never had to delete .pyc files for simple code
> changes. Running under a webserver or not makes no difference in this.
> Where running under a web server may make a difference is in the need to
> restart the server to get it to see changes. You generally don't need to
> do that for runserver, but usually do for production setups. You do not,
> however, need to delete .pyc files -- you just need to restart the server.

I listed runserver above, but its not normally a problem.

The problem only appears when you do an update of the .py files while
either Apache or Lighttpd are running.  For some reason, even a restart
of the servers will not always catch the modification of the .py file.
Not sure why this is, but I've run into this on multiple Linux distros,
multiple versions of Python and Django, and multiple versions of web
servers.

...Ken

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to