Re: Python, Matlab and AI question

2005-02-18 Thread Alexander Schmolck
Robert Kern <[EMAIL PROTECTED]> writes: > dataangel wrote: >> I'm a student who's considering doing a project for a Machine Learning class >> on pathing (bots learning to run through a maze). The language primarily >> used by the class has been Matlab. I would prefer to do the bulk of the >> proje

Re: Python, Matlab and AI question

2005-02-18 Thread Alexander Schmolck
Robert Kern <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > >> Actually, I've written a highlevel matlab-python bridge (based on bugfixed >> and >> slightly extended version of the original pymat) which is quite up-to-date; >> by >> and

[ANN] mlabwrap v0.9b3

2005-02-19 Thread Alexander Schmolck
I have recently uploaded mlabwrap v0.9b3, a high-level python to matlab(tm) bridge, you can get it from It should work with recent python >=2.3 and matlab(tm) >=6.0; I've used it extensively myself but this is the first announcement to a wider public -- so I'd v

Re: [ANN] mlabwrap v0.9b3

2005-02-19 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > I'd very much like to hear some feedback (even if it's just "works fine"). Sorry to anyone who got a bounce -- obviously just on the day I write this my email account gets "temporarily deactivated" -- till I

[ANN] mlabwrap v0.9 released

2005-02-28 Thread Alexander Schmolck
This release just adds OS X support to setup.py (thanks to Josh Marshall). I've also made some recent improvements to the website, based on user feedback. In the absence of any bug reports so far I'd tentatively consider mlabwrap as stable. Dowload from: What

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Alexander Schmolck
"Raymond Hettinger" <[EMAIL PROTECTED]> writes: > The rationale is to replace the awkward and slow existing idioms for > dictionary > based accumulation: > > d[key] = d.get(key, 0) + qty > d.setdefault(key, []).extend(values) > > In simplest form, those two statements would now be coded m

Re: Pre-PEP: Dictionary accumulator methods

2005-03-20 Thread Alexander Schmolck
Beni Cherniavsky <[EMAIL PROTECTED]> writes: >> The relatively recent "improvement" of the dict constructor signature >> (``dict(foo=bar,...)``) obviously makes it impossible to just extend the >> constructor to ``dict(default=...)`` (or anything else for that matter) which >> would seem much less

Re: Array of Chars to String

2005-04-19 Thread Alexander Schmolck
James Stroud <[EMAIL PROTECTED]> writes: > But this seems ugly. I especially don't like "newstr += lttr" because it > makes > a new string every time. I am thinking that something like this has to be a > function somewhere already or that I can make it more efficient using a > built-in tool.

Re: How to "generalize" a function?

2005-04-24 Thread Alexander Schmolck
Thomas Köllmann <[EMAIL PROTECTED]> writes: > confFile.close You want ``confFile.close()`` -- the above won't do anything [1]. 'as Footnotes: [1] Best practice would be something like this (don't worry to much about it -- it just ensures the file is properly closed, even if somethin

Re: Very newbie programming

2006-06-10 Thread Alexander Schmolck
TheSaint <[EMAIL PROTECTED]> writes: > # Filling the c with the list of devices which are recorded to be mounted > > d = filter((lambda a: a[:2] =='/d'),mnt.readlines()) # non /dev-mounts are > off > d = map((lambda a: a.split()[:1]),d) # only the first info column is used Just focusing one one

py-ext: casting pointers to ints on 32bit and 64bit systems

2006-01-27 Thread Alexander Schmolck
what's the best approach to write C(++)-extension code that has to create a python int from a C pointer and vice versa so that it works smoothly on 32 bit and 64 platforms (on which sizeof(int) != sizeof(*void)) equally work (under unix,mac&windows and with gcc, vc and borland)? Currently the rele

Re: Python vs. Lisp -- please explain

2006-02-19 Thread Alexander Schmolck
"Terry Reedy" <[EMAIL PROTECTED]> writes: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > In learning Python I've read more about Lisp than when I was actually > > trying to learn it, and it seems that the two languages have lots of > > similarities: > > > > http://www.norvig.

Re: Python vs. Lisp -- please explain

2006-02-19 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: > Hi, I've been thinking about Python vs. Lisp. I've been learning > Python the past few months and like it very much. A few years ago I > had an AI class where we had to use Lisp, and I absolutely hated it, > having learned C++ a few years prior. They didn't teach Lis

Re: Python vs. Lisp -- please explain

2006-02-19 Thread Alexander Schmolck
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > DH a écrit : > (snip) > > It is by design. Python is dynamically typed. It is essentially an > > interpreted scripting language like javascript or ruby or perl, > > > It's not a "scripting" language, and it's not interpreted. Of course it is. Wh

Re: Python vs. Lisp -- please explain

2006-02-19 Thread Alexander Schmolck
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > > What's far more interesting to me, however, is that I think there a good > > reasons to suspect python's slowness is more of a feature than a flaw: I'd > > n

Re: Python vs. Lisp -- please explain

2006-02-19 Thread Alexander Schmolck
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > > You might want to argue about whether scriping language is a meaningful and > > useful concept, but it's really hard to see how you could talk about > > "scripting &g

Re: Python vs. Lisp -- please explain

2006-02-20 Thread Alexander Schmolck
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > > My point was that Guido probably (and fortunately!) was unaware of the > > extent > > to which you can have both dynamism and speed For the convenience of other readers, allow

Re: Python vs. Lisp -- please explain

2006-02-20 Thread Alexander Schmolck
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > Alexander Schmolck a écrit : > > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > > > > >>DH a écrit : > >>(snip) > >> > >>>It is by design. Python is dynamically typed. It is

Re: Python vs. Lisp -- please explain

2006-02-20 Thread Alexander Schmolck
"Donn Cave" <[EMAIL PROTECTED]> writes: > Quoth Alexander Schmolck <[EMAIL PROTECTED]>: > | "Fredrik Lundh" <[EMAIL PROTECTED]> writes: > ... > |> the only even remotely formal definition I've ever seen is "language with > |>

Re: Python vs. Lisp -- please explain

2006-02-20 Thread Alexander Schmolck
Torsten Bronger <[EMAIL PROTECTED]> writes: > I was rather stunned, too, when I read his line of thought. > Nevertheless, I think it's not pointless, albeit formulated in an > awkward way. Of course, Python has not been deliberately slowed > down. Indeed -- and I'm really not sure what defect in

Re: Python vs. Lisp -- please explain

2006-02-20 Thread Alexander Schmolck
"Kay Schluehr" <[EMAIL PROTECTED]> writes: > Alexanders hypothesis is completely absurd. You're currently not in the best position to make this claim, since you evidently misunderstood what I wrote (I certainly did not mean to suggest that Guido *deliberately* chose to make python slow; quite th

Re: Python vs. Lisp -- please explain

2006-02-20 Thread Alexander Schmolck
"Michele Simionato" <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > As common lisp and scheme demonstrate you can have high level of dynamism > > (and > > in a number of things both are more dynamic than python) and still get very > >

Re: Python vs. Lisp -- please explain

2006-02-22 Thread Alexander Schmolck
"Michele Simionato" <[EMAIL PROTECTED]> writes: > I replied to this message yesterday, but it did not appear, so let's > try again. > > I agree with your points, but I would not say that Lisp is > intrinsically more dynamic than Python as a language; Neither would I -- I don't think either is ob

Re: Python vs. Lisp -- please explain

2006-02-22 Thread Alexander Schmolck
Rocco Moretti <[EMAIL PROTECTED]> writes: > I think it's worth pointing out that not all dynamicism is equal, when it > comes to difficulty in compiling to machine code. No kidding (do you have any idea how this thread started out?). > Lisp, like the good functional language that it is, has (pri

Re: Searching for uniqness in a list of data

2006-03-01 Thread Alexander Schmolck
"rh0dium" <[EMAIL PROTECTED]> writes: > Hi all, > > I am having a bit of difficulty in figuring out an efficient way to > split up my data and identify the unique pieces of it. > > list=['1p2m_3.3-1.8v_sal_ms','1p2m_3.3-1.8_sal_log'] > > Now I want to split each item up on the "_" and compare i

Re: Searching for uniqness in a list of data

2006-03-01 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > The easiest way to do this is to have a nested dictionary of prefixes: for > each prefix as key add a nested dictionary of the rest of the split as value > or an empty dict if the split is empty. Accessing the dict with an userinput

Re: Python Polymorphism

2005-05-13 Thread Alexander Schmolck
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Carlos Moreira wrote: > >> Supose that I want to create two methos (inside a >> class) with exactly same name, but number of >> parameters different: > > that's known as multimethods, or multiple dispatch. No -- multiple dispatch is something entirel

Re: regexp for sequence of quoted strings

2005-05-25 Thread Alexander Schmolck
gry@ll.mit.edu writes: > I have a string like: > {'the','dog\'s','bite'} > or maybe: > {'the'} > or sometimes: > {} > > [FYI: this is postgresql database "array" field output format] > > which I'm trying to parse with the re module. > A single quoted string would, I think, be: > r"\{'([^']|\\'

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-09 Thread Alexander Schmolck
Josiah Carlson <[EMAIL PROTECTED]> writes: > James Stroud wrote: >> Terry Reedy wrote: >>> In Python, you have a choice of recursion (normal or tail) >> >> Please explain this. I remember reading on this newsgroup that an advantage >> of ruby (wrt python) is that ruby has tail recursion, implying

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-10 Thread Alexander Schmolck
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Sat, 09 Jun 2007 22:42:17 +0100, Alexander Schmolck wrote: > >>> As for why tail calls are not optimized out, it was decided that being able >>> to have the stack traces (with variable information, etc.) was more

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-12 Thread Alexander Schmolck
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Mon, 11 Jun 2007 01:28:09 +0100, Alexander Schmolck wrote: > >> Steven D'Aprano <[EMAIL PROTECTED]> writes: >> >>> On Sat, 09 Jun 2007 22:42:17 +0100, Alexander Schmolck wrote: >>> >>

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-12 Thread Alexander Schmolck
"Anders J. Munch" <[EMAIL PROTECTED]> writes: > Like Steven said, tail-call optimisation is not necessary as you can always > hand-optimise it yourself. Care to demonstrate on some code written in CPS (a compiler or parser, say)? 'as -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-25 Thread Alexander Schmolck
Douglas Alan <[EMAIL PROTECTED]> writes: >> Python has built-in abstractions for a few container types like >> lists and dicts, and now a new and more general one (iterators), so >> it's the next level up. > > Common Lisp has had all these things for ages. Rubbish. Do you actually know any common

Re: bool behavior in Python 3000?

2007-07-10 Thread Alexander Schmolck
Steven D'Aprano <[EMAIL PROTECTED]> writes: > I mean, really, does anyone *expect* True+True to give 2, or that 2**True > even works, without having learnt that Python bools are ints? I doubt it. Sure, why not? It's pretty damn useful. Ever heard of things like "indicator functions", "Iverson bra

Re: Tuple vs List: Whats the difference?

2007-07-11 Thread Alexander Schmolck
Shafik <[EMAIL PROTECTED]> writes: > Hello folks, > > I am an experienced programmer, but very new to python (2 days). I > wanted to ask: what exactly is the difference between a tuple and a > list? I'm sure there are some, but I can't seem to find a situation > where I can use one but not the oth

Re: bool behavior in Python 3000?

2007-07-12 Thread Alexander Schmolck
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Expressions like (i == j) used to return 0 and 1, and it was to avoid > breaking hacks like the above that bools were implemented as a subclass of > int, not because being able to write the above was a specific feature > requested. In the hypothetical

Re: [ANN] mlabwrap-1.0final

2007-04-22 Thread Alexander Schmolck
Stef Mientki <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > I'm pleased to finally announce mlabwrap-1.0: > > Project website > > > --- > > <http://mlabwrap.sourceforge.net/> > > Description > > > --

Re: List objects are un-hashable

2007-04-27 Thread Alexander Schmolck
Andy <[EMAIL PROTECTED]> writes: > Hi, I'm trying to search and print any no# of Python keywords present > in a text file (say - foo.txt), and getting the above error. Sad for > not being able to decipher such a simple problem (I can come up with Without looking at the docs, it seems save to assu

Re: Emacs and pdb after upgrading to Ubuntu Feisty

2007-05-06 Thread Alexander Schmolck
levander <[EMAIL PROTECTED]> writes: > Anybody can tell me who to get pdb working under emacs on Ubuntu > Feisty? This is not a direct answer to your question, but I'd recommend you try ipython (apt-get'able) and ipython.el; (manual install). Just enter ``pdb on`` in the interactive shell to end

Re: Emacs and pdb after upgrading to Ubuntu Feisty

2007-05-08 Thread Alexander Schmolck
levander <[EMAIL PROTECTED]> writes: > Okay, thanks Alexander and Bernstein. I'll lookinto Emacs 23, but I'm > worried about compatibility with modes. Does all the stuff that works > in Emacs 21 work in 23? I've switched from 21 to 23 a few weeks ago and don't recall any particular issues (an

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Alexander Schmolck
Jarek Zgoda <[EMAIL PROTECTED]> writes: > Martin v. Löwis napisał(a): > >> So, please provide feedback, e.g. perhaps by answering these >> questions: >> - should non-ASCII identifiers be supported? why? > > No, because "programs must be written for people to read, and only > incidentally for machi

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Alexander Schmolck
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > PEP 1 specifies that PEP authors need to collect feedback from the > community. As the author of PEP 3131, I'd like to encourage comments > to the PEP included below, either here (comp.lang.python), or to > [EMAIL PROTECTED] > > In summary, this PEP

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Alexander Schmolck
Neil Hodgson <[EMAIL PROTECTED]> writes: > Paul Rubin wrote: >>> Plenty of programming languages already support unicode identifiers, >> >> Could you name a few? Thanks. > >C#, Java, Ecmascript, Visual Basic. (i.e. everything that isn't a legacy or niche language) scheme (major implementat

Re: Lists vs tuples (newbie)

2007-05-21 Thread Alexander Schmolck
Szabolcs <[EMAIL PROTECTED]> writes: > Thanks for all the replies! > > Phoe6 wrote: >> 1) Return values from a function. When you return multiple values >> from a function. You store them as a tuple and access them >> individually rather then in the list, which bear the danger of being >> modifie

Re: matplotlib, usetex

2007-05-25 Thread Alexander Schmolck
Bill Jackson <[EMAIL PROTECTED]> writes: > > The problem does not exist when text.usetex is False. Ideas? I have no idea whether this will resolve your problem, but you could try updating to 0.90 (BTW what happens if you do axis([0,128,0,128])). cheers, 'as -- http://mail.python.org/mailman/l

Re: matplotlib, usetex

2007-05-27 Thread Alexander Schmolck
Bill Jackson <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote the following on 05/25/2007 02:33 PM: >> I have no idea whether this will resolve your problem, but you could try >> updating to 0.90 (BTW what happens if you do axis([0,128,0,128])). > > The p

Re: What is the "functional" way of doing this?

2007-08-01 Thread Alexander Schmolck
beginner <[EMAIL PROTECTED]> writes: > Hi, > > If I have a number n and want to generate a list based on like the > following: > > def f(n): > l=[] > while n>0: > l.append(n%26) > n /=26 > return l > > I am wondering what is the 'functional' way to do the same. Thi

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-12 Thread Alexander Schmolck
Erik Max Francis <[EMAIL PROTECTED]> writes: > For a file hashing system (finding similar files, rather than identical ones), > I need to be able to efficiently and quickly sum the ordinals of the bytes of > a file and their squares. Because of the nature of the application, it's a > requirement

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-13 Thread Alexander Schmolck
Erik Max Francis <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > >> Is this any faster? >> >> ordSum, orsSumSq = (lambda c:c.real,c.imag)(sum(complex(ord(x),ord(x)<<1) >> for x in data)) > > That's pretty clever, but I neglected to

Re: decorators - more than just syntactic sugar

2007-08-13 Thread Alexander Schmolck
Michele Simionato <[EMAIL PROTECTED]> writes: > On Aug 11, 8:30 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote: >> Hi, >> >> are decorators more than just syntactic sugar in python 2.x and what >> about python 3k ? > > Well, I argued may times that syntactic sugar is important (all Turing > complet

Re: Fatest standard way to sum bytes (and their squares)?

2007-08-13 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > Erik Max Francis <[EMAIL PROTECTED]> writes: > >> Alexander Schmolck wrote: >> >>> Is this any faster? >>> >>> ordSum, orsSumSq = (lambda c:c.real,c.imag)(sum(complex(ord(x),ord(x)&

Re: best GUI library for vector drawing program

2007-08-17 Thread Alexander Schmolck
[x-posts removed] chewie54 <[EMAIL PROTECTED]> writes: > I should have also mentioned that is for a commercial application. That > doesn't rule Qt or PyQt out, but this is a startup company with very little > income so my first choice would be to use some GUI library that is free to > use for comme

Re: Calling a matlab script from python

2007-09-05 Thread Alexander Schmolck
n o s p a m p l e a s e <[EMAIL PROTECTED]> writes: > Suppose I have a matlab script mymatlab.m. How can I call this script > from a python script? You could use . 'as -- http://mail.python.org/mailman/listinfo/python-list

Re: Try to get help on pymat

2007-03-06 Thread Alexander Schmolck
"CHRIS CHEW" <[EMAIL PROTECTED]> writes: > I am trying to get my pymat to work. The Python script did not interface to > matlab yet. What are the required script to get the interface to work? Please > send me email at [EMAIL PROTECTED] You might want to have a look at . c

Re: Python equivalents to MATLAB str2func, func2str, ischar, isfunc?

2007-03-14 Thread Alexander Schmolck
"dmitrey" <[EMAIL PROTECTED]> writes: > I can't find these via web serch > > thank you in advance, > Dmitrey str2func: getattr(some_module, 'f') func2str: f.__name__ ischar: isinstance(x, basestring) and len(x) == 1 isfunc: callable(x) # is most likely to be what you want 'as -- http://mail.p

Re: Python equivalents to MATLAB str2func, func2str, ischar, isfunc?

2007-03-14 Thread Alexander Schmolck
"dmitrey" <[EMAIL PROTECTED]> writes: > Thank you > (however in MATLAB ischar is the same as isstr) Right, sorry. > but what if I don't know the name of module? > I.e. I have > > def myfunc(param): ... > #where param can be both funcName or a function, and I want to obtain > both name and func,

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-03-31 Thread Alexander Schmolck
"Luis M. González" <[EMAIL PROTECTED]> writes: > On Mar 31, 8:38 am, Bjoern Schliessmann [EMAIL PROTECTED]> wrote: > > Mark Dufour wrote: > > > Shed Skin allows for translation of pure (unmodified), implicitly > > > statically typed Python programs into optimized C++, and hence, > > > >

Re: zip list with different length

2007-04-04 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: C> hi > suppose i have 2 lists, a, b then have different number of elements, > say len(a) = 5, len(b) = 3 > >>> a = range(5) > >>> b = range(3) > >>> zip(b,a) > [(0, 0), (1, 1), (2, 2)] > >>> zip(a,b) > [(0, 0), (1, 1), (2, 2)] > > I want the results to be > [(0, 0), (1,

Re: zip list with different length

2007-04-04 Thread Alexander Schmolck
MC <[EMAIL PROTECTED]> writes: > Hi! > > Brutal, not exact answer, but: > > a = range(5) > b = range(3) > print zip(a+[None]*(len(b)-len(a)),b+[None]*(len(a)-len(b))) You reinvented map(None,a,b). 'as -- http://mail.python.org/mailman/listinfo/python-list

Re: String manipulation

2007-04-04 Thread Alexander Schmolck
All the code is untested, but should give you the idea. [EMAIL PROTECTED] writes: > Hi all! > > I have a file in which there are some expressions such as "kindest > regard" and "yours sincerely". I must create a phyton script that > checks if a text contains one or more of these expressions an

Re: String manipulation

2007-04-04 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > That doesn't work. What about "kindest\nregard"? I think you're best of > reading the whole file in (don't forget to close the files, BTW). I should have written "that may not always work, depending of wh

Re: String manipulation

2007-04-04 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: > Thank you very much, your code works perfectly! One thing I forgot: you might want to make the whitespace handling a bit more robust/general e.g. by using something along the lines of set_phrase.replace(' ', r'\w+') 'as -- http://mail.python.org/mailman/listinfo/p

Re: String manipulation

2007-04-05 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: > On 4 Apr, 21:47, Alexander Schmolck <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] writes: > > > Thank you very much, your code works perfectly! > > > > One thing I forgot: you might want to make the whitespace handling a bit

Re: block scope?

2007-04-08 Thread Alexander Schmolck
Neal Becker <[EMAIL PROTECTED]> writes: > One thing I sometimes miss, which is common in some other languages (c++), > is idea of block scope. It would be useful to have variables that did not > outlive their block, primarily to avoid name clashes. This also leads to > more readable code. I h

Re: itertools, functools, file enhancement ideas

2007-04-08 Thread Alexander Schmolck
[EMAIL PROTECTED] (Alex Martelli) writes: > > 4. functools enhancements (Haskell-inspired): > >Let f be a function with 2 inputs. Then: > > a) def flip(f): return lambda x,y: f(y,x) > > b) def lsect(x,f): return partial(f,x) > > c) def rsect(f,x): return partial(flip(f), x)

[ANN] mlabwrap-1.0final

2007-04-11 Thread Alexander Schmolck
eedback and keep informed about new releases is mlabwrap-user: <https://lists.sourceforge.net/lists/listinfo/mlabwrap-user> the list is low-volume and subscription is recommended. Discussion of mlabwrap development takes place on the scipy-dev (please mention mlabwrap in the subject line):

Re: in place-ness of list.append

2007-02-05 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: > > "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes: > > >> Such an operation will be O(N**2), > > Bart> why is that? > > The a[:] operation makes a copy of a (as will the x = a + [n] idiom). I'm pretty confident append itself (and a+[n]) are linear in

Re: in place-ness of list.append

2007-02-05 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] writes: > > > >>>>> "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes: > > > > >> Such an operation will be O(N**2), > > > > Bart>

Re: Calling J from Python

2007-02-05 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: > Gosi> J is in many ways similar to Python. > > Gosi> J has very many advanced operations. > > Gosi> http://www.jsoftware.com/ > > Doesn't look like open source of any variety. If a person uses Python with > various add-ons (RPy, numpy, matplotlib, etc) w

Re: Calling J from Python

2007-02-05 Thread Alexander Schmolck
Robin Becker <[EMAIL PROTECTED]> writes: > Dennis Lee Bieber wrote: > > On Mon, 05 Feb 2007 17:52:27 +0100, Bjoern Schliessmann > > <[EMAIL PROTECTED]> declaimed the following > > in comp.lang.python: > > > > >> Mh, just looking at some "advanced" J source taken from > >> wikipedia.org makes me f

Re: Calling J from Python

2007-02-05 Thread Alexander Schmolck
Larry Bates <[EMAIL PROTECTED]> writes: > And why is that superior to this: > > def avg(l): > return float(sum(l))/len(l) > > >>>avg([1,2,3,4]) > 2.5 Apart from being less to type and it is superior in that it's generalizes much better, e.g: avg&.^. NB. geomtric mean avg&.%NB. harmon

Re: Calling J from Python

2007-02-05 Thread Alexander Schmolck
Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > > Apart from being less to type > > Cool. Less to type. Yes. Readability is more important in many context, but for something designed for interactive experimentation and exploration lit

Re: Calling J from Python

2007-02-05 Thread Alexander Schmolck
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > No, thanks. But hopefully we have Python : > > Python 2.4.1 (#1, Jul 23 2005, 00:37:37) > [GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. >

Re: Calling J from Python

2007-02-09 Thread Alexander Schmolck
[restoring context] "Ant" <[EMAIL PROTECTED]> writes: > > On Feb 6, 12:21 am, greg <[EMAIL PROTECTED]> wrote: > > > > Alexander Schmolck wrote: > > > For example I once wrote this (slow) code to display > > > part of a mandelbrot fractal: &

[ANN] mlabrap-1.0b: a high level python to matlab bridge

2007-02-27 Thread Alexander Schmolck
URL --- Description --- Mlabwrap-1.0 is a high-level python to matlab(tm) bridge that makes calling matlab functions from python almost as convenient as using a normal python library. It is available under a very liberal license (BSD/MIT) and should work

Re: Calling Python from Matlab

2006-04-23 Thread Alexander Schmolck
"Daniel Nogradi" <[EMAIL PROTECTED]> writes: > > I am desperately looking for a way to call Python from Matlab. I have become > > used to Python's rich syntax and large number of libraries, and feel > > ridiculously clumsy being stuck with Matlab's rather restricted facilities > > for doing other

Re: NaN handling

2006-05-06 Thread Alexander Schmolck
Robert Kern <[EMAIL PROTECTED]> writes: > Ivan Vinogradov wrote: > > > It doesn't seem to be here under OSX either (universal Python install). > > It's not enabled by default. In the source distribution, it is > Modules/fpectlmodule.c . > > > Since numpy seems to be working on a variety of plat

Re: NaN handling

2006-05-06 Thread Alexander Schmolck
Felipe Almeida Lessa <[EMAIL PROTECTED]> writes: > Em Sex, 2006-05-05 às 16:37 -0400, Ivan Vinogradov escreveu: > > This works to catch NaN on OSX and Linux: > > > > # assuming x is a number > > if x+1==x or x!=x: > > #x is NaN > > This works everywhere: > > nan = float('nan') > > . > . >

Re: A critic of Guido's blog on Python's lambda

2006-05-07 Thread Alexander Schmolck
[trimmed groups] Ken Tilton <[EMAIL PROTECTED]> writes: > yes, but do not feel bad, everyone gets confused by the /analogy/ to > spreadsheets into thinking Cells /is/ a spreadsheet. In fact, for a brief > period I swore off the analogy because it was so invariably misunderstood. > Even Graham mis

Re: A critic of Guido's blog on Python's lambda

2006-05-07 Thread Alexander Schmolck
Bill Atkins <[EMAIL PROTECTED]> writes: > Here's how one of the cells examples might look in corrupted Python > (this is definitely not executable): > > class FallingRock: > def __init__(self, pos): > define_slot( 'velocity', lambda: self.accel * self.elapsed ) > define_slot( 'p

Re: Matplotlib in Python vs. Matlab, which one has much better graphical pressentation?

2006-05-11 Thread Alexander Schmolck
N/A <[EMAIL PROTECTED]> writes: > Hi all, > > Can I have your opinions on Matlab vs. Matplotlib in Python in terms of 2D and > 3D graphical presentation please. > > > Matplotlib in Python vs. Matlab, which one has much better graphical > pressentation? As far as 2D plots are concerned I think

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
jayessay <[EMAIL PROTECTED]> writes: > "Michele Simionato" <[EMAIL PROTECTED]> writes: > > > I was interested in a proof of concept, to show that Python can > > emulate Lisp special variables with no big effort. > > OK, but the sort of "proof of concept" given here is something you can > hack up

Re: New tail recursion decorator

2006-05-12 Thread Alexander Schmolck
Duncan Booth <[EMAIL PROTECTED]> writes: > Tim N. van der Leeuw wrote: > > > The other thing I do not understand, due to my limited understanding of > > what is tail-recursion: factorial2 (Duncan's definition) is not proper > > tail-recursion. Why not? How does it differ from 'real' tail recursio

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
Ken Tilton <[EMAIL PROTECTED]> writes: > In Common Lisp we would have: > > (defvar *x*) ;; makes it special > (setf *x* 1) > (print *x*) ;;-> 1 > (let ((*x* 2)) >(print *x*)) ;; -> 2 > (print *x*) ;; -> 1 You seem to think that conflating special variable binding and

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
Ken Tilton <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > jayessay <[EMAIL PROTECTED]> writes: > > > > >>"Michele Simionato" <[EMAIL PROTECTED]> writes: > >> > >> > >>>I was interested in a proo

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
Duane Rettig <[EMAIL PROTECTED]> writes: > Alexander Schmolck <[EMAIL PROTECTED]> writes: > > > Ken Tilton <[EMAIL PROTECTED]> writes: > > > >> In Common Lisp we would have: > >> > >> (defvar *x*) ;; makes it special > >

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
Duane Rettig <[EMAIL PROTECTED]> writes: > My reason for responding to you in the first place was due to your poor use > of the often misused term "bug". You could have used many other words or > phrases to describe the situation, and I would have left any of those alone. I'm happy to accept you

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
jayessay <[EMAIL PROTECTED]> writes: > > Great -- so can I see some code? Can't be that difficult, it takes about > > 10-15 > > lines in python (and less in scheme). > > Do you actually need the code to understand this relatively simple concept??? Yes. I'd be genuinely curious to see how an imp

Re: A critic of Guido's blog on Python's lambda

2006-05-12 Thread Alexander Schmolck
Ken Tilton <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > Ken Tilton <[EMAIL PROTECTED]> writes: > > > > >>In Common Lisp we would have: > >> > >>(defvar *x*) ;; makes it special > >>(setf *x* 1) >

Re: round numbers in an array without importing Numeric or Math?

2006-05-16 Thread Alexander Schmolck
Lance Hoffmeyer <[EMAIL PROTECTED]> writes: > Is there an easy way to round numbers in an array? > > I have > Test = [1.1,2.2,3.7] > > and want to round so the values are > > print Test [1,2,4] [int(x+0.5) for x in Test] 'as -- http://mail.python.org/mailman/listinfo/python-list

Re: string.count issue (i'm stupid?)

2006-05-22 Thread Alexander Schmolck
"Dirk Hagemann" <[EMAIL PROTECTED]> writes: > I think I can tell you WHY this happens, but I don't know a work-around > at the moment. len(re.findall('_(?=a_)', '_a_a_a_a_')) # untested def countWithOverlaps(s, pat): return len(re.findall("%s(?=%s)" % (re.escape(pat[0]), re.escape(pat[1:]))

Re: Inefficient summing

2008-10-09 Thread Alexander Schmolck
beginner <[EMAIL PROTECTED]> writes: > Hi All, > > I have a list of records like below: > > rec=[{"F1":1, "F2":2}, {"F1":3, "F2":4} ] > > Now I want to write code to find out the ratio of the sums of the two > fields. > > One thing I can do is: > > sum(r["F1"] for r in rec)/sum(r["F2"] for r in re

Re: Inefficient summing

2008-10-10 Thread Alexander Schmolck
beginner <[EMAIL PROTECTED]> writes: > On Oct 9, 3:53 pm, Alexander Schmolck <[EMAIL PROTECTED]> wrote: >> beginner <[EMAIL PROTECTED]> writes: >> how about: >> >> ratio = (lambda c: c.real/c.imag)(sum(complex(r["F1"], r["F2"]

[ANN] mlabwrap-1.0.1 released

2009-03-24 Thread Alexander Schmolck
Mlabwrap allows pythonistas to interface to Matlab(tm) in a very straightforward fashion: >>> from mlabwrap import mlab >>> mlab.eig([[0,1],[1,1]]) array([[-0.61803399], [ 1.61803399]]) More at . Mlabwrap 1.0.1 is just a maintenance release

Re: Separators inside a var name

2008-06-09 Thread Alexander Schmolck
Rainy <[EMAIL PROTECTED]> writes: > I have a stylistic question. In most languages words in var. name are > separated by underscores or cap letters, resulting in var names like > var_name, VarName and varName. I don't like that very much because all > 3 ways of naming look bad and/or hard to type.

Re: how to indent/dedent a region in emacs?

2008-06-11 Thread Alexander Schmolck
Grant Edwards <[EMAIL PROTECTED]> writes: > I've recently switched from Jed to Emacs for editing python > source, and I'm still stumped as to how one indents or dedents > a region of code. In Jed it's 'C-c <' or 'C-c >'. Google has > found several answers, but none of them work, for example I've

Re: python-mode is missing the class browser

2008-08-07 Thread Alexander Schmolck
Michele Simionato <[EMAIL PROTECTED]> writes: > I have noticed that the python-mode for Emacs that comes with the > latest Ubuntu is missing the class browser. Moreover if works > differently from the python-mode I was used to (for instance CTRL-c-c > works as CTRL-c-! whereas CTRL-c-! is missing,

Re: python-mode is missing the class browser

2008-08-08 Thread Alexander Schmolck
"Adam Jenkins" <[EMAIL PROTECTED]> writes: > On Fri, Aug 8, 2008 at 7:32 AM, Michele Simionato > <[EMAIL PROTECTED]> wrote: >> On Aug 7, 5:55 pm, Alexander Schmolck <[EMAIL PROTECTED]> wrote: > ... >> >> I have solved by using ipython.el wh

Re: is +=1 thread safe

2008-05-03 Thread Alexander Schmolck
AlFire <[EMAIL PROTECTED]> writes: >> The threading module already has a function to return the number of Thread >> objects currently alive. > > I have threads within threads - so it does not suit me :-(. How about using a scalar numpy array? They are mutable, so I assume that x += 1 should be at

Re: is +=1 thread safe

2008-05-04 Thread Alexander Schmolck
Gary Herron <[EMAIL PROTECTED]> writes: > But... It's not! > > A simple test shows that. I've attached a tiny test program that shows this > extremely clearly. Please run it and watch it fail. In [7]: run ~/tmp/t.py final count: 200 should be: 200 (I took the liberty to correct yo

  1   2   >