Re: best way to read a huge ascii file.

2016-11-30 Thread Rolando Espinoza
Hi, Yes, working with binary formats is the way to go when you have large data. But for further reference, Dask[1] fits perfectly for your use case, see below how I process a 7Gb text file under 17 seconds (in a laptop: mbp + quad-core + ssd). # Create roughly ~7Gb worth text data. In [40]: impo

Re: Source code for itertools

2010-08-30 Thread Rolando Espinoza La Fuente
oint to a windows path. If the file ends with a ".py", you can open the file with any editor. If ends with ".so" or something else likely is a compiled module in C and you should search in the source distribution, not the binary distribution. Hope it helps. Regards, Rolando Espinoza La fuente www.insophia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: python interview quuestions

2010-08-10 Thread Rolando Espinoza La Fuente
efore: http://gist.github.com/518370 Well.. I tried to use generators to make it "cool" but changed it for a test-friendly approach. I'll find hard to remember the one-liners in an interview and get it right. Rolando Espinoza La fuente www.insophia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: understanding the mro (long)

2010-07-23 Thread Rolando Espinoza La Fuente
On Sat, Jul 24, 2010 at 12:28 AM, Benjamin Kaplan wrote: [...] > > And second, not to in any way diminish the work you did tracing out > the inheritance tree and working through the inheritance, but Python > has easier ways of doing it :) > BBar.__mro__ > (, , 'exceptions.RuntimeError'>, ,

understanding the mro (long)

2010-07-23 Thread Rolando Espinoza La Fuente
TL;DR: if you want to stay sane, don't inherit two classes that share same inheritance graph I recently got puzzled by a bug from a legacy lib (ClientForm) which have this code: class ParseError(sgmllib.SGMLParseError, HTMLParser.HTMLParseError, ):

Re: Difficulty w/json keys

2010-04-23 Thread Rolando Espinoza La Fuente
On Fri, Apr 23, 2010 at 10:20 AM, Red wrote: [...] > for line in f: >        j = json.loads(line) >        if 'text' in j: >                if 'lang' in j: >                        lang = j['lang'] >                        print "language", lang >                text = j['text'] "lang" key is in

Re: Incorrect scope of list comprehension variables

2010-04-06 Thread Rolando Espinoza La Fuente
On Sun, Apr 4, 2010 at 5:20 PM, Paul Rubin wrote: [...] > >    d[r] = list(r for r in [4,5,6]) > This have a slightly performance difference. I think mainly the generator's next() call. In [1]: %timeit list(r for r in range(1)) 100 loops, best of 3: 2.78 ms per loop In [2]: %timeit [r for r

Re: How to access args as a list?

2010-04-03 Thread Rolando Espinoza La Fuente
On Sat, Apr 3, 2010 at 6:28 PM, kj wrote: > Is there a way to refer, within the function, to all its arguments > as a single list?  (I.e. I'm looking for Python's equivalent of > Perl's @_ variable.) > def spam(*args, **kwargs): print args print kwargs class Spam: def __init__(self,

Re: installing something to a virtualenv when it's already in site-packages

2010-03-19 Thread Rolando Espinoza La Fuente
On Fri, Mar 19, 2010 at 4:05 AM, nbv4 wrote: > I have ipython installed via apt. I can go to the command line and > type 'ipython' and it will work. If I try to install ipython to a > virtualenv, I get this: > > $ pip install -E env/ ipython > Requirement already satisfied: ipython in /usr/share/p

Re: isinstance(False, int)

2010-03-05 Thread Rolando Espinoza La Fuente
On Fri, Mar 5, 2010 at 2:32 PM, mk wrote: > Arnaud Delobelle wrote: > > 1 == True >> >> True > > 0 == False >> >> True >> >> So what's your question? > > Well nothing I'm just kind of bewildered: I'd expect smth like that in Perl, > but not in Python.. Although I can understand the rat

Re: isinstance(False, int)

2010-03-05 Thread Rolando Espinoza La Fuente
On Fri, Mar 5, 2010 at 2:00 PM, Steve Holden wrote: [...] > > Just a brainfart from the BDFL - he decided (around 2.2.3, IIRC) that it > would be a good ideal for Booleans to be a subclass of integers. > I would never figured out >>> bool.__bases__ (,) Doesn't have side effects not knowing tha

Re: ConfigParser is not parsing

2010-02-12 Thread Rolando Espinoza La Fuente
read() does not return the config object >>> import ConfigParser >>> config = ConfigParser.SafeConfigParser() >>> config.read('S3Files.conf') ['S3Files.conf'] >>> config.sections() ['main'] >>> config.get(&

Re: BeautifulSoup

2010-01-13 Thread Rolando Espinoza La Fuente
;beautifulsoup" module. > but it doesnt work! > [snip] -- Rolando Espinoza La fuente www.rolandoespinoza.info -- http://mail.python.org/mailman/listinfo/python-list

Re: Regex help needed!

2010-01-07 Thread Rolando Espinoza La Fuente
; Take the advice other people gave you and use BeautifulSoup. > -- > Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/ > > "If you think it's expensive to hire a professional to do the job, wait > until you hire an amateur."  --Red Adair > -- > http://mail.python.org/mailman/listinfo/python-list > -- Rolando Espinoza La fuente www.rolandoespinoza.info -- http://mail.python.org/mailman/listinfo/python-list