been well tested in practice already and is
feature-complete for its fairly minimal goals as of now. The site has a link
to a mailing list (Google Groups) for further discussion, if this interests you!
Thanks,
Steve Howell
--
http://mail.python.org/mailman/listinfo/python-announce-list
,
Steve Howell
On Dec 11, 5:10 am, Steve Howell showel...@yahoo.com wrote:
SHPAML is a HAML-like language for Python. If you are not familiar with
HAML, it is a markup language implemented in Ruby that allows you to create
web pages with an indentation-based syntax. SHPAML is not an exact
--- [EMAIL PROTECTED] wrote:
TCP/IP sounds good but isn't it a bit too heavy?
It depends on your judgment, of course. On a
simplistic level, using TCP/IP shouldn't be any more
work than what you'd do if you were reading and
writing files, especially if everything you're doing
is on the same
Python is my favorite programming language. I've used
it as my primary language for about six years now,
including four years of using it full-time in my day
job. Three months ago I decided to take a position
with a team that does a lot of things very well, but
they don't use Python. We use
--- Jan Claeys [EMAIL PROTECTED] wrote:
Op Mon, 03 Dec 2007 14:20:52 +1300, schreef greg:
If you want a really appropriate name for a
programming language, I'd
suggest Babbage. (not for Python, though!)
Konrad Zuse wrote the first high-level programming
language, so I think
his
--- Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
Colin J. Williams a écrit :
I'm not sure that I like add 3, 5, 7
but it would be nice to be able to drop the
parentheses
when no argument is required.
Thus: close;
could replace close();
This just could not work given
--- [EMAIL PROTECTED] wrote:
What don't I know that I should know to just
edit/run, preferably at
the tap of a function key?
Most good editors let you do these things:
1) Save a file.
2) Run a script from the shell.
3) Turn steps 1 and 2 into a macro.
4) Allow you to map the
--- Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] a écrit :
I'm a java guy used to the effective edit/run
cycle you get with a
good IDE.
Today I'm writing my first Python, but can't seem
to find the way to
use Python's inherent edit/run cycle.
Use an IDE
--- Samuel [EMAIL PROTECTED] wrote:
Hi,
Following the masses I was drawn to RoR's website
today and I saw the
following HTML template in one of the screencasts:
I know a lot of Rails goodies have been ported to
Python, so you might want to google some variations on
form_remote_tag
--- Bruno Desthuilliers
Another aspect of Ruby is that the final
expression
evaluated in a method actually gets returned as
the
result of a method,
Unless there's an explict return before...
which has further implications on
whether close is simply evaluated or called.
I'm
--- Richard Jones [EMAIL PROTECTED]
wrote:
class A(object):
def set_a(self, value):
self._a = value
a = property(lambda self: self._a, set_a)
Note that this differs from a regular attribute
because a is not deletable
from instances (the property defines no deleter).
--- Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sat, 08 Dec 2007 16:58:25 -0800, Karthik Gurusamy
wrote:
Why are the following accepted even without a
warning about syntax
error?
(I would expect the python grammar should catch
these kind of syntax
errors)
2 * + n
--- Jeremy C B Nicoll [EMAIL PROTECTED] wrote:
Steve Howell [EMAIL PROTECTED] wrote:
There are a zillion powerful editors out there.
I've
been productive in EditPlus, MultiEdit, SlickEdit,
vim, and emacs, just to throw out a few examples.
What command (in XP) does one need to issue
--- Rick Muller [EMAIL PROTECTED] wrote:
If I want to do this, it seems like I need to keep a
connection
between the gui element and the original value in
the elementtree, so
I can update it. But I'm having a hard time
visualizing exactly how
this works. Can someone help me out here a
--- Jeremy C B Nicoll [EMAIL PROTECTED] wrote:
Steve Howell [EMAIL PROTECTED] wrote:
--- Jeremy C B Nicoll [EMAIL PROTECTED]
wrote:
What command (in XP) does one need to issue to
syntax check a saved python
script without running it?
Perhaps oversimplifying a bit
--- [EMAIL PROTECTED] wrote:
In a C++ application having a Python interpreter
embedded, is it
possible to compile a small Python snippet into
object code and
serialize the compiled object code to, for example,
a database? I am
exploring the possibility of writing a data driven
--- caroliina [EMAIL PROTECTED] wrote:
i made a list of lists but i cant write it into a
file. how do i get the
first string in a sublist?
--
Try doing this:
print list_of_lists
print list_of_lists[0]
print list_of_lists[0][0]
print list_of_lists[0][0][0]
It might give you some
After starting this discussion thread, I found the
link below:
http://www.b-list.org/weblog/2006/jun/18/lets-talk-about-python-and-ruby/
If you're like me--struggling to learn Ruby while
having Python as your primary point of reference--you
might find some of the points informative. I suspect
--- MonkeeSage [EMAIL PROTECTED] wrote:
Not just callable, but interchangeable. My point was
that in ruby, if
you use a block or a lambda as a HOF, you have to
use #call / #[] /
yield keyword on it to call it.
def foo(a)
puts a
end
bar = lambda { | a | puts a }
# these do the
--- CoolGenie [EMAIL PROTECTED] wrote:
self.feed = self.config['feedsrc']
self.numfeeds = self.config['numfeeds']
self.numlines = self.config['numlines']
self.w = 520
self.h = 12*self.numfeeds*(self.numlines+1)
--- CoolGenie [EMAIL PROTECTED] wrote:
OK, sorry, this was about indents. Stupid VIM!
No prob. Add something like this (untested) to your
~/.vimrc:
set expandtab
set sw=4
set ts=4
Looking for
--- CoolGenie [EMAIL PROTECTED] wrote:
OK, sorry, this was about indents. Stupid VIM!
One more piece of VIM advice. You can use set list
to show where tabs are. I prefer to convert my own
tabs to spaces automatically, but you inevitably come
across code that you don't own where it's nice to
--- Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
Steve Howell a écrit :
(snip)
Jordan and others, thanks for all your posts; I am
learning a lot about both languages.
This is what I've gathered so far.
Python philosophy:
passing around references to methods should
--- MonkeeSage [EMAIL PROTECTED] wrote:
On Dec 9, 6:23 pm, MonkeeSage [EMAIL PROTECTED]
wrote:
Hi Bruno,
I think that we've been having a mainly semantic
(pun intended)
dispute. I think you're right, that we've been
using the same words
with different meanings.
I think Ruby and
--- Jan Claeys [EMAIL PROTECTED] wrote:
To conclude this discussion:
* in Python, methods are attributes
* in Ruby, attributes are methods
So clearly one of the languages has it all wrong. ;)
I've always thought that the best way to introduce new
programmers to Python is to show them small code
examples.
When you go to the tutorial, though, you have to wade
through quite a bit of English before seeing any
Python examples.
Below is my attempt at generating ten fairly simple,
--- Steven Bethard [EMAIL PROTECTED] wrote:
Very cool! Do you mind putting this up on the Wiki
somewhere so that we
can link to it more easily? Maybe something like:
http://wiki.python.org/moin/SimplePrograms
Done.
nitpick
Though the code should probably follow PEP 8
--- Paul McGuire [EMAIL PROTECTED] wrote:
I ***love*** this 10 Little Programs idea! As
soon as I get a
breathing space, I'm going to add a 10 Little
Parsers page to the
pyparsing wiki!
Thanks. :)
I'm thinking you could actually have a progression
from a 1 line program up to a 50-line
--- Paul McGuire [EMAIL PROTECTED] wrote:
On May 26, 8:48 pm, Steve Howell
[EMAIL PROTECTED] wrote:
I'm thinking you could actually have a progression
from a 1 line program up to a 50-line program.
The
number 50 is kind of arbitrary, but my gut says
that
by a 50-line program, you
--- Steven D'Aprano
[EMAIL PROTECTED] wrote:
On Sat, 26 May 2007 18:48:45 -0700, Steve Howell
wrote:
It also has a ComplexNumber class, but I don't
want to
scare away mathphobes.
Is it as short as this one-liner?
ComplexNumber = complex
The It above refers to *the* Python
--- Steven D'Aprano wrote:
On Sat, 26 May 2007 18:48:45 -0700, Steve Howell
wrote:
It also has a ComplexNumber class, but I don't
want to
scare away mathphobes.
Is it as short as this one-liner?
ComplexNumber = complex
Along the idea of not reinventing a class from
--- Ben Finney [EMAIL PROTECTED]
wrote:
Paul McGuire [EMAIL PROTECTED] writes:
At this point, I realized that I was taking things
too far
off-topic, so I decided to start a new thread.
So, uh, what's the purpose of this thread? Did you
have a specific
point to start off with, or a
--- Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
Maybe it's easier to use a key function instead of a
compare function. A
key function receives an element and must return
something that is then
sorted and the element ends up where the computed
key is in the sorted
list. Little
--- mark [EMAIL PROTECTED] wrote:
Hi all
I posted earlier on this but have changed my
approach so here is my
latest attempt at solving a problem. I have been
working on this for
around 12 hours straight and am still struggling
with it.
Write a program that reads the values for a
--- Eric [EMAIL PROTECTED] wrote:
I have some working code, but I realized it is just
the way I would
write it in C, which means there is probably a
better (more pythonic)
way of doing it.
Here's the section of code:
accumulate = firstIsCaps = False
accumStart = i = 0
--- Gabriel Genellina [EMAIL PROTECTED] wrote:
Underscores are not always easily available on non
us-layout keyboards,
like \ and @ and many other special characters. A
language that requires
more symbols than the 26 english letters has to make
room somewhere -
keyboards usually
--- BartlebyScrivener [EMAIL PROTECTED] wrote:
On May 26, 1:43 pm, Steve Howell
[EMAIL PROTECTED] wrote:
--
# def defines a method in Python
def tax(itemCharge, taxRate = 0.05):
return itemCharge * taxRate
print '%.2f' % tax(11.35)
print '%.2f' % tax
--- BartlebyScrivener [EMAIL PROTECTED] wrote:
For the person new to programming (doesn't come from
C or other
languages), I think you need to add a separate
explanation of string
formatting and how it works, or at least add a
comment that tells them
you are using string formatting so
--- romiro [EMAIL PROTECTED] wrote:
Anyway, my first question was if anyone knows of a
tutorial that
focuses on PHP - Python learning, in such that
there might be a block
of PHP code alongside an example of how to do the
same thing in
Python.
I know exactly what you mean, and I
--- romiro [EMAIL PROTECTED] wrote:
I've recently tried
C#, a very short
lived re-attempt at C++ and Java, and Ruby.
To the extend that you're familiar with C++/Java/Ruby,
you may find this link as an interesting way to see
how Python looks:
http://www.dmh2000.com/cjpr/cmpframe.html
--- erikcw [EMAIL PROTECTED] wrote:
('SELECT payment_id FROM amember_payments WHERE
member_id=%s AND
expire_date NOW() AND completed=1 AND
(product_id 11 AND product_id
21)', (1608L,))
()
Here is a copy of the table schema and the first 2
rows.
Does your table actually
--- Wildemar Wildenburger [EMAIL PROTECTED]
wrote:
Steve Howell wrote:
# def defines a method in Python
def say_hello(name):
print 'hello', name
say_hello('Jack')
say_hello('Jill')
Doesn't def define methods *xor* functions,
depending on the context
--- 7stud [EMAIL PROTECTED] wrote:
Bejeezus. The description of groupby in the docs is
a poster child
for why the docs need user comments. Can someone
explain to me in
what sense the name 'uniquekeys' is used this
example: [...]
The groupby method has its uses, but it's behavior is
--- 7stud [EMAIL PROTECTED] wrote:
Bejeezus. The description of groupby in the docs is
a poster child
for why the docs need user comments.
I would suggest an example with a little more
concreteness than what's currently there.
For example, this code...
import itertools
syslog_messages
--- Steven Bethard [EMAIL PROTECTED] wrote:
I think I would rewrite the current unit-testing
example to use the
standard library unittest module::
# Let's write reusable code, and unit test it.
def add_money(amounts):
# do arithmetic in pennies so as not to
--- Steven Bethard [EMAIL PROTECTED] wrote:
I think I would rewrite the current unit-testing
example to use the
standard library unittest module::
# Let's write reusable code, and unit test it.
def add_money(amounts):
# do arithmetic in pennies so as not to
--- 7stud [EMAIL PROTECTED] wrote:
I'd settle for a simple explanation of what it does
in python.
The groupby function prevents you have from having to
write awkward (and possibly broken) code like this:
group = []
lastKey = None
for item in items:
newKey = item.key()
--- Steve Howell [EMAIL PROTECTED] wrote:
--- 7stud [EMAIL PROTECTED] wrote:
Bejeezus. The description of groupby in the docs
is
a poster child
for why the docs need user comments.
Regarding the pitfalls of groupby in general (even
assuming we had better documentation), I
--- Steven Bethard [EMAIL PROTECTED] wrote:
Steve Howell wrote:
--- Steven Bethard [EMAIL PROTECTED]
wrote:
I think I would rewrite the current unit-testing
example to use the
standard library unittest module::
# Let's write reusable code, and unit test
it.
def
--- Steven Bethard [EMAIL PROTECTED] wrote:
Have you tried py.test?
http://codespeak.net/py/dist/test.html
I've heard good things about it, but haven't gotten
around to trying it
yet. Here's a two-line test suite from the page
above:
def test_answer():
assert 42
--- Steven Bethard [EMAIL PROTECTED] wrote:
Maybe this is the first good example that
motivates a
hyperlink to alternatives. Would you accept the
idea
that we keep my original example on the
SimplePrograms
page, but we link to a UnitTestingPhilosophies
page,
and we show your
--- paul [EMAIL PROTECTED] wrote:
Regarding the pitfalls of groupby in general (even
assuming we had better documentation), I invite
people
to view the following posting that I made on
python-ideas, entitled SQL-like way to manipulate
Python data structures:
LINQ?
Maybe. I
--- Carsten Haese [EMAIL PROTECTED] wrote:
On Sun, 2007-05-27 at 10:17 -0700, 7stud wrote:
Bejeezus. The description of groupby in the docs
is a poster child
for why the docs need user comments. Can someone
explain to me in
what sense the name 'uniquekeys' is used this
example:
--- John Machin [EMAIL PROTECTED] wrote:
(And you can
ignore the fact that
it won't find a sequence at the very end of
words, that is fine for my
purposes).
[...]
Bzzzt. Needs the following code at the end:
if accumulator:
doSomething(accumulator)
FWIW the OP already
--- Steven D'Aprano wrote:
On Sun, 27 May 2007 14:55:42 -0700, John Machin
wrote:
Bzzzt.
Bzzzt!
Can we please refrain from buzzer sounds in this
mostly civil forum, even if one beep deserves another?
Let me preface every reply here by YMMV. I strongly,
strongly encourage people to tap into the unit testing
community for all tools that are available to them.
Also, let me say that despite any place where Steven
and I disagree about the mechanics of unit testing,
we're in firm agreement that
--- Carsten Haese [EMAIL PROTECTED] wrote:
[...] It's an abstract code pattern for an abstract
use
case.
I question the use of abstract code patterns in
documentation, as they just lead to confusion. I
really think concrete examples are better in any
circumstance.
Also, to the OP's
--- Raymond Hettinger [EMAIL PROTECTED] wrote:
FWIW, I wrote those docs. Suggested improvements
are
welcome; however, I think they already meet a
somewhat
high standard of quality:
I respectfully disagree, and I have suggested
improvements in this thread.
Without even reading the
--- Nis Jørgensen [EMAIL PROTECTED] wrote:
Steve Howell skrev:
def firstIsCapitalized(word):
return 'A' = word[0] = 'Z'
For someone who is worried about the impact of
non-ascii identifiers,
you are making surprising assumptions about the
contents of data.
The function
--- Raymond Hettinger [EMAIL PROTECTED] wrote:
+ The operation of \function{groupby()} is similar
to the \code{uniq}
filter
+ in \UNIX{}. [...]
Thanks!
The comparison of groupby() to uniq really clicks
with me.
To the extent that others like the Unix command line
analogy for
--- Paul Rubin http://phr.cx@NOSPAM.invalid wrote:
[...]
Here's yet another example that came up in something
I was working on:
you are indexing a book and you want to print a list
of page numbers
for pages that refer to George Washington. If
Washington occurs on
several consecutive
--- Roy Smith [EMAIL PROTECTED] wrote:
It's certainly easier to parse ip_address as
compared to IPAddress.
Same with snmp_manager vs SNMPManager.
Somebody earlier was actually advocating something
called proper_case, in which you can capitalize
certain letters for clarity, like
--- Nis Jørgensen [EMAIL PROTECTED] wrote:
I disagree that word.istitle is the correct idiom -
from the naming of
the function in the original example, I would guess
word[0].isupper
would do the trick.
nitpick
That would return something like this:
built-in method isupper of str
--- Stef Mientki [EMAIL PROTECTED]
wrote:
Steve Howell wrote:
I've always thought that the best way to introduce
new
programmers to Python is to show them small code
examples.
This is really a nice piece of missing Python.
Thanks.
The wxPython demo program is written
--- Carsten Haese [EMAIL PROTECTED] wrote:
On Sun, 2007-05-27 at 18:12 -0700, Steve Howell
wrote:
[...] there is no way
that uniquekeys is a sensible variable [...]
That's because the OP didn't heed the advice from
the docs that
Generally, the iterable needs to already be sorted
--- Raymond Hettinger [EMAIL PROTECTED] wrote:
That's not for everyone, so it isn't a loss if
someone sticks
with writing plain, clear everyday Python instead of
an itertool.
I know most of the module is fairly advanced, and that
average users can mostly avoid it, but this is a very
--- Stef Mientki [EMAIL PROTECTED]
wrote:
It would even be nicer, if everybody could drop
her/his examples
in a standard way, so they would be automatically
incorporated in
something like the wxPython interactive demo.
Can you elaborate?
Well if you see the above demo,
--- Stef Mientki [EMAIL PROTECTED]
I don't know MoinMoin,
but the answer is Yes (although maybe not for your
ten snippets).
First of all I think all programmers keep there own
collection of code snippets,
which much more valuable then all the code code
snippets from everyone.
Agreed.
--- Paul Rubin http://phr.cx@NOSPAM.invalid wrote:
But that is what groupby does, except its notion of
uniqueness is
limited to contiguous runs of elements having the
same key.
It occurred to me that we could also rename the
function uniq(), or unique(), after its Unix
counterpart, but
--- Raymond Hettinger [EMAIL PROTECTED] wrote:
That's not for everyone, so it isn't a loss if
someone sticks
with writing plain, clear everyday Python
instead of
an itertool.
I know most of the module is fairly advanced, and
that
average users can mostly avoid it, but this is
--- Alex Martelli [EMAIL PROTECTED] wrote:
Steve Howell [EMAIL PROTECTED] wrote:
...
for has_chars, frags in itertools.groupby(lines,
lambda x: len(x) 0):
Hmmm, it appears to me that itertools.groupby(lines,
bool) should do
just the same job, just a bit faster and simpler
--- Carsten Haese [EMAIL PROTECTED] wrote:
On Sun, 2007-05-27 at 07:30 +, OKB (not
okblacke) wrote:
Underscores are harder to type than any
alphanumeric character.
This is a discussion about underscores versus
capital letters denoting
the word boundaries in
--- Ramashish Baranwal [EMAIL PROTECTED]
wrote:
Hi,
I am trying to execute some tasks periodically,
those familiar with
unix can think of it as equivalent to cron jobs. I
have tried looking
around, but couldn't find a way. Would appreciate
any pointers or
clues..
I'm also interested
--- vasudevram [EMAIL PROTECTED] wrote:
On May 29, 4:39 pm, Steve Holden
[EMAIL PROTECTED] wrote:
Alternatively, the user could make use of the
already-existing sched
module from the standard library. With a little
threading that would do
the job fine.
Yes. Also, there's an
--- Carsten Haese [EMAIL PROTECTED] wrote:
As an aside, while groupby() will indeed often be
used in conjunction
with sorted(), there is a significant class of use
cases where that's
not the case: I use groupby to produce grouped
reports from the results
of an SQL query. In such cases, I
--- Ramashish Baranwal [EMAIL PROTECTED]
wrote:
Are you sure that your SMTP server uses this type
of authentication?
Some SMTP servers use POP3 followed by SMTP to
authenticate instead.
use telnet to verify, this link might help.
On May 29, 2:34 am, Raymond Hettinger
[EMAIL PROTECTED] wrote:
The gauntlet has been thrown down. Any creative
thinkers
up to the challenge? Give me cool recipes.
I don't make any claims to coolness, but I can say
that I myself would have written the code below with
significantly more
Raymond Hettinger [EMAIL PROTECTED] writes:
The gauntlet has been thrown down. Any creative
thinkers
up to the challenge? Give me cool recipes.
Twin primes? (Sorry, no code, but there's a good
Python example somewhere that returns an iterator that
keeps doing the sieve, feed it to
--- kaens [EMAIL PROTECTED] wrote:
Anyhow, I'm looking to expand my understanding of
python, and I feel
that one of the best ways to do that is looking at
other peoples code.
A lot of the built-in Python modules are implemented
in pure Python. If you are using any of those so far
and
--- Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
There was just recently a thread with a
`itertools.groupby()` solution.
Yes, indeed. I think it's a very common coding problem
(with plenty of mostly analogous variations) that has
these very common pitfalls:
1) People often forget to
--- stef [EMAIL PROTECTED] wrote:
doing a simulation of another language (JAL),
I translate the other language into Python code,
then I execute this converted Python code.
[...]
(btw the whole program is running as an graphical
(wxPython) application)
I worked on an open source project that
--- Diez B. Roggisch [EMAIL PROTECTED] wrote:
Are there any other (simple) ways of achieving
this ?
(btw the whole program is running as an graphical
(wxPython) application)
use the python trace facilities.
http://docs.python.org/lib/module-trace.html
I'm not sure how much that
--- Tijs [EMAIL PROTECTED] wrote:
Yes, or a single one that takes a wide range of
construction possibilities,
like strings, lambdas or regexes in various keyword
parameters.
BlockReader(f, start='')
BlockReader(f, start=re.compile('|'), end='---')
BlockReader(f, start=lambda x:
--- Tijs [EMAIL PROTECTED] wrote:
Steve Howell wrote:
[...] but I wonder if the Python community
couldn't help a lot of newbies (or insufficiently
caffeinated non-newbies) by any of the following:
Well, I'm not a newbie, and I always make sure to be
thoroughly caffeinated
before
--- A.T.Hofkamp [EMAIL PROTECTED] wrote:
lambda x: (lambda y: sin(y) + cos(y))(x*x)
Elegant.
I find the use of y confusing there (thinking about
the unit circle), so I'd amend it to this:
lambda x: (lambda x2: sin(x2) + cos(x2))(x*x)
But I like the overall idea.
--- stef [EMAIL PROTECTED] wrote:
the language I want to simulate (JAL),
is very Pascal like,
and therefor can be easily converted into equivalent
Python code.
One more idea. If you haven't already, maybe you can
post something to the PyPy community to effect of
this:
'''
I have a
--- A.T.Hofkamp [EMAIL PROTECTED] wrote:
I would probably generate a DOT file to get a 2D
visualization. DOT is part of
Graphviz (graphviz.org), and there are quite a few
graphviz front-ends
available in Python to make DOT generation easier
(pydot, yapgvb, and probably
a few others).
--- stef [EMAIL PROTECTED] wrote:
Steve,
that's exactly what I've in mind.
The screen shots, looks really good,
and I'll definitely will take a deeper look into
your code.
Cool, good luck. Feel free to contact me privately if
you have questions about the implementation. There's
also a
--- Sergey Dorofeev [EMAIL PROTECTED] wrote:
What syntax would you suggest for a lambda
enhanced to cover your use
case?
I suppose you will end up with roughly the same
number of characters, all
crammed in one line -- or broken into lines at a
random position as it
happens with
--- Tijs [EMAIL PROTECTED] wrote:
Steve Howell wrote:
FWIW there's the possibility that even without a
subexpression syntax, some Python implementations
would detect the duplication of x*x and optimize
that
for you. It would have to know that x*x had no
side
effects, which I think
--- Diez B. Roggisch [EMAIL PROTECTED] wrote:
The elegance of that solution very much depends on
the cost of the duplicate
operation vs. the additional function call.
And for the usecase at hand, that's exactly the
point not to do it:
[EMAIL PROTECTED]:/tmp$ python -m timeit '(lambda x:
--- Paul Boddie [EMAIL PROTECTED] wrote:
On 1 Jun, 12:55, Steve Howell [EMAIL PROTECTED]
wrote:
FWIW there's the possibility that even without a
subexpression syntax, some Python implementations
would detect the duplication of x*x and optimize
that
for you. It would have to know
def f(x): y = x*x; return sin(y)+cos(y);
Although I know valid trigonometry is not the point of
this exercise, I'm still trying to figure out why
anybody would ever take the square of an angle.
What's the square root of pi/4 radians?
--- Steven D'Aprano
[EMAIL PROTECTED] wrote:
On Sat, 02 Jun 2007 05:54:51 -0700, Steve Howell
wrote:
def f(x): y = x*x; return sin(y)+cos(y);
Although I know valid trigonometry is not the
point of
this exercise, I'm still trying to figure out why
anybody would ever take
--- Stef Mientki [EMAIL PROTECTED]
wrote:
Maybe he meant
sin(x)^2 + cos(x)^2
which is well known demodulation technique if you
create two signals 90 degrees out of phase.
There's a shorter way to phrase that expression, of
course. :)
1
--- Steve Howell [EMAIL PROTECTED] wrote:
--- Stef Mientki [EMAIL PROTECTED]
wrote:
Maybe he meant
sin(x)^2 + cos(x)^2
which is well known demodulation technique if you
create two signals 90 degrees out of phase.
A more realistic subexpression where you might repeat
yourself
--- George Sakkis [EMAIL PROTECTED] wrote:
It seems
like it would be fairly straightforward to do a
quick
prototype implementation of this. I'm off to work
soon, so I can't do it today, but maybe Sunday.
I'm afraid I beat you to it :)
--- Steve Howell [EMAIL PROTECTED] wrote:
Can I suggest a minor optimization?
Instead of this...
def get_predicate(arg):
return arg if callable(arg) else (
arg.__eq__ if hasattr(arg,'__eq__')
else
lambda item: item == arg)
Never mind, I
--- Mark Carter [EMAIL PROTECTED] wrote:
Well, I know I'm preaching to the converted - but
Python rocks.
[...]
A few questions from the choir:
As a recent newcomer to the language, did you
encounter any traps or pitfalls while you were
learning? Also, could you single out anything in
George Sakkis produced the following cookbook recipe,
which addresses a common problem that comes up on this
mailing list:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/521877
I would propose adding something like this to the
cookbook example above.
def iterblocks2(lst, start_delim):
1 - 100 of 453 matches
Mail list logo