On Jun 5, 10:48 am, Steven D'Aprano wrote:
> Apparently it gives an error. Can anyone explain why this does not work?
>
> # Python 3.2
>
> >>> class MyType(type): # A metaclass...
>
> ... def __repr__(self):
> ... s = super().__repr__()
> ... return s.replace('class',
On Mar 16, 1:45 pm, Ray Song wrote:
> I confess i've indulged in Haskell and found
> f a
> more readable than
> f(a)
Hmmm... What about:
f a b
versus
f(a(b))
or was it supposed to be read as
f(a)(b)
or as
f(a, b)
?-)
> And why aren't functions curried (partially
On Feb 9, 5:06 am, Chris Angelico wrote:
> On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote:
>
> > My question is why is it that the id of Boo.daf is different from daf's hex
> > value in the above dict?
>
>
> daf is not a function, it's a special object for an unbound method.
http://wiki.python.org
On Feb 5, 4:29 pm, Andrew Berg wrote:
> This has nothing to do with dictionaries. If you want to add, delete, or
> change items, use a list (or a set if there aren't supposed to be any
> duplicates).
AND you don't care about ordering...
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 2, 9:23 pm, Michal Hantl wrote:
> See the link I attached.
> Ruby-like blocks would be nice too.
> Implicit returns.
> Better strings like """My name is #{name}""".
Uhu... Looks like you want Ruby, not Python
--
http://mail.python.org/mailman/listinfo/python-list
On 31 août, 18:45, Travis Parks wrote:
> I was a little disappointed the other day when I realized that
> closures were read-only. I like to use closures quite a bit.
They are not _strictly_ read only, but Python being first and foremost
an OO language, it's usually way simpler to use OO instead
On 25 juil, 17:36, "Steven W. Orr" wrote:
> I have been doing a lot of reading. I'm starting to get it. I think it's
> really cool as well as dangerous,
Dangerous ??? Why so ? Is there anything "dangerous" in a constructor
or an initialiser ??? A metaclass is just a class, and a class is just
an
On 28 juil, 00:34, rantingrick wrote:
> In Python4000 i'm making it a syntax error to
> include ANY blank lines in a func/meth body.
Hopefully this is not going to happen.
(snip remaining stupidities).
--
http://mail.python.org/mailman/listinfo/python-list
On 28 juil, 17:39, Ethan Furman wrote:
>
> --> bool(0) is bool(0)
> True
>
This test is not reliable - a same id can be reused for terms (I have
already seen such things happening). If you want a reliable test, use:
#> a = bool(0)
#> b = bool(0)
#> a is b
True
Note that this still fails to prov
On Jul 22, 1:12 pm, caccolangrifata wrote:
Totally OT but others already answered the question...
> class foo(object):
class names should start with an uppercase letter:
class Foo(object):
>
> __init__(self, len = 9):
1/ you want to add a "def" statement before "__init__"
2/ the argu
On 21 juil, 20:46, Andrew Berg wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: RIPEMD160
>
> On 2011.07.21 01:32 PM, Thomas Jollans wrote:> So, the PEP says: do not align
> operators. End of story.
>
> I'm pretty sure that colons, commas and equals signs are not operators.
1/ you can consid
On Jul 15, 10:28 am, Teemu Likonen wrote:
>
> How about accepting anything but ignoring all non-numbers?
Totally unpythonic. Better to be explicit about what you expect and
crash as loudly as possible when you get anything unexpected.
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 15, 9:44 am, Cameron Simpson wrote:
> On 15Jul2011 15:28, Steven D'Aprano
> wrote:
> | Against MISSING: users may expect to be able to choose their own sentinel by
> | assigning to MISSING. I don't want to support that.
>
> Well, we don't have readonly values to play with :-(
> Personally
On Jul 15, 7:28 am, Steven D'Aprano wrote:
>
> I'm designing an API for some lightweight calculator-like statistics
> functions, such as mean, standard deviation, etc., and I want to support
> missing values. Missing values should be just ignored. E.g.:
(snip)
> Against None: it's too easy to m
On Jul 14, 9:46 pm, Billy Mays wrote:
> I noticed that if a file is being continuously written to, the file
> generator does not notice it:
>
> def getLines(f):
> lines = []
> for line in f:
> lines.append(line)
> return lines
what's wrong with file.readlines() ?
--
http:
On Jul 15, 8:08 am, Chris Angelico wrote:
>
> Agreed that float('nan') and "" and "spam" are all bad values for
> Missings. Possibly "" should come out as 0
"In the face of ambiguity, refuse the temptation to guess."
As far as I'm concerned, I'd expect this to raise a TypeError...
--
http://m
On Jul 15, 9:27 am, "bruno.desthuilli...@gmail.com"
wrote:
> On Jul 15, 4:58 am, Inside wrote:
>
> > Hey guy,thx for you feedback first.
>
> > But I can't follow your opinion.Why?because of the list & tuple are placed
> > at built-in function,
On Jul 15, 4:58 am, Inside wrote:
> Hey guy,thx for you feedback first.
>
> But I can't follow your opinion.Why?because of the list & tuple are placed at
> built-in function,so before I type 'list' unintentionally on the pyshell and
> it show me "", I never know that the name 'list' is a type,I
On Jul 15, 8:36 am, Chris Angelico wrote:
> This can alternatively be done with map():
>
> sortlist = map(lambda x,y: x+y, npalist, nxxlist)
>
>
> (It would have been a lot cleaner if Python exposed its operators as
> functions.
from operator import add
--
http://mail.python.org/mailman/list
On Jul 12, 6:40 pm, John Keisling wrote:
> After too much time coding Python scripts and reading Mark Lutz's
> Python books, I was inspired to write the following lyrics.
Brillant. This deserves to become a cpython easter egg along with
import this or from __future__ import braces.
--
http://mai
On Jul 12, 4:46 pm, Billy Mays wrote:
> I want to make a generator that will return lines from the tail of
> /var/log/syslog if there are any
Err... I must have missed something, but python files are their own
iterators.
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type
On Jul 11, 2:42 am, Adam Tauno Williams
wrote:
>
> But Open Source land is simply too fragmented. There are too many
> database bindings [and RAD requires something like an ORM (think
> SQLalchemy)] and far too many GUI toolkits [Qt, Gtk, wx, and the list
> goes on and on].
>
> Nothing can muster
On Jun 23, 4:42 pm, Peter Otten <__pete...@web.de> wrote:
(snip)
> > However I end up doing it in every submodule, so it seems a little
> > redundant. I wish I could load the variable in the parent program and
> > have it be available in all submodules. Am I missing something?
>
> You can modify th
On Jun 22, 2:21 am, News123 wrote:
> Out of curiousity: Do you know whether the imports would be executed for
> each potential command as soon as I call manage.py or only
> 'on demand'?
Why would you care ? Just importing the module shouldn't have any side
effect.
--
http://mail.python.org/mailm
On 18 juin, 13:24, Tim Chase wrote:
> On 06/18/2011 05:55 AM, bruno.desthuilli...@gmail.com wrote:
>
> > On 18 juin, 06:17, John Salerno wrote:
> >> class Character:
>
> >> base_health = 50
> >> base_resource = 10
>
> >> de
On 18 juin, 06:17, John Salerno wrote:
> Note: I have in mind that when a specific subclass (Warrior, Wizard,
> etc.) is created, the only argument that will ever be passed to the
> __init__ method is the name. The other variables will never be
> explicitly passed, but will be set during initiali
On Jun 17, 3:53 pm, Ian Kelly wrote:
>
> That works, but I would be concerned about forgetting to specify the
> argument by keyword
(snip funny side effect description)
> Also, as in my suggestion, it doesn't seem
> like a big improvement to have to type out "replacement=" when you
> need the r
On Jun 11, 10:28 pm, Ian Kelly wrote:
>
> Since there is no way to distinguish the two cases by the arguments,
def deprecated(func=None, replacement=None):
if replacement:
# handle the case where a replacement has been given
elif func:
# handle the case where no replacement
On Jun 15, 9:50 am, sidRo wrote:
> Is Python only for server side?
Is it a theoretical question or a practical one ?-)
More seriously: except for the old proof-of-concept Grail browser, no
known browser uses Python as a client-side scripting language.
--
http://mail.python.org/mailman/listinfo/
On May 31, 10:32 am, Chris Rebert wrote:
> On Tue, May 31, 2011 at 1:21 AM, michal.bulla wrote:
> > Hello,
>
> > I'm trying to create simple method to create category. I set the model
> > category:
>
> > class Category(db.Model):
> > title = db.StringProperty(required=True)
> > clashes_count =
On 30 mar, 09:12, harrismh777 wrote:
> 2.6.2
> 2.5.1
> ==
> (___) \--- ( 3.2 )
>
> Cartman: Bring out yer dead,.. bring out yer dead...
>
> Devlpr: Here' one... (Python27)
>
> Cartman: ... nine pence!
>
> Python27: I'm not dead!
>
>
On 25 mar, 16:19, joy99 wrote:
> Dear Group,
>
> I got a question which might be possible but I am not getting how to
> do it.
>
> If I have a list, named,
> list1=[1.0,2.3,4.4,5.5]
>
> Now each element in the array holds the string property if I want to
> convert them to float, how would I do
On 21 déc, 03:03, Steve Holden wrote:
> On 12/20/2010 8:36 PM, Jshgwave wrote:>
> > When writing a function that uses a module such as NumPy, it is tempting
> > to include the statement "import numpy" or "import numpy as np" in the
> > definition of the function, in case the function is used in a
On 16 déc, 15:53, Jean-Michel Pichavant
wrote:
> Mel wrote:
> > Jean-Michel Pichavant wrote:
>
> >> Fellows,
>
> >> I'd like to illutrate the fact that comparing strings using identity is,
> >> most of the time, a bad idea. However I'm searching a short example of
> >> code that yields 2 different
On 16 déc, 15:52, Jean-Michel Pichavant
wrote:
> bruno.desthuilli...@gmail.com wrote:
> > On 16 d c, 12:55, Jean-Michel Pichavant
> > wrote:
>
> >> id('foo')
> >> 3082385472L
> >> id('foo')
> >> 3082385472L
>
> &g
On 16 déc, 12:55, Jean-Michel Pichavant
wrote:
> Fellows,
>
> I'd like to illutrate the fact that comparing strings using identity is,
> most of the time, a bad idea. However I'm searching a short example of
> code that yields 2 differents object for the same string content.
>
> id('foo')
> 308238
On 14 déc, 21:38, Arnaud Delobelle wrote:
> I almost used:
>
> True = "to be" or not "to be" # that is the question
KEYBOARD !-)
--
http://mail.python.org/mailman/listinfo/python-list
On 12 déc, 15:28, pyt...@lists.fastmail.net wrote:
> I have a routine in Python which is extracting information from a
> website. This information is read and inserted into objects.
>
> I currently have all the validations and checks implemented in the
> routines which are reading the HTML and crea
On 7 déc, 12:05, Steve wrote:
> Hi,
>
> I try to run a terminal emulation using Python+Gtk+Vte. Before develop
> my own sources, i'm testing some examples like this
> ;http://www.eurion.net/python-snippets/snippet/Embed%20a%20VTE%20termi...
>
> But when i try to run, i get this message error;
>
>
On 2 déc, 15:45, Jeremy wrote:
> On Dec 1, 10:47 pm, James Mills wrote:
>
>
>
> > On Thu, Dec 2, 2010 at 3:36 PM, Jeremy wrote:
> > > I have some methods that I need (would like) to define outside of the
> > > class. I know this can be done by defining the function and then
> > > setting it equ
On 2 déc, 06:36, Jeremy wrote:
> I have some methods that I need (would like) to define outside of the
> class. I know this can be done by defining the function and then
> setting it equal to some member
"assignement" or "binding" might be the terms you were looking for
here ;)
Also in Python
On 1 déc, 14:48, nelson wrote:
> Hi all,
> I have this function, defined in a string and ecetuted through ad
> exec call
>
> def cell1(d):
>
> x=d.get('x')
> print x
>
> import y
> return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x))
>
> d is a dict of this kind {'x':2}
>
On 22 nov, 21:44, Roman Dolgiy wrote:
>> http://stackoverflow.com/questions/4247036/python-recursively-getattr...
>
> I need to support a lot of legacy code, with THC4k's approach I'll
> have to modify project's existing code to use obj.attr1.val instead of
> obj.attr1 but this is not suitable.
Y
On 25 oct, 17:18, Joost Molenaar wrote:
> Thanks, Bruno.
> Your python-wiki page and walk-through for the Decorator code make it
> clear. I now finally understand that methods are in fact ordinary
> functions at the time the class is created, and that the descriptor
> protocol turns them into boun
On 25 oct, 15:34, Alex Willmer wrote:
> On Oct 25, 11:07 am, kj wrote:
>
> > In "The Zen of Python", one of the "maxims" is "flat is better than
> > nested"? Why? Can anyone give me a concrete example that illustrates
> > this point?
>
> I take this as a reference to the layout of the Python st
On 25 oct, 14:15, Joost Molenaar wrote:
> WebOb contains this little nugget of code that allows you to define a
> decorator that works on both methods and functions:
>
> class Decorator(object):
> def __init__(self, func):
> self.func = func
> def __get__(self, object, type=None):
On 25 oct, 12:05, targetsmart wrote:
> Hi,
> today I just came across a python code snippet where __init__ was
> defined inside a function..
> I am not able to understand the reason why
>
> The code snippet was similar like
>
> def func1(a,b):
> def __init__():
> func2(a,b)
> def func2(a,b
On 5 oct, 17:52, de...@web.de (Diez B. Roggisch) wrote:
> Btw, you are a bit on the overprotective side. The convention for
> marking attributes (methods or objects alike) "private"
s/private/implementation/
I find that thinking in terms of "interface / implementation" instead
of "public / privat
On 1 oct, 14:12, Fuzzyman wrote:
> On Sep 30, 6:07 pm, kj wrote:
>
>
>
> > This is a recurrent situation: I want to initialize a whole bunch
> > of local variables in a uniform way, but after initialization, I
> > need to do different things with the various variables.
>
> > What I end up doing i
On 30 sep, 19:22, Andreas Waldenburger
wrote:
> On Thu, 30 Sep 2010 03:42:29 -0700 (PDT)
>
> "bruno.desthuilli...@gmail.com" wrote:
> > On 29 sep, 19:20, Seebs wrote:
> > > On 2010-09-29, Tracubik wrote:
> > > > button = gtk.Button(("Fals
On 30 sep, 19:07, kj wrote:
> This is a recurrent situation: I want to initialize a whole bunch
> of local variables in a uniform way, but after initialization, I
> need to do different things with the various variables.
>
> What I end up doing is using a dict:
>
> d = dict()
> for v in ('spam', '
On 29 sep, 19:20, Seebs wrote:
> On 2010-09-29, Tracubik wrote:
> > button = gtk.Button(("False,", "True,")[fill==True])
> Oh, what a nasty idiom.
>
Well, it's not very different from dict-based dispatch , which is the
core of OO polymorphic dispatch in quite a few dynamic OOPLs.
Anyway, it's
On 29 sep, 13:38, Hrvoje Niksic wrote:
> Tracubik writes:
>
> > button = gtk.Button(("False,", "True,")[fill==True])
(snip)
> BTW adding "==True" to a boolean value is redundant and can even break
> for logically true values that don't compare equal to True (such as the
> number 10 or the strin
On 29 sep, 14:17, Steven D'Aprano wrote:
> On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
> > On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
>
> >> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
> >>> Hi all,
> >>> Have been grappling with a list problem for hours... a = [2, 3, 4,
> >>> 5
On 18 sep, 17:25, Niklasro wrote:
> Hi
> How can I make the visibility of a variable across many methods or
> files? To avoid repeating the same line eg url =
> os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else
> os.environ['SERVER_NAME']
First learn to use Python correctly:
url =
On 29 août, 06:39, Gregory Ewing wrote:
> Steven D'Aprano wrote:
> > I'm not entirely sure what the use-case for swapcase is.
>
> Obviously it's for correcting things that were typed
> in with tHE cAPS lOCK kEY oN bY mISTAKE. :-)
>
+1 QOTW !-)
--
http://mail.python.org/mailman/listinfo/python-l
On 27 août, 20:05, Jussi Piitulainen > def
palindromep(s):
> return ( s == "" or
> ( s[0] == s[-1] and
> palindromep(s[1:-1]) ) )
>
I-can-write-lisp-in-any-language-p !-)
--
http://mail.python.org/mailman/listinfo/python-list
On 27 août, 18:20, Mark Lawrence wrote:
> On 27/08/2010 15:43, Bruno Desthuilliers wrote:
>
> > Dave Angel a écrit :
> > (snip)
>
> >> or (untested)
> >> def is_palindrom(s):
> >> s = s.lower()
> >> return s == s[::-1]
>
> > Right, go on, make me feel a bit more stupid :-/
> > Who's next ?
>
> It
On 20 nov, 20:42, Ethan Furman wrote:
> Aahz wrote:
> > In article ,
> > Grant Edwards wrote:
>
> >>You've really got to try pretty hard to create one. But if you
> >>want to, here's how to do it:
>
> >>1) Start by complaining that your program doesn't work because
> >> of a bug in Python.
>
59 matches
Mail list logo