New submission from Alexander Schmolck a.schmolck+...@gmail.com:
In certain cases a zero-width /Z match that should be replaced isn't.
An example might help:
re.compile('(?m)(?Ptrailing_ws[
\t]+\r*$)|(?Pno_final_newline(?=[^\n])\Z)').subn(lambda m:next(''+k+'' for
k,v in m.groupdict().items
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 http://mlabwrap.sourceforge.net.
Mlabwrap 1.0.1 is just a maintenance release that
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 http://mlabwrap.sourceforge.net.
Mlabwrap 1.0.1 is just a maintenance release that
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] for r in
rec)))
Neat, but I will have a problem if I am dealing with three fields
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 rec)
But this is slow
Steven D'Aprano [EMAIL PROTECTED] writes:
On Thu, 04 Sep 2008 01:22:22 +0100, Alexander Schmolck wrote:
It seems to me that the right choice for thousands seperator is the
apostrophe.
You mean the character already used as a string delimiter?
Yup. No ambiguity or problem here; indeed
[EMAIL PROTECTED] writes:
A problem is that '1234' in Python is a string, so using ' in numbers
looks a bit dangerous to me (and my editor will color those numbers as
alternated strings, I think).
Yeah, editors, especially those with crummy syntax highlighting (like emacs)
might get it wrong.
Ben Finney [EMAIL PROTECTED] writes:
[EMAIL PROTECTED] writes:
For Python 2.7/3.1 I'd now like to write a PEP regarding the
underscores into the number literals, like: 0b_0101_, 268_435_456
etc.
+1 on such a capability.
-1 on underscore as the separator.
When you proposed this last
Without reading your post properly or having tried to do the same thing
myself: I think you might want to have a look at ipython; it gives a better
REPL and embedding ipython should give you plenty of hits as well.
Matthew Fitzgibbons [EMAIL PROTECTED] writes:
I've got a pretty complex
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 which was already installed. For the
sake of
future googlers using Ubuntu
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,
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
tried
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. From
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 your
Gary Herron [EMAIL PROTECTED] writes:
The test was meant to simulate the OP's problem, but even with your suggestion
of using numpy, it *still* fails!
Well, although I haven't tested it extensively, it doesn't appear to fail for
me, with numpy 1.02 and an AMD Athlon(tm) XP 2800+ under linux
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 atomic.
Alexander Schmolck [EMAIL PROTECTED] added the comment:
Ah, well nice to see this finally going somewhere, although I'm a bit
puzzled as to why my patch was clearly not implemented :)
Andy, wrt. to your points:
1. Yes, but see below.
2. Are you sure using inspect.ismethod is an improvement
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 http://mlabwrap.sourceforge.net/.
'as
--
http://mail.python.org/mailman/listinfo/python-list
[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 commercial
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 mention that I need to accumulate the
sums as ints/longs to avoid
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
complete languages
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)1)
for x in data))
That's pretty clever, but I neglected to mention that I need
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 that
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 n0:
l.append(n%26)
n /=26
return l
I am wondering what is the 'functional' way to do the same.
This is very
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
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 other.
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 brackets
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 lisp?
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:
As for why tail calls are not optimized out, it was decided that being
able
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
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 useful
than offering tail call optimization
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 that python
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 problem appears to be with a matplotlibrc file
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
--
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
modified.
Look up
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 implementations such
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 machines to
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 proposes
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 (and
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 up
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 assume
Stef Mientki [EMAIL PROTECTED] writes:
Alexander Schmolck wrote:
I'm pleased to finally announce mlabwrap-1.0:
Project website
---
http://mlabwrap.sourceforge.net/
Description
---
Mlabwrap-1.0 is a high-level python to matlab(tm) bridge that makes calling
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):
http://projects.scipy.org/mailman/listinfo/scipy-dev
cheers,
Alexander Schmolck, mlabwrap author and maintainer
--
http
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):
http://projects.scipy.org/mailman/listinfo/scipy-dev
cheers,
Alexander Schmolck, mlabwrap author and maintainer
--
http
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 have
[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)
[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
more
robust/general e.g. by using something
[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, 1), (2, 2) , (3) , (4)
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
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 and, in
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 whether the set
phrases you're interested in can
[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
--
Luis M. González [EMAIL PROTECTED] writes:
On Mar 31, 8:38 am, Bjoern Schliessmann usenet-
[EMAIL PROTECTED] wrote:
Mark Dufour wrote:
Shed Skin allows for translation of pure (unmodified), implicitly
statically typed Python programs into optimized C++, and hence,
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
--
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, something
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 http://mlabwrap.sf.net.
cheers,
URL
---
http://mlabwrap.sourceforge.net
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
URL
---
http://mlabwrap.sourceforge.net
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
[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:
load'viewmat'
viewmat+/2:|((j.~/~(%~i:)99)+@:*:)^:(i.32)0
[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 N=len(a) since
Alexander Schmolck [EMAIL PROTECTED] writes:
[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
[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) why would
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 feel sick:
|
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. harmonic mean
avg M
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 little typing is absolutely
essential
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.
3 + 4
7
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
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:])),s))
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
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 in pretty much
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 recursion?
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 lexical
Ken Tilton [EMAIL PROTECTED] writes:
Alexander Schmolck wrote:
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
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
(setf *x* 1)
(print *x*) ;;- 1
(let ((*x* 2))
(print *x*)) ;; - 2
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 your
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
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)
(print *x*) ;;- 1
(let ((*x* 2))
(print *x*)) ;; - 2
(print *x*) ;; - 1
You
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
[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
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( 'pos',
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
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')
.
.
.
if x == nan:
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 things than
[EMAIL PROTECTED] writes:
1. Which is the best graph plotting utility in python or linux.
matplotlib (provided it does the type of graphs you need, which is likely)
'as
--
http://mail.python.org/mailman/listinfo/python-list
Tomi Lindberg [EMAIL PROTECTED] writes:
# Adds another die to results.
def add_dice(sums, die):
# If first die, all values appear once
I'd add something like
sums = sums or {}
because otherwise your function will sometimes mutate sums and sometimes
return a fresh object, which
Tomi Lindberg [EMAIL PROTECTED] writes:
I'm trying to find a way to calculate a distribution of outcomes with any
combination of dice. I have the basics done, but I'm a bit unsure how to
continue. My main concern is how to make this accept any number of dice,
without having to write a new
Alexander Schmolck [EMAIL PROTECTED] writes:
addDice(resultFor1, pool[1])
addDice(pool[0], pool[1])
sorry should have spelled out that successive lines are meant to be
equivalent, i.e.
addDice(resultFor1, pool[1])
== addDice(pool[0], pool[1])
'as
--
http://mail.python.org
Mark Carter [EMAIL PROTECTED] writes:
A programmers mindset is usually geared towards writing applications. What
I'm currently doing in Lisp is building up functions as I need them. Using
emacs, I can just C-x C-e to make my functions live, and when it's time to
stop for the day, save my
[EMAIL PROTECTED] writes:
(defun (val num-bytes)
Right-shift positive integer val by num-bytes
(floor (/ val (expt 2 num-bytes
or just (floor val (expt 2 num-bytes))
'as
--
http://mail.python.org/mailman/listinfo/python-list
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 it with all
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
will give you all
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 obviously
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
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 me to restore the snipped second
half
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 essentially an
interpreted scripting language like javascript or ruby or perl,
It's
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
| designed to script an existing application, with limited support for
handling
| its
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
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 the
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
good performance (in some cases close to or better than C
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:
1 - 100 of 115 matches
Mail list logo