Steven Bethard [EMAIL PROTECTED] added the comment:
I'll take care of this, adding a bit to section 3.6.1, String Methods.
--
nosy: +bethard
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2326
Steven Bethard [EMAIL PROTECTED] added the comment:
I've got a patch against 2.6, and the docs seem to build fine. Since
I've never committed a doc patch before, I'd appreciate it if someone
could glance at this and make sure there's nothing obviously wrong.
--
keywords: +patch
Added
Steven Bethard [EMAIL PROTECTED] added the comment:
Committed in revision 61453.
--
status: open - closed
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2326
Steven Bethard [EMAIL PROTECTED] added the comment:
I'll start looking at this.
--
nosy: +bethard
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2342
__
___
Python-bugs
New submission from Steven Bethard [EMAIL PROTECTED]:
Some comparisons were changed or removed in Python 3.0. In 2.6 you could
compare types (e.g. ``str int``) and dicts supported more than just
equality. These comparisons should produce Py3K warnings.
--
assignee: bethard
components
Steven Bethard [EMAIL PROTECTED] added the comment:
The code is only invoked when NotImplemented is produced. Take a look at
the attached patch to try_3way_to_rich_compare and see if you think it's
going to be too expensive.
--
keywords: +patch
Added file: http://bugs.python.org
Steven D'Aprano wrote:
Double-underscore names and methods are special to Python. Developers are
prohibited from creating their own (although the language doesn't enforce
that prohibition). From PEP 0008, written by Guido himself:
__double_leading_and_trailing_underscore__: magic
Wildemar Wildenburger wrote:
Arnaud Delobelle wrote:
I believe both set and dict comprehensions will be in 3.0.
Python 3.0a1+ (py3k:59330, Dec 4 2007, 18:44:39)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type help, copyright, credits or license for more information.
{x*x for x in
[EMAIL PROTECTED] wrote:
1. functools.partialpre: partialpre( f, x, y )( z )- f( z, x, y )
2. functools.pare: pare( f, 1 )( x, y )- f( y )
3. functools.parepre: parepre( f, 1 )( x, y )- f( x )
4. functools.calling_default: calling_default( f, a, DefaultA, b )-
f( a, default 2rd arg, even if
Jeremy Sanders wrote:
[EMAIL PROTECTED] wrote:
Any elegant way of breaking out of the outer for loop than below, I
seem to have come across something, but it escapes me
for i in outerLoop:
for j in innerLoop:
if condition:
break
else:
continue
break
Arnaud Delobelle wrote:
Sligthly improved (not for performance! but signature-preserving and
looks for default values)
from functools import wraps
from inspect import getargspec
from itertools import izip, chain
def autoassign(*names):
def decorator(f):
fargnames, _, _,
Steven D'Aprano wrote:
I have a problem which I think could be solved by using a dict as a
namespace, in a similar way that exec and eval do.
When using the timeit module, it is very inconvenient to have to define
functions as strings. A good alternative is to create the function as
Alan Isaac wrote:
I have a small set of objects associated with a larger
set of values, and I want to map each object to its
minimum associated value. The solutions below work,
but I would like to see prettier solutions...
[snip]
# arbitrary setup
keys = [Pass() for i in range(10)]*3
Steven Bethard wrote:
rndblnch wrote:
my goal is to implement a kind of named tuple.
idealy, it should behave like this:
p = Point(x=12, y=13)
print p.x, p.y
but what requires to keep track of the order is the unpacking:
x, y = p
i can't figure out how to produce an iterable that returns
rndblnch wrote:
my goal is to implement a kind of named tuple.
idealy, it should behave like this:
p = Point(x=12, y=13)
print p.x, p.y
but what requires to keep track of the order is the unpacking:
x, y = p
i can't figure out how to produce an iterable that returns the values
in the right
Ross Ridge wrote:
Tim Golden [EMAIL PROTECTED] wrote:
but this doesn't:
c:/temp/firefox.bat
c:\Program Files\Mozilla Firefox\firefox.exe %*
/c:/temp/firefox.bat
code
import subprocess
cmd = [
rc:\temp\firefox.bat,
http://local.goodtoread.org/search?word=timcached=0;
]
Kristian Domke wrote:
I am trying to learn python at the moment studying an example program
(cftp.py from the twisted framework, if you want to know)
There I found a line
foo = (not f and 1) or 0
Equivalent to ``foo = int(not f)``
In this case f may be None or a string.
If I am not
Diez B. Roggisch wrote:
Jean-Paul Calderone wrote:
On Tue, 22 Jan 2008 15:15:43 +0100, Diez B. Roggisch
[EMAIL PROTECTED] wrote:
Jean-Paul Calderone wrote:
On Tue, 22 Jan 2008 14:20:35 +0100, Diez B. Roggisch
[EMAIL PROTECTED] wrote:
For a simple greenlet/tasklet/microthreading
I'm having trouble using the subprocess module on Windows when my
command line includes special characters like (ampersand)::
command = 'lynx.bat', '-dump', 'http://www.example.com/?x=1y=2'
kwargs = dict(stdin=subprocess.PIPE,
... stdout=subprocess.PIPE,
...
Steven D'Aprano wrote:
On Tue, 22 Jan 2008 22:53:20 -0700, Steven Bethard wrote:
I'm having trouble using the subprocess module on Windows when my
command line includes special characters like (ampersand)::
command = 'lynx.bat', '-dump', 'http://www.example.com/?x=1y=2'
kwargs = dict
George Sakkis wrote:
Unless I missed it, PEP 328 doesn't mention anything about this.
What's the reason for not allowing from .relative.module import *' ?
Generally, there's a move away from all import * versions these days.
For example, Python 3.0 removes the ability to use import * within a
Chris Leary wrote:
As I understand it, the appeal of properties (and descriptors in
general) in new-style classes is that they provide a way to
intercept direct attribute accesses. This lets us write more clear
and concise code that accesses members directly without fear of future
API
Steven D'Aprano wrote:
On Tue, 01 Jan 2008 13:36:57 +0100, Diez B. Roggisch wrote:
And codemonkeys know that in python
doc = et.parse(StringIO(string))
is just one import away
Yes, but to play devil's advocate for a moment,
doc = et.parse(string_or_file)
would be even simpler.
I
Steven D'Aprano wrote:
When you call a new-style class, the __new__ method is called with the
user-supplied arguments, followed by the __init__ method with the same
arguments.
I would like to modify the arguments after the __new__ method is called
but before the __init__ method, somewhat
[EMAIL PROTECTED] wrote:
First, it is absolutely horrible being a newbie. I'd forgot how bad it
was. In addition to making a fool of yourself in public, you have to
look up everything. I wanted to find a substring in a string. OK,
Python's a serious computer language, so you know it's got a
Fuzzyman wrote:
On Nov 26, 11:56 pm, Carl Banks [EMAIL PROTECTED] wrote:
On Nov 20, 3:50 pm, [EMAIL PROTECTED] (John J. Lee) wrote:
Not much to add to the subject line. I mean something like this:
ProxyClass.__name__ = ProxiedClass.__name__
I've been told that this is common practice. Is
Jeff wrote:
On Nov 21, 6:25 am, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
joe jacob a écrit :
(snip)
Thanks everyone for the response. From the posts I understand that
Django and pylons are the best. By searching the net earlier I got the
same information that Django is best
Boris Borcic wrote:
davenet wrote:
Hi,
I'm new to Python and working on a school assignment.
I have setup a dictionary where the keys point to an object. Each
object has two member variables. I need to find the smallest value
contained in this group of objects.
The objects are defined as
blaine wrote:
Hey guys,
For my Network Security class we are designing a project that will,
among other things, implement a Diffie Hellman secret key exchange.
The rest of the class is doing Java, while myself and a classmate are
using Python (as proof of concept). I am having problems
gamename wrote:
In TCL, you can do things like:
set foobar HI!
set x foo
set y bar
subst $$x$y
HI!
Is there a way to do this type of evaluation in python?
If this is at the outer-most scope, you can use globals()::
foobar = 'HI!'
x = 'foo'
y = 'bar'
globals_dict
braver wrote:
Steve -- thanks for your pointer to argparse, awesome progress --
optional arguments.
However, I still wonder how I do reporting. The idea is that there
should be a list with tuples of the form:
(short, long, value, help)
-- for all options, regardless of whether they
Tim Chase wrote:
ASIDE: I've started refactoring this bit out in my local
source...how would I go about contributing it back to the
Python code-base? I didn't get any feedback from posting to
the Optik site.
You can post a patch to bugs.python.org, but it will probably
just get forwarded
Tim Chase wrote:
ASIDE: I've started refactoring this bit out in my local source...how
would I go about contributing it back to the Python code-base? I didn't
get any feedback from posting to the Optik site.
You can post a patch to bugs.python.org, but it will probably just get
forwarded
braver wrote:
Posted to the Optik list, but it seems defunct. Optik is now Python's
optparse.
I wonder how do you implement optional arguments to Optik.
You may want to check out argparse:
http://argparse.python-hosting.com/
It supports optional arguments like this::
parser =
[EMAIL PROTECTED] wrote:
(1).__cmp__(10)
-1
Integer object (1) followed by method call .__cmp__(10)
1.__cmp__(10)
File stdin, line 1
1.__cmp__(10)
^
SyntaxError: invalid syntax
Floating point number 1. followed by __cmp__(10).
STeVe
--
konryd wrote:
- string building...do they use += or do they build a list
and use .join() to recombine them efficiently
I'm not dead sure about that, but I heard recently that python's been
optimized for that behaviour. That means: using += is almost as fast
as joining list.
For some
Neil Cerutti wrote:
On 2007-10-29, Steven Bethard [EMAIL PROTECTED] wrote:
Hrvoje Niksic wrote:
Tommy Nordgren [EMAIL PROTECTED] writes:
Given the following:
def outer(arg)
avar = ''
def inner1(arg2)
# How can I set 'avar' here ?
I don't think you can, until Python 3
Hrvoje Niksic wrote:
Tommy Nordgren [EMAIL PROTECTED] writes:
Given the following:
def outer(arg)
avar = ''
def inner1(arg2)
# How can I set 'avar' here ?
I don't think you can, until Python 3:
http://www.python.org/dev/peps/pep-3104/
But it definitely does work in
Fuzzyman wrote:
On Oct 22, 6:43 pm, Steven Bethard [EMAIL PROTECTED] wrote:
# Inherit from object. There's no reason to create old-style classes.
We recently had to change an object pipeline from new style classes to
old style. A lot of these objects were being created and the *extra
Ben Finney wrote:
What it doesn't allow is for the testing of the 'if __name__ ==
__main__:' clause itself. No matter how simple we make that, it's
still functional code that can contain errors, be they obvious or
subtle; yet it's code that *can't* be touched by the unit test (by
design, it
Ben Finney wrote:
Steven Bethard [EMAIL PROTECTED] writes:
Ben Finney wrote:
What it doesn't allow is for the testing of the 'if __name__ ==
__main__:' clause itself. No matter how simple we make that,
it's still functional code that can contain errors, be they
obvious or subtle; yet it's
Nicko wrote:
If you don't like the rounding errors you could try:
def fact(n):
d = {p:1L}
def f(i): d[p] *= i
map(f, range(1,n+1))
return d[p]
It is left as an exercise to the reader as to why this code will not
work on Py3K
Serves you right for
Adam Donahue wrote:
class X( object ):
... def c( self ): pass
...
X.c
unbound method X.c
x = X()
x.c
bound method X.c of __main__.X object at 0x81b2b4c
If my interpretation is correct, the X.c's __getattribute__ call knows
the attribute reference is via a class, and thus returns
Dan wrote:
On Oct 24, 12:06 pm, Tim Chase [EMAIL PROTECTED] wrote:
I've been using optparse for a while, and I have an option with a
number of sub-actions I want to describe in the help section:
parser.add_option(-a, --action,
help=\
[snipped formatted help] )
Marc 'BlackJack' Rintsch wrote:
On Mon, 22 Oct 2007 17:31:51 -0600, Steven Bethard wrote:
Bruno Desthuilliers wrote:
Computed attributes are IMHO not only a life-saver when it comes to
refactoring. There are cases where you *really* have - by 'design' I'd
say - the semantic of a property
Bruno Desthuilliers wrote:
Steven Bethard a écrit :
Bruno Desthuilliers wrote:
Steven Bethard a écrit :
(snip)
In Python, you can use property() to make method calls look like
attribute access. This could be necessary if you have an existing
API that used public attributes, but changes
Bruno Desthuilliers wrote:
I guess as long as your documentation is clear about which attributes
require computation and which don't...
Why should it ? FWIW, I mentionned that I would obviously not use
properties for values requiring heavy, non cachable computation. This
set aside, the
Bruno Desthuilliers wrote:
Steven Bethard a écrit :
Bruno Desthuilliers wrote:
I guess as long as your documentation is clear about which
attributes require computation and which don't...
Why should it ?
[snip]
I believe we simply disagree on weither properties should be used when
Bruno Desthuilliers wrote:
Now how does your desire for documentation imply that if you're
creating a class for the first time, it should *never* use property() ?
Of course, there's *never* any such thing as never in Python. ;-)
STeVe
P.S. If you really don't understand what I was getting
Gabriel Genellina wrote:
I actually do a lot of unit testing. I find it both annoying and highly
necessary and useful. - Steven Bethard
http://groups.google.com/group/comp.lang.python/msg/4df60bdff72540cb
That quote is actually due to Dan McLeran. A very good quote though.
Steve
--
http
Sunburned Surveyor wrote:
Contents of input text file:
[Name]
Fire Breathing Dragon
[Properties]
Strength
Scariness
Endurance
[Methods]
eatMaiden argMaiden
fightKnight argKnight
Generated Python Class File:
def class FireBreathingDragon:
def getStrength(self):
Sunburned Surveyor wrote:
I also intended to add statements creating properties from the getter
and setter methods. I understand that getters and setters aren't
really necessary if you aren't making a property. I just forgot to add
the property statements to my example.
You still don't want
Michael J. Fromberger wrote:
# Not legal Python code.
def fact3(n, acc = 1):
TOP:
if n 0
n = n - 1
acc = acc * n
goto TOP
else:
return acc
Yes, to write this in legal Python code, you have to write::
from goto import goto, label #
Bruno Desthuilliers wrote:
Steven Bethard a écrit :
(snip)
In Python, you can use property() to make method calls look like
attribute access. This could be necessary if you have an existing API
that used public attributes, but changes to your code require those
attributes to do
Monty Taylor wrote:
MySQL has put up a poll on http://dev.mysql.com asking what your primary
programming language is. Even if you don't use MySQL - please go stick
in a vote for Python.
I agree with others that voting here if you don't use MySQL is *not* a
good idea. That said, I still
[EMAIL PROTECTED] wrote:
Is there any buildin function which mimics the behavior of the
standard commandline parser (generating a list of strings
foo bar and some text from the commandline
foo bar some text)?
Try the shlex module::
import shlex
shlex.split('foo bar some text')
Kevin wrote:
Am I missing something, or am I the only one who explicitly declares
structs in python?
For example:
FileObject = {
filename : None,
path : None,
}
fobj = FileObject.copy()
fobj[filename] = passwd
fobj[path] = /etc/
Yes, I think this is the only time I've
Diez B. Roggisch wrote:
lgwe wrote:
On 9 Okt, 17:18, Diez B. Roggisch [EMAIL PROTECTED] wrote:
lgwe wrote:
I have a python-script: myscript, used to start a program on another
computer and I use OptionParser in optpars.
I use it like this: myscript -H host arg1 -x -y zzz
I would like
Bjoern Schliessmann wrote:
Kevin wrote:
Am I missing something, or am I the only one who explicitly
declares structs in python?
Yes -- you missed my posting :)
Actually, your posting just used dicts normally.
Kevin is creating a prototype dict with a certain set of keys, and then
copying
Kay Schluehr wrote:
Originally I came up with the idea of a pure Python implementation for
copyable generators as an ActiveState Python Cookbook recipe. Too bad,
it was badly broken as Klaus Müller from the SimPy project pointed
out. Two weeks and lots of tests later I got finally a running
Aahz wrote:
In article [EMAIL PROTECTED],
Steven Bethard [EMAIL PROTECTED] wrote:
You can use __slots__ [...]
Aaaugh! Don't use __slots__!
Seriously, __slots__ are for wizards writing applications with huuuge
numbers of object instances (like, millions of instances).
You clipped me
Mathias Panzenboeck wrote:
Marc 'BlackJack' Rintsch wrote:
``del b`` just deletes the name `b`. It does not delete the object.
There's still the name `_` bound to it in the interactive interpreter.
`_` stays bound to the last non-`None` result in the interpreter.
Actually I have the
Licheng Fang wrote:
Python is supposed to be readable, but after programming in Python for
a while I find my Python programs can be more obfuscated than their C/C
++ counterparts sometimes. Part of the reason is that with
heterogeneous lists/tuples at hand, I tend to stuff many things into
George Sakkis wrote:
On Oct 7, 2:14 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Licheng Fang wrote:
Python is supposed to be readable, but after programming in Python for
a while I find my Python programs can be more obfuscated than their C/C
++ counterparts sometimes. Part of the reason
Alex Martelli wrote:
Steven D'Aprano [EMAIL PROTECTED] wrote:
class Record(object):
__slots__ = [x, y, z]
has a couple of major advantages over:
class Record(object):
pass
aside from the micro-optimization that classes using __slots__ are faster
and smaller than classes with
[EMAIL PROTECTED] wrote:
On Oct 5, 5:38 am, Craig Howard [EMAIL PROTECTED] wrote:
Brad:
If the program is more than 100 lines or is a critical system, I
write a unit test. I hate asking myself, Did I break something?
every time I decide to refactor a small section of code. For
instance, I
[EMAIL PROTECTED] wrote:
On Oct 4, 1:02 pm, brad [EMAIL PROTECTED] wrote:
Does anyone else feel that unittesting is too much work? Not in general,
just the official unittest module for small to medium sized projects?
[snip]
I actually do a lot of unit testing. I find it both annoying and
TheFlyingDutchman wrote:
Does anyone know how the variables label and scale are recognized
without a global statement or parameter, in the function resize() in
this code:
[snip]
def resize(ev=None):
label.config(font='Helvetica -%d bold' % \
scale.get())
You're just calling
Tim Chase wrote:
I've been learning the ropes of the optparse module and have been
having some trouble getting the help to format the way I want.
I want to specify parts of an option's help as multiline.
However, the optparse formatter seems to eat newlines despite my
inability to find
Ben Finney wrote:
Steven Bethard [EMAIL PROTECTED] writes:
Argparse knows what your option flags look like, so if you specify
one, it knows it's an option. Argparse will only interpret it as a
negative number if you specify a negative number that doesn't match
a known option.
That's also
Casey wrote:
Ben Finney wrote:
I believe they shouldn't because the established interface is that a
hyphen always introduced an option unless (for those programs that
support it) a '--' option is used, as discussed.
Not THE established interface; AN established interface. There
are other
Carl Banks wrote:
On Sep 28, 9:51 am, Steven Bethard [EMAIL PROTECTED] wrote:
It was decided that practicality beats purity here. Arguments with
leading hyphens which look numeric but aren't in the parser are
interpreted as negative numbers. Arguments with leading hyphens which
don't look
[EMAIL PROTECTED] wrote:
On Sep 28, 8:30 pm, xkenneth [EMAIL PROTECTED] wrote:
Looking to do something similair. I'm working with alot of timestamps
and if they're within a couple seconds I need them to be indexed and
removed from a list.
Is there any possible way to index with a custom cmp()
Casey wrote:
Is there an easy way to use getopt and still allow negative numbers as
args?
[snip]
Alternatively, does optparse handle this?
Peter Otten wrote:
optparse can handle options with a negative int value; -- can be used to
signal that no more options will follow:
import optparse
Ben Finney wrote:
Steven Bethard [EMAIL PROTECTED] writes:
In most cases, argparse (http://argparse.python-hosting.com/)
supports negative numbers right out of the box, with no need to use
'--':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument
Mark Summerfield wrote:
PEP: XXX
Title: Sorted Dictionary
[snip]
In addition, the keys() method has two optional arguments:
keys(firstindex : int = None, secondindex : int = None) - list of keys
The parameter names aren't nice, but using say start and end would
be
Paul Hankin wrote:
On Sep 25, 12:51 pm, Mark Summerfield [EMAIL PROTECTED]
wrote:
On 25 Sep, 12:19, Paul Hankin [EMAIL PROTECTED] wrote:
Recall sorted...
sorted(iterable, cmp=None, key=None, reverse=False) -- new sorted
list
So why not construct sorteddicts using the same idea of
[EMAIL PROTECTED] wrote:
Hi there. I just wondered whether anyone could recommend the correct
way I should be passing command line parameters into my program. I am
currently using the following code:
def main(argv = None):
file1= directory1
file2 = directory2
if argv
Ratko wrote:
I was wondering if something like this is possible. Can a base class
somehow know if a certain method has been overridden by the subclass?
You can try using the __subclasses__() method on the class::
def is_overridden(method):
... for cls in
[EMAIL PROTECTED] wrote:
I am trying to compile Python with cmake, but perhaps there are a few
dependencies that have not been corrected for Windows compilation.
I don't know the specific answers to your questions, but I wanted to
point out, in case you didn't already know, that Alexander
Carsten Haese wrote:
Indeed, if you have an __init__ method that shouldn't see the group
argument, you need a metaclass after all so you can yank the group
argument between __new__ and __init__. The following code seems to work,
but it's making my brain hurt:
class SplinterBorgMeta(type):
Sönmez Kartal wrote:
I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as
f.write(str(xml)). At execution of that line, it gives error with
description, configure your default encoding...
[and later]
http://rafb.net/p/RfaF8215.html
products in the code is a list of
Sönmez Kartal wrote:
I was using the XMLBuilder(xmlbuilder.py). I'm writing XML files as
f.write(str(xml)). At execution of that line, it gives error with
description, configure your default encoding...
[and later]
I get this when it happens: Decoding Error: You must configure
default
Sönmez Kartal wrote:
On 31 A ustos, 04:24, Steven Bethard [EMAIL PROTECTED] wrote:
Sönmez Kartal wrote:
I've had an encoding issue and solved it by
sys.setdefaultencoding('utf-8')...
My first try wasn't successful since setdefaultencoding is not named
when I imported sys module. After, I
Sönmez Kartal wrote:
I've had an encoding issue and solved it by
sys.setdefaultencoding('utf-8')...
My first try wasn't successful since setdefaultencoding is not named
when I imported sys module. After, I import sys module, I needed to
write reload(sys) also.
I wonder why we need to
Russ wrote:
I just stumbled onto PEP 316: Programming by Contract for Python
(http://www.python.org/dev/peps/pep-0316/). This would be a great
addition to Python, but I see that it was submitted way back in 2003,
and its status is deferred. I did a quick search on
comp.lang.python,
but I
Paul McGuire wrote:
On Aug 26, 10:48 pm, Steven Bethard [EMAIL PROTECTED] wrote:
In Japanese and Chinese tokenization, word boundaries are not marked by
different classes of characters. They only exist in the mind of the
reader who knows which sequences of characters could be words given
Paul McGuire wrote:
On Aug 26, 8:05 pm, Ryan Ginstrom [EMAIL PROTECTED] wrote:
The only caveat being that since Chinese and Japanese scripts don't
typically delimit words with spaces, I think you'd have to pass the text
through a tokenizer (like ChaSen for Japanese) before using PyParsing.
Omari Norman wrote:
On Mon, Aug 20, 2007 at 05:31:00PM -0400, Jay Loden wrote:
Robert Dailey wrote:
Well, I don't know what is wrong with people then. I don't see how
required arguments are of bad design.
I tend to agree...while required option may be an oxymoron in
English, I can think of
Floris Bruynooghe wrote:
When in a new-style class you can easily transform attributes into
descriptors using the property() builtin. However there seems to be
no way to achieve something similar on the module level, i.e. if
there's a version attribute on the module, the only way to change
james_027 wrote:
i am very new to python, not knowing much about good design. I have an
object here for example a Customer object, where I need to retrieve a
info which has a number of lines of code to get it.
my question is weather what approach should I use? to use the property
which is
[EMAIL PROTECTED] wrote:
Some rather unexpected behavior in the set_default/set_defaults
methods for OptionParser that I noticed recently:
import optparse
parser = optparse.OptionParser()
parser.add_option(-r, --restart, dest=restart, action=store_true)
Option at 0x-483b3414: -r/--restart
Gerardo Herzig wrote:
Hi all. I guess i have a conceptual question:
Im planing using a quite simple decorator to be used as a conditional
for the execution of the function. I mean something like that:
@is_logued_in
def change_pass():
bla
bla
And so on for all the other functions
[EMAIL PROTECTED] wrote:
Also, does anyone know if there is some magic that makes
i in some_set
loads faster than
i in some_list
It's not magic, per se. It's really part of the definition of the data
type. Lists are ordered, and are slow when checking containment. Sets
are unordered and
Michele Simionato wrote:
SPECIALMETHODS = ['__%s__' % name for name in
'''
abs add and call concat contains delitem delslice div eq floordiv ge
getitem
getslice gt iadd iand iconcat idiv ifloordiv ilshift imod imul index
inv invert
ior ipow irepeat irshift isub iter itruediv ixor le len
Michele Simionato wrote:
On Aug 10, 7:09 pm, Steven Bethard [EMAIL PROTECTED] wrote:
There were also a few recipes posted during this discussion that wrap
weakrefs up a bit nicer so it's easier to use them in place of __del__:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/519635
Dick Moores wrote:
I'm still trying to understand classes. I've made some progress, I
think, but I don't understand how to use this one. How do I call it, or
any of its functions? It's from the Cookbook, at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/523048.
The short answer is
Dick Moores wrote:
At 03:09 PM 8/12/2007, Steven Bethard wrote:
Here's how I'd write the recipe::
import itertools
def iter_primes():
# an iterator of all numbers between 2 and +infinity
numbers = itertools.count(2)
# generate primes forever
Dustan wrote:
On Aug 12, 7:35 pm, Dustan [EMAIL PROTECTED] wrote:
On Aug 12, 5:09 pm, Steven Bethard [EMAIL PROTECTED] wrote:
def iter_primes():
# an iterator of all numbers between 2 and +infinity
numbers = itertools.count(2)
# generate primes forever
Dick Moores wrote:
At 03:35 PM 8/12/2007, Steven Bethard wrote:
Note that if you just want to iterate over all the primes, there's no
need for the class at all. Simply write::
for prime in iter_primes():
Even if I want to test only 1 integer, or want the list of primes in a
certain
301 - 400 of 1712 matches
Mail list logo