Christian Heimes wrote:
eliben wrote:
Ruby's 'Scruct' class (http://ruby-doc.org/core/classes/Struct.html)
does this. I suppose it can be done with 'exec', but is there a more
Pythonic way ?
Try named tuple http://code.activestate.com/recipes/500261/
A named tuple implementation is part of
eliben wrote:
Whaaa? Named tuples are being added to Python? Neat! Is there any
documentation on this? I can't seem to find anything on the web...
It's not easy to find unless you recall where you've seen it:
http://docs.python.org/dev/3.0/library/collections.html#collections.namedtuple
Daniel Fetchinson wrote:
The reason I need this is that my current best strategy to avoid ads
in web pages is putting all ad server names into /etc/hosts and stick
my local ip number next to them (127.0.0.1) so every ad request goes
to my machine. I run apache which has an empty page for 404
cbmeeks wrote:
I have created an image hosting site and when a user uploads an image,
I want a service to run on the server to create a few thumbnails while
the user does other things.
My stupid host (pair.com) doesn't have PIL installed and I'm too much
of a stupid newbie to figure out how
Neil Cerutti wrote:
There's been only one (or two?) languages in history that
attempted to provide programmers with the ability to implement
new infix operators, including defining precedence level and
associativity (I can't think of the name right now).
You're probably thinking of SML or
On Wed, 18 Jul 2006, Sanjay wrote:
What is the equivalent in Python? Inheriting is a way, but is not
working in all scenerios.
Have you tried multiple inheritance? For example:
from GeneratedPerson import GeneratedPerson
from HandcraftedPerson import HandcraftedPerson
class
Ten wrote:
Respectfully, that sounds like a reason for *you* to bundle pythonwin (and
python, to be honest :) ), not a reason for everyone else to have to download
an extra 40-50% of potentially superfluous cruft with their standard python
setup.
Certainly, I could bundle Python and
[EMAIL PROTECTED] wrote:
The ctypes.com package is no longer part of ctypes.
It has been split by Thomas Heller into a separate package comtypes.
See: http://sourceforge.net/projects/comtypes/
Still in its childhood but as easy as com can get, I guess, way easier
and better than pythonWin
Martin v. Löwis wrote:
Dave Benjamin wrote:
Why is PythonWin (win32all) still a separate download from a third
party? Is it legal, technical, or what? I think it's about time it be
part of the standard distribution.
Both legal and technical. The PythonWin author and maintainer (Mark
On Thu, 11 May 2006, Alex Martelli wrote:
Dave Benjamin [EMAIL PROTECTED] wrote:
...
It's time to bundle PythonWin.
No: the Python Standard Distribution, in 2.5, includes instead ctypes,
which is lower-level than PythonWin but more general (exists for other
platforms, lets you call other
tasks. My users are thankfully benevolent enough to download and install
Python on their own. They don't know what PythonWin is, they aren't
remembering it, and frankly, I don't think it should be their concern.
It's time to bundle PythonWin.
--
.:[ dave benjamin -( ramen/sp00 )- http
On Thu, 11 May 2006, Robert Hicks wrote:
No it isn't. It is a Windows only package. It needs to stay a separate
download.
The Windows installer for Python is an MSI file. It's already Windows
only.
Dave
--
http://mail.python.org/mailman/listinfo/python-list
.
Also worth a mention is Alice ML, which runs on the Mozart system but is
statically typed, type-inferred, very similar to SML but with concurrency
support (lazies and futures), typesafe marshalling, and packages, which
allow for dynamically-typed interfaces between modules.
--
.:[ dave
, but I don't think it will do what I need.
What about regular expressions?
--
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
one man's constant is another man's variable - alan perlis
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 20 Mar 2006, Ben Cartwright wrote:
Dave Hansen wrote:
On 20 Mar 2006 15:45:36 -0800 in comp.lang.python,
[EMAIL PROTECTED] (Aahz) wrote:
Personally, I think it's a Good Idea to stick with the semi-standard
names of *args and **kwargs to make searching easier...
Agreed (though
import * should be avoided anyway, for reasons that
have been discussed many times in the past. The annoyance with reloading
is just one more reason. Better to just use import X in the first place.
--
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
one man's constant
On Thu, 2 Mar 2006, John Salerno wrote:
Dave Benjamin wrote:
In general, from X import * should be avoided anyway, for reasons that
have been discussed many times in the past. The annoyance with reloading is
just one more reason. Better to just use import X in the first place.
Thanks. I
.
--
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
one man's constant is another man's variable - alan perlis
--
http://mail.python.org/mailman/listinfo/python-list
Python and Zope as it's
moderately hardcore open source stuff.
Moderately hardcore? Is that like listening to Rage Against the Machine
with your seatbelt on?
--
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
To attain knowledge, add things every day.
To attain
before. Equality in this case is
left completely open-ended, and as a result, there is no way that you can
guarantee that a == b is the same as b == a if a is a foo and b
is of unknown type. This can lead to bizarre and unpredictable behavior.
--
.:[ dave benjamin -( ramen/sp00 )- http
the implementation of b.
--
.:[ dave benjamin -( ramen/sp00 )- http://spoomusic.com/ ]:.
To attain knowledge, add things every day.
To attain wisdom, remove things every day. - Lao Tzu
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 26 Jan 2006, Dave Benjamin wrote:
On Thu, 26 Jan 2006, Rocco Moretti wrote:
You were better off with what you had before. Equality in this case is
left completely open-ended, and as a result, there is no way that you can
guarantee that a == b is the same as b == a if a is a foo
could do a lot worse than Python 2.1, as far as feature set is concerned.
(Of course, this is not to discourage the Jython team from coming through
with a new stable release. ;)
--
.:[ dave benjamin: ramen/[spoomusic.com] ]:.
--
http://mail.python.org/mailman/listinfo/python-list
/01/01/turbogears-now-supports-cheetah-and-stan/
Happy New Year!
Dave
--
.:[ dave benjamin: ramen/[spoomusic.com] ]:.
--
http://mail.python.org/mailman/listinfo/python-list
that produces values
on-demand, you don't have to rewrite your function to save intermediate
states (which can be a considerable amount of work).
A good explanation of the rationale for generators in Python is in the
Motivation section of PEP 255:
http://www.python.org/peps/pep-0255.html
--
.:[ dave
Cappy2112 wrote:
Does anyone know if the table align property is available in
HTMLgen.Table?
The docs don't show it, but I find it hard to believe that it is not
available.
I want to center the table.
Only the cell align propterty is available
I've never used HTMLgen, but you might try
Cappy2112 wrote:
Does anyone know if the table align property is available in
HTMLgen.Table?
The docs don't show it, but I find it hard to believe that it is not
available.
I want to center the table.
Only the cell align propterty is available
print HTMLgen.TableLite(align=center)
TABLE
Cappy2112 wrote:
Table and TableLite are different classes. Tablelite requires a little
more work, and I will ave to rewrite some code to use it.
I am using Table a tthe moment
Well, as far as I know, wrapping a DIV align=center around a TABLE
should produce the same effect as giving the
Alex Martelli wrote:
The main reason I suggest a general-purpose mechanism for the hooking-up
of the preprocessor is that such a mechanism might stand a chance to be
accepted (via the usual PEP procedure), as long as other interesting use
cases can be found; I suspect that if the only use case
by compassion and sympathy, in
consideration of humans. In a world of increasing software complexity,
this doesn't sound half bad to me.
--
.:[ dave benjamin: ramen/[sp00] ]:.
\\ who will clean out my Inbox after I'm dead[?] - charles petzold
--
http://mail.python.org/mailman/listinfo/python
On Mon, 19 Dec 2005, Paul Rubin wrote:
Russell E. Owen [EMAIL PROTECTED] writes:
I disagree. Once you've picked a database (not trivial in itself, of
course), you typically only have a few options for talking to in in
Python. Also, typically either:
- One stands out (because others have been
On Thu, 15 Dec 2005, Richie Hindle wrote:
[Steve]
Since Python is Turing-complete
Is there some equivalent of Godwin's Law that we can invoke at this
point? 8-)
None that I know of, but perhaps there should be. =) Note that in this
particular thread, we could have invoked the real
On Thu, 15 Dec 2005, Simon Brunning wrote:
On 12/15/05, Steve Holden [EMAIL PROTECTED] wrote:
Aahz wrote:
python -c 'import this'
Faster:
python -m this
So, there's two ways to do it. ;-)
Yes, but which way do you do it if you're Dutch?
--
On Thu, 15 Dec 2005, Adrian Holovaty wrote:
bruno at modulix wrote:
RoR is not an IDE, it's a web framework. The closest things in Python
are TurboGears (good Ajax/js support via Mochikit), Subway (never
tested), and Django (no Ajax support AFAIK).
Note that no Ajax support is misleading.
. This
problem has been solved.
Here's a list of apps, including TagRename, that can query freedb:
http://www.freedb.org/freedb_aware_apps.php
--
.:[ dave benjamin: ramen/[sp00] ]:.
\\ who will clean out my Inbox after I'm dead[?] - charles petzold
--
http://mail.python.org/mailman/listinfo/python-list
Jorgen Grahn wrote:
On Fri, 14 Oct 2005 12:37:25 +0200, Christophe [EMAIL PROTECTED] wrote:
Kenneth McDonald a écrit :
For unfortunate reasons, I'm considering switching back to Win XP (from
OS X) as my main system. Windows has so many annoyances that I can
...
Yes, I know that Cygwin
Misto . wrote:
Hi folks!
Short:
There is a way to dumplicate a module ?
Here's one way... it doesn't quite work with modules inside of packages,
unfortunately, but it does avoid defeating module caching and tries to
keep sys.modules in a predictable state. I don't know what the
Reinhold Birkenfeld wrote:
after Guido's pronouncement yesterday, in one of the next versions of Python
there will be a conditional expression with the following syntax:
X if C else Y
Hooray! After years of arguing over which syntax to use, and finally
giving up since nobody could agree,
Tor Erik Sønvisen wrote:
I need to browse the socket-module source-code. I believe it's contained in
the file socketmodule.c, but I can't locate this file... Where should I
look?
You can browse the Python CVS tree here:
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/
For
[EMAIL PROTECTED] wrote:
Let's say I define a list of pairs as follows:
l = [('d', 3), ('a', 2), ('b', 1)]
Can anyone explain why this does not work?
h = {}.update(l)
and instead I have to go:
h = {}
h.update(l)
to initialize a dictionary with the given list of pairs?
when
Terry Hancock wrote:
On Monday 05 September 2005 08:10 am, Laszlo Zsolt Nagy wrote:
The problem is that now I have so many modules that the shell (cmd.exe)
cannot interpret this as a one command.
In POSIX systems, the shell expands wildcards into multiple files on
the command line, but
Ramza Brown wrote:
This is an update from Brian Zimmer of the Jython group, new release:
Great news!
- new installer
How do I use it?
Thanks,
Dave
--
http://mail.python.org/mailman/listinfo/python-list
Dave Benjamin wrote:
Ramza Brown wrote:
This is an update from Brian Zimmer of the Jython group, new release:
Great news!
- new installer
How do I use it?
I figured it out. You might want to document this somewhere. ;)
java -cp jython_Release_2_2alpha1.jar
Ramza Brown wrote:
I figured it out. You might want to document this somewhere. ;)
java -cp jython_Release_2_2alpha1.jar
org.python.util.install.Installation
Did you try double clicking on the jar. That is what most do or at
least the last package supported that.
Yeah. It opens in
Joseph Garvin wrote:
Robert Kern wrote:
Not everyone is reading this list in a conveniently threaded form
Why not? Just about every modern newsgroup reader and e-mail app has a
threaded view option.
My newsreader supports threading, but the first message I see in this
thread is from
Brett Hoerner wrote:
Is there a different shell I can use (other than cmd.com) to run Python
in, where I can full-screen the window (if I pleased), etc? As it is,
things that would run far off the right have to be word wrapped after
very few characters.
I have a pretty exotic setup but I
Steven Bethard wrote:
Guido also suggests that the explicit:
class C(object):
pass
is much preferred[2] over:
__metaclass__ = type
class C:
pass
Really? I have been toying with the idea of using the __metaclass__
trick, since it results in completely
Stephen Kellett wrote:
In message [EMAIL PROTECTED], Simon
Brunning [EMAIL PROTECTED] writes
Eclipse's refactorings are a great boon, I find. Refectoring is never
*fully* automatic, of course, but the ability to, for example, select
a chunk of code and have it extracted into a separate
Sakesun Roykiattisak wrote:
What's being ignored is that type information is useful for other things
than compile type checking. The major case in point is the way IDEs
such as IntelliJ and Eclipse use type information to do refactoring, code
completion and eventually numerous other things.
BORT wrote:
I am toying with the idea of teaching my ten year old a little about
programming. I started my search with something like best FREE
programming language for kids. After MUCH clicking and high-level
scanning, I am looking at Python and Forth. Both have advocates that
say each is
Guido gave a good, long interview, available at IT Conversations, as was
recently announced by Dr. Dobb's Python-URL! The audio clips are available
here:
http://www.itconversations.com/shows/detail545.html
http://www.itconversations.com/shows/detail559.html
I'd like to comment on a few parts of
Jan Danielsson wrote:
Sorry, but I Just Don't Get It. I did search the 'net, I did read the
FAQ, but I'm too dumb to understand.
Say we define a string s as follows:
s = 'hello'
If we print s, we see its string form (__str__):
print s
hello
However, if we just examine s, we see its
Jordan Rastrick wrote:
Surely the != operator should, if no __ne__ method is present for
either object, check to see if an __eq__ method is defined, and if so,
return its negation?
Actually, that brings me to a wider question - why does __ne__ exist at
all? Surely its completely
bens wrote:
I'm trying to return an 'mmap' object from a function. The return
works, but some of the object's methods crash. Here are two examples
doesntwork.py
---
import mmap
import os
name=/any/real/file/on/my/hard/drive
def getfile(name):
Torsten Bronger wrote:
When I add a warning filter with warnings.filterwarnings, how can I
get rid of it? I've read about resetwarnings(), but it removes all
filters, even those that I didn't install in a certain function.
I have never used this module, but judging by a quick glance of the
[EMAIL PROTECTED] wrote:
Dave Benjamin wrote:
I think it's much better for simplify() to return a new object
and leave the original object unmodified. You can still write:
expression2 = expression2.simplify()
A belated thank-you message for your reply to my posting. I took your
advice
Tomas Christiansen wrote:
Im trying to make a simple TCP socket relay or proxy, but my skills in
Python are not high (yet).
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/114642
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Now suppose I set expression2 = Sum([a,-a]) and Sum.simplify()
recognises that the two terms cancel and the Sum has value 0.
Can I make expression2.simplify() transform expression2 from an
instance of Sum to an instance of Number(0) **in place**? Is that
possibe, or
praba kar wrote:
In Php I can use strip_tags() function to strip out
all html tags. I want to know that strip_tags()
equivalent function in Python.
Here's a simple function based on Python's HTMLParser class. If you need
to reject only certain tags, you'll probably want to subclass
Fredrik Lundh wrote:
Dave Benjamin wrote:
In this case, having to name these callback functions is tiring and
awkward, and (IMHO) disrupts the flow of my function:
so name them all func or next or something, so you don't have
to think. once the object is bound, the name is irrlevant.
Sure
Fredrik Lundh wrote:
Dave Benjamin wrote:
so name them all func or next or something, so you don't have
to think. once the object is bound, the name is irrlevant.
Sure, you could do this, but then you'd have multiple functions at
different nesting levels with the same name, which would
Steve Holden wrote:
tlviewer wrote:
CHM is supposed to be structured storage (ITSF). If a given CHM
file is infected it most likely has an embedded EXE file -- mine
had one called [Open.exe].
Ironic, really, since Microsoft insist that the browser must be
fully-integrated with
Dave Benjamin wrote:
Steve Holden wrote:
tlviewer wrote:
CHM is supposed to be structured storage (ITSF). If a given CHM
file is infected it most likely has an embedded EXE file -- mine
had one called [Open.exe].
Ironic, really, since Microsoft insist that the browser must
Peter Hansen wrote:
Dave Benjamin wrote:
def add_thingy():
def func(thingy_id):
print 'got thingy id:', thingy_id
def funnc(doodad_id):
print 'got doodad id:', doodad_id
def func(thingy_doodad):
print 'thingy doodad created
Peter Hansen wrote:
I doubt there's a valid usecase for a anonymous function that has more
than a line or two. Personally, I don't think there's a good usecase
for an anonymous function longer than one line...
The case that I keep running into regards event-driven programming. I
need to do
Michael Hoffman wrote:
Paul Miller wrote:
I see lambda is going away, so I want to use something that will be
around for awhile.
All I want to do is provide an inline function as an argument to
another function.
That's what lambda does. But it's going away, you'll have to use def
when
Paul Miller wrote:
Michael Hoffman wrote:
Dave Benjamin wrote:
I think you meant to write something like this:
def attrsetter(obj, name, value):
def _return_func():
return setattr(obj, name, value)
return _return_func
Sure did. Sorry.
You guys have been very helpful!
While
Dave Benjamin wrote:
You could use a combination of bound methods and the curry function
defined in the Python Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549
The examples in the discussion do just that.
Also, in the CVS version of Python, there's a new module called
Cameron Laird wrote:
In article [EMAIL PROTECTED],
Peter Hansen [EMAIL PROTECTED] wrote:
This meets your requirements as stated:
def temp():
foo.var = 1
bind('a', temp)
def temp():
foo.var = 2
bind('b', temp)
del temp
Ewww! *When* is lambda going bye-bye? I apparently
haven't been paying
seem unreasonably slow to me. (CPUs
have of course exploded in speed in the past few years.)
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
talking about music is like dancing about architecture.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2005-03-04 at 08:36 -0800, gf gf wrote:
Is there a better, more FP style, more Pythonic way to
write this:
def compute_vectors(samples, dset):
vectors = {}
for d in dset:
vectors[d] = [sample.get_val(d) for sample in
samples]
return vectors
You
On Sat, 2005-03-05 at 00:00 -0700, Dave Benjamin wrote:
On Fri, 2005-03-04 at 08:36 -0800, gf gf wrote:
Is there a better, more FP style, more Pythonic way to
write this:
def compute_vectors(samples, dset):
vectors = {}
for d in dset:
vectors[d
Jeremy Bowers wrote:
I'd point out that the Zen that can be comprehended by checking off items
in a list is not the true Zen.
The Zen that can be imported is not the eternal Zen. =)
--
http://mail.python.org/mailman/listinfo/python-list
.
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
talking about music is like dancing about architecture.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks, Nick and Alex, for the nice, detailed explanations. My understanding
of Python bytecode is not deep enough to comment at this time. ;)
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
talking about music is like dancing about architecture.
--
http
= 5
class C(object):
... x = x
...
C.x
5
Any implementation gurus have some insight into what's going on here?
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
talking about music is like dancing about architecture.
--
http://mail.python.org
Davor wrote:
Is it possible to write purely procedural code in Python, or the OO
constructs in both language and supporting libraries have got so
embedded that it's impossible to avoid them? Also, is anyone aware of
any scripting language that could be considered as Python minus OO
stuff? (As you
Kevin Smith wrote:
I have many cases in my code where I use a property for calculating a
value on-demand. Quite a few of these only need to be called once.
After that the value is always the same. In these properties, I set a
variable in the instance as a cached value and return that value
Mike Meyer wrote:
Robert Brewer [EMAIL PROTECTED] writes:
Why aren't built
in lists and dictionaries real heritable types that can save
this kind of patchwork?
They are since Python 2.2 (IIRC):
And before Python 2.2 there was the UserList class in the standard
library. Which is still there in
. Decimals will be converted to rationals before the
operation. [Open question: is this the right thing to do?]
Sounds right to me.
Cheers,
Dave
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
talking about music is like dancing about architecture.
--
http
something like a Java class containing only static methods and inner classes.
Even this would be considered rebellious within the context of ordinary Java
programming.
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
talking about music is like dancing about
In article [EMAIL PROTECTED], Fredrik Lundh wrote:
Dave Benjamin wrote:
I looked around for recordings of Guido, but couldn't find any.
http://www.python.org/~guido/guido.au
I found a few--slightly longer--video interviews here today:
http://technetcast.ddj.com/tnc_catalog.html?item_id=90
In article [EMAIL PROTECTED], Jimmy Retzlaff wrote:
Dave Benjamin wrote:
I looked around for recordings of Guido, but couldn't find any. Does
anyone know of any streamable audio (or video) interviews or speeches
featuring Guido, the bots, or any other interesting people in the
Python
83 matches
Mail list logo