Neil Cerutti wrote:
> On 2006-09-26, Neal Becker <[EMAIL PROTECTED]> wrote:
> > Any suggestions for transforming the sequence:
> >
> > [1, 2, 3, 4...]
> > Where 1,2,3.. are it the ith item in an arbitrary sequence
> >
> > into a succession of tuples:
> >
> > [(1, 2), (3, 4)...]
> >
> > In other wo
Steve Holden wrote:
> George Sakkis wrote:
> > Neil Cerutti wrote:
> >
> >
> >>On 2006-09-26, Neal Becker <[EMAIL PROTECTED]> wrote:
> >>
> >>>Any suggestions for transforming the sequence:
> >>>
> >>>[1, 2, 3, 4...
[EMAIL PROTECTED] wrote:
> I dont mean google
> i dont mean onelook.com
>
> these are only examples
>
> i hop eyou understand what i mean
Apparently, *you* don't understand what they're trying to tell you. It
roughly boils down to the following:
- All (except perhaps the most trivial small) site
Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, George
> Sakkis wrote:
>
> > Lawrence D'Oliveiro wrote:
> >
> >> Fredrik Lundh wrote:
> >> > you're not the designer...
> >>
> >> I don't have to be.
Antoon Pardon wrote:
> What bothers me a bit about the rejection of PEP 326 is that one of the
> reasons stated is:
>
> http://mail.python.org/pipermail/python-dev/2004-January/042306.html
>
> - it is easily implemented when you really need it
>
> Well I thought it would simplify some things f
John Martin wrote:
> 'pythonol' is a program for learning spanish. I think it's a really great
> program. Unfortunately it ceased to work when I moved to SuSE 10 and 10.1 .
> The author makes it clear on her website that she has devoted all the time
> she's prepared to and won't maintain it. I thi
efrat wrote:
> 1. What exactly is a Python list? If one writes a[n], then is the
> complexity Theta(n)? If this is O(1), then why was the name "list"
> chosen? If this is indeed Theta(n), then what alternative should be
> used? (array does not seem suited for teaching purposes.)
Indexing for pyth
Gabriel Genellina wrote:
> At Thursday 28/9/2006 22:07, Lawrence D'Oliveiro wrote:
>
> >How about this: (where n is the integer you want to convert):
> >
> > "".join([["0", "1"][(1 << i & n) != 0] for i in
> > range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)])
>
> Uhm... so to generate a bina
Steve Holden wrote:
> MonkeeSage wrote:
> > So far as unobfuscated versions go, how about the simple:
> >
> > def to_bin(x):
> > out = []
> > while x > 0:
> > out.insert(0, str(x % 2))
> > x = x / 2
> > return ''.join(out)
> >
> > Regards,
> > Jordan
> >
> >>> to_bin(0)
> ''
>
> 6/
Matthew Wilson wrote:
> I wrote a function that I suspect may already exist as a python builtin,
> but I can't find it:
>
> def chunkify(s, chunksize):
> "Yield sequence s in chunks of size chunksize."
> for i in range(0, len(s), chunksize):
> yield s[i:i+chunksize]
>
> I wrote thi
Matthew Wilson wrote:
> I'm writing a function that accepts a function as an argument, and I
> want to know to all the parameters that this function expects. How can
> I find this out in my program, not by reading the source?
>
> For example, I would want to know for the function below that I hav
Ben Cartwright wrote:
> [EMAIL PROTECTED] wrote:
> > Hey, I have the following code that has to send every command it
> > receives to a list of backends.
>
> > I would like to write each method like:
> >
> > flush = multimethod()
>
> Here's one way, using a metaclass:
Or if you don't mind a
Kai Kuehne wrote:
> Hi list!
> It is possible to overwrite only one function with the property-function?
>
> x = property(getx, setx, delx, 'doc')
>
> I just want to overwrite setx, but when I set the others to None,
> I can't read and del the member. Any ideas or is this not possible?
There are
James Stroud wrote:
> walterbyrd wrote:
> > Reading "Think Like a Computer Scientist" I am not sure I understand
> > the way it describes the way objects work with Python.
> >
> > 1) Can attributes can added just anywhere? I create an object called
> > point, then I can add attributes any time, an
Bruno Desthuilliers wrote:
> AFAIK, everything you do with old-style classes can be done with new-style
> ones.
The only thing I occasionally (or rather rarely) miss about old-style
classes is instance-specific special methods:
>>> class C:
... def __init__(self,x):
... self.__getit
Thuan Seah Tan wrote:
> Hi all,
>
> I am new to python and currently I am working on a traffic simulation
> which I plan to define the various agents using scripting. It's kind of like
> scripting for non-playable character in games. I am thinking of using python
> for this but I am concerned
Will McGugan wrote:
> > #!/usr/bin/python -OO
> > import math
> > import sys
> > import psyco
> >
> > psyco.full()
> >
> > def primes():
> > primes=[3]
> > for x in xrange(5,1000,2):
> > maxfact = int(math.sqrt(x))
> > flag=True
> > for y in primes:
> >
Carl Banks wrote:
> alf wrote:
> > Hi,
> > is there a more elegant way to get o.__class__.__name__. For instance I
> > would imagine name(o).
>
> def name_of_type(o):
> return o.__class__.__name__
>
> name_of_type(o)
>
>
> Carl Banks
>
> P.S. name(o) suggests it's the name of the object, not t
Evan wrote:
> Hi
>
> I have a short script that makes 2 calls to methods in another script
> as follows:
>
> import canPlaces as canp
>
> callOne=canp.addMe(3,5)
> callTwo=canp.estocStn()
>
> The 2 methods in the second script are:
>
> def addMe(a,b)
>sumAb=a+b
>return sumAb
>
> def
Jon Harrop wrote:
> Ok. Perhaps starting a Python JIT in something like MetaOCaml or Lisp/Scheme
> would be a good student project?
I guess for a student project it's not that important, but if you have
higher ambitions, make sure you read
http://dirtsimple.org/2005/10/children-of-lesser-python.h
[EMAIL PROTECTED] wrote:
> Hi,
>
> I need to parse a binary file produced by an embedded system, whose
> content consists in a set of events laid-out like this:
>
> ...
>
> Every "event" is a single byte in size, and it indicates how long is
> the associated "data". Thus, to parse all events
[EMAIL PROTECTED] wrote:
> I am sure this is a basic math issue, but is there a better way to
> ensure an int variable is divisible by 4 than by doing the following;
>
> x = 111
> x = (x /4) * 4
>
> Just seems a bit clunky to me.
if x % 4 == 0:
# x is divisible by 4
George
--
http://mail.pyt
Romulo A. Ceccon wrote:
> George Sakkis wrote:
>
> > If you actually intend to
> > 1) name your Event subclasses Evt1, Evt2, ... EvtN and not give more
> > descriptive (but unrelated to the magic event number) names
>
> No, those names are just an example. The act
Simon Bunker wrote:
> Hi I have code similar to this:
>
> class Input(object):
>
> def __init__(self, val):
> self.value = val
>
> def __get__(self, obj, objtype):
> return self.value
>
> def __set__(self, obj, val):
> # do some checking... only accept flo
[EMAIL PROTECTED] wrote:
> George Sakkis wrote:
> > Simon Bunker wrote:
> >
> > > Hi I have code similar to this:
> > >
> > > class Input(object):
> > >
> > > def __init__(self, val):
> > > self.value = val
&g
Jeff Rush wrote:
> These works are to be formed into advocacy kits for various audiences. So far
> we have the following ideas for kits:
>
>- College Student's Python Advocacy Kit
>- IT Department Python Advocacy Kit
>- University Educator's Python Advocacy Kit
>- K-12 Educator's
Danny Colligan wrote:
> > Is there a list somewhere listing those not-so-obvious-idioms?
>
> I don't know about lists of not-so-obvious idioms, but here's some
> gotchas (there may be some overlap with what you're asking about):
>
> http://zephyrfalcon.org/labs/python_pitfalls.html
> http://www.fer
Steven D'Aprano wrote:
> On Thu, 07 Dec 2006 13:52:33 -0800, George Sakkis wrote:
>
> > I'm surprized that none of these pages mentions the incompatible type
> > comparison gotcha:
> >
> >>>> 5 < "4"
> > True
> >
> >
manstey wrote:
> I have a ClassWrapper that wraps around a third party database object.
> Each database object has a set of properties, like columns in a
> relational database.
>
> I want my wrapper to generate a property for each database object and
> load its value into it.
>
> Thus, in my datab
Allen wrote:
> Does anyone agree with me?
> If you have used Matlab, welcome to discuss it.
Sure, and earth is a heavy version of a basketball. If all you have is
a hammer...
George
--
http://mail.python.org/mailman/listinfo/python-list
Alex Mizrahi wrote:
> (message (Hello 'Istvan)
> (you :wrote :on '(8 Dec 2006 06:11:20 -0800))
> (
>
> ??>> seems to show that Python is a cut down (no macros) version of Lisp
> ??>> with a worse performance.
>
> IA> or maybe it shows that Lisp is an obfuscated version of Python
>
> hell no, l
André Thieme wrote:
> On the other hand can I see difficulties in adding macros to Python,
> or inventing a new object system, or adding new keywords without
> changing the sources of Python itself.
Actually, an even bigger difficulty is the rejection of programmable
syntax by Guido, both for the
[EMAIL PROTECTED] wrote:
> Okay, since everyone ignored the FAQ, I guess I can too...
>
> Mark Tarver wrote:
> > How do you compare Python to Lisp? What specific advantages do you
> > think that one has over the other?
>
> (Common) Lisp is the only industrial strength language with both pure
> com
Ken Tilton wrote:
> George Sakkis wrote:
> > [EMAIL PROTECTED] wrote:
> >
> >>Okay, since everyone ignored the FAQ, I guess I can too...
> >>
> >>Mark Tarver wrote:
> >>
> >>>How do you compare Python to Lisp? What sp
manstey wrote:
> We've looked at them a little. Cache is a native OO dbase, so there is
> no ORM required. Cache does that for you behind the scenes if you need
> it to. What I want is to translate Cache classes and properties into
> Python classes and properties. We can only use class wrappers, b
Cliff Wells wrote:
> On Sat, 2006-12-09 at 00:26 -0800, hankhero wrote:
>
> > The Common-Lisp object systems has all and more OO-features, some which
> > you never probably have thought of before. Here's one:
> > Inheritance lets you specialise a method so a rectangle and a circle
> > can have a d
tom arnall wrote:
> >object data member dumper?
> >George Sakkis george.sakkis at gmail.com
> >Wed Nov 8 03:42:47 CET 2006
>
> > tom arnall wrote:
> >
> > > Bruno Desthuilliers wrote:
> > >
> > > > tom arnall a écrit :
> > >
Robert Uhl wrote:
> o Macros
>
> As mentioned above, macros can make one's life significantly nicer. I
> use Python a lot (it's currently a better choice than Lisp for many of
> the problems I face), and I find myself missing macros all the time.
> The ability to take some frequently-used idiom a
I wonder if the following is possible:
def inject_n_call(func, **kwds):
'''Call func by first updating its locals with kwds.'''
def f():
return x*y
>>> inject_n_call(f, x=3, y=4)
12
I've been playing with sys.settrace, updating frame.f_locals in the
trace function, but it doesn't seem t
Gabriel Genellina wrote:
> On 12 dic, 17:46, "George Sakkis" <[EMAIL PROTECTED]> wrote:
>
> > I wonder if the following is possible:
> >
> > def inject_n_call(func, **kwds):
> > '''Call func by first updating its locals with
Bill Atkins wrote:
> greg <[EMAIL PROTECTED]> writes:
>
> > When moving a set of statements in Python, you
> > are usually selecting a set of complete lines,
> > cutting them out and then pasting them in
> > between two other lines somewhere else.
>
> You're missing Ken's point, which is that in L
George Sakkis wrote:
> Gabriel Genellina wrote:
> > On 12 dic, 17:46, "George Sakkis" <[EMAIL PROTECTED]> wrote:
> >
> > > I wonder if the following is possible:
> > >
> > > def inject_n_call(func, **kwds):
> > > '
Hi there,
I'm happy to announce Pyflix, a small Python package that provides an
easy entry point for those wishing to get up and running at the Netflix
Prize competition (http://www.netflixprize.com/). For those who are not
aware of it, the Netflix Prize challenge is to write a recommendation
algo
king kikapu wrote:
> Your example Dennis, work as expected. I understand the mistake i have
> made. But when i try to fix the original code usihn @property now, it
> gives me the same error.
> So, here it is:
>
> class Person(object):
> _age = 0
>
> @property
> def age():
> def
Christoph Zwerschke wrote:
> The statement "if you are looking for index() or count() for your
> tuples, you're using the wrong container type" is too extreme I think. I
> would agree with "it *may indicate* that you should better use lists".
And also if that statement was correct, I would argue
king kikapu wrote:
> Your example Dennis, work as expected. I understand the mistake i have
> made. But when i try to fix the original code usihn @property now, it
> gives me the same error.
> So, here it is:
>
> class Person(object):
> _age = 0
>
> @property
> def age():
> def
king kikapu wrote:
> Your example Dennis, work as expected. I understand the mistake i have
> made. But when i try to fix the original code usihn @property now, it
> gives me the same error.
> So, here it is:
>
> class Person(object):
> _age = 0
>
> @property
> def age():
> def
king kikapu wrote:
> Your example Dennis, work as expected. I understand the mistake i have
> made. But when i try to fix the original code usihn @property now, it
> gives me the same error.
> So, here it is:
>
> class Person(object):
> _age = 0
>
> @property
> def age():
> def
The following snippet results in different outcome for (at least) the
last three major releases:
>>> import urllib
>>> urllib.unquote(u'%94')
# Python 2.3.4
u'%94'
# Python 2.4.2
UnicodeDecodeError: 'ascii' codec can't decode byte 0x94 in position 0:
ordinal not in range(128)
# Python 2.5
u'\x9
Fredrik Lundh wrote:
> George Sakkis wrote:
>
> > The following snippet results in different outcome for (at least) the
> > last three major releases:
> >
> >>>> import urllib
> >>>> urllib.unquote(u'%94')
> >
> > # P
Gert Cuykens wrote:
> > > class HelloWorld(object):
> > > @cherrypy.exposed
> > > def index(self):
> > >return "Hello World"
>
> do i have to write @cherrypy.exposed before every def or just once for
> all the def's ? and why not write something like @index.exposed ?
>
> in other wo
John Machin wrote:
> Bruno Desthuilliers wrote:
>
> >
> > Python is dynamic, and fighting against the language is IMHO a really
> > bad idea. The only places where theres a real need for this kind of
> > stuff are when dealing with the "outside world" (IOW : inputs and
> > outputs). And then packa
Duncan Booth wrote:
> "John Machin" <[EMAIL PROTECTED]> wrote:
>
> >> > if isinstance(
> >> > action_for_type1(...
> >> > # big snip
> >> > elif isinstance(...
> >> > action_typeN( ...
> >> > # no else statement
> >>
> >> Ouch.. someone must have skipped his/her OO class...
> >
> > Qui
John Machin wrote:
> Peter Wang wrote:
> > Bruno Desthuilliers wrote:
> > >
> > > Python is dynamic, and fighting against the language is IMHO a really
> > > bad idea. The only places where theres a real need for this kind of
> > > stuff are when dealing with the "outside world" (IOW : inputs an
Bruno Desthuilliers wrote:
> FWIW, I guess that what you want here may looks like this:
>
> class Word(object):
>def __init__(self, word=''):
> self._word = word
>def __repr__(self):
> return "" % (self._word, id(self))
>
>
> words = []
> for w in ['this', 'is', 'probably', 'what
dwelden wrote:
> I have successfully used the sort lambda construct described in
> http://mail.python.org/pipermail/python-list/2006-April/377443.html.
> However, how do I take it one step further such that some values can be
> sorted ascending and others descending? Easy enough if the sort values
vizcayno wrote:
> Hello:
> Need your help in the "correct" definition of the next function. If
> necessary, I would like to know about a web site or documentation that
> tells me about best practices in defining functions, especially for
> those that consider the error exceptions management.
> I h
> Any tips, stories, recommendations, and/or experiences are most
> welcome.
Just one suggestion, read the article "Things You Should Never Do, Part
I" first (
http://www.joelonsoftware.com/articles/fog69.html). Quoting
from the article:
(Netscape made) "the *single worst strategic mistak
You may want to start from HarvestMan:
http://harvestman.freezope.org/
George
--
http://mail.python.org/mailman/listinfo/python-list
rtilley wrote:
> Duncan Booth wrote:
>
>> How about just concatentating the two lists:
>>
>>> for root, dirs, files in os.walk(path):
>>
>>for fs_object in files + dirs:
>>
>>> ADD fs_object to dictionary
>
>
> Thank you Duncan! that solves the problem perfectly!
Or a bit more effi
Using the (non-standard yet) path module
(http://www.jorendorff.com/articles/python/path/), your code can be
simplified to:
from path import path, copy
def copy_first_match(repository, filename, dest_dir):
try:
first_match = path(repository).walkfiles(filename).next()
except StopI
You'd probably get more results by searching for "web crawlers" or "web
spiders". You may start from here:
http://harvestman.freezope.org/faq.html
HTH,
George
--
http://mail.python.org/mailman/listinfo/python-list
Is there any tool in python (or with python bindings) like Oracle
Application Express, former HTML DB
(http://www.oracle.com/technology/products/database/application_express/index.html)
? Ideally it should be dbms-agnostic, e.g. by using SQLObject to talk
to the database. The closest I can think of
Learn about ther itertools module, one of the most useful and elegant
modules in the standard library
(http://docs.python.org/lib/module-itertools.html):
import itertools as it
colors = ["#ff", "#00FF00", "#FF"]
words = "Itertools is a pretty neat module".split()
for word_color in it.izip(
"Peter Otten" <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
>
> > What's the fastest and most elegant equivalent of zip() in
> > Numeric/Numarray between two equally sized 1D arrays ? That is, how
to
> > combine two (N,)-shaped arrays to one (N,2)
"Peter Otten" <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
>
> > Though not the fastest to execute; using concatenate instead of
> > initializing an array from a list [a,a] is more than 2,5 time
faster in
> > my system (~4.6 vs 11.8 usec per loop a
"Tim Henderson" <[EMAIL PROTECTED]> wrote:
> Hello
>
> I want to creat a program that can inspect a set of classes that i
have
> made and spit out a savable version of these classes. To do this I
need
> to be able to inspect each class and get all of its instance data as
> well as information about
> > I have no idea how to do the inspection part of this little
> > problem. I could just have each class define its own meathod to
> > convert to this format, but that would be a lot of work when i
> > could just make one class that solves the problem for all classes.
> > Is there a way to do this
This newsgroup is in general very helpful, but there are some
exceptions; one of them is when the problem appears blatantly to be a
homework. Perhaps if you showed that you worked on it and made some
progress, but it's not quite right, someone may help you.
George
--
http://mail.python.org/mailm
"bruno modulix" <[EMAIL PROTECTED]> wrote:
> Josef Meile wrote:
> (snip)
> >
> > I don't find this two replies funy :-(. I think it is impolite to
make
> > fun of the OP.
>
> My intent was not to make fun *of* the OP. Now I'm willing to admit
that
> my answer may not be as (kindly) funny as intend
I came across a strange error when trying to define a settable property
for a new-style subclass of UserArray (Numeric). Here's a shorter
example that reproduces the problem:
from UserArray import UserArray
from math import hypot
class Vector(UserArray,object):
def __init__(self,x,y):
"Florian Lindner" wrote:
> Hello,
> when I'm iterating through a list with:
>
> for x in list:
>
> how can I get the number of the current iteration?
>
> Thx,
>
> Florianfor
in python 2.3+:
for i,x in enumerate(sequence):
print "sequence[%d] = %s" %(i,x)
George
--
http://mail.python.org/
To answer my own question, the error is caused by the __setattr__
defined in UserArray:
def __setattr__(self,attr,value):
if attr=='shape':
self.array.shape=value
self.__dict__[attr]=value
I'm not sure though how to "undefine" __setattr__ in a subclass so that
property
> What disappoints me is that pyton will happily accept and execute
this
> code :
>
> if ( aConditionThatIsFalse ):
> AFunctionThatIsntDefined()
>
> print "Hello world"
>
> The fact that python doesn't check if the symbol
> AFunctionThatIsntDefined is defined, is really bad when you develop
bi
Does cimport work for importing from different packages in Pyrex ?
Here's a minimal example:
# in ./foo/bar.pxd
cdef class Bar:
cdef int i
# in ./foo/bar.pyx
cdef class Bar:
def __init__(self, i):
self.i = i
# in ./tmp.pyx
cimport foo.bar
$ pyrexc foo/bar.pyx
$ pyrexc tmp.pyx
tm
"Fredrik Lundh" wrote :
> [EMAIL PROTECTED] wrote:
>
> > To understand a program, however, you need also a flow chart...
>
> so understand a carefully designed modular component structure, you
> have to remove the structure so you can create a flow chart?
>
> did you perhaps stumble upon a strange
> Cuz I think the Language Reference is really more of a grammer
reference and
> far too technical to look up simple things like "how to declare a
> function".
>
> I guess what I'm trying to say is that there is no manual (for the
language
> itself, not the modules). There is just the tutorial tha
> Hi All,
>
> Could someone show me how to do this?
>
> I want to generate a list using a Markov chain, however, as well as
> using the previous two items in the list to decide the current choice
I
> want the decision to be also dependant on an item at the current
> position in another list.
>
> I
"Thomas W" wrote:
> I'm developing a web-application where the user sometimes has to
enter
> dates in plain text, allthough a format may be provided to give
clues.
> On the server side this piece of text has to be parsed into a
datetime
> python-object. Does anybody have any pointers on this?
>
>
"praba kar" <[EMAIL PROTECTED]> wrote:
>
> Dear All,
>
> I have doubt regarding date string to time
> conversion function. In Python I cannot find flexible
> date string conversion function like php strtotime. I
> try to use following type
> function
> 1) parsedate function failed if a date s
"John Machin" <[EMAIL PROTECTED]> wrote:
> On 16 May 2005 17:51:31 -0700, "George Sakkis" <[EMAIL PROTECTED]>
> wrote:
>
>
> >#===
> >
> >def parseDateTime(string, USA=Fal
"flamesrock" wrote:
> I don't understand.. why is everyone talking about christ on
> comp.lang.python? Isn't this not the place?
>
Maybe they know something we don't.
--
http://mail.python.org/mailman/listinfo/python-list
"Ivan Van Laningham" wrote:
> What you're going to run into are two major stumbling blocks. One,
> Python's got no credibility with management types unless the
> credibility's already there. "Python? Never heard of it. Tell me
> about it. ... Oh, it's interpreted, is it? Interesting." You
"Kay Schluehr" wrote:
> > Think about it: if the
> > project fails (and that's quite likely for huge projects, not dark
> > humour) and you've done it in python, everyone will blame python
and
> > you who chose it; java OTOH belongs in the realm of "standard
> business
> > practices", so in a way
"Steven Bethard" wrote:
> It would help if you explained what you expected. But here's code
that
> prints about the same as your non-generator function.
>
> py> def bin(n):
> ... s = []
> ... def bin(n):
> ... if n == 0:
> ... yield s
> ... else:
> ...
"Christopher J. Bottaro" wrote:
> Cool signature, can anyone do a Python one that I can leech? =)
>
> -- C
>
Here's the transliteration in python for your address:
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')])
for p in '[EMAIL PROTECTED]'.split('@')])"
Cheer
"Darran Edmundson" wrote:
> I was playing around with the inspect module the other day
> trying to write a quick and dirty "smart" logger. By this I mean
> that writing a message to the global log would also yield some
> info about the calling scope. If you look at my function "test"
> below, I'd
David Pratt wrote:
> Hi. I am creating methods for form validation. Each validator has its
> own method and there quite a number of these. For each field, I want
> to evaluate errors using one or more validators so I want to execute
> the appropriate validator methods from those available. I am
"Jordan Rastrick" wrote:
> I'd suggest the only nessecary change is, if objects a,b both define
> __eq__ and not __ne__, then a != b should return not (a == b)
>
> If a class defines __ne__ but not __eq__, well that seems pretty
> perverse to me. I don't especially care one way or another how that
"Greg Ewing" wrote:
> > More generally, I think there is no abstract distinction between
> > statements and expressions. Everything is an expression, can be evaluated
> > to a value.
>
> That's true in a functional language, but Python is not a
> functional language. In imperative programming, of
"Rocco Moretti" wrote:
> One way to handle that is to refuse to sort anything that doesn't have a
> "natural" order. But as I understand it, Guido decided that being able
> to sort arbitrary lists is a feature, not a bug.
He has changed his mind since then
(http://mail.python.org/pipermail/python
"Mandus" wrote:
> Thu, 09 Jun 2005 03:32:12 +0200 skrev David Baelde:
> [snip]
> >
> > set_callback(obj,
> > lambda x: (if a:
> >2
> > else:
> >3)
> >
> [snip]
>
> You can do stuff like this: lambda x: x and 2 or 3
>
> Of course, you are st
"Kay Schluehr" wrote:
> > Thu, 09 Jun 2005 03:32:12 +0200 skrev David Baelde:
> > [snip]
> > >
> > > set_callback(obj,
> > > lambda x: (if a:
> > >2
> > > else:
> > >3)
> > >
> > [snip]
> >
> > You can do stuff like this: lambda x: x and 2
"Kay Schluehr" wrote:
> > You can do stuff like this: lambda x: x and 2 or 3
>
> You can also do this
>
>lambda x: {True:2,False:3}.get(bool(a))
>
> which is both beautiful and pythonic.
>
> Kay
Beauty is in the eye of the beholder, and the same holds for
'pythonicity'; IMO both are much less
> Hello,
>
> Does anyone have an efficient Python routine for calculating the
> structure function?
>
>
> Thanks very much,
>
>
> Daran
> [EMAIL PROTECTED]
Read this first and come back:
http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
George
--
http://mail.python.org/mailman/listin
"alex23" wrote:
> Kalle Anke wrote:
> > I'm coming to Python from other programming languages. I like to
> > hide all attributes of a class and to only provide access to them
> > via methods.
>
> I'm pretty fond of this format for setting up class properties:
>
> class Klass(object):
> def pro
"Jorgen Grahn" wrote:
> I have a set of tests in different modules: test_foo.py, test_bar.py and so
> on. All of these use the simplest possible internal layout: a number of
> classes containing test*() methods, and the good old lines at the end:
>
> if __name__ == "__main__":
> unittest.m
"Kalle Anke" wrote:
> [snipped]
>
> So, I'm looking for advice/information on:
>
> + How to write "proper" python code instead of
> Java/Perl/C/C++/Pascal/Modula-2/etc inspired code
>
> + The more advanced parts/uses of Python
>
> + Discussions about the ideas behind different Python
> constru
"Mike Meyer" wrote:
> Andrea Griffini <[EMAIL PROTECTED]> writes:
> > On Sat, 11 Jun 2005 21:52:57 -0400, Peter Hansen <[EMAIL PROTECTED]>
> > wrote:
> > Also concrete->abstract shows a clear path; starting
> > in the middle and looking both up (to higher
> > abstractions) and down (to the impleme
"Jeff Epler" wrote:
> On Sun, Jun 12, 2005 at 04:55:38PM -0700, Xah Lee wrote:
> > if i have
> > mytext.replace(a,b)
> > how to find out many many occurances has been replaced?
>
> The count isn't returned by the replace method. You'll have to count
> and then replace.
>
> def count_replace(a, b,
401 - 500 of 1186 matches
Mail list logo