Re: Why and how "there is only one way to do something"?

2005-12-15 Thread bonono
Steve Holden wrote: > This would have the unfortunate side effect of only allowing changes to > Python that allowed users to do things which are currently impossible. > > Since Python is Turing-complete, this would effectively inhibit all > further changes to the language. I don't quite understand

Re: Optimize function similiar to dict.update() but adds common values

2005-12-15 Thread bonono
Christopher Subich wrote: > Peter Otten wrote: > > > > def add_freqs3(freq1, freq2): > > total = dict(freq1) > > for key, value in freq2.iteritems(): > > try: > > total[key] += value > > except KeyError: > > total[key] = value > > return total >

Re: How to get the local mac address?

2005-12-15 Thread bonono
Dejan Rodiger wrote: > I was looking on how to get MAC address universally (Windows and Linux) and > found one package that is doing that and more... > > http://libdnet.sourceforge.net/ > Thanks for the info. -- http://mail.python.org/mailman/listinfo/python-list

Re: split string saving screened spaces

2005-12-16 Thread bonono
Sergey wrote: > Which module to use to do such thing: > > "-a -b -c '1 2 3'" -> ["-a", "-b", "-c", "'1 2 3'"] > > (i have string, need to pass it to getopt) seems like CSV except that the seperator is space. You may check to see if the CSV module can take space as delimiter. -- http://mail.pytho

Re: Which Python web framework is most like Ruby on Rails?

2005-12-16 Thread bonono
Mike Meyer wrote: > It's conceivable that a change might make Python more popular and also > detract from the language in some way. For a ridiculous example, > making Python interpret Perl 6 would certainly make it more popular, > but I would argue that would seiously detract from the language. >

Re: Wingide is a beautiful application

2005-12-18 Thread bonono
I have been using vi/vim for a very long time and love it(now using ion3 + vim, not even gvim on debian), but never found it blend well with the Windows GUI. Sybren Stuvel wrote: > Claudio Grondi enlightened us with: > > The file I was editing was just 22 KByte large having 450 lines, so > > you t

Re: debian and python--any potential pitfalls?

2005-12-18 Thread bonono
Brian van den Broek wrote: > Hi all, > > I know that this is something for which I could (keep) STFW, but I'm > mostly ignorant of the subject area and under a bit of a deadline. So > I hope people won't mind if I truncate my search and ask here. > > I've tried solo and failed a few times to insta

Re: how to remove duplicated elements in a list?

2005-12-19 Thread bonono
Steve Holden wrote: > Kevin Yuan wrote: > > How to remove duplicated elements in a list? eg. > > [1,2,3,1,2,3,1,2,1,2,1,3] -> [1,2,3]? > > Thanks!! > > > > >>> list(set([1,2,3,1,2,3,1,2,1,2,1,3])) > [1, 2, 3] > Would this have the chance of changing the order ? Don't know if he wants to maintain

Re: reading files

2005-12-19 Thread bonono
Johhny wrote: > Hello All, > > I am working my way through learning python as a language. I am having > some issues with something that looks right and does not work. I am > trying to get myself more familure with reading files. Based on the > tutorials at www.python.org This "should" work. but im

Re: reading files

2005-12-19 Thread bonono
Steve Holden wrote: > Johhny wrote: > > Hello All, > > > > I am working my way through learning python as a language. I am having > > some issues with something that looks right and does not work. I am > > trying to get myself more familure with reading files. Based on the > > tutorials at www.pyt

Re: reading files

2005-12-19 Thread bonono
Johhny wrote: > Thanks for your assistance, Is it proper practice in python to flush > any memory when you exit? for example Ive read the file into memory, > when I close the file do I also have to flush any memory allocations ? No. you don't need to and shouldn't unless you have very very specifi

Re: How to check if a string "is" an int?

2005-12-21 Thread bonono
Steven D'Aprano wrote: > If you really wanted to waste CPU cycles, you could do this: > > s = "1579" > for c in s: > if not c.isdigit(): > print "Not an integer string" > break > else: > # if we get here, we didn't break > print "Integer %d" % int(s) > > > but notice th

Re: Newbie: adding string values to a list?

2005-12-21 Thread bonono
planetthoughtful wrote: > Hi All, > > Sorry for the influx of newbie questions -- I'm trying to figure these > things out on my own before bothering the community, but a lot of bits > and pieces are escaping me at the moment. > > I'm retrieving a result set from an SQLite db (using the APSW module

Re: Guido at Google

2005-12-21 Thread bonono
Anand wrote: > This is very good news. I wish Guido all the best! > > I wonder if this has got to do something with Microsoft developing > IronPython. Incidentellay it is reaching a 1.0 release pretty soon. > Perhaps Google has some cards up their sleeve. What other best way to > counter this than

Re: Guido at Google

2005-12-22 Thread bonono
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: > > > Anand wrote: > > > This is very good news. I wish Guido all the best! > > > > > > I wonder if this has got to do something with Microsoft developing > > > IronPython. Incidentellay it is reaching a 1.0 release pretty soon. > > > Perhaps Googl

Re: Guido at Google

2005-12-22 Thread bonono
Gary Herron wrote: > You don't appear to understand Open Source very well. > > Python is the way it is because we, the community, *like* it that way. > It evolves in directions that we (all) decide it is to evolve. Guido is > our leader in this because we trust him and *choose* to follow his lead.

Re: Guido at Google

2005-12-22 Thread bonono
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >... > > > > > I wonder if this has got to do something with Microsoft developing > > > > > IronPython. Incidentellay it is reaching a 1.0 release pretty soon. > > > > > Perhaps Google has some cards up their sleeve. What other best way to > >

Re: Guido at Google

2005-12-22 Thread bonono
Alex Martelli wrote: > In the general case, it's pretty general;-). In the specific case of > your "question" above quoted (interpreting the mis-spelled words and > grammatical errors to the best of my modest ability), reading it as > rhetorical means it's in fact intended as a statement (that a

Re: Guido at Google

2005-12-22 Thread bonono
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > <[EMAIL PROTECTED]> wrote: > . > . > . > >Well, this may be the CPython way of open source but I don't know if > >that is "Open source" in general. Another way is that if som

Re: Guido at Google

2005-12-22 Thread bonono
Steve Holden wrote: > Well the name "Python" is a trade mark of the Python Software > Foundation. So if you invent another language and start calling it > "Python" just to get an audience you should expect to receive a > cease-and-desist letter. > That is what I expect but don't know to what exten

Re: Guido at Google

2005-12-22 Thread bonono
Carsten Haese wrote: > So, if there is something you don't like about Python, you have two > choices: > 1) Seek consensus with the Python community and have your changes > accepted into the "official" Python version, or > 2) Fork Python into something else with a different name. If the > different

Re: sorting with expensive compares?

2005-12-23 Thread bonono
Dan Stromberg wrote: > Hi folks. > > Python appears to have a good sort method, but when sorting array elements > that are very large, and hence have very expensive compares, is there some > sort of already-available sort function that will merge like elements into > a chain, so that they won't ha

Re: sorting with expensive compares?

2005-12-23 Thread bonono
gene tani wrote: > [EMAIL PROTECTED] wrote: > > Dan Stromberg wrote: > > > Hi folks. > > > > > > Python appears to have a good sort method, but when sorting array elements > > > that are very large, and hence have very expensive compares, is there some > > > sort of already-available sort function

Re: sorting with expensive compares?

2005-12-23 Thread bonono
Dan Stromberg wrote: > On Thu, 22 Dec 2005 22:06:42 +, Dan Stromberg wrote: > > > > > Hi folks. > > > > Python appears to have a good sort method, but when sorting array elements > > that are very large, and hence have very expensive compares, is there some > > sort of already-available sort f

Re: Indentation/whitespace

2005-12-23 Thread bonono
James Tanis wrote: >Honestly I wonder how so many coders actually came to be > interested in the field -- one that pretty much thrives in part on its > neverending ability to vary, grow, and change -- if something so small > can warrant so much attention. > That is what a "cafe" type newsgroup is

Re: help with lists and writing to file in correct order

2005-12-26 Thread bonono
[EMAIL PROTECTED] wrote: > sorry for asking such beginner questions but i tried this and nothing > wrote to my text file > > for food, price, store in bs(food, price, store): > out = open("test.txt", 'a') > out.write (food + price + store) >

Re: fetching images from web?

2005-12-27 Thread bonono
may be using wget/curl but then it is no longer python ;-) [EMAIL PROTECTED] wrote: > hi, i want to automate some tasks of gathering photos from web, i tried > urllib/urllib2, both ended up without much success (saved gifs with > only a border, nothing else).. > > the code i used was: > > >>> data

Re: recursive function return value problems

2005-12-28 Thread bonono
[EMAIL PROTECTED] wrote: > hi, i have the following recursive function (simplified to demonstrate > the problem): > > >>> def reTest(bool): > ... result = [] > ... if not bool: > ... reTest(True) > ... else: > ... print "YAHHH" > ... result = ["should be the onl

Re: Memoization and encapsulation

2005-12-30 Thread bonono
Steven D'Aprano wrote: > I was playing around with simple memoization and came up with something > like this: > > _cache = {} > def func(x): > global _cache > if _cache.has_key(x): > return _cache[x] > else: > result = x+1 # or a time consuming calculation... >

Re: Python article in Free Software Magazine

2006-01-01 Thread bonono
Steven D'Aprano wrote: > On Sat, 31 Dec 2005 14:42:36 -0600, Kirk Strauser wrote: > > > I wrote this article which was published in Free Software Magazine: > > > > http://www.freesoftwaremagazine.com/free_issues/issue_09/intro_zope_1/ > > > > It's intended as a high-level overview of the language,

Re: Python article in Free Software Magazine

2006-01-01 Thread bonono
Steven D'Aprano wrote: > I'm worried > about people who pre-judging (as in prejudice) Python negatively on the > basis of buzzwords they barely understand. > For those with prejudice, it doesn't matter anyway. -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2006-01-01 Thread bonono
Steven D'Aprano wrote: > I'm reminded of a time I was going for a drive in the country when I drove > past an apple orchid. Standing in the orchid was a farmer with a pig. He > lifted the pig into the air, and the pig then bit an apple and slowly > chewed it. The farmer then carried him over to an

Re: itertools.izip brokeness

2006-01-03 Thread bonono
But that is exactly the behaviour of python iterator, I don't see what is broken. izip/zip just read from the respectives streams and give back a tuple, if it can get one from each, otherwise stop. And because python iterator can only go in one direction, those consumed do lose in the zip/izip cal

Re: itertools.izip brokeness

2006-01-03 Thread bonono
Paul Rubin wrote: > > I think you need to use map(None,...) which would not drop anything, > > just None filled. Though you don't have a relatively lazy version as > > imap(None,...) doesn't behave like map but a bit like zip. > > I don't understand what you mean by this? None is not callable. z

Re: itertools.izip brokeness

2006-01-03 Thread bonono
Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > map(None,[1,2,3],[4,5]) gives [(1,4),(2,5),(3,None)] > > I didn't know that until checking the docs just now. Oh man, what a > hack! I always thought Python should have a built-in identity > function for situations like that. I guess it does the

Re: itertools.izip brokeness

2006-01-03 Thread bonono
Paul Rubin wrote: > Any idea how Haskell would deal with this? I don't recall haskell has the map(None,...) behaviour in the standard Prelude. But then, I don't see how the iterator concept would fit into haskell as well. -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.izip brokeness

2006-01-03 Thread bonono
[EMAIL PROTECTED] wrote: > It is clear that there is a real need for iterating in parallel > over multiple iterators to the end of the longest one. Why > does something that stops at the shortest get included in > the standard library, but one that stops after the longest > doesn't? Is there any

Re: How to generate (enumerate) 2**N tuples representing all vertices of unit hypercube in N-dimensional hyperspace ?

2006-01-04 Thread bonono
Dr. Colombes wrote: > I'm looking for a good Python way to generate (enumerate) the 2**N > tuples representing all vertices of the unit hypercube in N-dimensional > hyperspace. > > For example, for N=4 the Python code should generate the following 2**N > = 16 tuples: > > (1,1,1,1), (1,1,1,-1), >

Re: Is 'everything' a refrence or isn't it?

2006-01-06 Thread bonono
Steven D'Aprano wrote: > I'll tell you what I say: Python passes objects to functions or > assignments. > Which in C sense, is a reference(or pointer) to some opaque "table" maintain by the system, identified by id(). -- http://mail.python.org/mailman/listinfo/python-list

Re: Is 'everything' a refrence or isn't it?

2006-01-06 Thread bonono
Steven D'Aprano wrote: > On Fri, 06 Jan 2006 02:19:29 -0800, bonono wrote: > > > > > Steven D'Aprano wrote: > >> I'll tell you what I say: Python passes objects to functions or > >> assignments. > >> > > Which in C sense, is

Re: Is 'everything' a refrence or isn't it?

2006-01-06 Thread bonono
Steven D'Aprano wrote: > But in programming, things do work that way. If my class Book contains a > reference to Smith's classic work, I can modify it. (Unless the language > deliberately restricts my ability to modify certain objects, as Python > does with immutable objects.) > > That's what prog

Re: Translate this to python?

2006-01-07 Thread bonono
Xavier Morel wrote: > While xrange does have it's place in Python, it has very few actual uses > (yours being one of the few), and is usually more harmful than beneficial. > > While the deprecation of xrange is not that "soon", it is part of the > Python 3000 PEP (http://www.python.org/peps/pep-30

Re: is there any lib can split string in this way?

2006-01-09 Thread bonono
This has been asked not long ago. the shlex module as well as csv module both should be able to handle it. for this simple case shlex.split() seems to be the easiest. Leo Jay wrote: > I want to split a string like this: > 'abc def "this is a test" ok' > into: > ['abc', 'def', 'this is a test',

Re: Change Gateway Programmatically

2006-01-10 Thread bonono
Godwin Burby wrote: > Dear Pythoneer, > I need to toggle the gateway ip of my windows xp machine quite > often due to some software requirements. I just want to know whether i > could do it programmatically using Python. > If so how? I am sure there must be some elegant python way but you

Re: Change Gateway Programmatically

2006-01-10 Thread bonono
Godwin Burby wrote: > Well netsh turned out to be the perfect solution for my problem(even > though doing it in python would have given me some kicks). I managed it > with two .bat files for toggling the gateway ips. Thank you friend. there is os.system/os.open* if you want to put python in the e

Re: String question - find all possible versions of a person's firstname

2006-01-11 Thread bonono
Nico Grubert wrote: > > This sounds like a homework problem. You might try splitting the name > > at the e's, check the length of the resulting list and do that many > > nested loops. > > This was my idea too but I am wondering if there are any scripts for > tasks like this. > > Nico def combine

Re: flatten a level one list

2006-01-11 Thread bonono
Robin Becker wrote: > Is there some smart/fast way to flatten a level one list using the > latest iterator/generator idioms. > > The problem arises in coneverting lists of (x,y) coordinates into a > single list of coordinates eg > > f([(x0,y0),(x1,y1),]) --> [x0,y0,x1,y1,] or > > g([x0,x1,

Re: flatten a level one list

2006-01-12 Thread bonono
Robin Becker wrote: > Paul Rubin wrote: > > Paul Rubin writes: > > > >import operator > >a=[(1,2),(3,4),(5,6)] > >reduce(operator.add,a) > >> > >>(1, 2, 3, 4, 5, 6) > > > > > > (Note that the above is probably terrible if the lists are large and > > you're aft

Re: flatten a level one list

2006-01-12 Thread bonono
David Murmann wrote: > Robin Becker schrieb: > > # New attempts: > > from itertools import imap > > def flatten4(x, y): > > '''D Murman''' > > l = [] > > list(imap(l.extend, izip(x, y))) > > return l > > > > > > from Tkinter import _flatten > > def flatten5(x, y): > > '''D Murm

Re: flatten a level one list

2006-01-13 Thread bonono
Peter Otten wrote: > [EMAIL PROTECTED] wrote: > > > David Murmann wrote: > > >> > # New attempts: > >> > from itertools import imap > >> > def flatten4(x, y): > >> > '''D Murman''' > >> > l = [] > >> > list(imap(l.extend, izip(x, y))) > >> > return l > > >> well, i would really lik

Re: flatten a level one list

2006-01-13 Thread bonono
Peter Otten wrote: > [EMAIL PROTECTED] wrote: > > > David Murmann wrote: > > >> > # New attempts: > >> > from itertools import imap > >> > def flatten4(x, y): > >> > '''D Murman''' > >> > l = [] > >> > list(imap(l.extend, izip(x, y))) > >> > return l > > >> well, i would really lik

Re: How to remove subset from a file efficiently?

2006-01-13 Thread bonono
fynali wrote: > $ cat cleanup_ray.py > #!/usr/bin/python > import itertools > > b = set(file('/home/sajid/python/wip/stc/2/CBR333')) > > file('PSP-CBR.dat,ray','w').writelines(itertools.ifilterfalse(b.__contains__,file('/home/sajid/python/wip/stc/2/PSP333'))) > > -- > $

Re: How to remove subset from a file efficiently?

2006-01-14 Thread bonono
fynali wrote: > [bonono] > > Have you tried the explicit loop variant with psyco ? > > Sure I wouldn't mind trying; can you suggest some code snippets along > the lines of which I should try...? > > [fynali] > > Needless to say, I'm utterly new to

Re: How to remove subset from a file efficiently?

2006-01-14 Thread bonono
fynali wrote: > $ cat cleanup_use_psyco_and_list_compr.py > #!/usr/bin/python > > import psyco > psyco.full() > > postpaid_file = open('/home/sajid/python/wip/stc/2/PSP333') > outfile = open('/home/sajid/python/wip/stc/2/PSP-CBR.dat.psyco', > 'w') > > barred = {} > >

Re: How to remove subset from a file efficiently?

2006-01-14 Thread bonono
fynali wrote: > Sorry, pls read that ~15 secs. That is more or less about it. As set() is faster than dict(), about 2x on my machine and I assume a portion of your time is in set/dict creation as it is pretty large data set. -- http://mail.python.org/mailman/listinfo/python-list

Re: Listing partitions (on win32)

2006-01-15 Thread bonono
Tim Golden wrote: > Claude Henchoz wrote: > > > Is there any way of listing partitions on a (win32) computer without > > using WMI? > > Not that this answers your question, but why _don't_ you > want to use WMI? > > TJG >>> import wmi Traceback (most recent call last): File "", line 1, in -top

Re: Listing partitions (on win32)

2006-01-15 Thread bonono
Tim Golden wrote: > [EMAIL PROTECTED] wrote: > > Tim Golden wrote: > > > Claude Henchoz wrote: > > > > > > > Is there any way of listing partitions on a (win32) computer without > > > > using WMI? > > > > > > Not that this answers your question, but why _don't_ you > > > want to use WMI? > > > > >

Re: PEP 309 (Partial Function Application) Idea

2006-01-15 Thread bonono
Giovanni Bajo wrote: > Ronald Mai wrote: > > > Here is a reference implementation: > > > > _ = lambda x: x.pop(0) > > > > def partial(func, *args, **keywords): > > def newfunc(*fargs, **fkeywords): > > newkeywords = keywords.copy() > > newkeywords.update(fkeywords)

Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread bonono
Fuzzyman wrote: > Claudio Grondi wrote: > > Steve Holden wrote: > [snip..] > > The problem here is, that I mean, that in Python it makes no sense to > > talk about a value of an object, because it leads to weird things when > > trying to give a definition what a value of an object is. > > > > You'

Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread bonono
Fuzzyman wrote: > The above gentleman is asserting that in *Python* the term value has no > meaning. I don't know what he meant and don't want to get into that value/reference/object thingy discussion as it would be a never ending thing. I just want to say that '==' in C is very clear to me, wheth

Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread bonono
Fuzzyman wrote: > Ok... so I'm now assuming that the information about '==' provided by > the above gentleman *and* that I understand it correctly. > > The only confusion in C (which doesn't have classes) is that two list > (like) objects can't be tested by value - only identity. > In C, they are

Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread bonono
Claudio Grondi wrote: > As also the fact, that when > a = [1,2.0,3L] > b = [1.0,2,3 ] > a==b # gives True > even if the objects in the lists are actually different, > or when the objects being members of the list redefine __eq__ so, that > no matter how different they are, the lists always compare

Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread bonono
Fuzzyman wrote: > I'm not familiar with the C basic datatypes - I assume it has an array > or list like object. > > Would it contain a sequence of poitners to the members ? In which case > they would only be equal if the pointers are the same. > > In this case : > > a = ['some string'] > b = ['som

Re: list comprehention

2006-01-19 Thread bonono
Tim Chase wrote: > > Python beginner here and very much enjoying it. I'm looking > > for a pythonic way to find how many listmembers are also > > present in a reference list. Don't count duplicates (eg. if > > you already found a matching member in the ref list, you can't > > use the ref membe

new.instancemethod as a form of partial()

2006-01-21 Thread bonono
I came across this while searching for a way to DIY partial(), until it is available in 2.5 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/229472 However, when trying for the following, it doesn't work and is wondering if it is a bug or intended : >>> import operator >>> import new >>>

Re: new.instancemethod as a form of partial()

2006-01-21 Thread bonono
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >... > > So it seems that instancemethod() don't like "None" as the instance. > > "bound methods" and "unbound methods" are instance of the same type, > distinguished by one thing: the im_self of an unbound method is None, > the im_self of a bo

Re: new.instancemethod as a form of partial()

2006-01-22 Thread bonono
Alex Martelli wrote: > Guido has mused about abolishing "unbound methods" (in 3.0, I guess), so > there's hope for the future. But a more complete 'partial' is likely to > be acceptable sooner than any fix to bound/unbound methods: I suspect > the only ingredient that's missing is a generous help

Re: indentation messing up my tuple?

2006-01-27 Thread bonono
Steven D'Aprano wrote: > On Fri, 27 Jan 2006 16:45:54 -0800, localpricemaps wrote: > > > here is my code: > > > > for row in bs('div', {'style' : 'both'}): > > What is bs? Is it a secret? seems to be beautiful soup, in this context. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about idioms for clearing a list

2006-02-07 Thread bonono
Fredrik Lundh wrote: > > Python now has, what, three built-in mutable collections types: > > lists, dictionaries, and sets. Dicts and sets both have a clear() > > method and lists do not. > > dicts and sets are mappings, and lists are not. mappings don't > support slicing. lists do. I am confus

Re: Question about idioms for clearing a list

2006-02-07 Thread bonono
Fredrik Lundh wrote: > > Python now has, what, three built-in mutable collections types: > > lists, dictionaries, and sets. Dicts and sets both have a clear() > > method and lists do not. > > dicts and sets are mappings, and lists are not. mappings don't > support slicing. lists do. I am confus

Re: Question about idioms for clearing a list

2006-02-07 Thread bonono
Tim Hochberg wrote: > [EMAIL PROTECTED] wrote: > > Fredrik Lundh wrote: > > > >>>Python now has, what, three built-in mutable collections types: > >>>lists, dictionaries, and sets. Dicts and sets both have a clear() > >>>method and lists do not. > >> > >>dicts and sets are mappings, and lists are

Re: removing characters before writing to file

2006-02-09 Thread bonono
[EMAIL PROTECTED] wrote: > hi > i have some output that returns a lines of tuples eg > > ('sometext1', 1421248118, 1, 'P ') > ('sometext2', 1421248338, 2, 'S ') > and so on > > > I tried this > re.sub(r" '() ",'',str(output)) but it only get rid of the ' and not > the braces. I need to write

Re: Question about idioms for clearing a list

2006-02-10 Thread bonono
Raymond Hettinger wrote: > [Alex] > > So what is the rationale for having list SO much harder to use in such a > > way, than either set or collections.deque? > > Sounds like a loaded question ;-) > > If you're asking why list's don't have a clear() method, the answer is > that they already had two

Re: Question about idioms for clearing a list

2006-02-10 Thread bonono
Magnus Lycka wrote: > >>> class BryansList(list): > ... add=list.append > ... def clear(self): > ... del self[:] > ... > >>> b = BryansList([1,2,3,4,5]) > >>> b > [1, 2, 3, 4, 5] > >>> b.add(6) > >>> b.clear() > >>> b > [] > > Happy now? You can keep it, I don't need it. :) >

Re: ordered sets operations on lists..

2006-02-10 Thread bonono
Amit Khemka wrote: > Hello, Is there a *direct* way of doing set operations on lists which > preserve the order of the input lists ? > For Ex. l1 = [1, 5, 3, 2, 4, 7] > l2 = [3, 5, 10] > > and (l1 intersect l2) returns [5, 3] (and (l2 intersect l1) > returns [3, 5]) > what

Re: ordered sets operations on lists..

2006-02-10 Thread bonono
Raymond Hettinger wrote: > The intersection step is unnecessary, so the answer can be simplified a > bit: > > >>> filter(set(l2).__contains__, l1) > [5, 3] > >>> filter(set(l1).__contains__, l2) > [3, 5] stand corrected. -- http://mail.python.org/mailman/listinfo/python-list

Re: functional 0.5 released

2006-02-10 Thread bonono
Collin Winter wrote: > As always, feedback welcome! Any specific reason flip only flip the first 2 arguments rather than the whole tuple ? That is, I would like to see: assert(f(a,b,c, d) == flip(f)(d, c, b, a)) -- http://mail.python.org/mailman/listinfo/python-list

Re: functional 0.5 released

2006-02-11 Thread bonono
Collin Winter wrote: > On 10 Feb 2006 19:57:48 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > Collin Winter wrote: > > > As always, feedback welcome! > > > > Any specific reason flip only flip the first 2 arguments rather than > > the whole tuple ? > > > > That is, I would like to see

Re: Is python very slow compared to C

2006-02-12 Thread bonono
[EMAIL PROTECTED] wrote: > Steven D'Aprano>Very slow to do what, compared to what? The decay time > of the tau meson?< > > Probably every answer I can give you is wrong for you, so answering is > almost useless... In this thread we have already given the most > pertinent answers to the original qu

Re: Is python very slow compared to C

2006-02-12 Thread bonono
Felipe Almeida Lessa wrote: > Em Dom, 2006-02-12 às 03:20 -0800, [EMAIL PROTECTED] escreveu: > > However, to me, the strength of python is the batteries that is > > included(and there are more and more coming). > > So .NET is as good as Python? Hmmm... I think the language itself is the > best par

Re: Is python very slow compared to C

2006-02-12 Thread bonono
Steven D'Aprano wrote: > But, in general, more often than not, Python is fast enough. The extra > value of using something like Lua or Ocaml or even C is just not enough to > make up for the disadvantages of using those languages. > What is the disavantage of Lua comparing with Python ? Or Ocaml c

Re: Is python very slow compared to C

2006-02-12 Thread bonono
Steven D'Aprano wrote: > Lua appears to be *too* lightweight, without even classes or inheritance, > and a single data type where Python has dicts, sets, tuples and lists. > I believe Lua does have features to implement class/inheritance. As for the distinction of dict/set/tuple/list or one singl

Re: Is python very slow compared to C

2006-02-12 Thread bonono
Steven D'Aprano wrote: > > Programming in Lua > > Object-Oriented Programming > > http://www.lua.org/pil/16.html > > Did you actually bother to read the page you linked to? It describes how > you can emulate object-like behaviour for Lua tables. The following page > is even more explicit: "Lua doe

Re: Newbie

2006-02-12 Thread bonono
LittlePython wrote: > I am very new to python. I have been studying it for only a month or so. I > have been using vbscript for about 2-3 yrs and only recently been using it > rather heavily the past 9 months or so. I am new very new to oop. My main > use will be administrative scripting into the

Re: Is python very slow compared to C

2006-02-12 Thread bonono
Steven D'Aprano wrote: > [EMAIL PROTECTED] wrote: > > > I can speak the same about Python if I view it from a prototype based > > perspective, where one get them for free in Lua but need to implement > > them in Python. > > Sure. And if you need prototypes, then all else being > equal that would b

Re: Is python very slow compared to C

2006-02-12 Thread bonono
PA wrote: > On Feb 13, 2006, at 06:44, [EMAIL PROTECTED] wrote: > > > And if we use market penetration as measure, Perl seems to be easier > > for people ? > > Perl: Shell scripts/awk/sed are not enough like programming languages. > > Python: Perl is a kludge. > > "What Languages Fix" > http://www

Re: Loop Backwards

2006-02-13 Thread bonono
[EMAIL PROTECTED] wrote: > Dave wrote: > > This should be simple, but I can't get it: > > > > How do you loop backwards through a list? > > > > For example, in, say, Javascript: > > > > for (var i = list.length - 1; i >=0; i--) { > > do_stuff() > > } > > > > I mean, I could reverse the list,

Re: Newbie

2006-02-14 Thread bonono
This is top posting, i.e. my post is above yours. For this particular response, it seems to be a bit more appropriate to do bottom posting, see below. However, don't take that as a rule or convention that you need to do one or another exclusively, it depends and I believe mature and sincere posters

Re: How to cat None

2006-02-14 Thread bonono
Seems that what you want to do is to create a string in the form of : "55Init=Init\n55First=first\n55Last=Last\n55Alias=None" for each dictionary. If that is the case, may be you can try this : "\n".join("%s=%s" % x for x in user1.iteritems()) Note that you cannot control the ordering of the ke

Re: how to write a C-style for loop?

2006-02-14 Thread bonono
John Salerno wrote: > for (int i = 0; i < 50; i += 5) > > How would that go in Python, in the simplest and most efficient way? for i in xrange(0,50,5): print i -- http://mail.python.org/mailman/listinfo/python-list

Re: getting the line just before or after a pattern searched

2006-02-17 Thread bonono
[EMAIL PROTECTED] wrote: > hi > > i have a file something like this > > abcdefgh > ijklmnopq > 12345678 > rstuvwxyz > . > . > . > 12345678 > . > > whenever i search the file and reach 12345678, how do i get the line > just above and below ( or more than 1 line above/below) the patt

Re: Print a PDF transparently

2006-02-17 Thread bonono
Daniel Crespo wrote: > Yes, I've seen it, but that's it: another program that I have to > install, which I want to avoid. > > I'd be happy if I just do "printer.Print(file.pdf/.ps)" and walá, the > printing just starts (in 98,2000,XP... sounds like a dream), without > having another window opened.

Re: number ranges (was Re: Matlab page on scipy wiki)

2006-02-19 Thread bonono
Tim Hochberg wrote: > Colin J. Williams wrote: > > >> > >>It would be good if the range and slice could be merged in some way, > >>although the extended slice is rather complicated - I don't understand it. > >> > >> The semantics for an extended slicing are as follows. The primary > >> must ev

Re: Quesion about the proper use of __slots__

2006-02-20 Thread bonono
Zefria wrote: > >>> class Fighter: > ... '''Small one man craft that can only harm other fighters on > their own.''' > ... def __init__(self,statsTuple=(50,5,0,(2,4),1)): > ... self.fuel = statsTuple[0] > ... self.life = statsTuple[1] > ... self.armor =

Re: Quesion about the proper use of __slots__

2006-02-20 Thread bonono
Peter Otten wrote: > Zefria wrote: > > > Also, I don't generally do any optimization at all yet (as a highschool > > student projects get trashed often enough no to bother over), but in > > this special case I'm expecting each "carrier" to have up to 150 > > fighters, and 3 to 5 carriers for each

Re: Quesion about the proper use of __slots__

2006-02-20 Thread bonono
Zefria wrote: > Well, my computer tends to run at about 497 to 501 out of 504 MB of RAM > used once I start up Gnome, XMMS, and a few Firefox tabs, and I'd > prefer not to see things slipping into Swap space if I can avoid it, > and the fighter data would be only part of a larger program. > > And

Re: Quesion about the proper use of __slots__

2006-02-20 Thread bonono
Peter Otten wrote: > > He could be working on a machine with < 1M RAM or some other > > constraints. > > I have 256K, by the way. > Impressive, curious to know what kind of environment it is as it has been a long time I have seen such limited spec. My first x86(IBM PC) had more than that. -- htt

Re: how to break a for loop?

2006-02-20 Thread bonono
Gregory Petrosyan wrote: >I need to remove zeros from > the begining of list, but I can't :-(. I believe the following is almost a direct translation of the above sentence. import itertools as it a=[0,0,0,1,0] a[:]=it.dropwhile(lambda x: x is 0, a) -- http://mail.python.org/mailman/listinfo/py

Re: In need of a virtual filesystem / archive

2006-02-20 Thread bonono
may be store them in sqlite ? On linux, fuse can also be an interesting option, gmailfs is written in python. Enigma Curry wrote: > I need to store a large number of files in an archive. From Python, I > need to be able to create an archive, put files into it, modify files > that are already in i

Re: Augmented assignment

2006-02-20 Thread bonono
Terry Reedy wrote: > Program performance might be noticeable if 'x' is something like a.b.c.d > that takes some lookup time. But again, I would use the += form for > readability without testing run time. Would x=x + 1 be more readable, regardless of the background(whether being introduced to the

<    1   2   3   >