Pygame.draw challenge
http://media.pyweek.org/static/pygame.draw-0606.html THE CHALLENGE: Create a game in 64kbytes of source code using only pygame. No additional libraries, no external files (even ones loaded from a network). That means no PyOpenGL, no PNGs, no OGGs. THE DEADLINE: Start as soon as you read this announcement. Human-readable, Linux-compatible entries must be received by [EMAIL PROTECTED] before midnight on the 25th of June, 2006. That's Australian Eastern Standard Time, which is UTC +10. Multiple entries are allowed. Teams are allowed. Monkeys are allowed! Ponies, sadly, are not allowed. THE RESULTS: All entries will be posted to a page on the http://www.pyweek.org/ website. Entry gameplay instructions and license must be included in the source or in the game itself. I will probably choose one of the entries as my favourite, and declare this in various obscure fora and private email messages. No other mention of rankings or favourites will be made. THANKS: Thanks to Phil Hassey for the challenge inspiration! -- Visit the PyWeek website: http://www.pyweek.org/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
numeric/numpy/numarray
hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, Numarray is a re-implementation of an older Python array module called Numeric http://www.stsci.edu/resources/software_hardware/numarray this page says, NumPy derives from the old Numeric code base and can be used as a replacement for Numeric. http://numeric.scipy.org/ i looked at the matplotlib examples today and if i remember correctly, the examples didn't use numarray. so i'm a bit confused. thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list
Getting TypeError:list indices must be integers
Hi, Please check out the following loop,here indexList1 and indexList2 are a list of numbers. for index1 in indexList1: for index2 in indexList2: if ti1[index1] == ti2[index2] and not index1 != indexList1.pop(): index1+=1 index2+=1 continue elif index1 == indexList1.pop() and charList in pairList: k = string2.index(char2[0]) instance = ti2(k) tiNew = ti1.append(instance) tiNewList.append(tiNew) else: break On running my program, python gives me a TypeError saying: if ti1[index1] == ti2[index2] and not index1 != indexList1.pop(): TypeError: list indices must be integers Even though index1 and index2 are really integers.Please help! -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]apache authentication questions
[EMAIL PROTECTED] wrote: Steve Holden wrote: [EMAIL PROTECTED] wrote: Since HTTP authentication is managed by the browser it's difficult to integrate it with web application authentication: basically you have to choose between the two. There's no way for the server to tell the browser to start presenting the required authentication credentials except by raising a 401 (not authorised) error response, which is what makes the browser bring up its little popup. It is not impossible though and in cases where you don't have a choice but to use a HTTP authentication scheme, use of AJAX may be the answer to still allowing use of a form based login scheme. See: http://www.peej.co.uk/articles/http-auth-with-html-forms.html That's neat! regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
groupby is brilliant!
Hi all This is probably old hat to most of you, but for me it was a revelation, so I thought I would share it in case someone has a similar requirement. I had to convert an old program that does a traditional pass through a sorted data file, breaking on a change of certain fields, processing each row, accumulating various totals, and doing additional processing at each break. I am not using a database for this one, as the file sizes are not large - a few thousand rows at most. I am using csv files, and using the csv module so that each row is nicely formatted into a list. The traditional approach is quite fiddly, saving the values of the various break fields, comparing the values on each row with the saved values, and taking action if the values differ. The more break fields there are, the fiddlier it gets. I was going to do the same in python, but then I vaguely remembered reading about 'groupby'. It took a little while to figure it out, but once I had cracked it, it transformed the task into one of utter simplicity. Here is an example. Imagine a transaction file sorted by branch, account number, and date, and you want to break on all three. - import csv from itertools import groupby from operator import itemgetter BRN = 0 ACC = 1 DATE = 2 reader = csv.reader(open('trans.csv', 'rb')) rows = [] for row in reader: rows.append(row) for brn,brnList in groupby(rows,itemgetter(BRN)): for acc,accList in groupby(brnList,itemgetter(ACC)): for date,dateList in groupby(accList,itemgetter(DATE)): for row in dateList: [do something with row] [do something on change of date] [do something on change of acc] [do something on change of brn] - Hope someone finds this of interest. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: How to link foreign keys primary keys using python?
Hi Mr. Steve, The *indexes* i am using are lists... The code for creation of the PartionedPK is given below... *** class PartitionedPK(object): def __init__(self, name, save_to, fields): self.name= name self.idx_name= save_to self.part_name = save_to + PARTITION_SUFFIX self.fields = fields self.digester= sha.new def setup(self, schema): self.partitions = [[] for i in range(256)] self.flush_pos = [[] for i in range(256)] self.flush_count = 0 self.index = {} self.offsets = field_offsets(self.fields, schema) if not self.offsets: raise ValueError('One or more index field names are invalid') self.idx_file= open(self.idx_name, 'wb+') self.part_file = open(self.part_name, 'wb+') def save(self): pickle.dump(self.flush_count, self.part_file, -1) pickle.dump(self.flush_pos, self.part_file, -1) self.idx_file.close() self.part_file.close() def flush(self): self.flush_count += 1 for i in range(256): self.flush_pos[i].append(self.idx_file.tell()) pickle.dump(self.partitions[i], self.idx_file, -1) self.partitions[i] = [] def valid(self, record, data): key = self.digester(''.join( [data[i] for i in self.offsets] )).digest() self.partitions[ ord(key[0]) ].append( (key, record) ) # defer checking till later return True def finalize(self): self.flush() errors = [] for bin in range(256): #show('Checking %s, bin %d/256 ... ' % (self.name, bin)) seen = {} has = seen.has_key for flush in range(self.flush_count): self.idx_file.seek( self.flush_pos[bin][flush] ) records = pickle.load(self.idx_file) for key, value in records: if has(key): errors.append(value) else: seen[key] = value return errors *** the PK definition is as follows: vol_pk = PartitionedPK( name = 'VOL_PK', save_to = '../Index/vol.idx', fields = ['ID','Type','Curr_Code','Tenor']) The code for the Foreign Key declaration (referencing to the indexes) is as given below... *** class HashedFK(object): def __init__(self, name, load_from, fields): self.name = name self.filename = load_from self.fields = fields self.digester = sha.new def setup(self, schema): self.index = {} self.offsets= field_offsets(self.fields, schema) if not self.offsets: raise ValueError('One or more index field names are invalid') file = open(self.filename, 'rb+') self.index = pickle.load(file) file.close() def valid(self, record, fields): key = self.digester(''.join( [fields[i] for i in self.offsets] )).digest() return self.index.has_key(key) def flush(self): pass def finalize(self): return None *** the FK definition is as follows: vol_fk = HashedFK( name = ' VOL_FK, load_from = '../Index/vol.idx', fields= ['ID','Type','Curr_Code','Tenor']) The code is working fine when the foreign key is referenced to the complete primary key But if the FK were to be on only 'ID' the FK defn would have been like = vol_fk = HashedFK( name= ' VOL_FK, load_from = '../Index/vol.idx', fields= ['ID'] ) This is were the problem lies... it shows AttributeError: 'list' object has no attribute 'has_key' I have also tried defining another PK with a single field as follows = Tvol_pk = PartitionedPK( name = 'TVOL_PK', save_to = '../Index/tvol.idx', fields = ['ID'] ) The index ''tvol.idx'' is being created at the given location(path specified) but referencing to this index(i.e., tvol.idx) with the vol_fk given above also gives the same error. -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining The Best Of Python, Ruby, Java??????
Ok, here's the Hello World example from the Scala website: object HelloWorld { def main(args: Array[String]) = { Console.println(Hello, world!) } } Opening and closing braces? def main(args: Array[String])? Console.println? About the only Pythonic thing I can see here is the def keyword. Otherwise, it looks too much like Java - no, thanks! -- Paul Don't be too harsh on it though. It is a language built for the JVM/CLR. The author perhaps intended the library to be natural to the users of the respective SDKs regardless of its' aesthetics and it explicitly seems to provide a unified API for Java and .NET. Of course, that is nothing new. Many languages have interchangeable backends for these platforms these days but there seems to be a specific focus on that here. The syntax does resemble Java/C#, which is also important if you want buy in from the Java/C# crowd. But semantically it is a proper functional language. The features may not attract Python users who might prefer Boo/Jython/IronPython. But it does offer something to disillusioned Groovy users. But on the other hand, there are some neat features even for Python programmers. Tail recursion Pattern matching Currrying Macros Concurrency Native XML support Of course, you can get by without some of these in Python with workarounds, libraries or hacks. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 http://www.python.org/dev/peps/pep-0309/ (in 2.5) http://logix.livelogix.com/ (offline) -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting TypeError:list indices must be integers
On 13/06/2006 4:11 PM, Girish Sahani wrote: [snip] instance = ti2(k) tiNew = ti1.append(instance) ti2 is quacking function but ti1 is quacking list. Possibilities: (1) You meant to type ti2[k] ... and this section of code has not yet been executed, and would have featured as episode N+1 had morbid curiosity not led me to read further. (2) You have the weirdest system of choosing names that I have seen for decades. (3) Both of the above. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Getting TypeError:list indices must be integers: apology
Hi ppl, I'm really sorry for the previous post. I write mails very quickly and end up making errors in it. This time i ended up giving a code portion from an old copy of my program. Here's the code portion that is giving a TypeError:list indices must be integers for index1 in indexList1: for index2 in indexList2: if ti1[index1] == ti2[index2] and index1 != indexList1[-1]: index1+=1 index2+=1 continue elif index1 == indexList1[-1] and charList in pairList: k = string2.index(char2[0]) instance = ti2(k) tiNew = ti1.append(instance) tiNewList.append(tiNew) else: break -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah Lee network abuse
Its not Xah Lee, who abuses the system. But people like Erik Max Francis and Philippa Cowderoy who carry on nonsense discussions across mailing lists. -- Surendra Singhi http://ssinghi.kreeti.com , | WHY SHOULD WE SAVE TIGER? | Ans: Saving the tiger means saving mankind.. | | Help http://pudang.tripod.com/ | or https://secure.worldwildlife.org/forms/tiger_appeal_1.cfm ` -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting TypeError:list indices must be integers
On 13/06/2006 4:11 PM, Girish Sahani wrote: [snip] instance = ti2(k) tiNew = ti1.append(instance) ti2 is quacking function but ti1 is quacking list. Possibilities: (1) You meant to type ti2[k] ... and this section of code has not yet been executed, and would have featured as episode N+1 had morbid curiosity not led me to read further. That is corrected. I'm appending a particular element of ti2 to ti1. It hasnt been executed because i'm stuck on that TypeError since 2 hours :( (2) You have the weirdest system of choosing names that I have seen for decades. :(( (3) Both of the above. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: groupby is brilliant!
Hi Frank This is one of the reasons why I love Python, you can write readable code. I strive to write clean code but I find that exception handling code e.g. try: makes my code ugly and significantly harder to read. Does anyone have any good pointers for a former C++ / Perl coder. /vpr Frank Millman wrote: Hi all This is probably old hat to most of you, but for me it was a revelation, so I thought I would share it in case someone has a similar requirement. I had to convert an old program that does a traditional pass through a sorted data file, breaking on a change of certain fields, processing each row, accumulating various totals, and doing additional processing at each break. I am not using a database for this one, as the file sizes are not large - a few thousand rows at most. I am using csv files, and using the csv module so that each row is nicely formatted into a list. The traditional approach is quite fiddly, saving the values of the various break fields, comparing the values on each row with the saved values, and taking action if the values differ. The more break fields there are, the fiddlier it gets. I was going to do the same in python, but then I vaguely remembered reading about 'groupby'. It took a little while to figure it out, but once I had cracked it, it transformed the task into one of utter simplicity. Here is an example. Imagine a transaction file sorted by branch, account number, and date, and you want to break on all three. - import csv from itertools import groupby from operator import itemgetter BRN = 0 ACC = 1 DATE = 2 reader = csv.reader(open('trans.csv', 'rb')) rows = [] for row in reader: rows.append(row) for brn,brnList in groupby(rows,itemgetter(BRN)): for acc,accList in groupby(brnList,itemgetter(ACC)): for date,dateList in groupby(accList,itemgetter(DATE)): for row in dateList: [do something with row] [do something on change of date] [do something on change of acc] [do something on change of brn] - Hope someone finds this of interest. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting TypeError:list indices must be integers
On 13/06/2006 5:08 PM, John Machin wrote: On 13/06/2006 4:11 PM, Girish Sahani wrote: [snip] instance = ti2(k) tiNew = ti1.append(instance) ti2 is quacking function but ti1 is quacking list. Possibilities: (1) You meant to type ti2[k] ... and this section of code has not yet been executed, and would have featured as episode N+1 had morbid curiosity not led me to read further. (2) You have the weirdest system of choosing names that I have seen for decades. (3) Both of the above. Episode N+2: tiNew = ti1.append(instance) doesn't do what you think it does: foo = [9, 8, 7] bar = 'xyz' bar = foo.append(42) foo [9, 8, 7, 42] repr(bar) 'None' Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib behaves strangely
John J. Lee wrote: It looks like wikipedia checks the User-Agent header and refuses to send pages to browsers it doesn't like. Try: [...] If wikipedia is trying to discourage this kind of scraping, it's probably not polite to do it. (I don't know what wikipedia's policies are, though) They have a general policy against unapproved bots, which is understandable since badly behaved bots could mess up or delete pages. If you read the policy it is aimed at bots which modify wikipedia articles automatically. http://en.wikipedia.org/wiki/Wikipedia:Bots says: This policy in a nutshell: Programs that update pages automatically in a useful and harmless way may be welcome if their owners seek approval first and go to great lengths to stop them running amok or being a drain on resources. On the other hand something which is simply retrieving one or two fixed pages doesn't fit that definition of a bot so is probably alright. They even provide a link to some frameworks for writing bots e.g. http://sourceforge.net/projects/pywikipediabot/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting TypeError:list indices must be integers
On 13/06/2006 5:33 PM, Girish Sahani wrote: Python prints 'c','c' when i print repr(index1),repr(index2).This means they are characters right?? But i have defined indexList as follows (and also tested the output, both are outputted as lists of numbers): for char in list1: i = substring1.index(c) That would be char, I presume, not c. indexList1.append(i) for char in list2: j = substring2.index(char) indexList2.append(j) (substring1 and substring2 are 2 different strings) Then i'm iterating over indexList1 and indexList2, so i fail to understand why i am getting the typeError On 13/06/2006 5:08 PM, John Machin wrote: On 13/06/2006 4:11 PM, Girish Sahani wrote: [SNIPPED] Girish, Could we please abide by the Geneva Convention: 1. Please don't top-post. 2. Please don't type what you thought was in your code; copy/paste actual most-recently-executed code. 3. Please reply to the newsgroup/mailing-list -- I've taken the liberty of dragging this back there as there appears to be no private content ... OK, so you've found that index1 and index2 each contain 'c'. Despite your belief that they should contain the results of some_string.index(some_char), the only reasonable hypothesis is that somebody is polluting the water further upstream. Who is that somebody? The usual and only suspect is *you*. Please go away and sprinkle print statements at likely spots further upstream until you have found the problem. Kindest possible regards, John -- http://mail.python.org/mailman/listinfo/python-list
Pygame.draw challenge
http://media.pyweek.org/static/pygame.draw-0606.html THE CHALLENGE: Create a game in 64kbytes of source code using only pygame. No additional libraries, no external files (even ones loaded from a network). That means no PyOpenGL, no PNGs, no OGGs. THE DEADLINE: Start as soon as you read this announcement. Human-readable, Linux-compatible entries must be received by [EMAIL PROTECTED] before midnight on the 25th of June, 2006. That's Australian Eastern Standard Time, which is UTC +10. Multiple entries are allowed. Teams are allowed. Monkeys are allowed! Ponies, sadly, are not allowed. THE RESULTS: All entries will be posted to a page on the http://www.pyweek.org/ website. Entry gameplay instructions and license must be included in the source or in the game itself. I will probably choose one of the entries as my favourite, and declare this in various obscure fora and private email messages. No other mention of rankings or favourites will be made. THANKS: Thanks to Phil Hassey for the challenge inspiration! -- Visit the PyWeek website: http://www.pyweek.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: groupby is brilliant!
reader = csv.reader(open('trans.csv', 'rb')) rows = [] for row in reader: rows.append(row) This is untested, but you might think about converting your explicit for... append loop into either a list comp, rows = [row for row in reader] or just a plain list constructor: rows = list(reader) Neh? -- Paul (Oh, and I like groupby too! Combine it with sort to quickly create histograms.) # tally a histogram of a list of values from 1-10 dataValueRange = range(1,11) data = [random.choice(dataValueRange) for i in xrange(1)] hist = [ (k,len(list(g))) for k,g in itertools.groupby(sorted(data)) ] print hist histAsDict = dict((k,len(list(g))) for k,g in itertools.groupby(sorted(data))) print histAsDict Gives: [(1, 979), (2, 1034), (3, 985), (4, 969), (5, 1020), (6, 975), (7, 981), (8, 1070), (9, 1003), (10, 984)] {1: 979, 2: 1034, 3: 985, 4: 969, 5: 1020, 6: 975, 7: 981, 8: 1070, 9: 1003, 10: 984} -- http://mail.python.org/mailman/listinfo/python-list
Re: Intermittent Failure on Serial Port (Other thread code)
I would like to publicly thank Serge Orloff for the effort he has put in so far and his patience... He is a Scholar and a Gentleman. Serge Orloff wrote: | H J van Rooyen wrote: | | Note that the point of failure is not the same place in the python file, but it | is according to the traceback, again at a flush call... | | Yes, traceback is bogus. Maybe the error is raised during garbage | collection, although the strace you've got doesn't show that. The main | reason of the failure seems to be a workaround in python's function | new_buffersize, it doesn't clear errno after lseek and then this errno | pops up somewhere else. There are two places I can clearly see that | don't clear errno: file_dealloc and get_line. Obviously this stuff | needs to be fixed, so you'd better file a bug report. Ouch! - I am new in this neck of the woods - what are the requirements for something like this and where should I send it to so its useful? - so far its so very vague in my mind that I am not sure that I can actually tell someone else properly what's wrong - except for a it does not work bleat which is not very illuminating... | I'm not sure how | to work around this bug in the meantime, since it is still not clear | where this error is coming from. Try to pin point it. I will put in a lot of try - except stuff looking for this errno 29 and see what comes up and where. Not sure if this will catch it but it may give a clue.. |For example, if | your code relies on garbage collection to call file.close, try to close | all files in your program explicitly. It seems like a good idea anyway, | since your program is long running, errors during close are not that | significant. Instead of standard close I'd call something like this: | | def soft_close(f): | try: | f.close() | except IOError, e: | print stderr, Hmm, close of file failed. Error was: %s % | e.errno As you remark - the code is long running - its supposed to work for ever and come back up again if the power has failed - so for now the serial port is never explicitly closed - I open and close the other files as I use them to try to make sure the data is written to disk instead of just cached to memory. I will put this sort of thing in everywhere now to try and isolate whatever it is that is biting me, not only on the close statements. | | The close failed is explicable - it seems to happen during closedown, with the | port already broken.., | | It is not clear who calls lseek right before close. lseek is called by | new_buffersize that is called by file.read. But who calls file.read | during closedown? When I said closedown - I meant whatever the system does after the exception was raised - I have not yet gotten as far as writing a clean close... - so far I am concentrating on the polling protocol, to safely get the data from the readers to the disk - port to file hence the name :-) Now there is another thread running - it accesses files, (disk and a fifo to trigger the disk write) but not the serial port - I have not laid any stress on it because I thought it was irrelevant, but now I am not so sure - the code follows below - So question - is this error number a process global thing or is it local to a thread or an object? - it could be this thread that calls read while the other one is in the process of dying after the exception - it should not access the port, though, although it repetitively reads a fifo... - come to think of it - it could be this thread that first raises the ESPIPE for all I know (that is if its global and not thread specific)... def maintain_onsite(fifoname, filename): Here we keep track of who is in, and who out of the site j = thread.get_ident() print 'New Thread identity printed by new thread is:', j pfifo = open(fifoname,'r',1)# Reading, line buffered unblock(pfifo)# call some magic global on_site#use top level dictionary to avoid a lot of copying s = d = {} while True: try: s = pfifo.readline() except IOError: time.sleep(1) continue if s == '': continue if s != 'goon\n': # see if we got a go on signal continue d = on_site# make a copy of the on site dictionary pfile = open(filename,'w',1) # The file of people on site for x in d: pfile.write(x + ' ' + d[x] + '\n') # rewrite it - a bit brute force... pfile.close() s = '' # clean out the receive string again Here is unblock code: # Some magic to make a file non blocking - from the internet def unblock(f): Given file 'f', sets its unblock flag to true. fcntl.fcntl(f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 411.
What exactly is 411 in this context? A reference to higher education perhaps? Or perhaps part of the American constitution? What exactly? Also for that matter what is 101? Cheers, Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: numeric/numpy/numarray
Bryan wrote: hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, Numarray is a re-implementation of an older Python array module called Numeric http://www.stsci.edu/resources/software_hardware/numarray this page says, NumPy derives from the old Numeric code base and can be used as a replacement for Numeric. http://numeric.scipy.org/ i looked at the matplotlib examples today and if i remember correctly, the examples didn't use numarray. so i'm a bit confused. thanks, bryan Look again at numeric.scipy.org, and this time: read the whole page, especially the section called Older Array Packages. -- http://mail.python.org/mailman/listinfo/python-list
Decimals
Hello, I have a price column in a MySQL table: price decimal(5,2) When I access them in Python with SQLObject, prices display as 15.0 instead of 15.00. Why is this happening? I can't figure out why Python is trimming off the hundredth place. I'm not doing any formatting... Thanks, Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]apache authentication questions
Steve Holden wrote: [EMAIL PROTECTED] wrote: It is not impossible though and in cases where you don't have a choice but to use a HTTP authentication scheme, use of AJAX may be the answer to still allowing use of a form based login scheme. See: http://www.peej.co.uk/articles/http-auth-with-html-forms.html That's neat! IMHO this makes things more complicated and error-prone. And it requires Javascript. I also can't see why this is more secure than a proper session management (using cookies or URL for passing the session ticket around). Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib behaves strangely
On the other hand something which is simply retrieving one or two fixed pages doesn't fit that definition of a bot so is probably alright. They i think so, too. even provide a link to some frameworks for writing bots e.g. http://sourceforge.net/projects/pywikipediabot/ ah, that looks nice .. Best regards, Gabriel. -- /---\ | If you know exactly what you will do -- | | why would you want to do it? | | (Picasso) | \---/ -- http://mail.python.org/mailman/listinfo/python-list
Re: parent in a class __init__ def?
[EMAIL PROTECTED] wrote: bruno at modulix wrote: [EMAIL PROTECTED] wrote: Intuitively, the name lookup on self.parent.foo would be faster than if you passed in the object in question Each dot means doing a lookup in a namespace. The more dots, the more lookups. And lookups do have a cost. hmm, intuition may not be right in this case. Lookups do have a cost - now Im almost tempted to write and run a test for this - but the cost of each lookup is also relative to the current scope. A common optimization trick is to 'localize' references before a heavy loop, to avoid lookup cost, ie: def method(self, *args): dothis = self.dothis dothat = somemodule.somefunc CONST = othermodule.CONST # heavy processing loop here I haven't looked over the implementation of the python interpreter - but I would hope the lookup on self would be optimized and trivial. It's certainly not trivial. Must take into account instance attributes (in __dict__ or __slots__), class attributes, inherited attributes, overriding descriptors, non-overriding descriptors, __getattr__, etc... The incredible felxibility of Python's object model comes with a cost. The next relevant question would be is it cheaper to lookup self.parent or to look up a method variable, The second - cf above. which I supsect would depend on the number of names in self vs. number of names in the method. Namespaces are mostly built upon hashtables, so the number of names should be mostly irrelevant. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib behaves strangely
headers = {} headers['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4' request = urllib2.Request(url, headers) file = urllib2.urlopen(request) ah, thanks a lot, that works ! Best regards, Gabriel. -- /---\ | If you know exactly what you will do -- | | why would you want to do it? | | (Picasso) | \---/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals
Tgone írta: Hello, I have a price column in a MySQL table: price decimal(5,2) When I access them in Python with SQLObject, prices display as 15.0 instead of 15.00. Why is this happening? I can't figure out why Python is trimming off the hundredth place. I'm not doing any formatting... What do you mean by 'displays as 15.0'? Do you print in with the print statement? If your DB access module returns decimal.Decimal instances, then you are right. It should print as 15.00 instead of 15.0. Try to determine the type of the returned value. Maybe your DB module uses float instead of Decimal? Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: groupby is brilliant!
Paul McGuire wrote: reader = csv.reader(open('trans.csv', 'rb')) rows = [] for row in reader: rows.append(row) This is untested, but you might think about converting your explicit for... append loop into either a list comp, rows = [row for row in reader] or just a plain list constructor: rows = list(reader) Neh? -- Paul Yup, they both work fine. There may be times when you want to massage the data before appending it, in which case you obviously have to do it the long way. Otherwise these are definitely neater, the last one especially. You could even do it as a one-liner - rows = list(csv.reader(open('trans.csv', 'rb'))) It still looks perfectly readable to me. Thanks Frank -- http://mail.python.org/mailman/listinfo/python-list
Re: numeric/numpy/numarray
Simon Percivall wrote: Bryan wrote: hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. Look again at numeric.scipy.org, and this time: read the whole page, especially the section called Older Array Packages. In particular, ignore any references to SciPy Core... Not to mention anything regarding older NumPy, which is nothing to do with newer NumPy, which is why common libraries (such as PyOpenGL) ask for NumPy v23 when the latest download on SourceForge is 0.9.8. Numeric libraries in Python are a nomenclatural nightmare. It's well past time that something made it into the standard library, I feel. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals
Laszlo Nagy wrote: Tgone írta: Hello, I have a price column in a MySQL table: price decimal(5,2) When I access them in Python with SQLObject, prices display as 15.0 instead of 15.00. Why is this happening? I can't figure out why Python is trimming off the hundredth place. I'm not doing any formatting... What do you mean by 'displays as 15.0'? Do you print in with the print statement? If your DB access module returns decimal.Decimal instances, then you are right. It should print as 15.00 instead of 15.0. Try to determine the type of the returned value. Maybe your DB module uses float instead of Decimal? Sorry, when I print out the variable it displays as '15.0'. The price is '15.00' in the database though. Here's my code: product = Product.get(2) print product.price # 15.0 I'm using MySQLdb if that helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: [*SPAM*] Python open proxy honeypot
On 13/06/06, Alex Reinhart [EMAIL PROTECTED] wrote: Is running Python's built-in smtpd, pretending to accept and forward all messages, enough to get me noticed by a spammer, or do I have to do something else to advertise my script as an open proxy? This will get you noticed by crawlers that scan the Internet looking for SMTP open-relays on port 25, its not an open-proxy :):) This will work as planned, but you should also have some email addresses using this server for a full range of spam hits. A single domain is cheap and you can use it just for incoming spam - seed a few addresses around the internet and wait Things you should be aware of: a) You may be breaking your ISP's TCs and AUPs b) your ISP connection must have port 25 open c) Be prepared for potentially huge numbers of connections in intermittent but sustained batches which may make your connection unusable. d) point c might get you noticed in relation to point a. HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals
Sybren Stuvel wrote: Tgone enlightened us with: Sorry, when I print out the variable it displays as '15.0'. The price is '15.00' in the database though. That's the same thing, isn't it? 15.0 == 15.0 Yes, they're both mathematically the same. I never said they weren't... Here's my code: product = Product.get(2) print product.price # 15.0 Try string formatting: print '%.2f' % product.price That works. I expected Python to display the data exactly as it is in the database, like most languages. -- http://mail.python.org/mailman/listinfo/python-list
Screen capturing on Windows
Is it possible by use of pyWin32 or ctypes to make a screen capture of an inactive, or a hidden window if the hwnd/WindowName/ClassName is known? I've seen dedicated screen capture software do this. While PIL.ImageGrab.grab() is excellent, it will only capture the foreground of the desktop. I've tried for hours, but I soon get helplessly lost in the labyrinths of the Win32API. -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals
Try string formatting: print '%.2f' % product.price That works. I expected Python to display the data exactly as it is in the database, like most languages. It depends on what you get back from MySQLdb. Try this: import decimal d = decimal.Decimal(3.) print d Now try this: d = float(3.) print d The problem is -- probably -- with your db module. It may return a float instead of a Decimal. I cannot help more with MySQL, because I do not use it. Sorry. Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 411.
Mike T schreef: What exactly is 411 in this context? A reference to higher education perhaps? Or perhaps part of the American constitution? What exactly? Also for that matter what is 101? I don't know about 411, but 101 refers to basic or entry-level courses at universities in the United States. I gathered something like that from context after seeing many references to it; then I finally decided to look it up to be sure about it: http://en.wikipedia.org/wiki/101_%28number%29 under In other fields. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 411.
Mike T said unto the world upon 13/06/06 10:46 AM: What exactly is 411 in this context? A reference to higher education perhaps? Or perhaps part of the American constitution? What exactly? Also for that matter what is 101? Cheers, Mike Hi Mike, 411 is the number one dials in North America to reach directory assistance (getting telephone numbers). So, it has a slang usage meaning something like information. Introductory university course in a field are often numbered 101 (i.e. Computer Science 101). So, that number has acquired a slang meaning of basic and introductory information. Where I did my undergrad studies, a few Departments had 001 classes. Somehow that felt more honest ;-) Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 411.
Mike T [EMAIL PROTECTED] writes: What exactly is 411 in this context? A reference to higher education perhaps? Or perhaps part of the American constitution? What exactly? Also for that matter what is 101? It's a directory assistance number in the US. The site is a directory of URLs. Ganesan -- Ganesan Rajagopal -- http://mail.python.org/mailman/listinfo/python-list
What's wrong in this HTML Source file of a Bank
Several times I logged-in successfully but after log-in I can't use features/services which were shown prior to my login. Can anyone exoert from this forum check , is it technical fault of Bank Web Site or this problem pertaining to the user(me). HTML HEAD META http-equiv=Content-Type content=text/html; charset=UTF-8 META Http-Equiv=Cache-Control Content=no-cache META Http-Equiv=Pragma Content=no-cache META Http-Equiv=Expires Content=-1 TITLEhPLUS Login/TITLE LINK href=https://rs6.habibbank.ae/stylesheet.css;jsessionid=391BF2AEF1EC6EECFB...; rel=stylesheet title=Style type=text/css script type=text/javascript var processed = false; function processForm(alertMessage, button, buttonMessage, command , ignore ) { var msg = Please wait. Your request has been sent for processing.; if(alertMessage == null || alertMessage=='null') alertMessage = msg; if ( !ignore ) { if(processed) { alert(alertMessage); return false; } } processed=true; if(button!= null) { button.value = buttonMessage; } var f =document.forms[0]; f.hPLUSWEB_ACTION.value= command; f.pageId.value = 48416044248; f.submit(); return true; } /scriptscript type=text/javascript function commonPostForm( value, command ) { var url = value.split( ':', 2 ); var f = document.forms[0]; f.commonOptionLogic.value = url[ 0 ]; f.commonOptionNumber.value = url[ 1 ]; return processForm( null, null, null, command ); } function titleAccountPostForm( value, command ) { var f = document.forms[0]; f.accountSelected.value = value; return processForm( null, null, null, command ); } function titleOptionPostForm( value, command ) { var url = value.split( ':', 2 ); var f = document.forms[0]; f.optionLogic.value = url[ 0 ]; f.optionNumber.value = url[ 1 ]; return processForm( null, null, null, command ); } /script /HEAD BODY topmargin=0 leftmargin=0 TABLE border=1 cellpadding=0 cellspacing=0 width=100% TR TD align=center class=black width=125pxIMG src=https://rs6.habibbank.ae/banklogo.gif;jsessionid=391BF2AEF1EC6EECFBAF...;BR FONT size=1px/FONTService with Security/TDTD class=blue TABLE width=100% TR TD align=center class=blue width=300pxIMG src=https://rs6.habibbank.ae/title.gif;jsessionid=391BF2AEF1EC6EECFBAF1FD...;/TD /TR TR TD align=center class=blue height=25px width=300px (Incorporated in Switzerland 1967)/TDTD align=right class=blueJun 13 2006, 11:18:49 AM GMT/TD /TR /TABLE /TD /TR TR TD align=center class=red nbsp;nbsp; /TDTD class=blue TABLE border=0 cellpadding=1 cellspacing=1 TR TD class=buttonA href=http://www.habibbank.com; Home /A/TDtd class=buttonA href=https://rs6.habibbank.ae/WebRegister.po;jsessionid=391BF2AEF1EC6EECFB...;Register Online/A/td /TR /TABLE /TD /TR /TABLE script type=text/javascript function postForm( value, command ) { return processForm( null, null, null, command ); } /script form method=post id=WebDefaultMessage view=WebDefaultFormView action=https://rs6.habibbank.ae/hPLUS;jsessionid=391BF2AEF1EC6EECFBAF1FDE35C...; name=WebDefaultMessage input type=hidden name=Current_Form_View value=WebDefaultFormView table align=center border=0 class=blue width=100% cellpadding=0 cellspacing=0 tr td align=center colspan=3 class=blue h1/h1 /td /tr input name=pageId type=hidden value=P1150197529789input name=hPLUSWEB_ACTION type=hidden value= tr td class=blue br A href=# onClick=postForm('WebLogin' );return false;HBZ Web Login/A/td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue center h1Your request has been accepted/h1 /center /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br /td /tr tr td class=blue br A href=# onClick=postForm('WebLogin' );return false;HBZ Web Login/A/td /tr /table /form /BODY /HTML --
Re: What's wrong in this HTML Source file of a Bank
[EMAIL PROTECTED] wrote: Several times I logged-in successfully but after log-in I can't use features/services which were shown prior to my login. Can anyone exoert from this forum check , is it technical fault of Bank Web Site or this problem pertaining to the user(me). bofh It's definitively a problem with the user. The problem is : user posts in the wrong newsgroup. /bofh (snip a whole page of crappy tag soup) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Earthquake and Tornado Forecasting Programs June 13, 2006
edgrsprj [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html EARTHQUAKE AND TORNADO FORECASTING PROGRAMS Posted by E.D.G. June 13, 2006 http://www.freewebz.com/eq-forecasting/Data.html The information in this report represents expressions of personal opinion. On July 11, 2005 I posted a report to a number of Internet Newsgroups including sci.geo.earthquakes stating that I was considering creating a Web site where researchers around the world could post notes and develop computer programs associated with the science of earthquake forecasting. This present report is an update on that project. The effort is still underway. The present plan is to try to get the proposed Web site organized for the science of earthquake forecasting and then expand it to include other sciences such as tornado forecasting and different areas of medicine. The ultimate goal is to have discussion areas there for as many of the problems which threaten the health and lives of people around the world as possible. Professional and amateur computer programmers would probably be heavily involved with this work. Since that first report was posted last July I have been able to establish what looks like it will be a stable source of funding for the effort. It should at least enable me to continue working on the project and pay for things such as Web site rental fees etc. And I am presently working with two groups of legal people who are attempting to create a formal organization through which the actual funding and Web site operation etc. will take place. How fast this effort will progress is at the moment largely up to those legal groups. One of them is supposed to create the necessary legal documents. The other will be doing the filing with government agencies etc. Unfortunately, since I am not a major client of either group they are doing the work when they are not busy with other clients. A formal legal organization intended to be an introductory version of this new organization has existed since 2002. But it took my legal people about eight months to get all of the paperwork done and filed. The present effort has been underway for a month. Hopefully it will not take another seven months to finish. PROPOSED WEB SITE A number of years ago I worked with a Web site development expert to create a discussion group for earthquake forecasting. I believe that it eventually evolved into the two following discussion groups. The original Web site expert is no longer involved. http://groups.yahoo.com/group/earthwaves http://www.earthwaves.org/wwwboard/wwwboard.html For this proposed Web site I would probably try to use a discussion board which would be a highly modified version of that second board. And it will take a fair amount of computer programming to create the new version. The problem with the existing discussion board control computer program is that it is does not offer the necessary posting options. When researchers post a note to such a board, rules have to be in place regarding what types of notes other people can post in response. That is an absolute necessity. And the structure of that present board does not contain those types of rules within the control computer program itself. More details regarding that proposed Web site can be found in the following report that I submitted for a United Nations disaster mitigation related discussion back in July of 2004: http://www.unisdr.org/wcdr-dialogue/t3-dialogue.htm#34 Based on their starting dates etc. I believe that my report might have already led to the creation of the following Web sites: http://www.hewsweb.org http://www.grassroots.org Keep your fingers crossed. If the effort to create this proposed Web site is successful then it might assist researchers in quite a few areas of science and medicine around the world with significantly accelerating their lifesaving efforts. -- http://mail.python.org/mailman/listinfo/python-list
Unimporting modules, memory leak?
Hello everybody, Probably, this is being too demanding for Python, but it may be useful to unimport modules to work with dynamic code (though not the best, one example is [2]). In fact, it is supposed to be possible[1], but I have detected it usually leaks memory. When unimported in Linux, the simple C module attached (has no functions, just the structure) leaks two memory pages To see the test you can just put the files in a directory and: python setupmod1.py install --install-lib . python testMemory.py Its output follows. First, the memory used before import. Second memory used after the import. Third the number of references to that object is checked before using del. Finally the memory used after unimporting. -- Testing mod1 -- Mem. used: 1242 (gc: 0 ) Mem. used: 1244 (gc: 0 ) Check refs (should be = 2): 2 Mem. used: 1244 (gc: 0 ) -- Testing bigModule -- Mem. used: 1244 (gc: 0 ) Mem. used: 2686 (gc: 0 ) Check refs (should be = 2): 2 Mem. used: 1244 (gc: 0 ) -- Testing random -- Mem. used: 1244 (gc: 0 ) Mem. used: 1256 (gc: 0 ) Check refs (should be = 2): 2 Mem. used: 1256 (gc: 57 ) Unimporting attached bigmodule.py there are no memory leaks. Unimporting python's random module it leaks some pages, but garbage collector admit it can not free them. If a module with the same name that the unimported module is imported, the pages are reused. While, if this same module is loaded with another name, they are not freed, and the program grows with each module imported/unimported Is this a Python bug? A Linux bug? Am i missing some way of freeing that memory used by C module? [1] http://mail.python.org/pipermail/python-list/1999-May/002669.html [2] http://ax5.com/antonio/orangesnns -- Saludos, Antonio Arauzo Azofra def funcion_de_prueba(a,b): print a,b big_list = [] for i in xrange(1000): big_list.append(1000 * 'bg') from distutils.core import setup, Extension module1 = Extension('mod1', sources = ['srcmod1.c']) setup (name = 'OrangeSNNStmp', version = '1.0', description = 'Function that calls a trained NN', ext_modules = [module1]) #include Python.h static PyMethodDef orangeSnnsTmpMethods[] = { {NULL, NULL, 0, NULL}/* Sentinel */ }; PyMODINIT_FUNC initmod1(void) { (void) Py_InitModule(mod1, orangeSnnsTmpMethods); } # # Test memory comsumption importing and unimporting modules # import gc, os, sys def printMemoryUse(): rgc = gc.collect() f = open(/proc/ + str(os.getpid()) + /statm) totalMemorySize = f.readline().split()[0] f.close() print Mem. used:, totalMemorySize, (gc:, rgc, ) def testImport(moduleName): print -- Testing, moduleName, -- printMemoryUse() module = __import__(moduleName, globals(), locals()) printMemoryUse() del sys.modules[moduleName] print Check refs (should be = 2):, sys.getrefcount(module) del module printMemoryUse() testImport(mod1) testImport(bigModule) testImport(random) -- http://mail.python.org/mailman/listinfo/python-list
Python Video processing.
Hi all, I have a specific task I want to automate - rotating a video file through 90 degrees. I've used the PIL library quite a bit to perform batch processing on images, and would like to do similar on video. Can anyone see a problem with the following: 1) Use pymedia to convert the video into a sequence of stills (e.g. http://pymedia.org/tut/src/dump_video.py.html) 2) Use PIL to process each still 3) Use pymedia to re-pack the still into video format. In particular, does anyone know whether the data obtained from decoding the video frame as in the following snippet from http://pymedia.org/tut/src/dump_video.py.html: dd= d.convert( fmt ) img= pygame.image.fromstring( dd.data, dd.size, RGB ) can be directly loaded into a PIL Image object (and back again?)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Video processing.
Ant [EMAIL PROTECTED] wrote: In particular, does anyone know whether the data obtained from decoding the video frame as in the following snippet from http://pymedia.org/tut/src/dump_video.py.html: dd= d.convert( fmt ) img= pygame.image.fromstring( dd.data, dd.size, RGB ) can be directly loaded into a PIL Image object (and back again?)? iirc, the pygame fromstring/tostring methods are designed to be data-compatible with PIL's corresponding methods, so you should be able to do im = Image.fromstring(RGB, dd.size, dd.data) instead of doing that pygame.image call (not that the argument order is different). for details, see the pygame tostring/fromstring docs, and the corresponding PIL methods: http://www.pygame.org/docs/ref/image.html http://www.pythonware.com/library/pil/handbook/image.htm hope this helps! /F -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL problem after installation
Fredrik Lundh wrote: Lad wrote: I downloaded jpeg (from ftp://ftp.uu.net/graphics/jpeg/ ) source libraries( file jpegsrc.v6b.tar.gz) and installed them. Now in /usr/local/lib I have the following files: cjpeg ,djpeg,jpegtran,rdjpgcom and wrjpgcom cjpeg, djpeg etc are executables, not libraries. if you have them under /usr/local/lib, something's not quite right. to save some time, I suggest looking for a jpeg-dev or jpeg-devel package in the package repository for your platform. /F Hello Fredrik, Thank you for your reply. I installed jpeg-devel package and now selftest.py worked! But I want to use PIL in my Python program( Django) running under Apache. What permissions must I use for which files? Thank you very much for your help. regards, L, -- http://mail.python.org/mailman/listinfo/python-list
Adding dictionnaries
Hello, Does anybody had the problem of adding the content of two dictionnaries. ? Regards -- http://mail.python.org/mailman/listinfo/python-list
Re: Very nice python IDE (windows only)
Hello Luis, Luis M. González [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I happen to have delphi, so if someone wants me to make small changes, just let me know, I'll try to help Hmm... now that you offer, would it be possible to have the colors of text just like in IDLE? I tried configuring the colors, but some of them don't exist as options in this IDE (for example orange). Hmm, it's a little bit hidden, but if you go to Options / Editor / Syntax Colors and be sure to select Python language as editor syntax then select 'reserved words' and after that from the color dropdown box select Custom... (the topmost option) a color dialog pops up and you can select any color You want...;-)) I like how text looks in IDLE, with orange for reserved words, green for strings, etc... With the above, no problem at all...;-)) Greetings from sunny Amsterdam, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding dictionnaries
While reading the doc i've found 'update' :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Video processing.
im = Image.fromstring(RGB, dd.size, dd.data) instead of doing that pygame.image call (not that the argument order is different). for details, see the pygame tostring/fromstring docs, and the corresponding PIL methods: That's starting to look promising, yes - thanks! I'll give it a shot this evening and see what happens... -- http://mail.python.org/mailman/listinfo/python-list
Making a Label that looks the same as a button.
I have a Button object that gets replaced by a Label when clicked. Button(buttonsframe,text=' ',command=c,font=buttonsFont) Note that the text is a single space. buttonsFont uses 'Courier New' as a family. When clicked, the Button is destroyed and replaced with a Label object: Label(buttonsframe,text=x,font=buttonsFont,relief=RAISED) The intent is for the Label object to look identical to the button object, except for the non-space character x. The Label object is a little smaller than the Button object. When I set borderwidth, the label object does increase in size, but that's not going to make it look the same, since it makes the border thicker. How do I get the Label object to look just like the Button object? -- http://mail.python.org/mailman/listinfo/python-list
Re: Very nice python IDE (windows only)
Hello Jonathan, Jonathan Ellis [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] ago wrote: I have just discovered Python Scripter by Kiriakos Vlahos and it was a pleasant surprise. I thought that it deserved to be signalled. It is slim and fairly fast, with embedded graphical debugger, class browser, file browser... If you are into graphical IDEs you are probably going to enjoy it. Windows only unfortunately. http://mmm-experts.com/Products.aspx?ProductId=4 Not to rain on anyone's parade, but I'd recommend using an IDE that isn't based on an obviously dead-end platform. (PyScripter is written in Delphi.) Hmm, dead-end platform, where did that idea come from? I certainly won't want to start anything remotely resembling to a language warg, but I have to say after more than 20 years of programming with Borland products in C, C++(Builder), Kylix and Delphi, there's certainly no end in sight yet...;-)) -Jonathan Greetings from sunny Amsterdam, Jan -- http://mail.python.org/mailman/listinfo/python-list
Re: What's wrong in this HTML Source file of a Bank
This really isn't the place to ask what is wrong with code that isn't Python, especially of someone else's website. There is absolutely no way for us to tell what is happening on the server side. You should contact the maintainer of the site and let them know you are having problems. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
pylab doesn't find numpy on Windows
Hi all. I installed matplotlib 0.87.3 under Python 2.4 on both Linux (FC3) and Windows XP Pro. On the linux install, I can import pylab, but when I try to do the same thing on the Windows installation, I get from pylab import * Traceback (most recent call last): File pyshell#7, line 1, in -toplevel- from pylab import * File C:\Python24\Lib\site-packages\pylab.py, line 1, in -toplevel- from matplotlib.pylab import * File C:\Python24\Lib\site-packages\matplotlib\pylab.py, line 196, in -toplevel- import cm File C:\Python24\Lib\site-packages\matplotlib\cm.py, line 5, in -toplevel- import colors File C:\Python24\Lib\site-packages\matplotlib\colors.py, line 33, in -toplevel- from numerix import array, arange, take, put, Float, Int, where, \ File C:\Python24\Lib\site-packages\matplotlib\numerix\__init__.py, line 60, in -toplevel- from Numeric import * ImportError: No module named Numeric I have numpy 0.9.8 installed in both places too. Thanks for any help. -- http://mail.python.org/mailman/listinfo/python-list
.py and running in Windows:
Hello: Presently in my Windows 2000 system, when I double-click on a .py file (open it) it automatically runs it in Python. I would like to change that behavour. That is fine for .pyc file, but for .py files, I would either like to have it run in Python but return to the Python shell prompt when finished rather than exit the shell. How do I do that? Or would it cause a problem (so that Python no longer works) if I change the default .py extension to open in an editor rather than execute it if I open it? Thanks: Michael Yanowitz -- http://mail.python.org/mailman/listinfo/python-list
Re: pylab doesn't find numpy on Windows
Le 13-06-2006, timw.google [EMAIL PROTECTED] nous disait: Hi all. I installed matplotlib 0.87.3 under Python 2.4 on both Linux (FC3) and Windows XP Pro. On the linux install, I can import pylab, but when I try to do the same thing on the Windows installation, I get from pylab import * snip ImportError: No module named Numeric I have numpy 0.9.8 installed in both places too. it is trying to load Numeric python. You need to configure matplotlib to use numpy by saying numerix : numpy in the matplotlibrc file. -- Alexandre Fayolle LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science -- http://mail.python.org/mailman/listinfo/python-list
What's wrong in this HTML Source file of a Bank
They don't know whats happeing despite sending them several e-mails. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's wrong in this HTML Source file of a Bank
[EMAIL PROTECTED] wrote: They don't know whats happeing despite sending them several e-mails. So what? How are _we_ supposed to know? Even if somebody here found a bug in their java script (this is a Python NG, btw...) - now _how_ exactly are you planning to update their website with that information? It's their problem, and thus unfortunately yours. So - change your bank, or keep pestering them. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: .py and running in Windows:
You'll have better results posting this to it's own thread. On Jun 13, 2006, at 9:29 AM, Michael Yanowitz wrote: Hello: Presently in my Windows 2000 system, when I double-click on a .py file (open it) it automatically runs it in Python. I would like to change that behavour. That is fine for .pyc file, but for .py files, I would either like to have it run in Python but return to the Python shell prompt when finished rather than exit the shell. How do I do that? Or would it cause a problem (so that Python no longer works) if I change the default .py extension to open in an editor rather than execute it if I open it? Thanks: Michael Yanowitz -- http://mail.python.org/mailman/listinfo/python-list --- Andrew Gwozdziewycz [EMAIL PROTECTED] http://23excuses.com | http://ihadagreatview.org | http://and.rovir.us -- http://mail.python.org/mailman/listinfo/python-list
Re: Making a Label that looks the same as a button.
On 13 Jun 2006 06:14:03 -0700, Dustan [EMAIL PROTECTED] wrote: I have a Button object that gets replaced by a Label when clicked. Button(buttonsframe,text=' ',command=c,font=buttonsFont) Note that the text is a single space. buttonsFont uses 'Courier New' as a family. When clicked, the Button is destroyed and replaced with a Label object: Label(buttonsframe,text=x,font=buttonsFont,relief=RAISED) The intent is for the Label object to look identical to the button object, except for the non-space character x. The Label object is a little smaller than the Button object. When I set borderwidth, the label object does increase in size, but that's not going to make it look the same, since it makes the border thicker. How do I get the Label object to look just like the Button object? There is least two other options that are different for Labels and Buttons: b = Button(root) b.cget('padx') '3m' b.cget('pady') '1m' l = Label(root) l.cget('padx') '1' l.cget('pady') '1' The padx and pady are the distance between the text and the widget borders. They are larger on a Button. BTW, you can get all configuration options for any widget with: for k in widget.configure().keys(): print k, ':', widget.cget(k) So you can easily compare common options between a standard Label and a standard Button. HTH -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding dictionnaries
Salvatore [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] While reading the doc i've found 'update' :-) Bless you, Salvatore!! Too often we hear about the gross deficiencies of the Python documentation. I'd venture to say that documentation is mostly perceived as the last resource of a scoundrel. Thank you for logging for us at least one documented case of someone finding the answer to their question in, yes, the documentation! I really and sincerely thank you! Also, you will find a wealth of help by using (from the interactive Python prompt) help(dict) or help(str) or import unfamiliarModule; help(unfamiliarModule). -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Making a Label that looks the same as a button.
It's imperative that you explain which toolkit you are using since they all have differences. On Jun 13, 2006, at 9:14 AM, Dustan wrote: I have a Button object that gets replaced by a Label when clicked. Button(buttonsframe,text=' ',command=c,font=buttonsFont) Note that the text is a single space. buttonsFont uses 'Courier New' as a family. When clicked, the Button is destroyed and replaced with a Label object: Label(buttonsframe,text=x,font=buttonsFont,relief=RAISED) The intent is for the Label object to look identical to the button object, except for the non-space character x. The Label object is a little smaller than the Button object. When I set borderwidth, the label object does increase in size, but that's not going to make it look the same, since it makes the border thicker. How do I get the Label object to look just like the Button object? -- http://mail.python.org/mailman/listinfo/python-list --- Andrew Gwozdziewycz [EMAIL PROTECTED] http://23excuses.com | http://ihadagreatview.org | http://and.rovir.us -- http://mail.python.org/mailman/listinfo/python-list
a string problem
hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. If re module is not needed, how can i use string manipulation to do this? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining The Best Of Python, Ruby, Java??????
But semantically it is a proper functional language. The features may not attract Python users who might prefer Boo/Jython/IronPython. But it does offer something to disillusioned Groovy users. Are they disillusioned? Just wondering. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding dictionnaries
Paul McGuire a écrit : Also, you will find a wealth of help by using (from the interactive Python prompt) help(dict) or help(str) or import unfamiliarModule; help(unfamiliarModule). Thanks Paul -- http://mail.python.org/mailman/listinfo/python-list
What's wrong in this HTML Source file of a Bank
I have posted the same question in alt.html but no one yet replied. -- http://mail.python.org/mailman/listinfo/python-list
Re: .py and running in Windows:
Andrew Gwozdziewycz wrote: You'll have better results posting this to it's own thread. He certainly should have, but since I've read it here anyway: On Jun 13, 2006, at 9:29 AM, Michael Yanowitz wrote: Hello: Presently in my Windows 2000 system, when I double-click on a .py file (open it) it automatically runs it in Python. I would like to change that behavour. That is fine for .pyc file, but for .py files, I would either like to have it run in Python but return to the Python shell prompt when finished rather than exit the shell. How do I do that? Or would it cause a problem (so that Python no longer works) if I change the default .py extension to open in an editor rather than execute it if I open it? In an explorer window, go to Tools-Folder Options Go to the File Types tab, find the PY extension, then click on Advanced* Select the 'open' action, and click Edit... change the 'Application used to perform action', inserting a '-i' between the exe and the first parameter. For example, I changed mine to: C:\Python\python.exe -i %1 %* The exact line will depend on where your python.exe is. OK all the dialogs you've opened, then double click a .py file to test it. *I'm using WinXP, so the exact name of some of the buttons may be different for you. Iain -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython: how do i write this without the id parameter?
Scott David Daniels wrote: class InputForm(wx.Frame): def __init__(self, parent=None, id=-1, title=__file__): # or, if you prefer: ..., id=wx.ID_ANY, ... wx.Frame.__init__(self, parent=parent, id=id, title='%s v%s' % (title, __version__)) class MyApp(wx.App): def OnInit(self): frame = InputForm(title='Data Entry Form') self.SetTopWindow(frame) frame.Show() return True Thanks, but there was an example (which I can't find now) somewhere in the wxPython wiki that showed a call to wx.Frame without the id parameter at all, like wx.Frame(parent, title). How is that possible? Is the issue with my code just that I'm passing the parameters around and so I can't be as concise as that? -- http://mail.python.org/mailman/listinfo/python-list
Re: What's wrong in this HTML Source file of a Bank
[EMAIL PROTECTED] wrote: I have posted the same question in alt.html but no one yet replied. No wonder. -- http://mail.python.org/mailman/listinfo/python-list
RE: Making a Label that looks the same as a button.
Buttons can look like labels without the need to create another object - just remove the Command binding, set state to DISABLED and disabledforeground='same color as NORMAL'... This demonstrates how to play with button styles: import Tkinter as tk class GUI: def __init__(self): self.root = tk.Tk() self.root.title('Button Styles') for bdw in range(5): setattr(self, 'of%d' % bdw, tk.Frame(self.root, borderwidth=0)) tk.Label(getattr(self, 'of%d' % bdw), text='borderwidth = %d ' % bdw).pack(side=tk.LEFT) for relief in [tk.RAISED, tk.SUNKEN, tk.FLAT, tk.RIDGE, tk.GROOVE, tk.SOLID]: tk.Button(getattr(self, 'of%d' % bdw), text=relief, borderwidth=bdw, relief=relief, width=10, command=lambda s=self, r=relief, b=bdw: s.prt(r,b))\ .pack(side=tk.LEFT, padx=7-bdw, pady=7-bdw) getattr(self, 'of%d' % bdw).pack() def prt(self, relief, border): print '%s:%d' % (relief, border) myGUI = GUI() myGUI.root.mainloop() John Grayson -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dustan Sent: Tuesday, June 13, 2006 9:14 AM To: python-list@python.org Subject: Making a Label that looks the same as a button. I have a Button object that gets replaced by a Label when clicked. Button(buttonsframe,text=' ',command=c,font=buttonsFont) Note that the text is a single space. buttonsFont uses 'Courier New' as a family. When clicked, the Button is destroyed and replaced with a Label object: Label(buttonsframe,text=x,font=buttonsFont,relief=RAISED) The intent is for the Label object to look identical to the button object, except for the non-space character x. The Label object is a little smaller than the Button object. When I set borderwidth, the label object does increase in size, but that's not going to make it look the same, since it makes the border thicker. How do I get the Label object to look just like the Button object? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: numeric/numpy/numarray
Simon Percivall wrote: Bryan wrote: hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, Numarray is a re-implementation of an older Python array module called Numeric http://www.stsci.edu/resources/software_hardware/numarray this page says, NumPy derives from the old Numeric code base and can be used as a replacement for Numeric. http://numeric.scipy.org/ i looked at the matplotlib examples today and if i remember correctly, the examples didn't use numarray. so i'm a bit confused. thanks, bryan Look again at numeric.scipy.org, and this time: read the whole page, especially the section called Older Array Packages. at the end of that page, it says: Numarray is another implementation of an arrayobject for Python written after Numeric and before NumPy. Sponsors of numarray have indicated they will be moving to NumPy as soon as is feasible for them so that eventually numarray will be phased out. on the python wiki NumArray is the current reimplementation of NumPy. http://wiki.python.org/moin/NumArray so, was Numarray written *before* NumPY, or was it a reimplementation of NumPy which implies it came *after* NumPy? it seems clear that Numeric is the old one and i read is not being worked on anymore. so that leaves Numarray and numpy. which of these two should i use? thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
[EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. If re module is not needed, how can i use string manipulation to do this? thanks As far as re goes, you can search for the pattern '\bstring\b', which will find just the word 'string' itself. Not sure if there's a better way to do it with REs. And I'm actually ashamed to admit that I know the RE way, but not the regular string manipulation way, if there is one! This seems like something easy enough to do without REs though. -- http://mail.python.org/mailman/listinfo/python-list
RE: .py and running in Windows:
Thanks. XP looks to be the same as 2000. Works as expected now. Thank You. Not sure what this 'thread' issue is. I never specified a thread. I think perhaps though because I did open another message in this mailing list (to get the correct email address to send to), but I deleted all its contents i put it under that other thread, however there is no indication of a thread in Outlook email. I am sorry if it came up in another thread that was not my intention. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Iain King Sent: Tuesday, June 13, 2006 9:48 AM To: python-list@python.org Subject: Re: .py and running in Windows: Andrew Gwozdziewycz wrote: You'll have better results posting this to it's own thread. He certainly should have, but since I've read it here anyway: On Jun 13, 2006, at 9:29 AM, Michael Yanowitz wrote: Hello: Presently in my Windows 2000 system, when I double-click on a .py file (open it) it automatically runs it in Python. I would like to change that behavour. That is fine for .pyc file, but for .py files, I would either like to have it run in Python but return to the Python shell prompt when finished rather than exit the shell. How do I do that? Or would it cause a problem (so that Python no longer works) if I change the default .py extension to open in an editor rather than execute it if I open it? In an explorer window, go to Tools-Folder Options Go to the File Types tab, find the PY extension, then click on Advanced* Select the 'open' action, and click Edit... change the 'Application used to perform action', inserting a '-i' between the exe and the first parameter. For example, I changed mine to: C:\Python\python.exe -i %1 %* The exact line will depend on where your python.exe is. OK all the dialogs you've opened, then double click a .py file to test it. *I'm using WinXP, so the exact name of some of the buttons may be different for you. Iain -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
John Salerno wrote: [EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. If re module is not needed, how can i use string manipulation to do this? thanks As far as re goes, you can search for the pattern '\bstring\b', which will find just the word 'string' itself. Not sure if there's a better way to do it with REs. And I'm actually ashamed to admit that I know the RE way, but not the regular string manipulation way, if there is one! This seems like something easy enough to do without REs though. thanks ! -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. That's because all three lines DO include the substring string -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
John Salerno wrote: [EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. If re module is not needed, how can i use string manipulation to do this? thanks As far as re goes, you can search for the pattern '\bstring\b', which will find just the word 'string' itself. Not sure if there's a better way to do it with REs. And I'm actually ashamed to admit that I know the RE way, but not the regular string manipulation way, if there is one! This seems like something easy enough to do without REs though. if RE has the \b and it works, can we look into the source of re and see how its done for \b ? -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
John Salerno wrote: [EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. If re module is not needed, how can i use string manipulation to do this? thanks As far as re goes, you can search for the pattern '\bstring\b', which will find just the word 'string' itself. Not sure if there's a better way to do it with REs. And I'm actually ashamed to admit that I know the RE way, but not the regular string manipulation way, if there is one! This seems like something easy enough to do without REs though. just curious , if RE has the \b and it works, can we look into the source of re and see how its done for \b ? -- http://mail.python.org/mailman/listinfo/python-list
Re: .py and running in Windows:
The only problem I know of for changing PY files to open up in an editor is that it could screw up Python as a CGI with Apache under Windows. To change file associations, right click and go to Open With. Choose your text editor and click always open with this problem at the bottom. And easy way to run your scripts is to open a console (Start-Run-type cmd.exe and hit OK). Type python and dragdrop your .py file into the console. It will copy the path name (C:\programming\python stuff\myproject\mypython.py). Michael Yanowitz wrote: Hello: Presently in my Windows 2000 system, when I double-click on a .py file (open it) it automatically runs it in Python. I would like to change that behavour. That is fine for .pyc file, but for .py files, I would either like to have it run in Python but return to the Python shell prompt when finished rather than exit the shell. How do I do that? Or would it cause a problem (so that Python no longer works) if I change the default .py extension to open in an editor rather than execute it if I open it? Thanks: Michael Yanowitz -- http://mail.python.org/mailman/listinfo/python-list
Linux info
Hello there, I still learning, but I couldn't find anything which tells me where a symlink is pointing to. A part of os.system('ls -l ' + path) and cutting down to the need, I haven't got any specialized function. F -- http://mail.python.org/mailman/listinfo/python-list
Re: pylab doesn't find numpy on Windows
Thanks. That did it. Alexandre Fayolle wrote: Le 13-06-2006, timw.google [EMAIL PROTECTED] nous disait: Hi all. I installed matplotlib 0.87.3 under Python 2.4 on both Linux (FC3) and Windows XP Pro. On the linux install, I can import pylab, but when I try to do the same thing on the Windows installation, I get from pylab import * snip ImportError: No module named Numeric I have numpy 0.9.8 installed in both places too. it is trying to load Numeric python. You need to configure matplotlib to use numpy by saying numerix : numpy in the matplotlibrc file. -- Alexandre Fayolle LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
[EMAIL PROTECTED] wrote: just curious , if RE has the \b and it works, can we look into the source of re and see how its done for \b ? I had a look in the sre module (which re seems to import), but I couldn't find much. I'm not the best at analyzing source code, though. :) What is it you want to know about \b? It searches for the empty string before and after a word (word being an alphanumeric character that can include underscores). A little more specific info is in the docs: Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character. Note that \b is defined as the boundary between \w and \ W, so the precise set of characters deemed to be alphanumeric depends on the values of the UNICODE and LOCALE flags. Inside a character range, \b represents the backspace character, for compatibility with Python's string literals. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's wrong in this HTML Source file of a Bank
[EMAIL PROTECTED] wrote: I have posted the same question in alt.html but no one yet replied. You should ask your butcher. Now please stop posting off-topic. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux info
os.path.realpath TheSaint wrote: Hello there, I still learning, but I couldn't find anything which tells me where a symlink is pointing to. A part of os.system('ls -l ' + path) and cutting down to the need, I haven't got any specialized function. F -- http://mail.python.org/mailman/listinfo/python-list
Customized Boot Manager in Python
I have to create a small visual interface program called as Boot Manager which is customized accoring to the needs. I have around 8 pc's and 2 linux boxes. One Linux box is always on and all other are closed in sleep state. I have to perform the following things: 1. Boot up all of them. I used Wake on LAN and wrote a small python script for that. It works fine. 2. To shutdown all pc's when the work is done. For this I installed an OpenSSH server for Windows in PC. When I send a command using ssh it shuts it down. Now, I have to create a visual interface for such kind of small program. I have 2 questions (i) How can we use operating system specific commands like ssh within the python program (ii) Which grphics library (wxPython or any other) would be the fastest with least learning curve to get this thing done. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: numeric/numpy/numarray
Bryan wrote: at the end of that page, it says: Numarray is another implementation of an arrayobject for Python written after Numeric and before NumPy. Sponsors of numarray have indicated they will be moving to NumPy as soon as is feasible for them so that eventually numarray will be phased out. on the python wiki NumArray is the current reimplementation of NumPy. http://wiki.python.org/moin/NumArray so, was Numarray written *before* NumPY, or was it a reimplementation of NumPy which implies it came *after* NumPy? it seems clear that Numeric is the old one and i read is not being worked on anymore. so that leaves Numarray and numpy. which of these two should i use? Bryan, NumPy is the name of both an old package and a new package. I believe that NumArray came after the first incarnation, but that the new incarnation of NumPy is the most recent, and is probably the one you want. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: groupby is brilliant!
Frank; I would just like to thank-you for this timely post. I am working on a reporting project that needed groupby functionality and I was going to sit down this morning to rework some very ugly code into some not quite so ugly code. Your post got me pointed to in the right direction and the end results will be much more flexible and ALOT more maintainable. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
John Salerno wrote: [EMAIL PROTECTED] wrote: just curious , if RE has the \b and it works, can we look into the source of re and see how its done for \b ? I had a look in the sre module (which re seems to import), but I couldn't find much. I'm not the best at analyzing source code, though. :) What is it you want to know about \b? It searches for the empty string before and after a word (word being an alphanumeric character that can include underscores). A little more specific info is in the docs: Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character. Note that \b is defined as the boundary between \w and \ W, so the precise set of characters deemed to be alphanumeric depends on the values of the UNICODE and LOCALE flags. Inside a character range, \b represents the backspace character, for compatibility with Python's string literals. thanks..actually i had seen \b in the docs before, just that it slipped my mind when i was doing the coding. was even meddling with look aheads ..which is not the answer anyway. well, since re has the \b, was wondering why there is no implementation of it in strings. So the idea of looking at the source or re on how it's done came to my mine..i suppose we have to go down to viewing the C source then..:-) -- http://mail.python.org/mailman/listinfo/python-list
Re: numeric/numpy/numarray
Ben Sizer wrote: Bryan wrote: at the end of that page, it says: Numarray is another implementation of an arrayobject for Python written after Numeric and before NumPy. Sponsors of numarray have indicated they will be moving to NumPy as soon as is feasible for them so that eventually numarray will be phased out. on the python wiki NumArray is the current reimplementation of NumPy. http://wiki.python.org/moin/NumArray so, was Numarray written *before* NumPY, or was it a reimplementation of NumPy which implies it came *after* NumPy? it seems clear that Numeric is the old one and i read is not being worked on anymore. so that leaves Numarray and numpy. which of these two should i use? Bryan, NumPy is the name of both an old package and a new package. I believe that NumArray came after the first incarnation, but that the new incarnation of NumPy is the most recent, and is probably the one you want. thanks ben, i'll use NumPy then. just wish it was clear and obvious which one to use so i wouldn't have had to ask this question here. bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux info
os.system('ls -lL ' + path) should also work. But check, I may be wrong about the L option, and am not near a Linux system right now. That's lL - a small letter l (ell) followed by a capital letter L in the ls options above. This way may be slower than os.path.realpath if that is implemented as a system call, i.e.via Python -C-Linux kernel, which it probably is. Slower since my way given above will create a new process to run the ls command in. Just mentioning it as another way, plus, it does have the small benefit that it'll work the same way on any other language such as Perl, Ruby, etc., which supports something similar to os.system(). Vasudev Ram http://www.geocities.com/vasudevram PDF conversion tools: http://sourceforge.net/projects/xtopdf faulkner wrote: os.path.realpath TheSaint wrote: Hello there, I still learning, but I couldn't find anything which tells me where a symlink is pointing to. A part of os.system('ls -l ' + path) and cutting down to the need, I haven't got any specialized function. F -- http://mail.python.org/mailman/listinfo/python-list
Re: numeric/numpy/numarray
Bryan == Bryan [EMAIL PROTECTED] writes: Bryan hi, what is the difference among numeric, numpy and Bryan numarray? i'm going to start using matplotlib soon and i'm Bryan not sure which one i should use. numpy is the successor to numarray and Numeric. All three do basically the same thing. You should use numpy. matplotlib works with all three, you just need to be sure to set your numerix setting to numpy in your matplotlibrc file. numerix : numpy # numpy, Numeric or numarray On unix like OSes, this file is placed in ~/.matplotlib. On windows systems, it is usually found in C:\Documents and Settings\yourname\.matplotlib JDH -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 411.
Steve, thanks for the note. The name Python411 comes from me copying my good friend Rob Walch, who named his podcast Podcast411, which is a popular show on which he interviews other podcasters like Adam Curry etc. He also has a book just published about podcasting. Ron Stephens -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
[EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie the first line and not the others. If i use re module, how to compile the expression to do this? I tried the re module and using simple search() and everytime it gives me all the 3 lines that have string in it, whereas i only need line 1. If re module is not needed, how can i use string manipulation to do this? thanks If this is a RL-situation, if mystring.endswith('string') will do -- http://mail.python.org/mailman/listinfo/python-list
Re: groupby is brilliant!
Frank Millman wrote: reader = csv.reader(open('trans.csv', 'rb')) rows = [] for row in reader: rows.append(row) Why do you create a list of rows instead of just iterating over the reader directly? -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Vancouver Python Workshop - Talk submission reminder
What's New? === The deadline for submitting a talk or tutorial for the Vancouver Python Workshop is fast approaching. Talks will be accepted until Friday June 16th. To submit a talk, see: http://www.vanpyz.org/conference/talksubmission.html About the Vancouver Python Workshop === The conference will begin with keynote addresses on August 4st by Guido van Rossum [1], Jim Hugunin [2], and Ian Cavén [3]. Further talks (and tutorials for beginners) will take place on August 5th and 6th. The Vancouver Python Workshop is a community organized and designed for both the beginner and for the experienced Python programmer with: * tutorials for beginning programmers * advanced lectures for Python experts * case studies of Python in action * after-hours social events * informative keynote speakers * tracks on multimedia, Web development, education and more More information see: http://www.vanpyz.org/conference/ or contact Brian Quinlan at: [EMAIL PROTECTED] Vancouver = In addition to the opportunity to learn and socialize with fellow Pythonistas, the Vancouver Python Workshop also gives visitors the opportunity to visit one of the most extraordinary cities in the world [4]. For more information about traveling to Vancouver, see: http://www.vanpyz.org/conference/vancouver.html http://www.tourismvancouver.com http://en.wikipedia.org/wiki/Vancouver Important dates === Talk proposals accepted: May 15th to June 15th Early registration (discounted): May 22nd to June 30th Normal registration: from July 1st Keynotes: August 4th Conference and tutorial dates: August 5th and 6th [1] Guido van Rossum (Google) is the inventor of Python and has managed its growth and development for more than a decade. Guido was awarded the Free Software Foundation Award in 2002 and Dr.Dobb's 1999 Excellence in Programming Award. Guido works at Google and spends half of his time on Python. [2] Jim Hugunin (Microsoft) is the creator of numerous innovations that take Python into new application domains. Jim's most recent project, IronPython integrates Python into Microsoft's .NET runtime. Jim's previous project, Jython is Python for the Java runtime and was the second production-quality implementation of Python. Before that, Jim's Numeric Python adapted Python to the needs of number crunching applications. Jim works at Microsoft adapting the .NET runtime to the needs of dynamic languages like Python. [3] Ian Cavén is the primary developer of the Lowry Digital Images motion picture restoration system. This Python and Zope-based system has been used to restore over 150 motion pictures. Highlights include Citizen Kane, Sunset Boulevard and both the Indiana Jones and Star Wars trilogies. While Ian was Chief Scientist at Lowry Digital, his rack of computers grew from a few Macintoshes on his desktop to over six hundred Macintosh and Linux servers - at one point earning Lowry the title as the second biggest installation of parallel processing Maintoshes in the world. In 2005, Lowry Digital Images was acquired by DTS (the famous movie audio company) and renamed DTS Digital Images. The motion picture restoration system has been discussed in publications as diverse as IEEE Spectrum, USA Today, the BBC NEWS, the New York Times and Apple.com. Ian has been a Python enthusiast since 1999. [4] http://news.bbc.co.uk/2/hi/business/2299119.stm Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Making a Label that looks the same as a button.
In article [EMAIL PROTECTED], Grayson, John [EMAIL PROTECTED] wrote: Buttons can look like labels without the need to create another object - just remove the Command binding, set state to DISABLED and disabledforeground='same color as NORMAL'... This demonstrates how to play with button styles: . . . John, as I read the original poster, Tkinter.DISABLED is *exactly* what he wants (although he might not realize it yet); I suspect there's no need at all for other styling. Are Button and Label styles truly identical except for disabledforeground? While I can't make the time now to research this for myself, it surprises me; I thought there were padding differences ... Your remark about the Command has me curious: why remove it? In terms of the original poster's description, what does this serve? I repeat my speculation that Tkinter.DISABLED will do it all for him. -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
Le Mardi 13 Juin 2006 15:59, John Salerno a écrit : And I'm actually ashamed to admit that I know the RE way, but not the regular string manipulation way, if there is one! eheh, In [39]: import string In [40]: sub, s1, s2 = 'string', 're string2, ,string1', 're string2, ,string' In [41]: sub in [ e.strip(string.punctuation) for e in s1.split() ] Out[41]: False In [42]: sub in [ e.strip(string.punctuation) for e in s2.split() ] Out[42]: True This seems like something easy enough to do without REs though. Yes, but python way seems a little faster python2.4 -mtimeit -s import re re.match('\bstring\b', 're string2, ,string1') and True 10 loops, best of 3: 7.3 usec per loop python2.4 -mtimeit -s import string 'string' in [ e.strip(string.punctuation) for e in 're string2, ,string1'.split() ] 10 loops, best of 3: 6.99 usec per loop -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: a string problem
John Salerno wrote: [EMAIL PROTECTED] wrote: hi if i have a some lines like this a ) here is first string b ) here is string2 c ) here is string3 When i specify i only want to print the lines that contains string ie ... And I'm actually ashamed to admit that I know the RE way, but not the regular string manipulation way, if there is one! This seems like something easy enough to do without REs though. I'd just split it on whitespace, just like with the RE: if string in here is first string.split(): ... -- http://mail.python.org/mailman/listinfo/python-list
Re: .py and running in Windows:
i modify C:\Python\python.exe -i %1 %* to cmd /k;C:\Python\python.exe -i %1 %* or cmd /k;C:\Python\python.exe%1 %* just a little trick. On 13 Jun 2006 06:48:23 -0700, Iain King [EMAIL PROTECTED] wrote: Andrew Gwozdziewycz wrote: You'll have better results posting this to it's own thread. He certainly should have, but since I've read it here anyway: On Jun 13, 2006, at 9:29 AM, Michael Yanowitz wrote: Hello: Presently in my Windows 2000 system, when I double-click on a .py file (open it) it automatically runs it in Python. I would like to change that behavour. That is fine for .pyc file, but for .py files, I would either like to have it run in Python but return to the Python shell prompt when finished rather than exit the shell. How do I do that? Or would it cause a problem (so that Python no longer works) if I change the default .py extension to open in an editor rather than execute it if I open it? In an explorer window, go to Tools-Folder OptionsGo to the File Types tab, find the PY extension, then click onAdvanced*Select the 'open' action, and click Edit... change the 'Application used to perform action', inserting a '-i'between the exe and the first parameter.For example, I changed mineto:C:\Python\python.exe -i %1 %*The exact line will depend on where your python.exe is.OK all the dialogs you've opened, then double click a .py file to testit.*I'm using WinXP, so the exact name of some of the buttons may bedifferent for you.Iain-- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 411.
Brian van den Broek [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] meaning something like information. Introductory university course in a field are often numbered 101 (i.e. Computer Science 101). So, that number has acquired a slang meaning of basic and introductory information. Where I did my undergrad studies, a few Departments had 001 classes. Somehow that felt more honest ;-) This is OT, but... Course numbering varies by college/university, but I think typically 1xx, 2xx, 3xx, and 4xx are aimed at students in years 1, 2, 3, and 4 majoring in that subject. Pre-100 courses would be remedial or aimed or even limited to non-major students. So a Math department might have 023 Business Math that would not count toward the math units needed to get a BS in math. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing PNG with pure Python
How about this here construct? #!/usr/bin/env python # png.py - PNG encoder in pure Python # Copyright (C) 2006 Johann C. Rocholl [EMAIL PROTECTED] # # This file is licensed alternatively under one of the following: # 1. GNU Lesser General Public License (LGPL), Version 2.1 or newer # 2. GNU General Public License (GPL), Version 2 or newer # 3. Apache License, Version 2.0 or newer # 4. The following license (aka MIT License) # # - start of license - # Copyright (C) 2006 Johann C. Rocholl [EMAIL PROTECTED] # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the Software), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # --- end of license - # # You may not use this file except in compliance with at least one of # the above four licenses. -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]apache authentication questions
Michael Ströder wrote: Steve Holden wrote: [EMAIL PROTECTED] wrote: It is not impossible though and in cases where you don't have a choice but to use a HTTP authentication scheme, use of AJAX may be the answer to still allowing use of a form based login scheme. See: http://www.peej.co.uk/articles/http-auth-with-html-forms.html That's neat! IMHO this makes things more complicated and error-prone. And it requires Javascript. I also can't see why this is more secure than a proper session management (using cookies or URL for passing the session ticket around). I don't believe I said it *was* any of those things. But I am constantly amazed at the lengths the world will go to just to prove me wrong! regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
TONIGHT! Lisp group beerfest in NYC, PyCells to be discussed
The royal We has just learned that His Kennyness will be honoring the boozehounds of LispNYC with His Presence tonight (deets below). He will come bearing Celtk and news of PyCells, though the top billing tonight goes to SoC student Extraordinaire Samantha Kleinberg. kenzo Please join us for our next meeting on Tuesday, June 13th from 7:00 to 9:00 at Westside Brewery. With Summer of Code being here, this is a great opportunity to talk and drink regarding the students and their projects! Hope to see you there! Directions: Westside Brewery in the VIP room 340 Amsterdam Ave. (On the West side of Amsterdam Ave., 76th-77th) Directions by subway: 1-2-3-9 (the red line) to 72nd or 79th and Broadway. From 72nd, walk up Amsterdam (not Broadway). From 79th, walk east one long block to Amsterdam and turn right/south. Directions by car: 79th street exit from west side highway, down West End Ave or Broadway to 76th, turn left and one or two blocks to Amsterdam. -- Cells: http://common-lisp.net/project/cells/ I'll say I'm losing my grip, and it feels terrific. -- Smiling husband to scowling wife, New Yorker cartoon -- http://mail.python.org/mailman/listinfo/python-list
Re: Making a Label that looks the same as a button.
Andrew Gwozdziewycz wrote: It's imperative that you explain which toolkit you are using since they all have differences. however, if you knew the answer, you would have recognized what toolkit he was using. /F -- http://mail.python.org/mailman/listinfo/python-list