Re: How to do this in Python?

2009-03-17 Thread Luis Zarrabeitia
On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: > > Am I missing something basic, or is this the canonical way: > > with open(filename,"rb") as f: > buf = f.read(1) > while len(buf) > 0 > # do something > buf = f.read(1) well, a

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread Benjamin Kaplan
On Tue, Mar 17, 2009 at 6:14 PM, grocery_stocker wrote: > Given the following > > [example of cached numbers] > > > It seems like id(list[]) == id(). However, I > can't find anything in the python documentation that talks about it. > Did I perhaps overlook something? You didn't find anythin

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread grocery_stocker
On Mar 17, 3:22 pm, Emile van Sebille wrote: > grocery_stocker wrote: > > > > > > > It seems like id(list[]) == id(). > > It might seem that way, but test with other than single-character > strings, eg lists like [7],[8],[9] and try again. > I still get the same thing... [cdal...@localhost ~]$

Re: ldap package question

2009-03-17 Thread Michael Ströder
John Gordon wrote: > I'm using the ldap package to connect to an ldap server and run a query. > Very simple code, along these lines: > > con = ldap.initialize(uri) > con.simple_bind_s(user, password) > results = con.search_s(group, ldap.SCOPE_SUBTREE, filter, attrs) > for r in results: >

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread Gary Herron
grocery_stocker wrote: Given the following [cdal...@localhost ~]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 Type "help", "copyright", "credits" or "license" for more information. list = [7,8,9] id(list) -1209401076 id(

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Jones
On Tue, Mar 17, 2009 at 02:10:36PM EDT, Chris Rebert wrote: > On Mon, Mar 16, 2009 at 6:05 PM, robert song > wrote: > > Hello, everyone. > > python can be debugged with pdb, but if there anyway to get a quick > > view of the python execution. > > Just like sh -x of bash command. > > I didn't find

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread Martin v. Löwis
> It seems like id(list[]) == id(). However, I > can't find anything in the python documentation that talks about it. It's deliberately undocumented (outside of the source code, that is). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: array next pointer

2009-03-17 Thread Armin
On Tuesday 17 March 2009 19:04:25 Luis Zarrabeitia wrote: > On Tuesday 17 March 2009 03:17:02 pm R. David Murray wrote: > > > > (btw, I love the new sentinel argument for the next function in > > > > python3!) > > > > > > next() doesn't have a sentinel argument. It's iter() which does, and > > > th

Re: How to do this in Python?

2009-03-17 Thread Armin
On Tuesday 17 March 2009 19:10:20 Josh Holland wrote: > On Tue, Mar 17, 2009 at 05:04:36PM -0500, Jim Garrison wrote: > > What's the canonical Python way of implementing this pseudocode? > > > > String buf > > File f > > while ((buf=f.read(1)).length() > 0) > > { > > d

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread andrew cooke
grocery_stocker wrote: > It seems like id(list[]) == id(). However, I > can't find anything in the python documentation that talks about it. > Did I perhaps overlook something? most of your examples stated the obvious (that if x is in a list l at index i then id(list[i]) == id(x) - this is because

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread Emile van Sebille
grocery_stocker wrote: On Mar 17, 3:22 pm, Emile van Sebille wrote: grocery_stocker wrote: It seems like id(list[]) == id(). It might seem that way, but test with other than single-character strings, eg lists like [7],[8],[9] and try again. I still get the same thing... Well, yes -- becaus

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread Aahz
In article <163b0c86-adf7-434c-9270-c819c5a07...@k29g2000prf.googlegroups.com>, grocery_stocker wrote: > >[cdal...@localhost ~]$ python >Python 2.4.3 (#1, Oct 1 2006, 18:00:19) >[GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 >Type "help", "copyright", "credits" or "license" for more informati

MySQL DB Error

2009-03-17 Thread manny
Hi, When I buil the MySQLDB mod I get the following error: [r...@box MySQL-python-1.2.2]# â_mysql.c:2420: error: â_mysql_ResultObjectâ has no member named âconverter -bash: â_mysql.c:2420:: command not found [r...@box MySQL-python-1.2.2]# â_mysql.c:2420: error: initializer element is not constan

Re: How to do this in Python?

2009-03-17 Thread Jim Garrison
Tim Chase wrote: >> Am I missing something basic, or is this the canonical way: >> >> with open(filename,"rb") as f: >> buf = f.read(1) >> while len(buf) > 0 >> # do something >> buf = f.read(1) > > That will certainly do. Since read()

Re: How to do this in Python?

2009-03-17 Thread Jim Garrison
andrew cooke wrote: > Jim Garrison wrote: >> I'm an experienced C/Java/Perl developer learning Python. >> >> What's the canonical Python way of implementing this pseudocode? [snip] > > embarrassed by the other reply i have read, There's always some "trollish" behavior in any comp.lang.* group.

Re: How to do this in Python?

2009-03-17 Thread MRAB
Jim Garrison wrote: [snip] Ah. That's the Pythonesque way I was looking for. > FYI, the correct word is "Pythonic". "Pythonesque" refers to Monty Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do this in Python?

2009-03-17 Thread Terry Reedy
Jim Garrison wrote: Ah. That's the Pythonesque way I was looking for. I knew it would be a generator/iterator but haven't got the Python mindset down yet and haven't played with writing my own generator. I'm still trying to think in purely object- oriented terms where I would override __next_

Re: Python + PostgreSQL

2009-03-17 Thread Lobo
Many thanks to all for your valuable input. I've done some research and I believe I will use (at least for now, to make it simple) psycopg2 module to connect Python to PostgreSQL. I am wondering whether I can jump directly to Python 3.x (instead of using Python 2.6), depending of course on psycop

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-17 Thread bdb112
Thanks for all the replies: I think I see now - % is a binary operator whose precedence rules are shared with the modulo operator regardless of the nature of its arguments, for language consistency. I understand the arguments behind the format method, but hope that the slightly idiosyncratic print(

Re: Python + PostgreSQL

2009-03-17 Thread Philip Semanchuk
On Mar 17, 2009, at 10:57 PM, Lobo wrote: Many thanks to all for your valuable input. I've done some research and I believe I will use (at least for now, to make it simple) psycopg2 module to connect Python to PostgreSQL. I am wondering whether I can jump directly to Python 3.x (instead of us

Roundup Issue Tracker release 1.4.8

2009-03-17 Thread Richard Jones
I'm proud to release version 1.4.8 of Roundup. This release fixes some regressions: - bug introduced into hyperdb filter (issue 2550505) - bug introduced into CVS export and view (issue 2550529) - bugs introduced in the migration to the email package (issue 2550531) And adds a couple of other fi

Re: How to do this in Python?

2009-03-17 Thread Grant Edwards
On 2009-03-17, Jim Garrison wrote: > I'm an experienced C/Java/Perl developer learning Python. > > What's the canonical Python way of implementing this pseudocode? > > String buf > File f > while ((buf=f.read(1)).length() > 0) > { > do something > } > >

Re: How to do this in Python?

2009-03-17 Thread Grant Edwards
On 2009-03-18, Jim Garrison wrote: > Tim Chase wrote: >>> Am I missing something basic, or is this the canonical way: >>> >>> with open(filename,"rb") as f: >>> buf = f.read(1) >>> while len(buf) > 0 >>> # do something >>> buf = f.read(1

Re: How to do this in Python?

2009-03-17 Thread Grant Edwards
On 2009-03-18, Grant Edwards wrote: > On 2009-03-17, Jim Garrison wrote: >> I'm an experienced C/Java/Perl developer learning Python. >> >> What's the canonical Python way of implementing this pseudocode? >> >> String buf >> File f >> while ((buf=f.read(1)).length() > 0) >>

RE: Python + PostgreSQL

2009-03-17 Thread Jeff Peck
Just thought I'd add that I've been using SQLAlchemy + Postgresql w/ psycopg2 driver with great success for a long time now. This is just a preference, but I like using SQLAlchemy without the ORM. It has really good support for basic low level stuff like defining tables, inserts and updates. The bi

Re: Creating a python extension that works with multiprocessing.Queue

2009-03-17 Thread Gabriel Genellina
En Sun, 15 Mar 2009 01:51:35 -0200, Travis Miller escribió: I am very new to the python C API, and have written a simple type called SU2 that has 4 members that are all doubles. Everything seems to work fine (can import my module and instantiate the new type and act on it with various method

Re: download x bytes at a time over network

2009-03-17 Thread Gabriel Genellina
En Tue, 17 Mar 2009 17:09:35 -0200, R. David Murray escribió: Jean-Paul Calderone wrote: On Tue, 17 Mar 2009 15:17:56 + (UTC), "R. David Murray" wrote: >Jean-Paul Calderone wrote: >> On Tue, 17 Mar 2009 12:15:23 +0530, Saurabh wrote: >> > >> >It seems to have some header like the

Re: Mangle function name with decorator?

2009-03-17 Thread Michele Simionato
On Mar 17, 7:45 pm, Aaron Brady wrote: > (Perhaps someday, we will be able to write: > def dec( namespace ): >   def outer( fun ): >     if fun.__name__ in namespace: >       namespace[ dup_var ]= namespace[ fun.__name__ ] >     return fun >   return outer > It allows us to see if there's a prior

Re: Mangle function name with decorator?

2009-03-17 Thread Michele Simionato
I forgot; people interested in metaclasses in Python 3.0 will want to read this paper: http://www.artima.com/weblogs/viewpost.jsp?thread=236234 -- http://mail.python.org/mailman/listinfo/python-list

Python to Perl transalators

2009-03-17 Thread Abhinayaraj . Raju
Could anyone suggest whether there is any Python to Perl code convertors? I found one on the net viz. Perthon. But it wasn't really helping out. Thanks Agni -- http://mail.python.org/mailman/listinfo/python-list

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-17 Thread Matt Nordhoff
bdb112 wrote: > Thanks for all the replies: > I think I see now - % is a binary operator whose precedence rules are > shared with the modulo operator regardless of the nature of its > arguments, for language consistency. > I understand the arguments behind the format method, but hope that the > sli

Re: Python to Perl transalators

2009-03-17 Thread Chris Rebert
2009/3/17 : > Could anyone suggest whether there is any Python to Perl code convertors? > I found one on the net viz. Perthon. But it wasn’t really helping out. Why on earth would you want to? That'd be like translating Shakespeare into a bad rap song! Cheers, Chris -- I have a blog: http://

Re: download x bytes at a time over network

2009-03-17 Thread Matt Nordhoff
Saurabh wrote: > Heres the reason behind wanting to get chunks at a time. > Im actually retrieving data from a list of RSS Feeds and need to > continuously check for latest posts. > But I dont want to depend on Last-Modified header or the pubDate tag > in . Because a lot of feeds just output date('

RE: Python to Perl transalators

2009-03-17 Thread Abhinayaraj . Raju
-Original Message- From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert Sent: Wednesday, March 18, 2009 10:53 AM To: Raju, Abhinayaraj Cc: python-list@python.org Subject: Re: Python to Perl transalators 2009/3/17 : > Could anyone suggest whether there is any Pyt

Re: Python to Perl transalators

2009-03-17 Thread Armin
On Wednesday 18 March 2009 02:22:57 Chris Rebert wrote: > 2009/3/17 : > > Could anyone suggest whether there is any Python to Perl code convertors? > > I found one on the net viz. Perthon. But it wasn’t really helping out. > > > Why on earth would you want to? That'd be like translating Shakespea

Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-17 Thread CJ Kucera
Hello list! I'm having a strange issue, and I'm not entirely certain yet where the actual problem is (ie, Python, PyGTK, or gtk+), but I figure I'll start here. Bear with me, this'll probably be a long explanation... I've been building an app which is meant to be run on both Linux and Windows.

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-17 Thread John Machin
On Mar 18, 4:19 pm, Matt Nordhoff wrote: > bdb112 wrote: > > Thanks for all the replies: > > I think I see now - % is a binary operator whose precedence rules are > > shared with the modulo operator regardless of the nature of its > > arguments, for language consistency. > > I understand the argum

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-17 Thread Gabriel Genellina
En Tue, 17 Mar 2009 01:24:18 -0200, Aaron Garrett escribió: On Mar 16, 9:59 pm, Chris Rebert wrote: On Mon, Mar 16, 2009 at 7:48 PM, Aaron Garrett wrote: > I have spent quite a bit of time trying to find the answer on this > group, but I've been unsuccessful. Here is what I'd like to be able

Re: Python + PostgreSQL

2009-03-17 Thread Jeroen Ruigrok van der Werven
-On [20090318 04:01], Lobo (carlosgali...@gmail.com) wrote: >I am wondering whether I can jump directly to Python 3.x (instead of >using Python 2.6), depending of course on psycopg2 compatibility?. Might I suggest sticking to 2.6 for now? The 2.x series is what is now going around as 'stable' in

<    1   2