psycopg2 & large result set

2007-05-25 Thread Jon Clements
Hi All. I'm using psycopg2 to retrieve results from a rather large query (it returns 22m records); unsurprisingly this doesn't fit in memory all at once. What I'd like to achieve is something similar to a .NET data provider I have which allows you to set a 'FetchSize' property; it then retrieves '

Re: Understanding mxODBC Insert Error

2007-07-29 Thread Jon Clements
On 29 Jul, 17:41, Greg Corradini <[EMAIL PROTECTED]> wrote: > Hello, > I'm trying to perform a simple insert statement into a table called > Parcel_Test (see code below). Yet, I get an error message that I've never > seen before (see traceback below). I've tried to put a semicolon at the end > of t

Re: What order does info get returned in by os.listdir()

2007-08-15 Thread Jon Clements
To emulate the order of XP, you might be able to get away with something like:- sorted( myData, key=lambda L: L.replace('~',chr(0)) ) That just forces all '~'s to be before everything else. hth, Jon. On 15 Aug, 14:33, Jeremy C B Nicoll <[EMAIL PROTECTED]> wrote: > Marc 'BlackJack' Rintsch

Re: Biased random?

2007-08-27 Thread Jon Clements
How about decorating your list of elements with an additional value, which indicates the weight of that element. A value of 1 will indicate 'as likely as any other', < 1 will be 'less likely than' any other and > 1 will be 'more likely than any other'. Then create a sorted list based on the combine

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm very new to python, the problem I need to solve is whats the "best/ > simplest/cleanest" way to read in multiple files (ascii), do stuff to > them, and write them out(ascii). > > -- > import os > > filePath = ('O:/spam/eggs/')

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: > On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: > > > > > > > Hi there, > > > I'm very new to python, the problem I need to solve is whats the "best/ > &g

CSV module and "fileobj"

2007-03-16 Thread Jon Clements
Hi Group, If I have a CSV reader that's passed to a function, is it possible for that function to retrieve a reference to the "fileobj" like object that was passed to the reader's __init__? For instance, if it's using an actual file object, then depending on the current row, I'd like to open the f

Re: String formatting with fixed width

2007-03-16 Thread Jon Clements
On 16 Mar, 13:20, Alexander Eisenhuth <[EMAIL PROTECTED]> wrote: > Hello alltogether, > > is it possible to format stings with fixed width of let's say 7 character. T > need a floating point with 3 chars before dot, padded with ' ' and 3 chars > after > dot, padded with '0'. > > Followingh is my a

Re: Boost Python properties/getter functions for strings

2007-03-19 Thread Jon Clements
On 19 Mar, 16:40, "Shawn McGrath" <[EMAIL PROTECTED]> wrote: > On Mar 19, 12:00 pm, "Shawn McGrath" <[EMAIL PROTECTED]> wrote: > > > I forgot to mention, getname is defined as: > > const std::string &Entity::getName() const; > > After more reading I found the copy_const_reference, and replaced: >

Re: ctypes with Compaq Visual Fortran 6.6B *.dll (Windows XP), passing of integer and real values

2009-01-27 Thread Jon Clements
On Jan 27, 9:41 pm, alex wrote: > Hello everybody > I am mainly a Fortran programmer and beginning to learn Python(2.5) > and OOP programming. > I hope in the end to put a GUI on my existing Fortran code. > Therefore I am also trying to learn Python's "ctypes" library. > > Unfortunately the ctypes

Re: Why doesn't eval of generator expression work with locals?

2009-01-27 Thread Jon Clements
On Jan 27, 11:31 pm, Fabio Zadrozny wrote: > Hi All, > > Anyone knows why the code below gives an error? > > global_vars = {} > local_vars = {'ar':["foo", "bar"], 'y':"bar"} > print eval('all((x == y for x in ar))', global_vars, local_vars) > > Error: > > Traceback (most recent call last): >   Fil

Re: How to execute a hyperlink?

2009-01-27 Thread Jon Clements
On Jan 28, 12:59 am, Muddy Coder wrote: > Hi Folks, > > Module os provides a means of running shell commands, such as: > > import os > os.system('dir .') > > will execute command dir > > I think a hyperlink should also be executed. I tried: > > os.system('http://somedomain.com/foo.cgi?name=foo&pas

Re: bigint to timestamp

2009-01-28 Thread Jon Clements
On Jan 28, 1:50 pm, Steve Holden wrote: > Shah Sultan Alam wrote: > > Hi Group, > > I have file with contents retrieved from mysql DB. > > which has a time field with type defined bigint(20) > > I want to parse that field into timestamp format(-MM-DD HH:MM:SS > > GMT) using python code. > > Th

Number of bits/sizeof int

2009-01-30 Thread Jon Clements
Hi Group, This has a certain amount of irony (as this is what I'm pretty much after):- >From http://docs.python.org/dev/3.0/whatsnew/3.1.html: "The int() type gained a bit_length method that returns the number of bits necessary to represent its argument in binary:" Any tips on how to get this in

Re: Number of bits/sizeof int

2009-01-30 Thread Jon Clements
On Jan 31, 7:29 am, John Machin wrote: > On Jan 31, 6:03 pm, Jon Clements wrote: > > > Hi Group, > > > This has a certain amount of irony (as this is what I'm pretty much > > after):- > > Fromhttp://docs.python.org/dev/3.0/whatsnew/3.1.html: > > &qu

Re: Problems installing PySQLite, SQLite and Trac

2009-02-01 Thread Jon Clements
On 1 Feb, 15:48, kimwlias wrote: > My initial goal is to finally install Trac. This is the second day > I've been trying to make this possible but I can't find, for the life > of me, how to do this. OK, here is the story: > > My system is a VPS with CentOS 5. > > I found out that I have two versio

Re: Source code for csv module

2009-02-02 Thread Jon Clements
On 2 Feb, 20:46, vsoler wrote: > Hi you all, > > I just discovered the csv module here in the comp.lang.python group. > > I have found its manual, which is publicly available, but since I am > still a newby, learning techniques, I was wondering if the source code > for this module is available. >

Re: Source code for csv module

2009-02-03 Thread Jon Clements
On 3 Feb, 04:27, Tim Roberts wrote: > vsoler wrote: > > >I'm still interested in learning python techniques. Are there any > >other modules (standard or complementary) that I can use in my > >education? > > Are you serious about this?  Are you not aware that virtually ALL of the > Python standard

Re: a regual expression problem

2008-11-30 Thread Jon Clements
On Nov 30, 9:10 am, lookon <[EMAIL PROTECTED]> wrote: > I have a url of image, and I want to get the filename and extension of > the image. How to write in python? > > for example, the url ishttp://a.b.com/aaa.jpg?version=1.1 > > how can I get aaa and jpg by python? Something like... >>> from url

Re: Module caching

2009-04-03 Thread Jon Clements
On 3 Apr, 23:58, Aaron Scott wrote: > > are you an experienced python programmer? > > Yeah, I'd link to think I'm fairly experienced and not making any > stupid mistakes. That said, I'm fairly new to working with mod_python. > > All I really want is to have mod_python stop caching variables. This

Re: How to add lines to the beginning of a text file?

2009-04-03 Thread Jon Clements
On 4 Apr, 02:21, dean wrote: > Hello, > > As the subject says how would I go about adding the lines to the beginning > of a text file? Thanks in advance. I'd create a new file, then write your new lines, then iterate the existing file and write those lines... If no errors occcur, issue a delete f

Re: Best way to extract from regex in if statement

2009-04-03 Thread Jon Clements
On 4 Apr, 02:14, bwgoudey wrote: > I have a lot of if/elif cases based on regular expressions that I'm using to > filter stdin and using print to stdout. Often I want to print something > matched within the regular expression and the moment I've got a lot of cases > like: > > ... > elif re.match("

Re: Using a decorator to *remove* parameters from a call

2009-04-13 Thread Jon Clements
On 13 Apr, 11:11, Michel Albert wrote: > A small foreword: This might look like a cherrypy-oriented post, and > should therefore go to the cherrypy group, but if you read to the end, > you'll see it's a more basic python problem, with cherrypy only as an > example. ;) > > From the decorator PEP (3

Re: for x,y in word1, word2 ?

2008-08-11 Thread Jon Clements
On Aug 11, 5:40 am, Mensanator <[EMAIL PROTECTED]> wrote: > On Aug 10, 11:18 pm, ssecorp <[EMAIL PROTECTED]> wrote: > > > Is there a syntax for looping through 2 iterables at the same time? > > > for x in y: > > for a in b: > > > is not what I want. > > > I want: > > for x in y and for a in b: > >

Re: How to stop iteration with __iter__() ?

2008-08-19 Thread Jon Clements
On Aug 19, 12:39 pm, ssecorp <[EMAIL PROTECTED]> wrote: > I want a parse a file of the format: > movieId > customerid, grade, date > customerid, grade, date > customerid, grade, date > etc. > > so I could do with open file as reviews and then for line in reviews. > > but first I want to take out th

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:16 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > anyone know how I would find out how many rows are in a csv file? > > I can't find a method which does this on csv.reader. > > Thanks in advance You have to iterate each row and count them -- there's no other way without supporting info

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > 2008/8/27 SimonPalmer <[EMAIL PROTECTED]>: > > > anyone know how I would find out how many rows are in a csv file? > > > I can't find a method which does this on csv.reader. > > len(list(csv.reader(open('my.csv' > > -- > Cheers,

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > 2008/8/27 Jon Clements <[EMAIL PROTECTED]>: > > >> len(list(csv.reader(open('my.csv' > > Not the best of ideas if the row size or number of rows is large! > > Manufactu

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Jon Clements
On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:50 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > > > > On Aug 27, 12:29 pm, "Simon Brunning&

Re: no string.downer() ?

2008-08-27 Thread Jon Clements
On Aug 27, 3:16 pm, ssecorp <[EMAIL PROTECTED]> wrote: > if i want to make a string downcase, is upper().swapcase() the onyl > choice? there is no downer() ? lower() You need to be careful ssecorp, you might be at risk of being considered a troll -- always give the benefit though (probably why I'

Re: Algorithm used by difflib.get_close_match

2008-09-02 Thread Jon Clements
On Sep 2, 2:17 pm, Guillermo <[EMAIL PROTECTED]> wrote: > Hi all, > > Does anyone know whether this function uses edit distance? If not, > which algorithm is it using? > > Regards, > > Guillermo help(difflib.get_close_matches) will give you your first clue... -- http://mail.python.org/mailman/list

Re: noob help request - how to make a list of defined class?

2008-09-09 Thread Jon Clements
On Sep 9, 3:11 pm, [EMAIL PROTECTED] wrote: > I have defined two classes with one common field (called code) and > several different fields. > In class A there is only one instance of any given code as all items > are individual. > In class B, there may be none, one or many instances of each code,

Re: dict slice in python (translating perl to python)

2008-09-10 Thread Jon Clements
On 10 Sep, 16:28, hofer <[EMAIL PROTECTED]> wrote: > Hi, > > Let's take following perl code snippet: > > %myhash=( one  => 1    , two   => 2    , three => 3 ); > ($v1,$v2,$v3) = @myhash{qw(one two two)}; # <-- line of interest > print "$v1\n$v2\n$v2\n"; > > How do I translate the second line in a s

Re: Reading binary data

2008-09-10 Thread Jon Clements
On 10 Sep, 18:14, Aaron Scott <[EMAIL PROTECTED]> wrote: > I've been trying to tackle this all morning, and so far I've been > completely unsuccessful. I have a binary file that I have the > structure to, and I'd like to read it into Python. It's not a > particularly complicated file. For instance:

Re: Reading binary data

2008-09-10 Thread Jon Clements
On 10 Sep, 18:33, Jon Clements <[EMAIL PROTECTED]> wrote: > On 10 Sep, 18:14, Aaron Scott <[EMAIL PROTECTED]> wrote: > > > > > I've been trying to tackle this all morning, and so far I've been > > completely unsuccessful. I have a binary file that I h

Re: Reading binary data

2008-09-10 Thread Jon Clements
On Sep 10, 6:45 pm, Aaron Scott <[EMAIL PROTECTED]> wrote: > > CORRECTION: '3cII' should be '3sII'. > > Even with the correction, I'm still getting the error. Me being silly... Quick fix: signature = file.read(3) then the rest can stay the same, struct.calcsize('3sII') expects a 12 byte string, w

Re: Reading binary data

2008-09-10 Thread Jon Clements
On Sep 10, 7:16 pm, Aaron Scott <[EMAIL PROTECTED]> wrote: > Taking everything into consideration, my code is now: > > import struct > file = open("test.gde", "rb") > signature = file.read(3) > version, attr_count = struct.unpack('II', file.read(8)) > print signature, version, attr_count > for idx

Re: del and sets proposal

2008-10-02 Thread Jon Clements
On Oct 2, 11:20 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > You can do the following: > > a = [1,2,3,4,5] > del a[0] > > and > > a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'} > del a[1] > > why doesn't it work the same for sets (particularly since sets are based on a > dictionary)? > > a = set([1,2,3,

Re: How to Detect Use of Unassigned(Undefined) Variable(Function)

2009-11-27 Thread Jon Clements
On Nov 27, 10:36 am, "++imanshu" wrote: >     Is there a script/module to detect the use of unassigned > (undefined) variables(functions) in python. e.g. can I detect the > problem on line 3 automatically :- > > i = 1 > if i == 3: >     print o > print i > > Thank You, > ++imanshu pychecker retur

Re: Python Programming Challenges for beginners?

2009-11-27 Thread Jon Clements
On Nov 27, 9:43 am, n00m wrote: > > You're missing some sub-strings. > > Yes! :) Of course, if you take '~' literally (len(s) <= -10001) I reckon you've got way too many :) Jon. -- http://mail.python.org/mailman/listinfo/python-list

Re: Access to file in Windows Xp

2009-11-27 Thread Jon Clements
On Nov 27, 11:26 am, FelixCatus wrote: > Good morning to all, > I have written a simple python script that extracts data from a lot > (800Mb) of text files. > Now... In Linux the extraction runs in more or less 1s in Windows Xp > it takes 325 - 326 s. I find that really hard to believe; I don't t

Re: parsing json data

2009-11-27 Thread Jon Clements
On 27 Nov, 13:52, jujulj wrote: > Hi, > > I get the data shown below from the json geonames web service. > What's the best way to get the name value of the alternateNames with a > given lang value? > Do I have to loop in the array to find it? > > thanks > > {u'adminCode1': u'09', >  u'adminName1':

Re: Filling in a tuple from unknown size list

2009-11-27 Thread Jon Clements
On 27 Nov, 12:18, boblatest wrote: > Hello all, > > (sorry for posting from Google. I currently don't have access to my > normal nntp account.) > > Here's my question: Given a list of onknown length, I'd like to be > able to do the following: > > (a, b, c, d, e, f) = list > > If the list has fewer

Re: Python-URL! - weekly Python news and links (Nov 24)

2009-11-30 Thread Jon Clements
On Nov 24, 8:21 pm, Bruno Desthuilliers wrote: > Cameron Laird a écrit : > > > > >     Grant Edwards on the best way to get help from this group :) > >         > > http://groups.google.com/group/comp.lang.python/t/b8a0c32cae495522/21... > > This one really deserves a POTM award !-) Absolutely --

Re: Python Programming Challenges for beginners?

2009-12-01 Thread Jon Clements
On Nov 30, 9:13 pm, f...@mauve.rahul.net (Edward A. Falk) wrote: > In article <09ea817f-57a9-44a6-b815-299ae3ce7...@x5g2000prf.googlegroups.com>, > > alex23   wrote: > >On Nov 27, 1:24 pm, astral orange <457r0...@gmail.com> wrote: > >> I would like to test out what I know so far by solving programm

Re: SUB-MATRIX extraction

2009-12-08 Thread Jon Clements
On Dec 8, 1:36 pm, Pierre wrote: > Hello, > > let b = array([ [0,1,2] , [3,4,5] , [6,7,8] ]) > > How can I easily extract the submatrix [ [0 ,1], [3, 4]] ? > > One possiblity is : b[[0,1],:][:,[0,1]] but it is not really easy ! > > Thanks. x = numpy.array([ [0,1,2], [3,4,5], [6,7,8] ]) print x[0:

Re: Sum of the factorial of the digits of a number - wierd behaviour

2009-12-09 Thread Jon Clements
Even though you've worked it out -- a couple of tips: On Dec 9, 5:39 pm, SiWi wrote: > On Dec 9, 6:36 pm, SiWi wrote: > > > > > Dear python community, > > I've got a wierd problem and I hope you can help me out at it. > > I wrote the following code to find the Sum of the factorial of the > > dig

Re: Immediate Help with python program!

2009-12-09 Thread Jon Clements
On Dec 9, 11:55 pm, Daniel wrote: > i am making a tic-tac-toe game using python. i am pretty new to it, > but cant seem to figure this one out. > Here is my code: > > X = "X" > O = "O" > empty = " " > tie = "Tie" > squares = 9 > > def display(): >     print """Welcome to Tic-Tac-Toe. Player will p

Re: KeyboardInterrupt

2009-12-10 Thread Jon Clements
On Dec 9, 11:53 pm, mattia wrote: > Hi all, can you provide me a simple code snippet to interrupt the > execution of my program catching the KeyboardInterrupt signal? > > Thanks, > Mattia Errr, normally you can just catch the KeyboardInterrupt exception -- is that what you mean? Jon. -- http://

Re: Moving from PHP to Python. Part Two

2009-12-14 Thread Jon Clements
On Dec 14, 12:55 pm, Sancar Saran wrote: > Hello Again. > > I hope, I don't bug too much. > > First of all. I want to Thank to everyone who respond my messages. > > I was able to do some of my needs and stuck some others. > > So ? I need help again. > > And here my progress.. > > Following was my

Re: Moving from PHP to Python. Part Two

2009-12-14 Thread Jon Clements
> > class Registry: > >         data = {} > >         def __init__(self,environ): >                 self.data['env'] = environ >                 self.data['init'] = 'hede' > >         def set_entry(self,key,data): >                 self.data[key] = data > >         def get_entry(self,key): >      

Re: Clustering technique

2009-12-22 Thread Jon Clements
On Dec 22, 11:12 am, Luca wrote: > Dear all, excuse me if i post a simple question.. I am trying to find > a software/algorythm that can "cluster" simple data on an excel sheet > > Example: >                 Variable a   Variable b   Variable c > Case 1        1                   0              0

Re: dict initialization

2009-12-22 Thread Jon Clements
On Dec 22, 11:51 pm, mattia wrote: > Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: > > > mattia wrote: > > >> Is there a function to initialize a dictionary? Right now I'm using: > >> d = {x+1:[] for x in range(50)} > >> Is there any better solution? > > > There is a dictionary varia

Re: Thanks for the help not given :)

2009-12-29 Thread Jon Clements
On Dec 29, 9:28 pm, a...@pythoncraft.com (Aahz) wrote: > In article , > > J   wrote: > > >So though I've only posted a small bit here and on python-win, I did > >want to thank y'all for helping me when you have, and even when you > >actually haven't! > > Get a teddybear, that helps, too.  ;-)  (I.e

Re: What is the best data structure for a very simple spreadsheet?

2010-01-03 Thread Jon Clements
On Jan 3, 2:58 pm, Lie Ryan wrote: > On 1/3/2010 10:27 PM, vsoler wrote: > > > 1) what are, in your opinion, the basic elements of the Cell class? > > The "user-entered formula" and "effective value". A Cell containing a > formula "abc" has a value of "abc"; a cell containing the formula "=1+5" >

Re: table from csv file

2010-01-08 Thread Jon Clements
On Jan 8, 5:59 pm, marlowe wrote: > I am trying to create a table in python from a csv file where I input > which columns I would like to see, and the table only shows those > columns. I have attached an example of the csv file i am using, and > some of the code I have written. I am having trouble

Re: table from csv file

2010-01-09 Thread Jon Clements
On Jan 8, 8:31 pm, J wrote: > On Fri, Jan 8, 2010 at 13:55, Jon Clements wrote: > > On Jan 8, 5:59 pm, marlowe wrote: > >> I am trying to create a table in python from a csv file where I input > >> which columns I would like to see, and the table only shows those &g

Re: Porblem with xlutils/xlrd/xlwt

2010-01-09 Thread Jon Clements
On Jan 9, 10:24 am, pp wrote: > Whenever i run the code below I get the following error: > > AttributeError: 'Book' object has no attribute 'on_demand' > WARNING: Failure executing file: > > Why is it so?? > > from xlrd import open_workbook > from xlwt import easyxf > from xlutils.copy import cop

Re: Porblem with xlutils/xlrd/xlwt

2010-01-09 Thread Jon Clements
On Jan 9, 10:44 am, pp wrote: > On Jan 9, 3:42 am, Jon Clements wrote: > > > > > On Jan 9, 10:24 am, pp wrote: > > > > Whenever i run the code below I get the following error: > > > > AttributeError: 'Book' object has no attribute 'on_de

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

2010-01-16 Thread Jon Clements
On Jan 16, 5:08 pm, Jonathan Temple wrote: > 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 case

Re: html code generation

2010-01-20 Thread Jon Clements
On Jan 20, 10:03 pm, "D'Arcy J.M. Cain" wrote: > On Wed, 20 Jan 2010 21:03:10 + > > George Trojan wrote: > > I need an advice on table generation. The table is essentially a fifo, > > containing about 200 rows. The rows are inserted every few minutes or > > so. The simplest solution is to sto

Re: Change sorting order?

2010-01-22 Thread Jon Clements
On Jan 22, 1:58 pm, Gilles Ganault wrote: > On 22 Jan 2010 13:35:26 GMT, Neil Cerutti wrote: > > >Resorting is more work than is needed. Just choose a different > >starting index each time you display the names, and set up your > >lister to wrap-around to your arbitrary starting index. > > Thanks

Re: ActivePython 3.1.1.2 vs Python 3.1.1 for OSX?

2009-09-30 Thread Jon Clements
On 1 Oct, 00:51, Robert Hicks wrote: > I am just curious which I should use. I am going to start learning > Python soon. Are they comparable and I just do a "eenie meenie minie > moe"? > > Bob First off, a great choice of language to begin trying! Is it your first language (I'm guessing not), or

Re: cx_freeze problem on Ubuntu

2009-10-01 Thread Jon Clements
On 1 Oct, 15:08, John wrote: > Sorry if this might be a repost.  I'm having problems with my newsreader. > > My system: > > cx_freeze 4.1 > Python 2.6 > Ubuntu Jaunty > > I downloaded the cx_freeze source code > fromhttp://cx-freeze.sourceforge.net/into a directory. > > I wrote a one line python

Re: emptying a list

2009-10-01 Thread Jon Clements
On 1 Oct, 16:30, "lallous" wrote: > Hello > > What is faster when clearing a list? > > del L[:] > > or > > L = [] > > -- > Elias Does it really matter that much? And you're really talking about two different things, which quite often come up on this group. Example follows: >>> x = range(5) >>>

Re: Enormous Input and Output Test

2009-10-04 Thread Jon Clements
On Oct 4, 12:08 pm, n00m wrote: > Duncan Booth, > > alas... still TLE: > > 2800839 > 2009-10-04 13:03:59 > Q > Enormous Input and Output Test > time limit exceeded > - > 88M > PYTH Just to throw into the mix... What about buffering? Does anyone know what the effective stdin buffer is for Python?

Re: restriction on sum: intentional bug?

2009-10-16 Thread Jon Clements
On Oct 16, 5:59 pm, Tim Chase wrote: > Stephen Hansen wrote: > >> Why doesn't duck typing apply to `sum`? > > > Because it would be so hideously slow and inefficient that it'd be way too > > easy a way for people to program something they think should work fine but > > really doesn't... alternativ

Re: restriction on sum: intentional bug?

2009-10-16 Thread Jon Clements
On Oct 17, 1:16 am, Terry Reedy wrote: > Alan G Isaac wrote: > > > As Tim explained in detail, and as Peter > > explained with brevity, whether it will > > happen or not, it should happen.  This > > conversation has confirmed that current > > behavior is a wart: an error is raised > > despite corr

Re: executing a function/method from a variable

2009-10-16 Thread Jon Clements
On Oct 17, 3:02 am, Yves wrote: > What is the best way to execute a function which name is stored in a variable > ? > > Right now I use an eval, but I'm wondering if there isn't a better way: > > Here is a simplified example, but what I use this for is to parse a formated > text file, and execute

Re: How would you design scalable solution?

2009-10-27 Thread Jon Clements
On 27 Oct, 17:10, Bryan wrote: > I'm designing a system and wanted to get some feedback on a potential > performance problem down the road while it is still cheap to fix. > > The system is similar to an accounting system where a system tracks > "Things" > which move between different "Buckets".  T

Re: ConfigParser.items sorting

2009-10-27 Thread Jon Clements
On 28 Oct, 06:21, Dean McClure wrote: > Hi, > > Just wondering how I can get the items() command from ConfigParser to > not resort all the item pairs that it presents. > > I am trying to get it to read some data in order: > > [Relay Info] > relay_name: IPC > relay_current_range: [60, 64, 68, 72, 7

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
On 28 Oct, 07:31, Steven D'Aprano wrote: > On Wed, 28 Oct 2009 07:52:17 +0100, Alf P. Steinbach wrote: > > Unfortunately Google docs doesn't display the nice table of contents in > > each document, but here's the public view of ch 1 (complete) and ch 2 > > (about one third completed, I've not yet

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
On 28 Oct, 07:44, Jon Clements wrote: > On 28 Oct, 07:31, Steven D'Aprano > > > > wrote: > > On Wed, 28 Oct 2009 07:52:17 +0100, Alf P. Steinbach wrote: > > > Unfortunately Google docs doesn't display the nice table of contents in > > > each docum

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
On 28 Oct, 08:58, "Alf P. Steinbach" wrote: [snip] > Without reference to an OS you can't address any of the issues that a beginner > has to grapple with, including most importantly tool usage, without which it's > not even possible to get started, but also, very importantly, a file system. > > Le

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Jon Clements
Inline reply: On 28 Oct, 11:49, "Alf P. Steinbach" wrote: > * Jon Clements: > > > On 28 Oct, 08:58, "Alf P. Steinbach" wrote: > > [snip] > >> Without reference to an OS you can't address any of the issues that a > >> beginner &g

Re: popen function of os and subprocess modules

2009-10-28 Thread Jon Clements
On 28 Oct, 13:39, banu wrote: > Hi, > I am a novice in python. I was trying to write a simple script on > Linux (python 3.0) that does the following > > #cd directory > #ls -l > > I use the following code, but it doesn't work: > > import os > directory = '/etc' > pr = os.popen('cd %s' % directory,

Re: ConfigParser.items sorting

2009-10-28 Thread Jon Clements
On 28 Oct, 21:55, Dean McClure wrote: > On Oct 28, 4:50 pm, Jon Clements wrote: > > > > > On 28 Oct, 06:21, Dean McClure wrote: > > > > Hi, > > > > Just wondering how I can get theitems() command fromConfigParserto > > > not resort all the item

Re: import bug

2009-10-31 Thread Jon Clements
On Oct 31, 3:12 pm, kj wrote: > I'm running into an ugly bug, which, IMHO, is really a bug in the > design of Python's module import scheme.  Consider the following > directory structure: > > ham > |-- __init__.py > |-- re.py > `-- spam.py > > ...with the following very simple files: > > % head ha

Re: About "Object in list" expression

2009-11-02 Thread Jon Clements
On Nov 2, 10:41 am, Mirons wrote: > Hi everybody! I'm having a very annoying problem with Python: I need > to check if a (mutable) object is part of a list but the usual > expression return True also if the object isn't there. I've > implemented both __hash__ and __eq__, but still no result. what

Re: exec-function in Python 3.+

2009-11-02 Thread Jon Clements
On 2 Nov, 10:49, "Hans Larsen" wrote: > Help! >     I'm begginer in Python 3.+! >     If i wih to update a module after an import and chages, >     How could I do: >     By "from imp import reload" and then reload(mymodule) >     or how to use "exec(?)", it is mentoined in docs. >     In Python ve

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread Jon Clements
On Nov 9, 1:53 pm, pinkisntwell wrote: > How can I make a regular expression that will match every occurrence > of a group and return each occurrence as a group match? For example, > for a string "-c-c-c-c-c", how can I make a regex which will return a > group match for each occurrence of "-c"?

Re: Req. comments on "first version" ch 2 progr. intro (using Python 3.x in Windows)

2009-11-09 Thread Jon Clements
On Nov 9, 4:10 pm, "Alf P. Steinbach" wrote: > Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far. > > It's now Python 3.x, and reworked with lots of graphical examples and more > explanatory text, plus limited in scope to Basic Concepts (which I previously > just had as a fir

Re: Req. comments on "first version" ch 2 progr. intro (using Python 3.x in Windows)

2009-11-09 Thread Jon Clements
On Nov 9, 5:22 pm, "Alf P. Steinbach" wrote: > * Jon Clements: > > > > > On Nov 9, 4:10 pm, "Alf P. Steinbach" wrote: > >> Chapter 2 "Basic Concepts" is about 0.666 completed and 30 pages so far. > > >> It's now Python 3

Re: Req. comments on "first version" ch 2 progr. intro (using Python 3.x in Windows)

2009-11-10 Thread Jon Clements
[posts snipped] The only other thing is that line_length is used as a constant in one of the programs. However, it's being mutated in the while loop example. It may still be in the reader's mind that line_length == 10. (Or maybe not) Cheers, Jon. -- http://mail.python.org/mailman/listinfo/pyt

Re: Create object from variable indirect reference?

2009-11-10 Thread Jon Clements
On Nov 10, 2:59 pm, NickC wrote: > I can't seem to find a way to do something that seems straighforward, so I > must have a mental block.  I want to reference an object indirectly > through a variable's value. > > Using a library that returns all sorts of information about "something", I > want to

Re: Authentication session with urllib2

2009-11-11 Thread Jon Clements
On 11 Nov, 07:02, Ken Seehart wrote: > I'm having some difficulty implementing a client that needs to maintain > an authenticated https: session. > > I'd like to avoid the approach of receiving a 401 and resubmit with > authentication, for two reasons: > > 1. I control the server, and it was easy

Re: The ol' [[]] * 500 bug...

2009-11-13 Thread Jon Clements
On 13 Nov, 21:26, kj wrote: > ...just bit me in the "fuzzy posterior".  The best I can come up with > is the hideous > >   lol = [[] for _ in xrange(500)] > > Is there something better?   That's generally the accepted way of creating a LOL. > What did one do before comprehensions > were availabl

Re: python win32com problem

2009-11-15 Thread Jon Clements
On Nov 15, 1:08 pm, elca wrote: > hello , these day im very stress of one of some strange thing. > > i want to enumurate inside list of url, and every enumurated url i want to > visit > > i was uplod incompleted script source in here => > > http://elca.pastebin.com/m6f911584 > > if anyone can help

Re: Slicing history?

2009-11-15 Thread Jon Clements
On Nov 15, 6:50 pm, a...@pythoncraft.com (Aahz) wrote: > Anyone remember or know why Python slices function like half-open > intervals?  I find it incredibly convenient myself, but an acquaintance > familiar with other programming languages thinks it's bizarre and I'm > wondering how it happened. >

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Jon Clements
On Nov 15, 7:23 pm, Steve Howell wrote: > On Nov 15, 10:25 am, Steve Howell wrote: > > > [see original post...] > > I am most > > interested in the specific mechanism for changing the __getitem__ > > method for a subclass on a dictionary.  Thanks in advance! > > Sorry for replying to myself, but

Re: getting properly one subprocess output

2009-11-18 Thread Jon Clements
On Nov 18, 11:25 am, Jean-Michel Pichavant wrote: > Hi python fellows, > > I'm currently inspecting my Linux process list, trying to parse it in > order to get one particular process (and kill it). > I ran into an annoying issue: > The stdout display is somehow truncated (maybe a terminal length i

Re: getting properly one subprocess output

2009-11-18 Thread Jon Clements
On Nov 18, 4:14 pm, Jon Clements wrote: > On Nov 18, 11:25 am, Jean-Michel Pichavant > wrote: > > > > > Hi python fellows, > > > I'm currently inspecting my Linux process list, trying to parse it in > > order to get one particular process (and kill it).

Re: using struct module on a file

2009-11-18 Thread Jon Clements
On Nov 18, 4:42 pm, Ulrich Eckhardt wrote: > Hia! > > I need to read a file containing packed "binary" data. For that, I find the > struct module pretty convenient. What I always need to do is reading a chunk > of data from the file (either using calcsize() or a struct.Struct instance) > and then

Re: make two tables having same orders in both column and row names

2009-11-20 Thread Jon Clements
On Nov 18, 8:57 pm, Ping-Hsun Hsieh wrote: > Hi, > > I would like to compare values in two table with same column and row names, > but with different orders in column and row names. > For example, table_A in a file looks like the follows: > AA100   AA109   AA101   AA103   AA102 > BB1     2      

Re: Creating a drop down filter in Admin site

2009-11-24 Thread Jon Clements
On Nov 24, 9:08 pm, Jase wrote: > Hoping someone could help me out. I am updating an admin site and > added a couple "list_filter"s. They are rather long so I wanted to > turn them into a drop down filter. Can this be done? Any suggestions? > > Thanks, > > Jase I'm guessing you mean Django - You

Re: Raw strings as input from File?

2009-11-24 Thread Jon Clements
On Nov 24, 9:20 pm, utabintarbo wrote: > On Nov 24, 3:27 pm, MRAB wrote: > > > > > .readlines() doesn't change the "\10" in a file to "\x08" in the string > > it returns. > > > Could you provide some code which shows your problem? > > Here is the code block I have so far: > for l in open(CONTENTS

Re: Raw strings as input from File?

2009-11-24 Thread Jon Clements
On Nov 24, 9:50 pm, Jon Clements wrote: > On Nov 24, 9:20 pm, utabintarbo wrote: [snip] > Although, "Pat\x08DJQ.D5-30Q5B-B-D5-BSHOE-MM.smz" and "Pat > \x08DJQ.D5-30Q5B-B-D5-BSHOE-MM.smz" seem to be fairly different -- are > you sure you're posting the corr

Re: CentOS 5.3 vs. Python 2.5

2009-11-25 Thread Jon Clements
On Nov 25, 8:13 am, Steven D'Aprano wrote: > On Tue, 24 Nov 2009 22:42:28 -0800, John Nagle wrote: > > My dedicated hosting provider wants to switch me to a new server with > > CentOS 5.3, so I have to look at how much work is required. > > >     CentOS 5.3 apparently still ships with Python 2.4.

Re: Raw strings as input from File?

2009-11-25 Thread Jon Clements
On Nov 25, 3:31 am, Grant Edwards wrote: > On 2009-11-25, Rhodri James wrote: > > > > > On Tue, 24 Nov 2009 21:20:25 -, utabintarbo   > > wrote: > > >> On Nov 24, 3:27 pm, MRAB wrote: > > >>> .readlines() doesn't change the "\10" in a file to "\x08" in the string > >>> it returns. > > >>> C

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread Jon Clements
On Feb 24, 12:21 pm, "Alf P. Steinbach" wrote: > * Nomen Nescio: > > > Hello, > > > Can someone help me understand what is wrong with this example? > > > class T: > >   A = range(2) > >   B = range(4) > >   s = sum(i*j for i in A for j in B) > > > It produces the exception: > > > : global name 'j'

<    1   2   3   >