Re: Any way to use cProfile in a multi-threaded program?

2009-12-30 Thread Jonathan Hartley
On Dec 30, 3:00 pm, mk wrote: > I'm stumped; I read somewhere that one would have to modify Thread.run() >   method but I have never modified Python methods nor would I really > want to do it. > > Is there any way to start cProfile on each thread and then combine the > stats? > > Regards, > mk W

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Jonathan Gardner
On Jan 1, 12:43 am, [email protected] (Aahz) wrote: > In article , > Benjamin Kaplan   wrote: > >In Python, throwing exceptions for expected outcomes is considered > >very bad form [...] > > Who says that?  I certainly don't. Agreed. int("asdf") is supposed to return what, exactly? Any languag

Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2010-01-01 Thread Jonathan Hartley
u can download the Windows binary under the 'featured downloads' from here: http://code.google.com/p/brokenspell/ I appreciate David Bolen's comment that an installer isn't that hard to put together: Acknowledged, but for the moment I still seem to be getting away without nee

Re: Is python not good enough?

2010-01-13 Thread Jonathan Hartley
er algorithms and refactor more easily than would otherwise be the case. Best regards, Jonathan -- http://mail.python.org/mailman/listinfo/python-list

Re: PyQt event recognition

2010-01-13 Thread Jonathan Gardner
On Jan 13, 12:21 pm, Zabin wrote: > On Jan 14, 9:00 am, Zabin wrote: > > > I am a new pyqt programmer. I have a tab widget with lots of line > > edits, radiobuttons and combo boxes. I want to trigger a single sub > > the moment any one of these widgets listed are modified. I tried using > > the c

Re: I really need webbrowser.open('file://') to open a web browser

2010-01-16 Thread Jonathan Temple
On Jan 15, 8:14 pm, Timur Tabi wrote: > After reading several web pages and mailing list threads, I've learned > that the webbrowser module does not really support opening local > files, even if I use a file:// URL designator.  In most cases, > webbrowser.open() will indeed open the default web br

Python decorator syntax limitations

2010-01-18 Thread Jonathan S
t, group, news): pass view = news_page('template.html').lookup(News, 'news_id', 'news') (view) Any suggestions? I have my reasons for doing this, (news_page is a class, and __call__ is used to wrap the template.) I'm sure this is a limitation in the syntax,

Re: Python decorator syntax limitations

2010-01-18 Thread Jonathan S
Thanks a lot, all of you! This was really helpful. (or at least give me the inspiration I needed to finish it.) I'm sure this is a use case where most other options are less readable than the chain of methods in the decorator. In this use case, I had a lot of Django views to which access permissio

Re: Recommended "new" way for config files

2010-01-19 Thread Jonathan Gardner
On Jan 8, 2:54 pm, Ben Finney wrote: > Chris Rebert writes: > > JSON is one option:http://docs.python.org/library/json.html > > YAML http://en.wikipedia.org/wiki/YAML> is another contender. > Compared to JSON, it is yet to gain as much mind-share, but even more > human-friendly and no less expres

Re: py2exe deal with python command line inside a program

2010-01-24 Thread Jonathan Hartley
On Jan 22, 7:35 pm, [email protected] wrote: > Hi, > > I need to create a python subprogress, like this: > myProcess = subprocess.Popen([sys.executable, 'C:\myscript.py'], >                                        env=env, stdin=subprocess.PIPE, >                                        stdout=su

Re: Python and Ruby

2010-01-27 Thread Jonathan Gardner
On Jan 27, 5:47 am, Simon Brunning wrote: > > I think Python is a little cleaner, but I'm sure you'd find Ruby fans > who'd argue the complete opposite. > Are you sure about that? There's a lot of line noise in Ruby. How are you supposed to pronounce "@@"? What about "{|..| ... }"? There's a lo

Re: Python and Ruby

2010-01-27 Thread Jonathan Gardner
On Jan 27, 6:56 am, Roald de Vries wrote: > On Jan 27, 2010, at 2:01 PM, Jean Guillaume Pyraksos wrote: > > > What are the arguments for choosing Python against Ruby > > for introductory programming? > > I think the main difference is in culture, especially for   > *introductory* programming. To

Re: python 3's adoption

2010-01-27 Thread Jonathan Gardner
On Jan 27, 9:38 am, Luis M. González wrote: > > Please don't post more noise and ad hominem attacks to the group, Steve. > > "Ad hominem"? > Please, operor non utor lingua non notus per vulgaris populus. > Gratias ago vos... My rough, machine-assisted translation: "Don't try to use language that

Re: python 3's adoption

2010-01-27 Thread Jonathan Gardner
On Jan 26, 10:12 pm, Steven D'Aprano wrote: > > I did too, when I first heard cmp was to be dumped. But I changed my mind > and now agree with the decision to drop cmp. Custom sorts are nearly > always much better written with key rather than cmp: key adds an O(N) > overheard to the sorting, while

Re: python 3's adoption

2010-01-27 Thread Jonathan Gardner
On Jan 27, 12:36 am, Paul Rubin wrote: > Steven D'Aprano writes: > > Without becoming a purely functional language, you won't get rid of all > > statements. > > Why not?  GCC lets you use any statement in an expression: > >     #include > >     main() >     { >       int i, x, p=0; >       x = (

Re: python 3's adoption

2010-01-27 Thread Jonathan Gardner
On Jan 27, 3:54 pm, Paul Rubin wrote: > Steven D'Aprano writes: > > always much better written with key rather than cmp: key adds an O(N) > > overheard to the sorting, while cmp makes sorting O(N**2). > > Whaa ..  No I don't think so. You're referring to the O(N**2) bit, right?

Re: python 3's adoption

2010-01-27 Thread Jonathan Gardner
On Jan 27, 4:25 pm, Paul Rubin wrote: > What about assert and pass? > If you're going to have statements, you're going to need the null statement. That's "pass". It could be renamed "null_statement" but "pass" is a better description. "None" and "pass" are cousins of sorts, since "None" is the n

Re: Wrap a function

2010-01-28 Thread Jonathan Gardner
On Jan 28, 10:20 am, Joan Miller wrote: > I've to call to many functions with the format: > > >>> run("cmd") > > were "cmd" is a command with its arguments to pass them to the shell > and run it, i.e. > > > > >>>  run("pwd") > or > >>> run("ls /home") > > Does anybody knows any library to help me

Re: Wrap a function

2010-01-28 Thread Jonathan Gardner
On Jan 28, 2:16 pm, Joan Miller wrote: > > There would be to make a function for each system command to use so it > would be too inefficient, and follow the problem with the quotes. > > The best is make a parser into a compiled language > Yeah, you could do that. Or you can simply rely on /bin/sh

Re: Keyboard input

2010-01-29 Thread Jonathan Gardner
On Jan 29, 8:53 am, "Mr.SpOOn" wrote: > Hi, > I need to get keyboard input in a python program. I need it to let the > user choose some options, for example: > > 1) option 1 > 2) option 2 > 3) option 3 > > and then to input some data to the program. > > I'm using the raw_input method and it works

Re: Threading issue with SQLite

2010-01-29 Thread Jonathan Gardner
On Jan 29, 8:37 am, Alan Harris-Reid wrote: > > Questions... > 1.  Is there a large overhead in opening a new SQLite connection for > each thread (ie. within each method)? Yes, but not as bad as some other DBs. > 2.  Is there any way to use the same connection for the whole class (or > should I

Re: which one is faster?

2010-01-29 Thread Jonathan Gardner
On Jan 28, 10:29 pm, "Stephen.Wu" <[email protected]> wrote: > str.find(targetStr) > str.index(targetStr) with exception > str.count(targetStr) > targetStr in str > > which is the fastest way to check whether targetStr is in str? > The fastest way of all is to forget about this and finish the res

Re: For loop searching takes too long!

2010-01-29 Thread Jonathan Gardner
On Jan 28, 3:52 pm, elsa wrote: > > I've got a problem with my program, in that the code just takes too > long to run. Here's what I'm doing. If anyone has any tips, they'd be > much appreciated! > First of all, don't play with large lists. Large lists have a tendency to grow larger over time, un

Re: How python source code in large projects are organized?

2009-09-29 Thread Jonathan Gardner
On Sep 20, 8:19 am, Peng Yu wrote: > > I am wondering what is the best way of organizing python source code > in a large projects. There are package code, testing code. I'm > wondering if there has been any summary on previous practices. > (Sorry for the late reply.) My advice: Don't write big p

Re: store encrypted data in sqlite ?

2009-10-02 Thread Jonathan Gardner
On Oct 2, 11:53 am, Stef Mientki wrote: > > Will this method work always ? > Are there better methods ? > I SQLite doesn't like raw data (with all its \0 glory), you're out of luck, unfortunately. Base64 encoding is a really good solution for places like this. You are aware, of course, of the da

Re: epydoc - can I provide multiple dirs to parse

2009-10-02 Thread Jonathan Gardner
On Oct 2, 11:38 am, Medi wrote: > Can I present multiple directories to epydoc to process. For example > > epydoc -option -option -option dir_1 dir_2 dir_3 > I know nothing of epydoc. However, it looks like it should be something like: epydoc -option dir_1 -option dir_2 -option dir_3 ...if a

Re: How would you design scalable solution?

2009-10-27 Thread Jonathan Gardner
On Oct 27, 10:10 am, Bryan wrote: > > How else to keep a record of every transaction, but not have the speed > of the > question "How many Things in Bucket x" depend on looking @ every > transaction > record ever made? You can have three different tables in your database: (1) The transaction log

comparing alternatives to py2exe

2009-11-03 Thread Jonathan Hartley
ojects to improve faster. Best regards, Jonathan -- http://mail.python.org/mailman/listinfo/python-list

unittest & setup

2009-11-03 Thread Jonathan Haddad
f the class are created. What's the best way for me to avoid this? It takes about a few seconds to load the CSV file. -- Jonathan Haddad http://www.rustyrazorblade.com -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing alternatives to py2exe

2009-11-12 Thread Jonathan Hartley
On Nov 10, 1:34 pm, Philip Semanchuk wrote: > On Nov 9, 2009, at 9:16 PM, Gabriel Genellina wrote: > > > > > En Fri, 06 Nov 2009 17:00:17 -0300, Philip Semanchuk > > escribió: > >> On Nov 3, 2009, at 10:58 AM, Jonathan Hartley wrote: > > >>> Re

bootstrapping on machines without Python

2009-11-13 Thread Jonathan Hartley
While examining py2exe et al of late, my thoughts keep returning to the idea of writing, in C or similar, a compiled stand-alone executable 'bootstrapper', which: 1) downloads and install a Python interpreter if none exists 2) runs the application's Python source code using this interpreter. An ap

Re: Does turtle graphics have the wrong associations?

2009-11-13 Thread Jonathan Campbell
on a Python binding of SDL (Simple DirectMedia Layer) an open-source games API. This could mean easy migration to C++ games programming (using SDL). Best regards, Jon C. -- Jonathan Campbell www.jgcampbell.com BT48, UK. -- http://mail.python.org/mailman/listinfo/python-list

Re: bootstrapping on machines without Python

2009-11-14 Thread Jonathan Hartley
On Nov 13, 1:57 pm, Tim Golden wrote: > Jonathan Hartley wrote: > > While examining py2exe et al of late, my thoughts keep returning to > > the idea of writing, in C or similar, a compiled stand-alone > > executable 'bootstrapper', which: > > 1) downloads and

Re: bootstrapping on machines without Python

2009-11-14 Thread Jonathan Hartley
On Nov 13, 10:25 pm, [email protected] wrote: > On Fri, 13 Nov 2009 02:40:28 -0800 (PST) > > Jonathan Hartley wrote: > > Even my very limited understanding of the issues is enough to see that > > the idea is far from trivial. Thanks heaps for the input from everyone. Mart

Re: Vote on PyPI comments

2009-11-15 Thread Jonathan Hartley
comments system at all. Can comments accrue which complain about bugs or missing features of old versions of the package? If so, they could be misleading for users coming to view a package before trying it. Or do comments and ratings only apply to a particular version of a package, and get removed from the package's 'front page' every time a new version is released? Thanks, Jonathan Hartley -- http://mail.python.org/mailman/listinfo/python-list

Re: IDE for python

2009-11-16 Thread Jonathan Hartley
On Nov 16, 5:09 am, sturlamolden wrote: > On 15 Nov, 18:09, Peng Yu wrote: > > > There had been some discussion on IDE. But I'm not sure what pros and > > cons of each choice. Current, I'm using vim and ctags. > > > Could somebody give some advices on choosing the best IDE for me? > > There is a

RE: New syntax for blocks

2009-11-17 Thread Jonathan Saxton
On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: >> Congratulations, you just reinvented one of the most infamous source of >> bugs in C, C++, Java, PHP, javascript and quite a few other languages. >> Believe it or not, but not allowing this in Python was a very deliberate >> design

FYI: ConfigParser, ordered options, PEP 372 and OrderedDict + big thank you

2009-11-17 Thread Jonathan Fine
been done already, and will be waiting for me when I move to Python3. So a big thank you is in order. -- Jonathan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Ruby

2010-02-01 Thread Jonathan Gardner
On Jan 30, 8:43 am, Nobody wrote: > On Wed, 27 Jan 2010 15:29:05 -0800, Jonathan Gardner wrote: > > Python is much, much cleaner. I don't know how anyone can honestly say > > Ruby is cleaner than Python. > > I'm not familiar with Ruby, but most languages are cle

Re: Python and Ruby

2010-02-01 Thread Jonathan Gardner
On Jan 31, 3:01 am, rantingrick wrote: > On Jan 30, 10:43 am, Nobody wrote: > > > That's also true for most functional languages, e.g. Haskell and ML, as > > well as e.g. Tcl and most shells. Why require "f(x)" or "(f x)" if "f x" > > will suffice? > > yuck! wrapping the arg list with parenthesis

Re: Python and Ruby

2010-02-01 Thread Jonathan Gardner
On Jan 31, 12:43 pm, Nobody wrote: > > If it was common-place to use Curried functions and partial application in > Python, you'd probably prefer "f a b c" to "f(a)(b)(c)" as well. > That's just the point. It isn't common to play with curried functions or monads or anything like that in computer

Re: For loop searching takes too long!

2010-02-02 Thread Jonathan Gardner
On Jan 29, 7:07 pm, Steven D'Aprano wrote: > On Fri, 29 Jan 2010 14:49:06 -0800, Jonathan Gardner wrote: > > On Jan 28, 3:52 pm, elsa wrote: > > >> I've got a problem with my program, in that the code just takes too > >> long to run. Here's what

Re: python admin abuse complaint

2010-02-02 Thread Jonathan Gardner
On Feb 2, 12:40 pm, Xah Lee wrote: > > (12:12:16 PM) xahlee: is hash={} and hash.clean() identical? > I think you mean hash.clear() instead of hash.clean() The answer is that "hash = {}" will create a new dict and assign it to "hash", while "hash.clear()" simply guts the dict that "hash" is poin

Re: How to guard against bugs like this one?

2010-02-02 Thread Jonathan Gardner
On Feb 1, 6:34 pm, kj wrote: > > An innocuous little script, let's call it buggy.py, only 10 lines > long, and whose output should have been, at most two lines, was > quickly dumping tens of megabytes of non-printable characters to > my screen (aka gobbledygook), and in the process was messing up

Re: Python and Ruby

2010-02-02 Thread Jonathan Gardner
On Feb 2, 2:21 am, waku wrote: > > for writing new code, it's not necessarily that helpful to be *forced* > to keep with strict indenting rules.  in early development phases, > code is often experimental, and parts of it may need to be blocked or > unblocked as the codebase grows, and for experime

Re: Python and Ruby

2010-02-02 Thread Jonathan Gardner
On Feb 1, 6:21 pm, Nobody wrote: > > You don't need to know the entire language before you can use any of it > (if you did, Python would be deader than a certain parrot; Python's dark > corners are *really* dark). > I'm curious. What dark corners are you referring to? I can't think of any. Especi

Re: Python and Ruby

2010-02-02 Thread Jonathan Gardner
On Feb 1, 6:36 pm, John Bokma wrote: > Jonathan Gardner writes: > > One of the bad things with languages like perl > > FYI: the language is called Perl, the program that executes a Perl > program is called perl. > > > without parentheses is that getting a funct

Re: Python and Ruby

2010-02-02 Thread Jonathan Gardner
On Feb 2, 7:23 am, "bartc" wrote: > Jonathan Gardner wrote: > > One of the bad things with languages like perl and Ruby that call > > without parentheses is that getting a function ref is not obvious. You > > need even more syntax to do so. In perl: > > >

Re: Python and Ruby

2010-02-02 Thread Jonathan Gardner
On Feb 1, 6:50 pm, Nobody wrote: > On Mon, 01 Feb 2010 14:13:38 -0800, Jonathan Gardner wrote: > > I judge a language's simplicity by how long it takes to explain the > > complete language. That is, what minimal set of documentation do you > > need to describe all of th

Re: Python and Ruby

2010-02-03 Thread Jonathan Gardner
On Feb 2, 9:11 pm, John Bokma wrote: > Jonathan Gardner writes: > > I can explain, in an hour, every single feature of the Python language > > to an experienced programmer, all the way up to metaclasses, > > Either you're a hell of a talker, or I am far, far away f

Re: Python and Ruby

2010-02-04 Thread Jonathan Gardner
On Feb 3, 3:39 pm, Steve Holden wrote: > Robert Kern wrote: > > On 2010-02-03 15:32 PM, Jonathan Gardner wrote: > > >> I can explain all of Python in an hour; I doubt anyone will understand > >> all of Python in an hour. > > > With all respect, talking abou

Re: Python and Ruby

2010-02-09 Thread Jonathan Gardner
On Feb 9, 1:51 am, waku wrote: > 'stupid', 'wrong', 'deficient', 'terrible', ...  you're using strong > words instead of concrete arguments, it might intimidate your > opponents, but is hardly helpful in a fair discussion. > In today's day and age, I don't know how a text editor which cannot do s

Re: PostgreSQL driver for Python applications that supports bytea correctly?

2010-02-09 Thread Jonathan Gardner
On Feb 9, 7:27 am, CyclingGuy wrote: > Can anyone recommend a PostgreSQL driver for Python that supports > selecting and inserting bytea types? > Can you name some that don't? -- http://mail.python.org/mailman/listinfo/python-list

Re: Need debugging knowhow for my creeping Unicodephobia

2010-02-10 Thread Jonathan Gardner
On Feb 10, 11:09 am, kj wrote: > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: > ordinal not in range(128) > You'll have to understand some terminology first. "codec" is a description of how to encode and decode unicode data to a stream of bytes. "decode" means you

Re: Is a merge interval function available?

2010-02-11 Thread Jonathan Gardner
On Feb 10, 3:23 pm, Peng Yu wrote: > I'm wondering there is already a function in python library that can > merge intervals. For example, if I have the following intervals ('[' > and ']' means closed interval as > inhttp://en.wikipedia.org/wiki/Interval_(mathematics)#Excluding_the_end...) > > [1,

Re: Please help with MemoryError

2010-02-11 Thread Jonathan Gardner
On Feb 11, 3:39 pm, Jeremy wrote: > I have been using Python for several years now and have never run into > memory errors… > > until now. > Yes, Python does a good job of making memory errors the least of your worries as a programmer. Maybe it's doing too good of a job... > My Python program no

Re: Parsing for email addresses

2010-02-15 Thread Jonathan Gardner
On Feb 15, 3:34 pm, galileo228 wrote: > > I'm trying to write python code that will open a textfile and find the > email addresses inside it. I then want the code to take just the > characters to the left of the "@" symbol, and place them in a list. > (So if [email protected] was in the file, '

Re: Few Small Questions Regarding CGI

2010-02-15 Thread Jonathan Gardner
On Feb 15, 2:04 pm, joy99 wrote: > > I am trying to learn CGI. I was checking Python Docs. There are > multiple modules. Which one to start with? > Is there any other material or URL for step by step learning of CGI. > I would suggest skipping 15 years of internet progress and going with a more m

Re: Time out a regular expression in Python 2.6.4?

2010-02-15 Thread Jonathan Gardner
On Feb 15, 7:59 am, Steve Holden wrote: > [email protected] wrote: > > Is there any way to time out a regular expression in Python 2.6.4? > > > Motiviation: Our application allows users to enter regular expressions > > as validation criteria. If a user enters a pathological regular > > expression

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-16 Thread Jonathan Gardner
On Feb 16, 11:41 am, Andrej Mitrovic wrote: > On Feb 16, 7:38 pm, Casey Hawthorne > wrote: > > > Interesting talk on Python vs. Ruby and how he would like Python to > > have just a bit more syntactic flexibility. > > >http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-de... > > --

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-17 Thread Jonathan Gardner
On Feb 17, 10:39 am, John Bokma wrote: > Jonathan Gardner writes: > > Then I looked at a stack trace from a different programming language > > with lots of anonymous functions. (I believe it was perl.) > > > I became enlightened. > > If it was Perl [1], I doub

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-17 Thread Jonathan Gardner
On Feb 17, 12:02 am, Lawrence D'Oliveiro wrote: > In message > <8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com>, > > Jonathan Gardner wrote: > > I used to think anonymous functions (AKA blocks, etc...) would be a > > nice feature for Python. &

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-17 Thread Jonathan Gardner
On Feb 17, 12:02 am, Lawrence D'Oliveiro wrote: > In message <60b1abce-4381-46ab-91ed- > > [email protected]>, Andrej Mitrovic wrote: > > Also, lambda's are expressions, not statements ... > > Is such a distinction Pythonic, or not? For example, does Python distinguish > be

Re: How to efficiently extract information from structured text file

2010-02-17 Thread Jonathan Gardner
On Feb 16, 3:48 pm, Imaginationworks wrote: > Hi, > > I am trying to read object information from a text file (approx. > 30,000 lines) with the following format, each line corresponds to a > line in the text file.  Currently, the whole file was read into a > string list using readlines(), then use

Re: Creating Import Hooks

2010-02-18 Thread Jonathan Gardner
On Feb 17, 10:48 pm, Sreejith K wrote: > Hi everyone, > > I need to implement custom import hooks for an application > (http://www.python.org/dev/peps/pep-0302/). I want to restrict an application > to import certain modules (say socket module). Google app engine is > using a module hook to do th

Re: Help with lambda

2010-02-18 Thread Jonathan Gardner
On Feb 18, 4:28 am, lallous wrote: > > f = [lambda x: x ** n for n in xrange(2, 5)] This is (pretty much) what the above code does. >>> f = [] >>> n = 2 >>> f.append(lambda x: x**n) >>> n = 3 >>> f.append(lambda x: x**n) >>> n = 4 >>> f.append(lambda x: x**n) >>> n = 5 >>> f.append(lambda x: x**

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Jonathan Gardner
On Feb 18, 8:15 am, Steve Howell wrote: > >     def print_numbers() >         [1, 2, 3, 4, 5, 6].map { |n| >             [n * n, n * n * n] >         }.reject { |square, cube| >             square == 25 || cube == 64 >         }.map { |square, cube| >             cube >         }.each { |n| >    

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Jonathan Gardner
On Feb 18, 3:04 pm, "[email protected]" wrote: > > You could do it without intermediate names or lambdas in Python as: > def print_numbers(): >     for i in [ cube for (square, cube) in >                          [(n*n, n*n*n) for n in [1,2,3,4,5,6]] >                if square!=25 and cube!=64 ]

Re: Creating Import Hooks

2010-02-18 Thread Jonathan Gardner
On Feb 18, 1:28 am, Sreejith K wrote: > On Feb 18, 1:57 pm, Steven D'Aprano > > > > wrote: > > On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote: > > > On Feb 17, 10:48 pm, Sreejith K wrote: > > >> Hi everyone, > > > >&

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-19 Thread Jonathan Gardner
doesn't mean you get to be silly in how you move data around. Avoid copies as much as possible, and try to avoid slurping in large files all at once. Line-by-line processing is best. I think you should invert this operation into a for loop. Most people tend to think of things better that w

Re: Chaining 501 generators breaks everything?

2010-02-19 Thread Jonathan Gardner
n: if i%s == 0: break else: # Run if the for loop doesn't break seen.append(i) yield i start = time() for i in islice(primes(), 0, 1): print i print time() - start -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't Access ANY url from python (errno 61)

2010-02-19 Thread Jonathan Gardner
> Are you running behind a firewall? See if Firefox is configured with a proxy. You'll have to use that to talk to any website. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-19 Thread Jonathan Gardner
some mathematics on them and > compare different files. So my interest was in making it faster to open them > as needed. I guess part of it is that they are about 5mb so I guess it might > be disk speed in part.nks > > Record your numbers in an array and then work your magic on the

Re: Scalable python dict {'key_is_a_string': [count, some_val]}

2010-02-19 Thread Jonathan Gardner
leneck is the 'sort' command. > > Any suggestions, comments? > You should be using BDBs or even something like PostgreSQL. The indexes there will give you the scalability you need. I doubt you will be able to write anything that will select, update, insert or delete data

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Jonathan Gardner
On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan wrote: > > Now, why don't we start a PEP to make python a fully-functional language > then? > Because people don't think the same way that programs are written in functional languages. -- Jonathan Gardner jgard...@jonath

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Jonathan Gardner
assigning a slice the elements will be copied. > Basically, I'm looking for something like l1.pop(10,len(l1)) which > returns and removes a whole chunk of data. Is there such a thing (and > if not, why not?) > The idiom is: >>> l1, l2 = l1[:10], l1[10:] Don't know

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-20 Thread Jonathan Gardner
is global state involved, you may want to save yourself some trouble in the future and put the above in a class where separate parsers can be kept separate. It looks like your program is turning into a regular old parser. Any format that is a little more than trivial to parse will need a real parser like the above. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: if not global -- then what?

2010-02-20 Thread Jonathan Gardner
lexically scoped variable that is shared among other functions. For instance: def foo(): i = 0 def inc(): global i; i+=1 def dec(): global i; i-=1 def get(): return i return (inc, dec, get) This really isn't that common, although it is useful. Note that the above might be better organized into a class instance. Good luck. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: /usr/bin/ld: cannot find -lz on Cent OS - Python 2.4

2010-02-20 Thread Jonathan Gardner
fferent version of libz than what's installed on your box. If so, you'll need to see if you can find the right version. The MySQL-python people should have more help for you. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-20 Thread Jonathan Gardner
g. > It may be that the csvfile is reading the entire file in, rather than line-by-line. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Jonathan Gardner
cessing files this large is possible, it isn't easy. Your time is better spent letting the DB figure out how to arrange your data for you. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Jonathan Gardner
array lengths than just copying the data over? Array copies are extremely fast on modern processors. Programmer time and processor time being what it is, I still think my answer is the correct one. No, it's not what he says he wants, but it is what he needs. -- Jonathan Gardner jgard...@

Re: lists of variables

2010-02-20 Thread Jonathan Gardner
>> vars['b'] = 2 >>> mylist = ['a', 'b'] >>> print [vars[i] for i in mylist] # Here's your dereference [1,2] >>> vars['a'] = 3 >>> print [vars[i] for i in mylist] [3,2] -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:53 PM, Vincent Davis wrote: >> On Sat, Feb 20, 2010 at 6:44 PM, Jonathan >> Gardner  wrote: >> >> With this kind of data set, you should start looking at BDBs or >> PostgreSQL to hold your data. While processing files this large is >>

Re: if not global -- then what?

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:53 PM, Steven D'Aprano wrote: > On Sat, 20 Feb 2010 17:34:15 -0800, Jonathan Gardner wrote: >> In terms of "global", you should only really use "global" when you are >> need to assign to a lexically scoped variable that is share

Re: Efficient way to break up a list into two pieces

2010-02-21 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 10:48 PM, Steven D'Aprano wrote: > On Sat, 20 Feb 2010 21:21:47 -0800, Jonathan Gardner wrote: >> For ten items, though, is it really faster to muck around with array >> lengths than just copying the data over? Array copies are extremely fast >

Re: Can I make sqlite3 or shelve work reliably on any Win/Linux/Mac?

2010-02-22 Thread Jonathan Gardner
ls your code, he must also install the requisite modules that you list as dependencies. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: Use eval() safely?

2010-02-22 Thread Jonathan Gardner
t string? > > Which Python built-ins and math functions would I have to add to > the functions dictionary to make it unsafe? > Why would you ever run untrusted code on any machine in any language, let alone Python? If you're writing a web app, make it so that you only run truste

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Jonathan Gardner
On Sun, Feb 21, 2010 at 10:22 AM, John Bokma wrote: > Jonathan Gardner writes: >> On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan wrote: >>> >>> Now, why don't we start a PEP to make python a fully-functional language >>> then? >> >> Because peop

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Jonathan Gardner
th the statement-based approach. A minority understand let alone appreciate the functional approach. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: When will Python go mainstream like Java?

2010-02-22 Thread Jonathan Gardner
On Mon, Feb 22, 2010 at 1:56 PM, AON LAZIO wrote: > That will be superb > It already has. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: SMTPServerDisconnected

2010-02-23 Thread Jonathan Gardner
t; unix  2      [ ]         DGRAM                    10370 >  @/org/kernel/udev/udevd > unix  2      [ ]         DGRAM                    6077731 > unix  3      [ ]         STREAM     CONNECTED     6077679 > unix  3      [ ]         STREAM     CONNECTED     6077678 > unix  2      [ ]

WANTED: Regular expressions for breaking TeX/LaTeX document into tokens

2010-02-24 Thread Jonathan Fine
Hi Does anyone know of a collection of regular expressions that will break a TeX/LaTeX document into tokens? Assume that there is no verbatim or other category code changes. Thanks Jonathan -- http://mail.python.org/mailman/listinfo/python-list

Re: Docstrings considered too complicated

2010-02-24 Thread Jonathan Gardner
stuff""" > def doStuff(): >    while not wise(up): >        yield scorn > > Now my question is this: How do I kill these people without the > authorities thinking they didn't deserve it? > kill -9 seems to work for me. You may want to explain, one day, wh

Re: WANTED: Regular expressions for breaking TeX/LaTeX document into tokens

2010-02-26 Thread Jonathan Fine
Wes James wrote: On Wed, Feb 24, 2010 at 5:03 AM, Jonathan Fine wrote: Hi Does anyone know of a collection of regular expressions that will break a TeX/LaTeX document into tokens? Assume that there is no verbatim or other category code changes. I'm not sure how this does it, but it

Re: Sort Big File Help

2010-03-03 Thread Jonathan Gardner
be appreciated. Thank you. > You may also want to look at the GNU tools "sort" and "cut". If your job is to process files, I'd recommend tools designed to process files for the task. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Re: Working group for Python CPAN-equivalence?

2010-03-03 Thread Jonathan Gardner
iencies in Perl that Python doesn't suffer from. I am sure we could do well not to replicate those features. Regardless, Python's packages are distributed in a number of ways. PyPI is only one of them. Fedora and Ubuntu are two other ways. -- Jonathan Gardner jgard...@jon

Re: Generic singleton

2010-03-03 Thread Jonathan Gardner
On Wed, Mar 3, 2010 at 1:11 PM, mk wrote: > > Or I could make my life simpler and use global variable. :-) > Ding ding ding! 90% of Design Patterns is making Java suck less. Other languages don't necessarily suffer from Java's design flaws. -- Jonathan Gardner jgard...@

Re: NoSQL Movement?

2010-03-03 Thread Jonathan Gardner
tood well enough that the general nature of the SQL database is unnecessary. -- Jonathan Gardner [email protected] -- http://mail.python.org/mailman/listinfo/python-list

Twisted 10.0.0 released

2010-03-03 Thread Jonathan Lange
On behalf of Twisted Matrix Laboratories, I am honored to announce the release of Twisted 10.0. Highlights include: * Improved documentation, including "Twisted Web in 60 seconds" * Faster Perspective Broker applications * A new Windows installer that ships without zope.interface * Twisted

<    1   2   3   4   5   6   7   >