Re: Is Python a Zen language?

2006-02-26 Thread bonono
André wrote: > Some "purist", like the Academie Francaise (or, apparently "Crutcher") > seem to believe that "one" can restrict the meaning of words, or the > evolution of language. The rest of us are happy to let language > evolution take place to facilitate communication. So instead of Zen of

Re: Optimize flag question

2006-02-25 Thread bonono
Steve Holden wrote: > > Some other functions rely on the AssertionError exception to indicate to > > the user that something went wrong instead of using a user defined > > exception. > > > > The real problem here is that you appear to be using AssertionError in > an inappropriate way. If some call

Re: Is Python a Zen language?

2006-02-25 Thread bonono
don't know but there is "Zen of Python". -- http://mail.python.org/mailman/listinfo/python-list

Re: A C-like if statement

2006-02-24 Thread bonono
Steven D'Aprano wrote: > On Thu, 23 Feb 2006 16:49:09 -0800, bonono wrote: > > > > > Steven D'Aprano wrote: > >> On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote: > >> > >> >> try: > >> >>i = a.find("3"

Re: "Temporary" Variable

2006-02-24 Thread bonono
Steven D'Aprano wrote: > Just out of curiosity, when do you think is the right time to begin > teaching programmers good practice from bad? Before or after they've > learnt bad habits? When you have authority over the coding guideline. Naming things is not something limited to programming and most

Re: A C-like if statement

2006-02-23 Thread bonono
Steven D'Aprano wrote: > On Thu, 23 Feb 2006 12:04:38 -0700, Bob Greschke wrote: > > >> try: > >>i = a.find("3") > >>print "It's here: ", i > >> except NotFound: > >>print "No 3's here" > > > > Nuts. I guess you're right. It wouldn't be proper. Things are added or > > proposed every

Re: Basic coin flipper program - logical error help

2006-02-21 Thread bonono
John Zenger wrote: > Also, with the functional programming tools of map, filter, and lambda, > this code can be reduced to just six lines: > > import random > > flips = map(lambda x: random.randrange(2), xrange(100)) > heads = len(filter(lambda x: x is 0, flips)) > tails = len(filter(lambda x: x i

Re: how to break a for loop?

2006-02-21 Thread bonono
[EMAIL PROTECTED] wrote: > This time it seems that using itertools gives slower results, this is > the test code: Understandable, as dropwhile still needs to go through the whole list and the difference will be larger when the list get longer. Though I still prefer that if the list is not horribly

Re: Little tool - but very big size... :-(

2006-02-21 Thread bonono
I doubt you can do much then as you mentioned you need GUI which is why there is the GUI related dll in the list(takes a large chunk of it), then the necessary python runtime. However, even for USB pen, I don't think 11M is that much a big deal. We have digicam that can produce file size like that

Re: Little tool - but very big size... :-(

2006-02-21 Thread bonono
11MB is seldom a concern for today's machine. Durumdara wrote: > Hi ! > > I have a problem. > I have a little tool that can get data about filesystems and wrote it in > python. > > The main user asked me a GUI for this software. > > This user is needed a portable program, so I create this kind of

Re: In need of a virtual filesystem / archive

2006-02-21 Thread bonono
Steven D'Aprano wrote: > I suspect you can pick any two of the following three: > > 1. single file > 2. space used for deleted files is reclaimed > 3. fast performance > > Using a proper database will give you 2 and 3, but at > the cost of a lot of overhead, and typically a > relational database i

Re: how to break a for loop?

2006-02-21 Thread bonono
Giovanni Bajo wrote: > [EMAIL PROTECTED] 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:

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

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: 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: 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: 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: > 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: > >>> 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: > > 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: 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: > 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
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
[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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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

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: 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

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: 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: > 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
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: > 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: 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: 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: 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: 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: 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: > [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-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: 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: 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-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-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: 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: 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: 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: 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: 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 '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: 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: > 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: 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: 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: 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
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: > > 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
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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: > 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: 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: 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
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
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
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
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: > > > 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-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: 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

  1   2   3   >