Re: TypeError: list indices must be integers

2010-06-01 Thread Jon Clements
On 1 June, 23:06, Terry Reedy wrote: > I got this error twice today > while creating lists of lists > of complicated stuff. > The first time I was puzzled, > but the second time I knew > that I had just forgotten a comma. > If you google this, you will too. > > Reduced example >  >>> [[1,2,3] # fo

Re: Omit the headers from XML message

2010-05-28 Thread Jon Clements
On 28 May, 16:24, "kak...@gmail.com" wrote: > Hi i have the following xml message i want to omit the headers, any > hints? > > POST /test/pcp/Listener HTTP/1.1 > User-Agent: Jakarta Commons-HttpClient/3.1 > Host: 127.0.0.1:50002 > Content-Length: 547 > > http://demo.com/demo";> >   >     >      

Re: Regular expression

2010-05-18 Thread Jon Clements
On 18 May, 15:32, Back9 wrote: > On May 18, 10:09 am, ilvecchio wrote: > > > > > On May 18, 3:48 pm, Back9 wrote: > > > >  Hi, > > > > I have a string like this: > > > 0x340x5A0x9B0xBA > > > I want to extract 0x from the string but the first one. > > > > How I can use re for this case? > > > > T

Re: shortcut for large amount of global var declarations?

2010-05-08 Thread Jon Clements
On 8 May, 16:03, Alex Hall wrote: > On 5/8/10, Jon Clements wrote: > > > On 8 May, 15:08, Alex Hall wrote: > >> Hi all, > >> I am sorry if this is the second message about this you get; I typed > >> this and hit send (on gmail website) but I got a

Re: shortcut for large amount of global var declarations?

2010-05-08 Thread Jon Clements
On 8 May, 15:08, Alex Hall wrote: > Hi all, > I am sorry if this is the second message about this you get; I typed > this and hit send (on gmail website) but I got a 404 error, so I am > not sure if the previous message made it out or not. > Anyway, I have about fifteen vars in a function which ha

Re: ConfigParser.get() defaults?

2010-05-07 Thread Jon Clements
On 7 May, 21:05, Tim Chase wrote: > With a normal dictionary, I can specify a default fallback value > in the event the requested key isn't present: > >    d = {} >    print d.get(42, 'Some default goes here') > > However, with the ConfigParser object, there doesn't seem to be > any way to do a si

Re: itertools: problem with nested groupby, list()

2010-05-04 Thread Jon Clements
my_list.sort( key=itemgetter('a','b','c') ) > for a, a_iter in groupby(my_list, itemgetter('a')): >    print 'New A', a >    inner_list =  list( groupby(a_iter, itemgetter('b')) ) >    for pass in ['first pass', 'se

Re: itertools: problem with nested groupby, list()

2010-05-04 Thread Jon Clements
On 4 May, 11:10, Nico Schlömer wrote: > Hi, > > I ran into a bit of an unexpected issue here with itertools, and I > need to say that I discovered itertools only recently, so maybe my way > of approaching the problem is "not what I want to do". > > Anyway, the problem is the following: > I have a

Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread Jon Clements
On 27 Apr, 10:43, King wrote: > Hi, > > I have just compiled python 2.6.5 from sources on ubuntu "hardy" 8.04. > I have used a simple script to do everything in one go: > > ./configure --enable-shared > make > make install > > Python is compiled and installed successfully. However the > modules(_s

Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Jon Clements
On 27 Apr, 12:16, Laszlo Nagy wrote: > > Please note: this is not a direct answer to your question. > > > I would personally go for a client-server model; not worrying what the > > server is written in or how it works. For some reason I have a scary > > thought of your widget pulling in 100million

Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Jon Clements
On 27 Apr, 10:10, Laszlo Nagy wrote: >   Hi All, > > I'm planning to create a new visual component for wxPython, for > designing, creating and printing pivot tables. Also known as: decision > cube, OLAP cube. I was searching on the internet for something similar, > but I could not find any open so

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
On 8 Apr, 19:49, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:  

Re: regex help: splitting string gets weird groups

2010-04-08 Thread Jon Clements
On 8 Apr, 19:49, gry wrote: > [ python3.1.1, re.__version__='2.2.1' ] > I'm trying to use re to split a string into (any number of) pieces of > these kinds: > 1) contiguous runs of letters > 2) contiguous runs of digits > 3) single other characters > > e.g.   555tHe-rain.in#=1234   should give:  

Re: Q: We have *args and **kwargs. Woud ***allargs be useful?

2010-04-01 Thread Jon Clements
On 1 Apr, 10:57, Jonathan Fine wrote: > The idioms >      def f(*args, **kwargs): >          # Do something. > and >      args = (1, 2, 3) >      kwargs = dict(a=4, b=5) >      g(*args, **kwargs) > are often useful in Python. > > I'm finding myself picking up /all/ the arguments and storing them f

Re: OT: Meaning of "monkey"

2010-03-26 Thread Jon Clements
On 26 Mar, 15:45, Grant Edwards wrote: > On 2010-03-26, Luis M  Gonz?lez wrote: > > > Webmonkey, Greasemonkey, monkey-patching, Tracemonkey, J?germonkey, > > Spidermonkey, Mono (monkey in spanish), codemonkey, etc, etc, etc... > > > Monkeys everywhere. > > Sorry for the off topic question, but wh

Re: Classes as namespaces?

2010-03-26 Thread Jon Clements
On 26 Mar, 14:49, kj wrote: > What's the word on using "classes as namespaces"?  E.g. > > class _cfg(object): >     spam = 1 >     jambon = 3 >     huevos = 2 > > breakfast = (_cfg.spam, _cfg.jambon, _cfg.huevos) > > Granted, this is not the "intended use" for classes, and therefore > could be vie

Re: Python database of plain text editable by notepad or vi

2010-03-26 Thread Jon Clements
On 26 Mar, 09:49, James Harris wrote: > On 25 Mar, 22:56, Jon Clements wrote: > > > > > On 25 Mar, 22:40, James Harris wrote: > > > > I am looking to store named pieces of text in a form that can be > > > edited by a standard editor such as notepad (unde

Re: Python database of plain text editable by notepad or vi

2010-03-25 Thread Jon Clements
On 25 Mar, 22:40, James Harris wrote: > I am looking to store named pieces of text in a form that can be > edited by a standard editor such as notepad (under Windows) or vi > (under Unix) and then pulled into Python as needed. The usual record > locking and transactions of databases are not requir

Re: Advice needed on parallel processing in python

2010-03-24 Thread Jon Clements
On 24 Mar, 15:27, Glazner wrote: > Hi! > > I need to replace an app that does number crunching over a local > network. > it have about 50 computers as slaves > each computer needs to run COM that will do the "job" > right now the system uses MFC threads and DCOM to distribute the load. > > as i sa

Re: Clearing memory (namespace) before running code

2010-03-21 Thread Jon Clements
On 21 Mar, 15:02, vsoler wrote: > Hi, > > Is there a way to erase/delete/clear memory before a piece of code is > run? > > Otherwise, the objects of the previous run are re-usable, and may > bring confusion to the tester. > > Thank you I'm guessing you're using some sort of IDE? For instance, in

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
On 13 Mar, 17:42, Jack Diederich wrote: > On Sat, Mar 13, 2010 at 12:10 PM, Jon Clements wrote: > > On 13 Mar, 16:42, Jack Diederich wrote: > >> On Sat, Mar 13, 2010 at 11:19 AM, Jon Clements > >> wrote: > >> > This is semi-experimental and I'd ap

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
On 13 Mar, 16:42, Jack Diederich wrote: > On Sat, Mar 13, 2010 at 11:19 AM, Jon Clements wrote: > > This is semi-experimental and I'd appreciate opinions of whether it's > > the correct design approach or not. It seems like a good idea, but it > > doesn't

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
On 13 Mar, 16:26, Patrick Maupin wrote: > On Mar 13, 10:19 am, Jon Clements wrote: > > > What I'd like to achieve is something similar to: > > > @inject(B): > >  def some_function(a, b): > >      pass # something useful > > So, just typing at the keybo

Decorator to inject function into __call__ of a class

2010-03-13 Thread Jon Clements
This is semi-experimental and I'd appreciate opinions of whether it's the correct design approach or not. It seems like a good idea, but it doesn't mean it is. I have a class 'A', this provides standard support functions and exception handling. I have 'B' and 'C' which specialise upon 'A' What I'

Re: building a dict

2010-03-13 Thread Jon Clements
On 13 Mar, 15:28, Patrick Maupin wrote: > On Mar 13, 9:05 am, vsoler wrote: > > > Say that "m" is a tuple of 2-tuples > > > m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6)) > > > and I need to build a "d" dict where each key has an associated list > > whose first element is the count, and

Re: building a dict

2010-03-13 Thread Jon Clements
On 13 Mar, 15:05, vsoler wrote: > Say that "m" is a tuple of 2-tuples > > m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6)) > > and I need to build a "d" dict where each key has an associated list > whose first element is the count, and the second is the sum. If a 2- > tuple contains a None

Re: AOP decorator?

2010-03-01 Thread Jon Clements
On Mar 1, 4:22 pm, gentlestone wrote: > Hi, > > suppose my source code looks like: > >   import aspect_xy >   class Basic(object, aspect_xy.Basic): >     pass # basic attributes and methods ... > > and the source code of aspect_xy.p

Re: parametrizing a sqlite query

2010-02-24 Thread Jon Clements
On Feb 24, 5:21 pm, Jon Clements wrote: > On Feb 24, 5:07 pm, Sebastian Bassi wrote: > > > c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) > > > This query returns empty. When it is executed, keywords = 'harve

Re: parametrizing a sqlite query

2010-02-24 Thread Jon Clements
On Feb 24, 5:07 pm, Sebastian Bassi wrote: > c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) > > This query returns empty. When it is executed, keywords = 'harvest'. > To check it, I do it on the command line and it works as expected: > > sqlite> SELECT bin FROM bins W

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'

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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
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, 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Format string with single quotes in it

2009-09-25 Thread Jon Clements
On 25 Sep, 13:42, Bahadir wrote: > Hi there, > > My question is simple, but I've been spending some hours over the web > and still struggling to get this right: How do I format a string that > contains single quotes in it? > > I am reading a file with lines of the form: > > CONT%d_VIRTMEM_REGIONS

Re: urllib, can't seem to get form post right

2009-09-24 Thread Jon Clements
On 24 Sep, 22:18, "Adam W." wrote: > I'm trying to scrape some historical data from NOAA's website, but I > can't seem to feed it the right form values to get the data out of > it.  Heres the code: > > import urllib > import urllib2 > > ## The source pagehttp://www.erh.noaa.gov/bgm/climate/bgm.sht

Re: Evaluate coding and style

2009-09-24 Thread Jon Clements
On 24 Sep, 21:11, "Brown, Rodrick " wrote: > I recently started playing with Python about 3 days now (Ex Perl guy) and > wanted some input on style and structure of what I'm doing before I really > start picking up some bad habits here is a simple test tool I wrote to > validate home dirs on my

Re: List comprehension vs generator expression memory allocation

2009-09-20 Thread Jon Clements
On 20 Sep, 14:35, candide wrote: > Let's code a function allowing access to the multiples of a given > integer (say m) in the range from a to b where a and b are two given > integers. For instance, with data input > > a,b,m=17, 42, 5 > > the function allows access to : > > 20 25 30 35 40 > > Each

Re: Array of objects lost in unpickling

2009-09-13 Thread Jon Clements
On 13 Sep, 15:19, Bahadir wrote: > Hi, > > I have a class: > > class second: >     a = None >     b = None > > class first: >     array = [] > > I populate the array in first class with instances of second, then > save by: > > shelve = shelve.open(), > shelve["first"] = myfirst > shelve.close() >

Re: pylucene installation problem on Ubuntu 9.04

2009-08-06 Thread Jon Clements
On 6 Aug, 19:49, KK wrote: > hi all, > I've trying to install pylucene on my linux box from last 2 days but > not able to do so. first i tried to install it using apt-get like > this, > kk-laptop$ sudo apt-get install pylucene > and it did install python2.5, python2.5-minimal and pylucene. I must

Re: Google sitemap generator in python gone?

2009-08-05 Thread Jon Clements
On 5 Aug, 22:44, Xah Lee wrote: > google used to have a sitemap generator written in python, at: >  https://www.google.com/webmasters/tools/docs/en/sitemap-generator.html > > but the url is gone. It seems the current version is moved > here:http://code.google.com/p/googlesitemapgenerator/ > and i

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Jon Clements
On 5 Aug, 20:41, "Martin P. Hellwig" wrote: > Paul Rubin wrote: > > "Martin P. Hellwig" writes: > >> Is there an advantage using shifts and masks over my kitchen type solution? > > > Weren't you complaining about the 8-to-1 expansion from turning each bit > > to an ascii char? > > Yes you are (of

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-05 Thread Jon Clements
On 5 Aug, 15:46, "Martin P. Hellwig" wrote: > Hi List, > > On several occasions I have needed (and build) a parser that reads a > binary piece of data with custom structure. For example (bogus one): > > BE > +-+-+-+-+--++ > | Version | Command |

<    1   2   3   >