Python-list Digest, Vol 65, Issue 365

M Kumar tomanishkb at gmail.com
Wed Feb 18 04:31:13 EST 2009


I think the given statement below will give you what you r looking
<imported module name>.__file__print

On Wed, Feb 18, 2009 at 2:43 PM, <python-list-request at python.org> wrote:

> Send Python-list mailing list submissions to
>        python-list at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>        python-list-request at python.org
>
> You can reach the person managing the list at
>        python-list-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Directory (gtillmon)
>   2. Re: Is there something easier than ORM? (Michele Simionato)
>   3. Re: flexible find and replace ? (OdarR)
>   4. Re: urllib confusion (Steven D'Aprano)
>   5. Re: numpy.memmap advice? (Carl Banks)
>   6. Building python with sqlite3 (Justin Li)
>   7. Calling a script requiring user input from another script
>      (mzagursk at gmail.com)
>   8. Re: Python 3D CAD -- need collaborators, or just brave souls
>      :) (r)
>   9. PyYaml in standard library? (Brendan Miller)
>  10. Re: Building python with sqlite3 (Christian Heimes)
>
>
> ---------- Forwarded message ----------
> From: gtillmon <gtill60 at gmail.com>
> To:
> Date: Tue, 17 Feb 2009 17:18:11 -0800 (PST)
> Subject: Directory
> Hello.  I am new to the Python language.
> I would like to know how to display and store the path of each mondule
> that is called.
> Similar to the old READY TRACE in COBOL of long ago.
>
> Thanks,
> George
>
>
>
> ---------- Forwarded message ----------
> From: Michele Simionato <michele.simionato at gmail.com>
> To:
> Date: Tue, 17 Feb 2009 08:46:02 -0800 (PST)
> Subject: Re: Is there something easier than ORM?
> On Feb 17, 5:35 pm, Philip Semanchuk <phi... at semanchuk.com> wrote:
> >
> > I don't intend this as a criticism of SqlAlchemy. On the contrary I am
> > impressed by what it does. But I often see people promoting ORM as the
> > solution to all database access problems, and I certainly don't feel
> > like it is.
>
> I am also not a big fan of ORM, especially in situations where you
> have
> performance issues and you are using database specific features. In
> such situations
> you don't care about portability, but you care about having your SQL
> explicit,
> so that you can run it directly under the profiler.
>
>
>
> ---------- Forwarded message ----------
> From: OdarR <Olivier.Darge at gmail.com>
> To:
> Date: Tue, 17 Feb 2009 11:29:19 -0800 (PST)
> Subject: Re: flexible find and replace ?
> Thanks to everybody.
> I need to test your propositions now :)
>
> Olivier
>
>
>
> ---------- Forwarded message ----------
> From: Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au>
> To: python-list at python.org
> Date: 18 Feb 2009 08:33:08 GMT
> Subject: Re: urllib confusion
> On Wed, 18 Feb 2009 01:17:40 -0700, Tim H wrote:
>
> > When I attempt to open 2 different pages on the same site I get 2 copies
> > of the first page. ??
> ...
> > Any thoughts?
>
> What does your browser do?
>
> What does your browser do if you turn off cookies, re-directions and/or
> referers?
>
>
>
> --
> Steven
>
>
>
> ---------- Forwarded message ----------
> From: Carl Banks <pavlovevidence at gmail.com>
> To: python-list at python.org
> Date: Wed, 18 Feb 2009 00:56:10 -0800 (PST)
> Subject: Re: numpy.memmap advice?
> On Feb 17, 3:08 pm, Lionel <lionel.ke... at gmail.com> wrote:
> > Hello all,
> >
> > On a previous thread (http://groups.google.com/group/comp.lang.python/
> > browse_thread/thread/64da35b811e8f69d/67fa3185798ddd12?
> > hl=en&lnk=gst&q=keene#67fa3185798ddd12) I was asking about reading in
> > binary data. Briefly, my data consists of complex numbers, 32-bit
> > floats for real and imaginary parts. The data is stored as 4 bytes
> > Real1, 4 bytes Imaginary1, 4 bytes Real2, 4 bytes Imaginary2, etc. in
> > row-major format. I needed to read the data in as two separate numpy
> > arrays, one for real values and one for imaginary values.
> >
> > There were several very helpful performance tips offered, and one in
> > particular I've started looking into. The author suggested a
> > "numpy.memmap" object may be beneficial. It was suggested I use it as
> > follows:
> >
> > descriptor = dtype([("r", "<f4"), ("i", "<f4")])
> > data = memmap(filename, dtype=descriptor, mode='r').view(recarray)
> > print "First 100 real values:", data.r[:100]
> >
> > I have two questions:
> > 1) What is "recarray"?
>
> Let's look:
>
> [GCC 4.3.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy
> >>> numpy.recarray
> <class 'numpy.core.records.recarray'>
> >>> help(numpy.recarray)
>
> Help on class recarray in module numpy.core.records:
>
> class recarray(numpy.ndarray)
>  |  recarray(shape, dtype=None, buf=None, **kwds)
>  |
>  |  Subclass of ndarray that allows field access using attribute
> lookup.
>  |
>  |  Parameters
>  |  ----------
>  |  shape : tuple
>  |      shape of record array
>  |  dtype : data-type or None
>  |      The desired data-type.  If this is None, then the data-type is
> determine
>  |      by the *formats*, *names*, *titles*, *aligned*, and
> *byteorder* keywords
>  |  buf : [buffer] or None
>  |      If this is None, then a new array is created of the given
> shape and data
>  |      If this is an object exposing the buffer interface, then the
> array will
>  |      use the memory from an existing buffer.  In this case, the
> *offset* and
>  |      *strides* keywords can also be used.
> ...
>
>
> So there you have it.  It's a subclass of ndarray that allows field
> access using attribute lookup.  (IOW, you're creating a view of the
> memmap'ed data of type recarray, which is the type numpy uses to
> access structures by name.  You need to create the view because
> regular numpy arrays, which numpy.memmap creates, can't access fields
> by attribute.)
>
> help() is a nice thing to use, and numpy is one of the better
> libraries when it comes to docstrings, so learn to use it.
>
>
> > 2) The documentation for numpy.memmap claims that it is meant to be
> > used in situations where it is beneficial to load only segments of a
> > file into memory, not the whole thing. This is definately something
> > I'd like to be able to do as my files are frequently >1Gb. I don't
> > really see in the diocumentation how portions are loaded, however.
> > They seem to create small arrays and then assign the entire array
> > (i.e. file) to the memmap object. Let's assume I have a binary data
> > file of complex numbers in the format described above, and let's
> > assume that the size of the complex data array (that is, the entire
> > file) is 100x100 (rows x columns). Could someone please post a few
> > lines showing how to load the top-left 50 x 50 quadrant, and the lower-
> > right 50 x 50 quadrant into memmap objects? Thank you very much in
> > advance!
>
>
> You would memmap the whole region in question (in this case the whole
> file), then take a slice.  Actually you could get away with memmapping
> just the last 50 rows (bottom half).  The offset into the file would
> be 50*100*8, so:
>
> data = memmap(filename, dtype=descriptor, mode='r',offset=
> (50*100*8)).view(recarray)
> reshaped_data = reshape(data,(50,100))
> intersting_data = reshaped_data[:,50:100]
>
>
> A word of caution: Every instance of numpy.memmap creates its own mmap
> of the whole file (even if it only creates an array from part of the
> file).  The implications of this are A) you can't use numpy.memmap's
> offset parameter to get around file size limitations, and B) you
> shouldn't create many numpy.memmaps of the same file.  To work around
> B, you should create a single memmap, and dole out views and slices.
>
>
> Carl Banks
>
>
>
> ---------- Forwarded message ----------
> From: Justin Li <justinli79 at gmail.com>
> To: python-list at python.org
> Date: Wed, 18 Feb 2009 00:59:20 -0800 (PST)
> Subject: Building python with sqlite3
>
> I'm building and installing Ptyhon 2.6.1 on Linux. After configure,
> make, make install, to import sqlite3 leads to ImportError. It looks
> like I have to build Python with sqlite. I have sqlite3 installed on
> my system. How should I build Python with it? I did not find any
> options relating with sqlite3 of configure and Makefile.
>
> Thanks in Advance!
> Justin
>
>
>
> ---------- Forwarded message ----------
> From: "mzagursk at gmail.com" <mzagursk at gmail.com>
> To: python-list at python.org
> Date: Wed, 18 Feb 2009 01:00:28 -0800 (PST)
> Subject: Calling a script requiring user input from another script
> I'm kind of new to this so bear with me.
>
> I have a script made that requires user input (lets call it script A)
> while it's running.  However, I would like to create another script
> (script B) that can batch process (i.e. run script A over and over
> with different user inputs based on script B).  Is this possible?  and
> how so?  Thanks in advance.
>
>
>
> ---------- Forwarded message ----------
> From: r <rt8396 at gmail.com>
> To: python-list at python.org
> Date: Wed, 18 Feb 2009 01:02:22 -0800 (PST)
> Subject: Re: Python 3D CAD -- need collaborators, or just brave souls :)
> Hello Josh,
> Blender is a lost cause. It is a powerful app but the UI is horrible.
> Even the Blender folks admit only a complete rewrite could solve the
> major flaws that plague the design. So maybe i could salvage some code
> but for what i have in mind, Blender will look like a piece of
> software from the middle ages. And i am absolutly only looking to do
> this in 3D, 2D is boring.
>
> So, yes, i have looked at both the applications you offer.
>
> Thanks
>
>
>
> ---------- Forwarded message ----------
> From: Brendan Miller <catphive at catphive.net>
> To: python-list at python.org
> Date: Wed, 18 Feb 2009 01:11:09 -0800
> Subject: PyYaml in standard library?
> I'm just curious whether PyYaml is likely to end up in the standard
> library at some point?
>
>
>
> ---------- Forwarded message ----------
> From: Christian Heimes <lists at cheimes.de>
> To: python-list at python.org
> Date: Wed, 18 Feb 2009 10:13:29 +0100
> Subject: Re: Building python with sqlite3
> Justin Li schrieb:
> > I'm building and installing Ptyhon 2.6.1 on Linux. After configure,
> > make, make install, to import sqlite3 leads to ImportError. It looks
> > like I have to build Python with sqlite. I have sqlite3 installed on
> > my system. How should I build Python with it? I did not find any
> > options relating with sqlite3 of configure and Makefile.
>
> Do you have the development files installed as well? Run "make" again
> and look at the list of missing modules.
>
> Christian
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards,

Maneesh KB

Comat Technologies

Bangalore

Mob: 9740-192309



We work with the underprivileged and in rural India. If you are interested
to be a part of it, please mail or call me. I will be happy to share and
inform - http://www.comat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090218/8881347e/attachment.html>


More information about the Python-list mailing list