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
Thank
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 Py
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 40
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 ou
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 Person(Generated
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
[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 python
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 Pyt
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
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
utomate basic office
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.
--
res), typesafe marshalling, and "packages", which
allow for dynamically-typed interfaces between modules.
--
.:[ 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
.
>
> I looked at shlex, 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
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
e.
So, to make a long story short, you have to do something like:
import X
reload(X)
del X # to keep your namespace clean
from X import *
In general, "from X import *" should be avoided anyway, for reasons that
have been discussed many times in the past. The annoyance with reloading
ges better cohesion.
--
.:[ 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 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 &q
ere to duck typing.
I don't think duck typing buys you anything valuable here. The usual
flexibility of duck typing is lost because of the symmetric nature of
equality; all participating classes need to be involved to guarantee
correctness. You *could* have "b.__eq__" just call
er.an_attribute
> except AttributeError:
> return False
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&
s interesting to see they're using 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/ ]:.
h the above. I've been using Jython in production for two
years now, and it's been rock-solid. A little bit outdated, yes, but you
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 ne
http://www.blueskyonmars.com/2006/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
f PEP 255:
http://www.python.org/peps/pep-0255.html
--
.:[ dave benjamin: ramen/[spoomusic.com] ]:.
--
http://mail.python.org/mailman/listinfo/python-list
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 t
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="cen
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
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 c
dle English humain
1 : marked by compassion, sympathy, or consideration for humans or animals
2 : characterized by or tending to broad humanistic culture : HUMANISTIC
Accepting both of these definitions as (potentially) ideal, we have humane
minimalism: a style or technique that is characteri
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 othe
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 mi
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?
--
http://mail.python.org
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 Go
handful of albums to rename, trust me. This
problem has been solved.
Here's a list of apps, including Tag&Rename, 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[?]"
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 k
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,
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
thre
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 exa
Mike Meyer wrote:
> Dave Benjamin <[EMAIL PROTECTED]> writes:
>
>>Python is actually quite consistent in this regard: methods that
>>modify an object in-place return None;
>
> Um, no. list.pop comes to mind as an immediate counterexample. It may
> be th
[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 l
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
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 ope
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
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
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
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 c
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 e
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
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
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",
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 incons
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 yo
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
> po
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
HTMLPar
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
>>
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].
>> &
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-integra
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 m
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
&
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 t
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
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 ne
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 on the
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 d
n popping
up quite a bit lately, and they don't 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 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 = {}
> > f
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
Michael Spencer wrote:
Grant Edwards wrote:
Thanks. The stuff provided by the "new" module is what I was
missing.
No magic in the 'new' module - new.instancemethod is just a synonym for
the method type:
>>> import new, types
>>> new.instancemethod is types.MethodType
True
(Assuming you're usin
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
Will McGugan wrote:
I'm accumulating a number of small functions, which I have sensibly put
in a single file called 'util.py'. But it occurs to me that with such a
generic name it could cause problems with other modules not written by
myself. Whats the best way of handling this? If I put it in a
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."
verifiable.
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
"talking about music is like dancing about architecture."
--
http://mail.python.org/mailman/listinfo/python-list
like Python is determining at that point that
"x" is a class variable, and refuses to search any further.
At the top-level, it works as expected:
>>> x = 5
>>> class C(object):
... x = x
...
>>> C.x
5
Any implementation gurus have some insight into w
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
Paul Rubin wrote:
Tim Peters <[EMAIL PROTECTED]> writes:
But at that time, Python didn't have lexical scoping, and it wasn't
clear that it ever would. So what's the bigger wart? Making
listcomps exactly equivalent to an easily-explained Python for-loop
nest, or introducing a notion of lexical sco
Will Stuyvesant wrote:
. def delay(exp): return lambda: exp
If you look at the definition of "delay" in SICP, you'll notice that
it's defined as "syntax sugar", in other words, a macro. Since Python
does not have macros, you'll have to just use "lambda", because by
defining "delay" as a function
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 on
Roman Suzi wrote:
I wish lambdas will not be deprecated in Python but the key to that is
dropping the keyword (lambda). If anybody could think of a better syntax for
lambdas _with_ arguments, we could develop PEP 312 further.
Well, my vote is still with Ruby-style codeblock syntax, but as a
compro
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
t impression that the results of the operation are
> precise. 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 ]:
t across all styles of programming.
Interestingly, Python's main unit of modularity is the "module", not the
"class". A direct translation of a typical Python module to Java would look
something like a Java class containing only static methods and inner classes.
Even this would
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
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://technet
27;s about the closest
I've found so far.
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
"talking about music is like dancing about architecture."
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden wrote:
Brad Tilley wrote:
Matt Gerrans wrote:
Anyway, what's to worry about?When the time comes just whip out a
little script that converts Python 1.6 (or whatever you like) to
Python3K; it will only take seven lines of P3K code.
How about 'import classic'
... or
from __past__
91 matches
Mail list logo