reduce expression to test sublist

2013-01-05 Thread Asim
Hi All

The following reduce expression checks if every element of list lst1 is present 
in list lst2.  It works as expected for integer lists but for lists of strings, 
it always returns False.

   reduce( lambda x,y: (x in lst2) and (y in lst2), lst1)

Moreover, for the lists of strings the following for-loop gives correct results 
when the above reduce expression doesn't.

   isSublist = True
   for i in lst1:
  isSublist = isSublist and (i in lst2)
  if not isSublist:
 isSublist = False
 break


Can someone help me understand why?

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


Re: Sorting Large File (Code/Performance)

2008-01-25 Thread Asim
On Jan 24, 4:26 pm, [EMAIL PROTECTED] wrote:
> Thanks to all who replied. It's very appreciated.
>
> Yes, I had to doublecheck line counts and the number of lines is ~16
> million (insetead of stated 1.6B).
>
> Also:
>
> >What is a "Unicode text file"? How is it encoded: utf8, utf16, utf16le, 
> >utf16be, ??? If you don't know, do this:
>
> The file is UTF-8
>
> > Do the first two characters always belong to the ASCII subset?
>
> Yes, first two always belong to ASCII subset
>
> > What are you going to do with it after it's sorted?
>
> I need to isolate all lines that start with two characters (zz to be
> particular)
>
> > Here's a start:http://docs.python.org/lib/typesseq-mutable.html
> > Google "GnuWin32" and see if their sort does what you want.
>
> Will do, thanks for the tip.
>
> > If you really have a 2GB file and only 2GB of RAM, I suggest that you don't 
> > hold your breath.
>
> I am limited with resources. Unfortunately.
>

Since the OP has stated that they are running Windows XP, and more
than one poster has suggested installing more RAM in the box, I
thought people should know that WinXP has certain limitations on the
amount of memory that may be used:

http://msdn2.microsoft.com/en-us/library/aa366778.aspx

Firstly, the maximum amount of physical memory that may be installed
is 4GB.  Secondly, with the "4 gigabyte tuning" and
"IMAGE_FILE_LARGE_ADDRESS_AWARE" patches, the maximum amount of
virtual memory (phyical memory + swapfile size) that may be assigned
to user processes is 2GB.

Hence, even if you made a 100GB swap file with 4GB RAM installed, by
default only a maximum of 2GB would ever be assigned to a user-
process.  With the two flags enabled, the maximum becomes 3GB.

If the OP finds performance to be limited and thinks more RAM would
help trying a later version of Windows would be a start, but better
would be to try Linux or Mac OSX out.

Cheers,
Asim


> Cheers,
>
> Ira

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


Re: Sorting Large File (Code/Performance)

2008-01-25 Thread Asim
On Jan 25, 9:23 am, Asim <[EMAIL PROTECTED]> wrote:
> On Jan 24, 4:26 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > Thanks to all who replied. It's very appreciated.
>
> > Yes, I had to doublecheck line counts and the number of lines is ~16
> > million (insetead of stated 1.6B).
>
> > Also:
>
> > >What is a "Unicode text file"? How is it encoded: utf8, utf16, utf16le, 
> > >utf16be, ??? If you don't know, do this:
>
> > The file is UTF-8
>
> > > Do the first two characters always belong to the ASCII subset?
>
> > Yes, first two always belong to ASCII subset
>
> > > What are you going to do with it after it's sorted?
>
> > I need to isolate all lines that start with two characters (zz to be
> > particular)
>
> > > Here's a start:http://docs.python.org/lib/typesseq-mutable.html
> > > Google "GnuWin32" and see if their sort does what you want.
>
> > Will do, thanks for the tip.
>
> > > If you really have a 2GB file and only 2GB of RAM, I suggest that you 
> > > don't hold your breath.
>
> > I am limited with resources. Unfortunately.
>
> Since the OP has stated that they are running Windows XP, and more
> than one poster has suggested installing more RAM in the box, I
> thought people should know that WinXP has certain limitations on the
> amount of memory that may be used:
>
> http://msdn2.microsoft.com/en-us/library/aa366778.aspx
>
> Firstly, the maximum amount of physical memory that may be installed
> is 4GB.  Secondly, with the "4 gigabyte tuning" and
> "IMAGE_FILE_LARGE_ADDRESS_AWARE" patches, the maximum amount of
> virtual memory (phyical memory + swapfile size) that may be assigned
> to user processes is 2GB.
>
> Hence, even if you made a 100GB swap file with 4GB RAM installed, by
> default only a maximum of 2GB would ever be assigned to a user-
> process.  With the two flags enabled, the maximum becomes 3GB.
>
> If the OP finds performance to be limited and thinks more RAM would
> help trying a later version of Windows would be a start, but better
> would be to try Linux or Mac OSX out.
>
> Cheers,
> Asim
>
> > Cheers,
>
> > Ira

Sorry, just to clarify my response.  Any 32-bit OS will only be able
to assign 4GB of virtual memory to a single processes, the argument
being that since processes can only issue 32-bit instructions the
process can only address a maximum of 2^32 bytes of addresses
(assuming the architecture is using byte-addressed memory).

Another link that's easier to grok:

http://www.codinghorror.com/blog/archives/000811.html

However, a 32-bit OS may support more than 4GB of virtual memory
(using "Physical Address Extension", or PAE) and split it more
intelligently between processes than Windows XP or Vista does:

http://www.ibm.com/developerworks/linux/library/l-memmod/

So allocating more than 4GB of virtual memory to your sort application
could be achieved through splitting your task into more than one
process on an appropriate OS.  AFAIK, such memory limitations are
dependent on the particular Linux distro you're using, and I'm not
sure about Mac OSX limitations.  This applies doubly for 64-bit
architectures and OS's.

Please correct me, with references, if my conclusions are wrong.

Cheers,
Asim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythons & Ladders

2008-02-29 Thread Asim
On Feb 28, 9:10 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Benoit wrote:
> > Forgive my language concerning C++ as its turned the thread into
> > something I did not intend. I merely wished to point out that Python
> > was easier for me to learn than C++.  To Schwab, its likely that Mark
> > Lutz is simply a better instructor than my professor.
>
> Sorry for hijacking your thread!
>
> In addition to Python Challenge, check out Code Golf:
>
>      http://codegolf.com/
>
> It's eye-opening to see how concise the solutions can be.

You should also give Project Euler a shot:

http://projecteuler.net/index.php?section=problems

Just keep in mind two points.  One, your solutions should work with
under one minute of execution time, even in Python.  Secondly, the
main benefit of the site is attempting some of the simpler problems
and then diving head-first into the forums to see other peoples'
solutions to the same problem.

I guarantee you'll find some unique Python techniques from these
forums that should open new avenues of learning wrt Python for you.
Nothing enterprise level...but definitely interesting.  Be warned that
some of the harder problems require undergraduate-level math.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ideal way to separate GUI and logic?

2013-07-15 Thread Asim Jalis
On Mon, Jul 15, 2013 at 5:25 PM,  wrote:

> Again, thanks for all the responses. I'm curious, though, what exactly is
> the rationale for making functions so small? (I've heard that the function
> calling of Python has relatively high overhead?)
>

There is a small overhead, but it makes the code easier to read and
understand. You can look at the function name and get and idea of _what_
the function is doing instead of having to figure out _how_ it is doing it.

Regarding optimization, after you have written your application if you see
performance issues you can surgically optimize the spots that have the
issues and leave most of the code untouched.

To quote Don Knuth, "premature optimization is the root of all evil". Also
the article at http://en.wikipedia.org/wiki/Program_optimization makes some
good points.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GDAL installation

2015-02-11 Thread Asim Jalis
Hi Leo,

This might be a PATH issue.

See this discussion for details.

https://pythongisandstuff.wordpress.com/2011/07/07/installing-gdal-and-ogr-for-python-on-windows/

Asim

On Tue, Feb 10, 2015 at 9:11 PM, Leo Kris Palao  wrote:

> Hi Python Users,
>
> I currently installed the Python 2.7.9 and installed the GDAL package.
> First, I tried to install GDAL using PIP but it throws an error - I cannot
> remember the exact error message. So, I install it using easy_install
> command. But when I import the package I am getting this message, which I
> really don't understand.
>
> Microsoft Windows [Version 6.1.7601]
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
>
> C:\Users\lpalao>python
>> Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)]
>> on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import gdal
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "C:\Python27\Python2.7.9\lib\site-packages\gdal.py", line 2, in
>> 
>> from osgeo.gdal import deprecation_warn
>>   File "C:\Python27\Python2.7.9\lib\site-packages\osgeo\__init__.py",
>> line 21, in 
>> _gdal = swig_import_helper()
>>   File "C:\Python27\Python2.7.9\lib\site-packages\osgeo\__init__.py",
>> line 17, in swig_import_helper
>> _mod = imp.load_module('_gdal', fp, pathname, description)
>> ImportError: DLL load failed: The specified module could not be found.
>> >>>
>
>
> Thanks in advance,
> -Leo
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Indian photographer denies affair with Lindsay Lohan!

2010-07-10 Thread asim malik
Speaking on the issue for the first time, Chaudhuri, over the phone
from New York, says, "They were completely distorted reports. We are
really good friends for more details www.bollywood789.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Cisco certification

2009-06-14 Thread Asim Saeed
if you wnat to know about cisco certification it books and dump
http://ciscocity.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list