On Sun, 21 Oct 2007 01:20:47 -, Daniel Pitts
<[EMAIL PROTECTED]> wrote:
>On Oct 20, 2:04 pm, llothar <[EMAIL PROTECTED]> wrote:
>> > I love math. I respect Math. I'm nothing but a menial servant to
>> > Mathematics.
>>
>> Programming and use cases are not maths. Many mathematics are
>> the wor
lar its syntax, on esthetical grounds, sucks in
>major ways.
No one except you thinks TeX is a "computer language".
>Btw, a example of item 4 above, is Python's documentation. Fucking
>asses and holes.
Watch your language, there are children present.
George
--
for email reply remove "/" from address
--
http://mail.python.org/mailman/listinfo/python-list
need one
more append outside the loop (if report_item:
report.append(report_item)).
> I feel this solution is not that good, can I make this more pythonic?!
Sure; get familiar with a swiss-knife module, itertools, and in
particular for this task, groupby:
from operator import itemgetter
from itertools import groupby, chain
def group_roster(rows, num_stats=12):
# group the rows by their first two elements
# Caveat: the rows should already be sorted by
# the same key
for key,group in groupby(rows, itemgetter(0,1)):
stats = [0.0] * num_stats
for row in group:
if row[2]: stats[int(row[2])-1] = float(row[3])
yield list(chain(key,stats))
if __name__ == '__main__':
import csv
for row in group_roster(csv.reader(open('roster.txt'))):
print row
HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 24, 10:42 am, [EMAIL PROTECTED] wrote:
> On Oct 24, 4:15 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 24, 2:02 pm, [EMAIL PROTECTED] wrote:
>
> > > On Oct 24, 7:09 am, Alexandre Badez <[EMAIL PROTECTED]> wrote:
>
> > > > I'm just wondering, if I could write a in a "better" way
On Oct 24, 2:42 pm, Vangati <[EMAIL PROTECTED]> wrote:
> Plusmo is Hiring!
>
> (snipped)
>
> Recruiting Agencies: Please do not send us unsolicited resumes.
> Plusmo does not consider resumes from any agencies.
Lame company headhunters: Please do not send us unsolicited
spamvertisments irrelevant
On Oct 25, 2:28 am, NoName <[EMAIL PROTECTED]> wrote:
> I try it:
>
> def b():
> ...
> a()
> ...
>
> def a():
> ...
> b()
> ...
>
> b()
> it's not work.
It sure does. Please post full code and error message, something else
On Oct 25, 6:12 am, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Template engines are amongst the things that seem easy enough to look at the
> available software and say "bah, I'll write my own in a day", but are complex
> enough to keep them growing over years until they become as huge and
> inacc
his is quite typical, and practically required for web
development. As Diez pointed out, your main problem will be which of
the dozen or so template packages to pick. Depending on your criteria
(expressive power, syntax close to python, performance, stability
etc.) you may narrow it down to a h
x27;E')`` is a little safer than ``s[0] == 'E'`` as the former
> returns `False` if `s` is empty while the latter raises an `IndexError`.
A string slice is safe and faster though: if s[:1] == 'E'.
George
--
http://mail.python.org/mailman/listinfo/python-list
urn value is >=0 ? That also looks odd in a dynamic language
with a "we're all adults here" philosophy and much less hand-holding
in areas that matter more (e.g. allowed by default comparisons between
instances of different types - at least that's one of the warts Python
3 gets right).
George
--
http://mail.python.org/mailman/listinfo/python-list
objects, and duck-typing, things like
> len() being a function rather than a method make perfect sense.
Does the fact that index() or split() are methods make perfect sense
as well? I guess after some time using Python it does, but for most
unbiased users the distinction seems arbitrary.
George
--
http://mail.python.org/mailman/listinfo/python-list
several '\n' and when I use
> readline it does NOT read the whole my record.
> So If I could change '\n' as a record separator for readline, it
> would solve my problem.
> Any idea?
> Thank you
> L.
Check out this recipe, it's pretty generic:
http://asp
seq)', 'seq = range(100)').timeit()
> 0.20332271187463391
> >>> timeit.Timer('seq.__len__()', 'seq = range(100)').timeit()
>
> 0.48545737364457864
Common mistake; try this instead:
timeit.Timer('seqlen()',
'seq = range(100); seqlen=seq.__len__').timeit()
George
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 28, 6:01 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
> Is there a way I can, for debugging, access the instance variable name from
> within a class?
Shouldn't this be in a FAQ somewhere? It's the second time (at least!)
it comes up this week.
George
--
http://m
On Oct 31, 8:44 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> >> On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTE
doing it once only. That
> is not relevant to the question of whether len() should be a function or
> a method.
No disagreement here; I didn't bring up performance and it's not at
all a reason I consider len() as a function to be a design mistake.
What I dispute is Neil's asse
panded & splitted (and maybe even commented) with a
> VERBOSE, to improve readability, maybe somethign like:
>
> \d {1,3}
> (?=# lockahead assertion
> (?: \d {3} )+ $ # non-group
> )
>
> Bye,
> bearophile
That's 3 times faster on my box and works f
ularly
> > like the ElementTree library for accessing the data. Is there a way
> > to have ElementTree read only one record of the data at a time?
>
> Have you tried `iterparse()`?
>
> Ciao,
> Marc 'BlackJack' Rintsch
Detailed docs at http://effbot.org/zo
f.Buf_wp = 0
@revaluatable
def Draw(self, x1 = Deferred('self.Buf_rp'),
x2 = Deferred('self.Buf_wp')):
return (x1,x2)
p = PlotCanvas()
p.Buf_rp = 2
p.Buf_wp = -1
print p.Draw(), p.Draw(x2='foo')
HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list
be sure what a
> peek() => None signifies until the next iteration unless you
> don't expect None in your sequence.
There is a different implementation in the Cookbook already:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373
George
--
http://mail.python.org/mailman/listinfo/python-list
s and the implications
this may have in the future (e.g. how well does this play with
inheritance). Is this a valid use case for type-changing behavior or is
there a better, more "mainstream" OO design pattern for this ? I can
post the relevant code if necessary.
George
--
http://mail.python.org/mailman/listinfo/python-list
For what it's worth, I added it to the Cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499373
George
--
http://mail.python.org/mailman/listinfo/python-list
metaclass to generate the boilerate,
filling in the gaps. It doesn't impose any constraints on which
comparisons you must implement, e.g you may implement __le__ and
__eq__, or __gt__ and __ne__, etc. Season to taste.
http://rafb.net/p/mpvsIQ37.nln.html
George
--
http://mail.python.org/mailman/listinfo/python-list
mport isclass
> getclasses = lambda module: filter(isclass, vars(module).itervalues())
>
> Bye,
> bearophile
Or even:
from inspect import getmembers, isclass
def getclasses(module):
return [cls for name,cls in getmembers(module,isclass)]
George
--
http://mail.python.org/mailman/listinfo/python-list
7;s not possible in a
dynamic language; that's the price you have to pay for leaving the
static typing world".
As for the OP's question, since file is a fixed builtin, I think it
should be possible to know all the possible exceptions that can be
raised; I'm not sure if it's clearly documented though.
George
--
http://mail.python.org/mailman/listinfo/python-list
; nelements = 0
> for _ in iterator:
> nelements += 1
> return nelements
>
> Is it a good idea to extend the functionalities of the built-in len
> function to cover such situation too?
>
> Bye,
> bearophile
Is this a rhetorical question ? If not, try this:
>>> x = (i for i in xrange(100) if i&1)
>>> if leniter(x): print x.next()
George
--
http://mail.python.org/mailman/listinfo/python-list
ied at the user level ?
George
--
http://mail.python.org/mailman/listinfo/python-list
thon is actually more than a simple shell. Give it a try:
http://ipython.scipy.org/.
George
--
http://mail.python.org/mailman/listinfo/python-list
Nick Craig-Wood wrote:
> George Sakkis <[EMAIL PROTECTED]> wrote:
> > I've been trying to track down a memory leak (which I initially
> > attributed erroneously to numpy) and it turns out to be caused by a
> > memory mapped file. It seems that mmap caches withou
Martin v. Löwis wrote:
> George Sakkis schrieb:
> > I've been trying to track down a memory leak (which I initially
> > attributed erroneously to numpy) and it turns out to be caused by a
> > memory mapped file. It seems that mmap caches without limit the chunks
> &g
Dennis Lee Bieber wrote:
> On 21 Jan 2007 13:32:19 -0800, "George Sakkis" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> >
> > The file is written once and then opened as read-only, there's no
> > flushing. So if cachi
(float, line.split()) for line in
open('my_space_separated_file.txt')]
This stores the values as a list of lists, each list corresponding to a
row in the file. Depending on what you plan to do next with these
numbers, this may or may not be the best way to go about it, but since
you only mentioned the file reading part, we can't assume much.
George
--
http://mail.python.org/mailman/listinfo/python-list
ey do not have the authority to actually define its
legal ramifications. Check with your company legal staff.
Having said that, I have been troubled by trolltech's approach from
the beginning, and therefore stay away from it. PyGTK and wdxPython
are solid GUIs, without the legal uncertainty.
--
Harry George
PLM Engineering Architecture
--
http://mail.python.org/mailman/listinfo/python-list
ust works. Same scripts run on every platform. Bindings
available to every C/C++/FORTRAN library I've needed so far. Often
the bindings are not complete, but oddly enough the binding developers
have chosen to do just the functions I need, so who cares. A clean
architecture for adding more f
on" and any other kind, and I'm not aware of any
> case law that does so either. This distinction is also not codified in
> the GPL itself anywhere, so it's not a necessary condition of the
> license - it is an interpretation by the FSF and that is all.
[snip]
It is
ions by running python with '-O' or '-OO'.
Optimization flags should never change the behavior of a program, so
using assertions for what's part of the normal program behavior
(validating user-provided input) is wrong.
George
--
http://mail.python.org/mailman/listinfo/python-list
h the
complexity and the error-proneness of having two new
similar-but-not-quite-the-same APIs with sets. Not only iteration is
arguably the most common operation on a view, but the cost (in extra
keystrokes and runtime performance) of populating any container that
the user may need from an iterator is pretty low.
George
--
http://mail.python.org/mailman/listinfo/python-list
s that the vertices iterator creates new vertex objects every
time instead of iterating over the existing ones. This essentially
prevents, among other things, storing vertices as keys in a dictionary
since the hashes of the stored and the new vertex differ although they
compare equal. Is this real
ation isn't arbitrary.
Indeed, and that's because it is arbitrary. Python has the arbitrary
limitation that it's not Perl (or C, or Lisp or what have you).
George
--
http://mail.python.org/mailman/listinfo/python-list
chain(seq, repeat(fill, minlen-len(seq)))
>>> list(ipad('one;two;three;four'.split(";"), 7, ''))
['one', 'two', 'three', 'four', '', '', '']
>>> tuple(ipad(xrange(1,5), 7))
(1, 2, 3, 4, None, None, None)
George
--
http://mail.python.org/mailman/listinfo/python-list
nd add Numpy, Zope, Django, PIL,
pretty much everything actually. Even better, make CheeseShop just a
frontend to a build system that adds and updates automatically
submitted packages to the core. Problem solved ! .
George
--
http://mail.python.org/mailman/listinfo/python-list
print
>print '==== test 2 '
>print adict
>print construct(C, adict)
>
> if __name__ == "__main__":
>test()
What's the point of this ? You can call C simply by C(**adict). Am I
missing something ?
George
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 2, 3:39 pm, Mister Newbie <[EMAIL PROTECTED]> wrote:
> I have no programming experience. I want to learn Python so I can make
> simple, 2D games. Where should I start? Can you recommend a good book?
>
> Thank you.
http://www.amazon.com/Game-Programming-Python-Development/dp/1584502584
--
>>> f(1, y='bar')
Supplied: {'y': 'bar', 'x': 1}
Default: {'z': None}
>>> f(1, z=None)
Supplied: {'x': 1, 'z': None}
Default: {'y': 'bar'}
>>> f(1, 'bar', None)
Supplied: {'y': 'bar', 'x': 1, 'z': None}
Default: {}
>>> f(1, 'bar', z=None)
Supplied: {'y': 'bar', 'x': 1, 'z': None}
Default: {}
>>> f(1, z=None, y='bar')
Supplied: {'y': 'bar', 'x': 1, 'z': None}
Default: {}
Regards,
George
--
http://mail.python.org/mailman/listinfo/python-list
quot;similar to python" when the following is a program
> written in it? Compared to that, even Perl is a wonder of readability...
>
> (cryptic gibberish snipped)
>
> http://www.jsoftware.com/jwiki/Essays/The_Ball_Clock_Problem
>
> Diez
Please avoid posting code looking like garbled profanities in c.l.py.
This was outright offensive.
George
--
http://mail.python.org/mailman/listinfo/python-list
rophile
Here's another one, adapted from the example (in Java) in Wikipedia's
entry (http://en.wikipedia.org/wiki/Sierpinski_triangle):
N=15
for x in xrange(N,0,-1):
print ''.join('* '[x&y!=0] for y in xrange(N+1-x))
George
--
http://mail.python.org/mailman/listinfo/python-list
se IronPython?
An alternative might be to work (cross-platform) wit the vxd (XML)
file format. A good reader/writer for that would be handy.
--
Harry George
PLM Engineering Architecture
--
http://mail.python.org/mailman/listinfo/python-list
s the specific command, and only
then they appear (typically by Javascript). When the form is
submitted, the selected options are passed in the server in some form
that preserves the hierarchy, i.e. not as a flat dict. Is there
anything close to such a beast around ?
George
--
http://mail.python.org/ma
On Feb 18, 4:44 am, Gregor Horvath <[EMAIL PROTECTED]> wrote:
> George Sakkis schrieb:
>
> > I'd like to gather advice and links to any existing solutions (e.g.
> > libraries, frameworks, design patterns) on general ways of writing
> > complex web forms, as oppos
is this a typo?).
If you insist on using exec (which, again, you have no reason to for
this example), take the union of d's globals and locals as f's
globals, and store f in d's locals():
from math import *
G = 1
def d():
L = 1
g = dict(globals())
g.update(locals())
exec "def f(x): return L + log(G) " in g, locals()
return f(1)
George
--
http://mail.python.org/mailman/listinfo/python-list
f.__class__ is Foo
True
Is there a way (even hackish) to bypass this, or at least achieve
somehow the same goal (change f's class) ?
George
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 20, 7:57 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Mon, 19 Feb 2007 23:18:02 -0800, Ziga Seilnacht wrote:
> > George Sakkis wrote:
> >> I was kinda surprised that setting __class__ or __dict__ goes through
> >> the __setattr__ mechanism, lik
On Feb 20, 3:54 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> On 20 fév, 05:39, "George Sakkis" <[EMAIL PROTECTED]> wrote:
>
> > I was kinda surprised that setting __class__ or __dict__ goes through
> > the __setattr__ mechanism, like a norm
ly? seems like a big kludge.
Unless I missed something, this is a simple string replacement:
''.join(packet).replace('01110', '011100')
George
--
http://mail.python.org/mailman/listinfo/python-list
ot on 2.4
print os.waitpid(p.pid, 0)
What gives ?
George
--
http://mail.python.org/mailman/listinfo/python-list
or addition/removal/insertion of elements not making sense for a
heterogeneous data structure, have you heard of database schema
change ?
Heterogeneous data structures are well known for several decades now;
they are commonly spelled "records" though, not tuples, and have a
more reasonable API to support their semantics.
George
--
http://mail.python.org/mailman/listinfo/python-list
ocess' stdin that causes it to somehow proceed, I can read
> from its stdout.
>
> Thus a useful dialogue is not possible.
>
> Regards,
> -Justin
>
>
>
Have you considered using pexpect: http://pexpect.sourceforge.net/ ?
George
--
http://mail.python.org/mailman/listinfo/python-list
;mpstat" are bored at 0% load.
You are probably not aware of Python's Global Interpeter Lock:
http://docs.python.org/api/threads.html.
George
--
http://mail.python.org/mailman/listinfo/python-list
the same signature
in __init__. For all other methods though, given that you have an
instance x so that isinstance(x, ContinuedFraction), the client should
be able to say x.foo(arg, kwd=v) without having to know whether
x.__class__ is ContinuedFraction. If not, you have a leaky abstraction
[1], i.e.
s) are
pretty close to interfaces and have been accepted for Python 3 (http://
www.python.org/dev/peps/pep-3119/). Personally I don't see any
tangible benefit in having "pure" interfaces in additon to ABCs.
George
--
http://mail.python.org/mailman/listinfo/python-list
of code for such a common operation.
Instead, you can pass a string for attrs instead of a dictionary. The
string will be used to restrict the CSS class.
"""
http://www.crummy.com/software/BeautifulSoup/documentation.html#Searching%20by%20CSS%20class
George
--
http://mail.python.org/mailman/listinfo/python-list
= atom(next, token)
next() # Skip key-value delimiter (':')
token = next()
out[key] = atom(next, token)
token = next()
if token == ',':
token = next()
return out
raise SyntaxError('malformed expression (%r)' % token)
Regards,
George
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 19, 7:44 am, Bruno Desthuilliers wrote:
> George Sakkis a écrit :
>
>
>
> > On Nov 16, 5:03 pm, Steven D'Aprano <[EMAIL PROTECTED]
> > cybersource.com.au> wrote:
>
> >> On Fri, 16 Nov 2007 18:28:59 +0100, Bruno Desthuilliers wrote:
> >
either of these is true for Python. I
certainly wouldn't consider better a solution that required declaring
local variables (e.g. "local x = 0").
George
--
http://mail.python.org/mailman/listinfo/python-list
osts.
To the OP: yes, your use case is quite valid; the keyword you are
looking for is "memoize". You can find around a dozen of recipes in
the Cookbook and posted in this list; here's one starting point:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413717.
HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list
> use more of it.
If you bothered to click on that link you would learn that memoization
can be used to save space too and matches OP's case exactly; even the
identity tests work. Self-importance is bad enough by itself, even
without the ignorance, but you seem to do great in both.
George
--
http://mail.python.org/mailman/listinfo/python-list
ain specific toy language,
which might well turn out to be less expressive than necessary for the
given problem domain. I guess Lisp/Scheme would be even more suited
for this task but then again there's a Web framework (TurboGears), an
ORM (SqlAlchemy) an RPC middleware (Pyro) and a dozen more batteries,
both standard and 3rd party. Can't think of anything better than
Python for this project.
George
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 1, 9:06 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> Pythons are big, non-poisonous snakes good for keeping the rats out
> of a system
I'm looking forward to Spider(TM), the first bug-free language ;-)
--
http://mail.python.org/mailman/listinfo/python-list
Never occured to you that the
goofiness of the name "Google" is at least an order of magnitude
greater than Python. And FYI, Google didn't start out with the
popularity it enjoys today, it gained it *despite* the silly name.
Thanks God it was created by geeks and not clueless PHBs like
tually mean something), but this has
more to do with Perl's fall than Python's increase:
http://www.tiobe.com/tiobe_index/Perl.html.
Even more amazing is the rate C++ is losing ground:
http://www.tiobe.com/tiobe_index/C__.html
George
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 4, 11:07 am, Paul Rudin <[EMAIL PROTECTED]> wrote:
> George Sakkis <[EMAIL PROTECTED]> writes:
> > Even more amazing is the rate C++ is losing ground:
> >http://www.tiobe.com/tiobe_index/C__.html
>
> I don't really find surprising that low level lan
rowing too:
http://www.ohloh.net/languages/compare?measure=commits&percent=&l0=perl&l1=php&l2=python&l3=-1&l4=-1&commit=Update
George
--
http://mail.python.org/mailman/listinfo/python-list
ect magic! :-)
>
> Output should be:
>
> | Chicago: 3
> | Fort Lauderdale: 1
> | Jersey City And South Florida: 1
> | New York: 1
Alas, it's not:
AttributeError: 'module' object has no attribute 'dom'
Here's a working version, optimized for char length (one line, 241
chars):
import urllib as U,elementtree.ElementTree as
E;c=[E.parse(U.urlopen('http://api.etsy.com/feeds/xml_user_details.php?
id=%d'%u)).findtext('//city')for u in
71234,729,42346,77290,729,729];print'\n'.join('%s: %s'%
(i,c.count(i))for i in set(c))
George
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 10, 11:07 pm, Stargaming <[EMAIL PROTECTED]> wrote:
> On Mon, 10 Dec 2007 19:27:43 -0800, George Sakkis wrote:
> > On Dec 10, 2:11 pm, Stargaming <[EMAIL PROTECTED]> wrote:
> >> On Mon, 10 Dec 2007 16:10:16 +0200, Nikos Vergas wrote:
>
> >> [snip]
nt; the inverse is not true though: time and time again people
cared about some syntax for properties without any change so far. The
result is a handful of different ways to spell out properties; python
2.6 will add yet another variation (http://mail.python.org/pipermail/
python-dev/2007-October/075
t comparable to the decorator syntax sugar, if not
more. Alas, it was too much ahead of its time.. who knows, it might
revive on some 3.x version.
George
--
http://mail.python.org/mailman/listinfo/python-list
> def fget(self):
> return self._foo
> def fset(self, value):
> self._foo = value
That's almost identical to a recipe I had written once upon a time,
without requiring a syntax change:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698
George
--
efinition Pythonic since it was conceived by the BDFL.It
is also certainly an improvement over the current common practice of
polluting the class namespace with private getters and setters. Still
it's a kludge compared to languages with builtin support for
properties.
George
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 12, 2:23 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On Dec 12, 2007 12:53 PM, George Sakkis <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Dec 12, 1:12 pm, Christian Heimes <[EMAIL PROTECTED]> wrote:
>
> > > Kay Schluehr
nd) is not supported.
>
> I hope I am missing something. I really like Python but if there is no
> way to process data efficiently, that seems to be a problem.
20 times slower because of garbage collection sounds kinda fishy.
Posting some actual code usually helps; it's hard to tell for sure
otherwise.
George
--
http://mail.python.org/mailman/listinfo/python-list
eal of exposure to language and class library, So it would
> be great if anyone would suggest such framework as well.
>
> Looking forward for suggestions Python community!
You may want to check out these first:
http://dirtsimple.org/2004/12/python-is-not-java.html
http://www.razorvine.ne
On Dec 14, 9:57 am, Stargaming <[EMAIL PROTECTED]> wrote:
> On Tue, 11 Dec 2007 08:57:16 -0800, George Sakkis wrote:
> > Closer, but still wrong; for some weird reason, __import__ for modules
> > in packages returns the top level package by default; you have to use
> &
csvutils is a single Python module for easily transforming csv (or csv-
like) generated rows. The release is available at
http://pypi.python.org/pypi/csvutils/0.1.
Regards,
George
What is csvutils?
The standard csv module is very useful for parsing tabular data in CSV
en't so many or compelling use cases for rationals as
for decimals (mainly money counting).
George
--
http://mail.python.org/mailman/listinfo/python-list
ficient and general (e.g. for infinite series) using itertools:
from itertools import islice, chain, repeat
def unpack(iterable, n, default=None):
return islice(chain(iterable,repeat(default)), n)
a, b, c = unpack(seq, 3)
George
--
http://mail.python.org/mailman/listinfo/python-list
andard exception classes were old-style so it's not safe to
assume that you only have new style classes to worry about when the
very standard library includes lots of legacy code.
George
--
http://mail.python.org/mailman/listinfo/python-list
or rather 4th party since "they" are the 3rd party here ;-)) module.
Even if it's technically possible and the change doesn't break other
things, I'd rather not have to maintain a patched version of the
stdlib.
George
--
http://mail.python.org/mailman/listinfo/python-list
t pyparsing parser.
Here's the relevant thread: http://preview.tinyurl.com/2aeswn. Note
that the builtin eval() is around 5x faster than this parser, and from
the statement above, 50x faster than the pyparsing solution.
George
--
http://mail.python.org/mailman/listinfo/python-list
compiles without
> complaint. I'm pretty sure any line of the form "name = 0x" was a
> product of some form of programmer interruptus.
:-) Are you a fiction writer by any chance ? Nice story but I somehow
doubt that the number of lines of the form "name = 0x" ever written in
Python is greater than a single digit (with zero the most likely one).
George
--
http://mail.python.org/mailman/listinfo/python-list
3]
>>> for c in combinations(xrange(4), 3): print c
Traceback (most recent call last):
File "combs.py", line 54, in
for c in combinations(xrange(4), 3): print c
File "combs.py", line 12, in combinations
for cc in combinations(seq[i+1:], n-1):
TypeError: sequence index must be integer, not 'slice'
George
--
http://mail.python.org/mailman/listinfo/python-list
e alternative implementations. E.g., multiple
processors in parallel, more efficient algorithms, ctypes or pyrex to
speed up the python.
In terms of the overall project notion-to-delivery duration,
implementing in Python might be the right first step on your way to an
assembler implementation.
sssibly do the whole job, could it?"
If you have a good regression test suite, you are done when it works.
If you need help getting on board unittests, see mkpythonproj:
http://www.seanet.com/~hgg9140/comp/index.html#L006
--
Harry George
PLM Engineering Architecture
--
http://mail.python.org/mailman/listinfo/python-list
hat cites his linguistic
> foundations).
>
> -- Pad.
>
I used Python for computational linguistics coursework, but not since. Google
for "nlp python". E.g.:
http://nltk.sourceforge.net/
http://www.logilab.org/projects/hmm
http://www.cs.berkeley.edu/~russell/aima/pyt
ap a
DateRangeField to a table column). Any ideas on how to decouple the
field from its widget(s), even by tweaking/patching Django itself ?
George
--
http://mail.python.org/mailman/listinfo/python-list
self, a):
self.b += a
return self.b
x = SomeFancyClassName()
print x.f(1)
print x.f(2)
HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list
turn i
You can even shadow the builtin len() if you prefer:
import __builtin__
def len(iterable):
try: return __builtin__.len(iterable)
except:
i = 0
for x in iterable: i += 1
return i
HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list
idiom that I could use?
>
> Thanks.
I guess you want something like:
while True:
random.shuffle(letters)
trans_letters = ''.join(letters)[:len(original_set)]
if some_compatison(original_set,trans_letters):
trans_table = string.maketrans(original_set, trans_letters)
for report generation ?
Thanks,
George
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> [EMAIL PROTECTED] (Cameron Laird) writes:
> > For that matter, would it be an advantage for len() to operate
> > on iterables?
>
>print len(itertools.count())
>
> Ouch!!
How is this worse than list(itertools.count()) ?
--
http://mail.python.org/mailman/listinfo/python-l
Delaney, Timothy (Tim) wrote:
> George Sakkis wrote:
>
> > Paul Rubin wrote:
> >
> >> [EMAIL PROTECTED] (Cameron Laird) writes:
> >>> For that matter, would it be an advantage for len() to operate
> >>> on iterables?
> >>
> >>
801 - 900 of 1560 matches
Mail list logo