Bulba! wrote:
Hello everyone,
I'm reading the rows from a CSV file. csv.DictReader puts
those rows into dictionaries.
The actual files contain old and new translations of software
strings. The dictionary containing the row data looks like this:
o={'TermID':'4', 'English':'System Administration'
Jordan Rastrick wrote:
[CHOP]
Behold:
# An Acceptor/Generator!!!
def combineIntoRecords():
optionalline = None # We may not get given a value for this line
accept firstline
accept secondline
if condition(secondline):
accept optionalline
accept lastline
Mandus wrote:
> Tue, 20 Dec 2005 19:32:13 +0530 skrev Suresh Jeevanandam:
>
>>Hi all,
>> Lets say I have an array:
>> from numarray import *
>> a = array([ 6, 7, 8, 9, 10, 11, 12])
>>
>> I want to multiply out all the elements and get the result.
>>
>> r = 1.0
>>
Christian Tismer wrote:
> Simon Hengel wrote:
>
>>-BEGIN PGP SIGNED MESSAGE-
>>Hash: SHA1
>>
>>
>>>I'm envisioning lots of convoluted one-liners which
>>>are more suitable to a different P-language... :-)
>>
>>I feel that python is more beautiful and readable, even if you write
>>short pro
Steven D'Aprano wrote:
> On Sun, 25 Dec 2005 19:14:43 -0500, rbt wrote:
>
>
>>Steven D'Aprano wrote:
>>
>>>On Sun, 25 Dec 2005 18:05:37 +0100, Simon Hengel wrote:
>>>
>>>
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
>I'm envisioning lots of convoluted one-liners which
>
Is it necessary to keep the input parameter as 'input'? Reducing that to
a single character drops the length of a program by at least 8
characters. Technically it changes the interface of the function, so
it's a little bogus, but test.py doesn't check. (Personally I prefer
that if be illegal,
Remi Villatel wrote:
> André Malo wrote:
>
>
>>>is two lines and 347 characters ugly enough to win?
>
>
>>Nope. 3 lines / 179 chars here >:->
>>Yes, it's quite unreadable.
>
>
> I'm in for the second place with 4 lines / 228 chars.
>
>
>>(The problem is that I need to find an internet cafe
[EMAIL PROTECTED] wrote:
> Currently I'm on 149 characters in one line - 128 without
> spaces/newlines. (it'd be three characters shorter if it didn't have
> to end with a "\n")
It'll be interesting to see what the short 1-line answers look like. I
have a hard time seeing how that's done. It'l
Claudio Grondi wrote:
> Peter Otten wrote:
[SNIP]
>>How good is "good" for
>>
>>import test_vectors
>>seven_seg = test_vectors.test_vectors.get
>>
>>or code using the test suite in general?
>>
>>Peter
>>
>
> This started to remind myself about the story of the contest where the
> shortest program
Steven D'Aprano wrote:
> On Mon, 26 Dec 2005 13:33:42 -0700, Tim Hochberg wrote:
>
>
>>Claudio Grondi wrote:
>
>
>>>I am currently at 39 bytes following the requirements and the principle
>>>given above (my module passes the test). Anyone able to
Tim Hochberg wrote:
[CHOP]
>
> import test;seven_seg=test.test_vectors.get
>
> This works if you run test. It fails if you try to run it standalone
> since the import order is wrong.
[CHOP]
Or maybe not. An earlier version did, but this one seems OK.
-tim
--
http://mail.pyt
Paul McGuire wrote:
> "Shane Hathaway" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>>I'm down to 133 characters (counted according to 'wc -c') on a single
>>line. It contains about 11 whitespace characters (depending on what you
>>consider whitespace.) It's way too tricky for
Shane Hathaway wrote:
> Tim Hochberg wrote:
>
>>Paul McGuire wrote:
>>
>>
>>>"Shane Hathaway" <[EMAIL PROTECTED]> wrote in message
>>>news:[EMAIL PROTECTED]
>>>
>>>
>>>
>>>>I'm down to 133 chara
py pan wrote:
> When you guys say 127~150 characters, did you guys mean
> usinging test_vectors.py in some way? Or there's no import at all?
>
No import at all. The shortest solution reported so far is 131
characters. Getting down to 127 is just a guess as to where the lower
bound is likely to
Shane Hathaway wrote:
> Paul McGuire wrote:
>
>>"Paul McGuire" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED]
>>
>>
>>>Well *I'm* certainly looking forward to learning some new tricks! My
>>>(non-cheat) version is a comparatively-portly 245, and no alternatives are
>>>popping into
Jean-Paul Calderone wrote:
> On Tue, 27 Dec 2005 14:02:57 -0700, Tim Hochberg <[EMAIL PROTECTED]> wrote:
>
>>Shane Hathaway wrote:
>>
>>>Paul McGuire wrote:
>>>
>>>
>>>Also, here's another cheat version. (No, 7seg.com does n
Christian Tismer wrote:
[SNIP]
> And then help me to setup a different contest about content -- chris
As usual, I expect that actually having some working code measuring
'Pythonic' length (and I'm sure we could get into all sorts of fun
arguments about the exact definition of that) would go a l
[EMAIL PROTECTED] wrote:
> hi all
> am searching for a key in a list, am using
>
> Found = 0
> for item in list:
> if not key == item:
> Found = 0
> elif key == item:
> Found =1
>
> Now based on the Found value i ll manipulate the list.
> but whenev
Shane Hathaway wrote:
> I just found a 125 character solution. It's actually faster and more
> readable than the 133 character solution (though it's still obscure.)
>
> It depends on Python 2.4. If Python 2.3 compatibility is required for
> the contest, I have to add 4 characters.
I asked, 2.
Marius Gedminas wrote:
> Jean-Paul Calderone wrote:
>
>>On Tue, 27 Dec 2005 14:02:57 -0700, Tim Hochberg <[EMAIL PROTECTED]> wrote:
>>
>>>Shane Hathaway wrote:
>>>
>>>>Paul McGuire wrote:
>>>>
>>>>
>>>>Also
Shane Hathaway wrote:
> Andrew Durdin wrote:
>
>>On 12/28/05, Shane Hathaway <[EMAIL PROTECTED]> wrote:
>>
>>
>>>I just found a 125 character solution. It's actually faster and more
>>>readable than the 133 character solution (though it's still obscure.)
>>
>>
>>Having spent a good deal of time a
Shane Hathaway wrote:
> André wrote:
>
>>For the few that might be interested, I will be posting the details of
>>a 117 character long solution to the challenge on my blog
>>http://aroberge.blogspot.com/.
>>
>>Enjoy!
>
>
> You took advantage of prime numbers, enabling you to extract encoded
> i
Brian van den Broek wrote:
> Gerard Brunick said unto the world upon 08/01/06 01:27 PM:
>
>>My way is ugly. These has to be a better way.
>>
>>Thanks,
>>Gerard
>
>
> If you'd posted your way, I might well have seen if I could do it in a
> nicer fashion. But, since for all I know, my best effor
Michael Spencer wrote:
> > Robin Becker schrieb:
> >> Is there some smart/fast way to flatten a level one list using the
> >> latest iterator/generator idioms.
> ...
>
> David Murmann wrote:
> > Some functions and timings
> ...
Here's one more that's quite fast using Psyco, but only average w
robert wrote:
> Turning algs for old NumPy modules into numpy code I suffer from this:
> Upon further processing of returns of numpy calculations, lots of data in an
> apps object tree will become elementary numpy types.
> First there is some inefficiency in calculations. And then you get data
>
Chris wrote:
> This is just some dummy code to mimic what's being done in the real
> code. The actual code is python which is used as a scripting language in
> a third party app. The data structure returned by the app is more or
> less like the "data" list in the code below. The test for "ELEMEN
Filip Wasilewski wrote:
> robert wrote:
>> I have an integer array with values limited to range(a,b) like:
>>
>> ia=array([1,2,3,3,3,4,...2,0,1])
>>
>> and want to speedly count the frequencies of the integers into get a density
>> matrix.
>> Is this possible without looping?
>
> See numpy.bincou
John Machin wrote:
> Jacob Rael wrote:
>> Hello,
>>
>> I have a simple script to parse a text file (a visual basic program)
>> and convert key parts to tcl. Since I am only working on specific
>> sections and I need it quick, I decided not to learn/try a full blown
>> parsing module. My simple scri
Szabolcs Nagy wrote:
>>Basically all I need is vectors and 3x3 matrices.
>
>
> hmm
> is numpy really efficient for 3x3 (or 4x4) matrices and vectors?
>
> IMHO an optimized matrix4x4 class can be much faster (i'm just guessing
> here)
>
> eg cgtypes is a simple c++ implementation with boost-pyth
mclaugb wrote:
> Is Scipy the same thing as ScientificPython?
> I am confused if SciPy is just the new version. they appear to be separate
> things.
> Bryan
No, Scientific Python is "a collection of Python modules that are useful
for scientific computing" written by Konrad Hinsen. I'm not a use
[EMAIL PROTECTED] wrote:
> I have a module that defines a variable with a constant value and now I
> need to make that value dynamic, without affecting module clients. In
> other words, I need to call a function witout using parenthesis.
> Example:
>
> mymod.py--
>
> def value
[EMAIL PROTECTED] wrote:
> Fredrik Lundh wrote:
>
>>>Python now has, what, three built-in mutable collections types:
>>>lists, dictionaries, and sets. Dicts and sets both have a clear()
>>>method and lists do not.
>>
>>dicts and sets are mappings, and lists are not. mappings don't
>>support slici
While not nearly the shortest proposed thus far, I'm fond of:
from itertools import count, ifilter
def sieve(s=count(2)):
while 1:p=s.next();s=ifilter(p.__rmod__,s);yield p
It will generate quite a large number of primes before blowing up (at
least 50,000 primes, p=611,957) and it's much fast
In the spirit of pointless pessimization and obfuscation I have crushed
something very similar to Alex Martelli's eratosthenes function onto a
single line. It's truly monstrous, but somewhat entertaining [Some
preemptive linebreaks added]:
def short():import itertools as it;D={};g=D.get;return
Avi Kak wrote:
> Hello:
>
>Suppose I write a function that I want to be called
>with ONLY keyword argumnts, how do I raise an
> exception should the function get called with
> what look like position-specfic arguments?
>
> Any help would be appreciated.
Say you want the signature
Erik Max Francis wrote:
> Roy Smith wrote:
>
>
>>A more interesting question is what do you call ()? A none-tuple?
>
>
> Yeah, that's at the point where it _really_ departs from anything
> remotely mathematical. Don't think I've ever heard the occasion to talk
> about 0-tuples in any contex
Colin J. Williams wrote:
>>
>>It would be good if the range and slice could be merged in some way,
>>although the extended slice is rather complicated - I don't understand it.
>>
>> The semantics for an extended slicing are as follows. The primary
>> must evaluate to a mapping object, and it i
[EMAIL PROTECTED] wrote:
> Tim Hochberg wrote:
>
>>Colin J. Williams wrote:
>>
>>
>>>>It would be good if the range and slice could be merged in some way,
>>>>although the extended slice is rather complicated - I don't understand it.
>>&g
Anthony Liu wrote:
> I am talking about the 'take' method of numarray.
>
> See here for more info:
>
> http://stsdas.stsci.edu/numarray/Doc/node33.html
>
> If I initialize a matrix 'mymatrix' by zeros((3,3),
> type="Float64"), I get a 3*3 matrix of all zeros.
>
> Look:
>
>
from numarray i
[Lots of proposals snipped]
90% of my gripes with range disappeared with the addition of enumerate.
However, if there's going to be another round of range literal proposals
I might as well throw out what seems (to me anyway) like the only
halfway obvious choice in the context of Python.
1. a:
Fredrik Lundh wrote:
> "Cassiano, Marco" wrote:
>
>
>>I have difficulties with a weird Python 2.4.2 behaviour in comparing
>>Decimal to Floats.
>>
>>For Example :
>>
>>
>>
>from decimal import Decimal
>a=Decimal('3.7')
>b=6.3
>>
>if a > b :print a,b,'a is greater than b - NOT TRUE
Magnus Lycka wrote:
> Dennis Lee Bieber wrote:
[SNIP]
>
>> For CPU-bound number-crunching, perhaps... For I/O-bound jobs, the
>>GIL is(should be) released when ever a thread is blocked waiting for I/O
>>to complete.
>
>
> I think CPU-bound number-crunching was the big deal in this case.
> S
Carl Banks wrote:
> Mike Orr wrote:
>
>>>I think this PEP is going off the rails. It's primary virtue was that it
>>
>>was a simpler, clearer way to write:
>>
>> class Foo(args):
>>__metaclass__ = some_metaclass
>>#...
>>
>>And it doesn't even do that. What's wrong with "class
Carl Banks wrote:
> Tim Hochberg wrote:
>
>>Carl Banks wrote:
>>
>>>Mike Orr wrote:
>>>
>>>
>>>>>I think this PEP is going off the rails. It's primary virtue was that it
>>>>
>>>>was a simpler, clea
Paul Rubin wrote:
> "Tuvas" <[EMAIL PROTECTED]> writes:
>
>>I've actually done the tests on this one, it's actually faster to use
>>the += than a list, odd as it may sound.
>
>
> Frederik explained the reason; there's an optimization in Python 2.4
> that I'd forgotten about, for that specific c
Michael Brenner wrote:
> Hi,
>
> I'm implementing a plugin-based program, structured like the example
> below (where m1 in the main module, loading m2 as a plugin). I wanted
> to use a single global variable (m1.glob in the example) to store some
> config data that the plugins can access. How
[EMAIL PROTECTED] wrote:
> richard wrote:
> [snip]
> Should the "Python Cheeseshop" have anything in it, though? Having a
> stocked cheese shop in relation to Python is just silly!
Well, it shouldn't have any *cheese*, but that's probably OK for a
software repository.
--
http://mail.python.org
Kent Johnson wrote:
> David Bear wrote:
>
>>I'm attempting to use the cgi module with code like this:
>>
>>import cgi
>>fo = cgi.FieldStorage()
>># form field names are in the form if 'name:part'
>>keys = fo.keys()
>>for i in keys:
>>try:
>>item,value=i.split(':')
>>
Tim Hochberg wrote:
> Kent Johnson wrote:
>
>>David Bear wrote:
>>
>>
>>>I'm attempting to use the cgi module with code like this:
>>>
>>>import cgi
>>>fo = cgi.FieldStorage()
>>># form field names are in t
Kent Johnson wrote:
> Tim Hochberg wrote:
>
>>Kent Johnson wrote:
>>
>>>David Bear wrote:
>>>
>>>
>>>>I'm attempting to use the cgi module with code like this:
>>>>
>>>>import cgi
>>>>fo = cgi.Fiel
Steven Bethard wrote:
> Steven Bethard wrote:
>
>>Duncan Booth wrote:
>>
>>>Steven Bethard wrote:
>>>
>>>
Should users of the make statement be able to determine in which dict
object the code is executed? The make statement could look for a
``__make_dict__`` attribute and call it to a
Steven Bethard wrote:
> Steven Bethard wrote:
>
>>Tim Hochberg wrote:
>>
>>>Steven Bethard wrote:
>>>
>>>>Steven Bethard wrote:
>>>>
>>>>>Duncan Booth wrote:
>>>>>
>>>>>>
Tim Hochberg wrote:
> Steven Bethard wrote:
>
>> Steven Bethard wrote:
>>
>>> Tim Hochberg wrote:
>>>
>>>> Steven Bethard wrote:
>>>>
>>>>> Steven Bethard wrote:
>>>>>
>>>>>> Dun
53 matches
Mail list logo