ate ten million integer objects dwarfs the time required to
allocate a single list with ten million entries, and this cost occurs
with both range and xrange, unless you break early.
> Given the amount of performance difference, I don't see why
> xrange even
> exists.
To keep memor
e OP was asked by a
misguided management to make sure it was "reverse-engineer-proof". So
any attempt to convince the OP may be aimed at the wrong person.
Misguided as they are, sometimes you have to placate these people.
So, are there any ways to make it "harder" to reverse engineer a
. If it's for
school you're probably covered, but in real world, it would be better
to:
1. Rewrite calculation to avoid arccos and arcsin (using trigonometric
or geometric identities)
2. Clamp it to range [-1.0:1.0]. You can do this in numpy with
numpy.clip().
Carl Banks
--
http://m
def set_state():
return my_machine.get_state()
Some users won't want the simplified interface. Really.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
en both be
> supplied by the contained objects.
And yet, by the same reasoning, using > and <= for list and tuple is
also a "bad idea".
> If a LarchTree user stores objects that don't support __gt__,
> will he have a legitimate complaint when using LarchTree.__le__
tly more self-documenting. And
if you had been using super(), you could have avoided repeating the
symbol Foo. But 2 is more efficient and less typing than 3.
Option 4 is abhorrent.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 15, 9:05 am, [EMAIL PROTECTED] wrote:
> On Dec 15, 8:33 am, Carl Banks <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Dec 14, 4:15 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
> > > When implementing the rich comparison operators for some sort of
>
plication to depend on their library?
Sometimes you have to work with code that's not up to your standards,
but come on.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ng old and new style
> classes.
>
> Monkey patching is definitely unpythonic. You must be a Ruby guy. Why
> don't you try doing something else to get the behavior you want,
> something more explicit?
Time and place.
A well-considered, timely monkey-patch can sometimes save all kinds of
workarounds and other headaches.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
p anyone.
The OP wanted to minimize memory usage, exactly the intended usage of
slots. Without knowing more about the OP's situation, I don't think
your or I or Chris Mellon can be sure it's not right for the OP's
situation.
You're obviously smart and highly expert i
On Dec 19, 10:55 am, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Dec 18, 3:16 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>
> > On Dec 18, 10:08 am, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > We are trying to monkey-patc
dict):
for key,value in clsdict.iteritems():
if isinstance(value,type):
clsdict[key] = type(value.__name__,(value,),{})
type.__new__(cls,name,bases,clsdict)
class A(object):
__metaclasS__ = AutoSubclassMetaclass
class C(object):
foobar = 40
class B(A):
pass
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
h to justify a new statement. Metaclasses aren't too
common, and are generally used by experts who don't need the
straightforwardness the make statement would provide.
But, properties, dicts, and other things could benefit from some of the
semantics the class statement, and with the make statem
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, clearer way to write:
> >>
> >> class Foo(args):
> &g
same exception; might have
to disambiguate them somehow in the except block.
Language-wise, I doubt there are any serious gotchas whem running
regular (as opposed to error handling) code in an except block. So go
right ahead; no need to feel guilty about it.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
es be mature enough that writing interface definitions
would be useful and not a burden. (And let's face it: there aren't
many projects that get that far. :)
Adaptation I have no comment about, not having needed it (yet).
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
e not - or hardly - existed in programming
> before python?
Nesting by indentation
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
Cameron Laird wrote:
> In article <[EMAIL PROTECTED]>,
> Carl Banks <[EMAIL PROTECTED]> wrote:
> >Wildemar Wildenburger wrote:
> >> Are there any concepts that python has not borrowed, concepts that were
> >> not even inspired by other languages? I'
[EMAIL PROTECTED] wrote:
> Heiko Wundram wrote:
> > Because sometimes you don't want to call the base classes constructors?
> Sounds strange to me at the moment, but I'll try to adjust to this
> thought.
In Java and C++, classes have private members that can only be accessed
by the class itself (a
that I'd say that Python __init__ is analogous to Java and
C++ constructors, but is not a constructor because C++ and Java
constructors are not constructors. :) And Java has pointers, not
references. :)
A-rose-by-any-other-name-ly yr's,
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
> In other words, the object is constructed in Python before any __init__ is
> called, but in C++ it isn't constructed until after all the base class
> constructors have returned.
That's true. Good point.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
t yet been
> set up.
In Python, if you try to use an uninitialized member you get an
AttributeError; I really don't see too much inherent danger here. If
you make a mistake, the language tells you and you fix it. C++ and
Java are worse since accessing uninitialized variables is a silen
ine if can't be
> followed by an else.
Thus proving the original claim about it being confusing. :) I think
he intended it to parse this way:
if ($x) { $y++ if $z; } else { $z--; }
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence D'Oliveiro wrote:
> In article <[EMAIL PROTECTED]>,
> "Carl Banks" <[EMAIL PROTECTED]> wrote:
>
> >bruno at modulix wrote:
> >> [EMAIL PROTECTED] wrote:
> >> > I was wondering, why you always have to remember to call bas
It would
accept a filename rather than a file descriptor, anonymous blocks would
be handled OS-independently, rather than mapping /dev/zero, and so on.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
q = 0
>>> r = 0
>>> s = 0
>>> id(q)
134536636
>>> id(r)
134536636
>>> id(s)
134536636
[snip]
> My rule, don't do it unless you know exactly why you
> want to do it. It will trip you up at some point and
> be VERY hard to find.
It's ok to do it with constant objects, really.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
e? If yes, then use ==. 0 == 0 should be true even if the two
zeros are different objects.
Corrollary:
You should test for singleton objects with is. None, NotImplemented,
and Ellipsis are singleton objects; this is part of the language and
not an implementation detail. You can rely on
ultiple times in the same statement.
Try showing what they look like nested. The "readable" example would
turn into ASCII vomit.
Probably the day it makes it into Python is the day Python jumps the
shark.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
gle-file
executables. PyInstaller works on Unix too, IIRC.
If you're good at tweaking stuff and have some knowledge of Python
internals; it's possible to make a minimal distro just by copying files
out of a regular installation by hand (and maybe zipping some them up).
This can be a
G. Monzón wrote:
> Please don't compare PHP with Python... They are very different worlds.
I'm not. I was simply agreeing that the single executable way the OP
claimed PHP does it can *sometimes* be preferrable in Python, and
giving him recommendations thereto.
Carl Ba
n func(*args,**kwd)
> return iterfunc
CONTINUE could be put inside tail_recursive, couldn't it? And to
squeeze a little more speed out of it, var could be a list (saves a
hash lookup).
Cool decorator.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ction for SGI IRIX modules, and IRIX support
is scheduled to be dropped in Python 3000. There might be a good
reason why win32 isn't in Python base distro, but that it's
Windows-only isn't it.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
shared library
(if the license allows it, of course), or rebuild the qt.so with the
static QT libraries.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
u're doing this on Linux, it's not all that unreasonable
to require QT to be installed on the target system. Any reasonable
distribution has it nicely packaged.
But, if you must, "ldd qt.so" will list library dependencies of qt.so.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
gt; Position the CWD in the desired base directory of
> the archive,
> add the files to the archive using their relative pathnames, and put
> the CWD back
> where it was when you started:
This may be the best way anyways, unless you have some reason to not
change the current directory.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
modifier (like Ada's "in and out") instead?
Problem with that is then positional arguments line up wrong. Ick.
def func(a : int = 1): pass
def func(a : kwonly int = 1): pass
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
alling it and catch CallableError (or whatever it is). Of
course, that error can be raised inside the function; and in this case,
there's no way to isolate only the part you you're checking for an
exception.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
hecking is appropriate to it -- and if needed, raise
> some custom "command failure" exception after handling the real failure
> internally.
That probably doesn't help when the exception is due to a bug and not
bad input. If you have an AttributeError due to a bug, it w
. So queuing instead of Queue.
Unfortunately, the Python library isn't setting a good example here.
Too much glob.glob, time.time, socket.socket, and Queue.Queue. I hope
all these go away in Python 3000.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
tianly negative) pronouncement, so we have it on the record.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
in y:
if x is not None:
_.append(x)
In other words, each for and if in a listcomp is equivalent to a nested
block in a regular statement. There's a regular way to nest, and
listcomp way, and they're separate. This PEP suggests we should mix
them up--now *that'
nnoys quite a few people. When you reply to a
message, please move your cursor to below the quoted message before
you begin typing. Thank you
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ne or two about the set objects. (It's
probably at least better than listing internal objects.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
which seems to be
what you need.
In IDLE, you'll have to capture the output of the programs and print
it yourself, since you can't (AFAIK) run a DOS shell in an IDLE
window. Untested:
import subprocess
output = subprocess.Popen('MD "' + new_folder + '"', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
print output
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
:
for i in xrange(len(x)-1):
j = random.randrange(i+1,len(x))
tmp = x[j]
if test_property_func(tmp):
return tmp
x[j] = x[i]
x[i] = tmp
return None
Then, for example, use it like this:
def odd(i): return i&1
e = random_element_with_proper
hildren to be an instance attribute rather than a class
attribute, so I redid it that way, but .)
P.S. Is calling a method called "firing" in C#?
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
en than a
benefit, especially in code that is young and still subject to lots of
redesign and refactoring.
And ehen interfaces do make sense, such as in a plugin system or a
complex framework, the user should be free to ignore the interface at his
own risk.
Carl Banks
--
http://mail.python.or
7;ve done enough to choose.
"it doesn't suck".
(Really. All programming languages have good, useful features. Even
Perl. Python is unique in having no very bad ones.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
quot;its pythonicity".
Mixing Greek and Latin suffixes usually works better than mixing Greek
and Germanic, doesn't it.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
intrc file (location may vary on Windows) and there was a
declaration in the file that listed symbols to ignore.
Last time I bothered running it, I added "id" to that list, since I use
it often (bad habit) and almost never use the builtin id, but still
wanted shadowing warnings for othe
the event loop, same as most GUIs do. Plus it's
not straightforward to integrate the SDL window into the widget systems.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
repeat" as the keyword.)
1. Looping a fixed number of times is quite uncommon.
2. A syntax for it buys you almost nothing.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
Obj(*args)
self.tracked_objs.add(obj)
return obj
def run(self):
for obj in self.tracked_objs:
# do something with obj
bigobj = Bigobj()
obj1 = bigobj.create_object(params1)
obj2 = bigobj.create_object(params2)
# maybe do something with obj1 and obj2 here
bigobj.run()
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
I recommend putting *.py files there as
well, so users can refer to it if there are any problems, but you don't
have to. The Python module compileall is your friend here.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
hatever to their path path and
use it that way.
I realize it's a fine line and a judgment call in some cases, but site-
packages is really for libraries; applications should use their own
directories.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ighted that str.rstrip()
> removed the trailing-padding-for-nicer-layout no-break spaces that the
> users had copy/pasted from some clown's website :-)
>
> What was the *real* cause of your irritation?
If you want to use str.split() to split words, you will foil the user who
wants to not break at a certain point.
Your use of rstrip() is a lot more specialized, if you ask me.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
recursion.
Or, perhaps something more subtle than infinite recursion, such as
hard-to-comprehend rules about what modules and subpackages would be
imported. So they just decided to disallow it. Just a guess.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
? Is there a best practices guide for module
> naming?
Not really. Try to pick a unique name for your project. <:\
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
dia
article, which led me to the topsort algorithm. I did a dance of joy.
Ten minutes later I saw it mentioned it on comp.lang.python.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ng "univeral newlines" in a non-text format seems like it's not a
good idea.
For text-format pickles it'd be the right thing, of course.
> Incidentally, in the subprocess, it's useful to do
>
> sys.stdout = sys.stderr
>
> after setting up the Pick
quot;
> % id(w.should_keep_running))
>
> if __name__ == "__main__":
> main()
It looks like your program's hanging while the waiter is waits to
acquire another plate of hot food.
Quick and dirty solution is to have waiter timeout at intervals while
waiting for the chef and check the clock to see if his shift has
ended. Better solution is to rewrite the logic, which you did.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
f itself).
You can reassign the class's module:
from org.lib.animal.monkey import Monkey
Monkey.__module__ = 'org.lib.animal'
(Which, I must admit, is not a bad idea in some cases.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 24, 10:14 am, Bjoern Schliessmann wrote:
> Tim Roberts wrote:
> > Grant is quite correct; Python scripts (in the canonical CPython)
> > are NOT compiled into assembly language. Scripts are compiled to
> > an intermediate language. Processors execute Python scripts when
> > the interpreter
t least for
classes, without softening the one-to-one module-to-file relationship,
or using "hacks".
In fact, I'd say this is good practice.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
s
when it's not there.
Make sense? Details can vary, but that's the basic idea. In this
way, you can combine some of the openness that helps in early
development, but also have some of the benefits of stricter typing
when things mature and turn out to be pretty strictly useful, withou
On Jan 26, 12:32 am, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> Carl Banks <[EMAIL PROTECTED]> writes:
> > AirplaneInterface = InterfaceTracker("Airplane")
> > ...
> > set_up_initial_state()
> > ...
> > Airplane
appropriate for that particular use.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ISTM you came here looking for a particular means and not a
particular end. Python already has the power to meet your stated
needs, but you won't use that solution because it's "hacky".
Apparently all you really wanted was the loosened file structure in
the first place.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
quot;unintended consequences", by a
very large margin. Python has always been one-to-one module-to-file
(excepting modules built into the interpretter), and many codes and
tools have come to depend on it.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
effect other than by writing separate, independent
> manpages?
Not a big expert on docstrings (they seem so superfluous...) but
perhaps there are third-party packages that let you specify meta-
documentation with function decorators. For example:
@overview("Blah blah blah")
@authors("So and so")
def some_function():
pass
Try looking on PyPI (cheeseshop.python.org). Python's in-code
documentation is pretty basic; I think Python is happy to outsource
more elaborate schemes to third party packages.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
on,
to get a random index in a range.
Perhaps even better still, use random.choice. It gets a random
element in a sequence.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
-readable form. It is appropriate to call
> such a program a script. If the first two characters is "#!"
> and the execution bit is set, it is a script in the linux sense.
>
> So as far as I can tell it boils down to a clear technical
> distinction, and I'm sure they didn't mean offence.
Java doesn't compile to ELF binaries, last time I checked.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
xplain why the code which does more work
> > takes less time?
>
> > --
> > Steven
>
> The code that does more work takes more time. The second one does
> quite a bit less work. Think of it like this:
>
> You have 500,000 people to fit through a door. He
ly the true/false test only works for certain set of expected
values that I have in my mind. When the acceptable values are
generalized, when you want to expand this function's role, does the
true/false test still work? I find it rarely does.
The Python treatment of booleans is, by far, my biggest gripe with
Python. (Which, you know, is a pretty good thing to have as a biggest
gripe.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
tainly it wouldn't be
possible if Python treated bools according to my preference.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
od choice.
But if you're at that stage you probably were doing something wrong in
the first place.
For a list of any decent size a few insertions using a bisection
algorithm will take fewer comparisons than a single bubblesort pass.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 9, 4:37 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Feb 8, 10:09 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> >> If you expect your data to be pretty nearly sorted
> >> already, but you just want to make sure (e.g. because a
with divide by zero?
I understand your pain, but Python, like any good general-purpose
language, is a compromise. For the vast majority of programming,
division by zero is a mistake and not merely a degenerate case, so
Python decided to treat it like one.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
broken in the special
> case of division by zero.
Do you recall what the very next Zen after "Special cases aren't
special enough to break the rules" is?
that's-why-they-call-it-Zen-ly yr's,
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
%s not found" % value)
As an added bonus, you get a more useful error message if it's not
there (I know what you said, but bugs happen). If it's too bulky for
you, put it into its own function and call it.
> Can't You first convert the tuple of tuples in a dict, and the
om a particular user?
>
> > Regards,
> > Marek
>
> In essence what I'm doing is trying to manage tickets for a helpdesk.
> I want the ticket identifier to be short enough to fit in the subject
> line along with the normal subject chosen by the user. So
> cryptograp
p the OS
could still write that memory to swap space, which, if your swap space
is fixed and limited, might negatively affect performance for the rest
of the system.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 12, 1:05 pm, [EMAIL PROTECTED] wrote:
> What is dream hardware for the Python interpreter?
A 10 GHz single core.
(Dual core if doing lots of I/O.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
lass(cls):
try:
modname = cls.__module__
except AttributeError:
return False
try:
mod = sys.modules[modname]
except KeyError:
return False
try:
filename = mod.__file__
except AttributeError:
return False
return filename.endswith('.pyc')
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
t I did - I made the release
> candidate available to the public.
>
> So is the subject incorrect as well? If so, what should it say?
I think it's fine as it is. You can "release" a release candidate.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
eed to do some preliminary calculations in Python (where there's no
edit/compile/run cycle but there is slicing and array ops), but want
the same floating point behavior.
IEEE conformance is not an unreasonable thing to ask for, and "you
should be using something else" isn't a good answer to "why not?".
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
garlic, that suddenly turns into
> >>>>> Sylvester Stallone in a tutu just before my program returns its result.
> >>>> IHNTA, IJWTSA
> >>> IJWTW? Anyone set up to profile CPython?... or step through?
> >> I give up. Is there a
occasional special purpose uses, but for most
cases they're at best marginally better then floats and more often
incomparably worse.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 16, 5:51 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Feb 16, 3:03 pm, Lie <[EMAIL PROTECTED]> wrote:
> >> Although rationals have its limitations too, it is a much
> >> better choice compared to floats/Decimals for most case
On Feb 16, 5:51 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Feb 16, 3:03 pm, Lie <[EMAIL PROTECTED]> wrote:
> >> Although rationals have its limitations too, it is a much
> >> better choice compared to floats/Decimals for most case
On Feb 16, 7:54 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Feb 16, 5:51 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> >> Carl Banks wrote:
> >>> On Feb 16, 3:03 pm, Lie <[EMAIL PROTECTED]> wrote:
> >>>
nd subtraction would only grow the denominator up to
> a certain limit
I said repeated additions and divisions.
Anyways, addition and subtraction can increase the denominator a lot
if for some reason you are inputing numbers with many different
denominators.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
type-checked language, which means it is
totally safer for newbies than Python. Yep, your big company is
totally safe with newbie C++ programmers.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
in __dict__, is this the only
> way of doing it?
OrderedDict is usually the term used here for this (not to be confused
with SortedDict, which is a mapping type with identically sorted
keys). It's asked for pretty often but no one's stepped up to
implement one for the standard library.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
a downside: it's at least a wash.
In C++ you manage memory and the language manages resources. In
Python you manage resources and the language manages memory.
RAII is merely one way of minimizing complexity. Garbage collection
is another way.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 21, 7:17 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Feb 21, 1:22 pm, Nicola Musatti <[EMAIL PROTECTED]> wrote:
> >> There are other downsides to garbage collection, as the fact that it
> >> makes it harder t
all I was really saying is that there are far more more important
things when it comes to "safety" than dynamic typing.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 22, 12:23 am, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > On Feb 21, 7:17 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> >> Carl Banks wrote:
> >>> On Feb 21, 1:22 pm, Nicola Musatti <[EMAIL PROTECTED]> wrote:
> >>&
if m where m = re.match(r"name=(.*)",line):
name = m.group(1).strip()
elif m where m = re.match(r"id=(.*)",line):
id = m.group(1).strip()
elif m where m = re.match(r"phone=(.*)",line):
phone = m.group(1).strip()
This won't happen because the set-a
e(m):
phone = m.group(1).strip()
This decorator might be more to the point:
def call_if_match(regexp):
m = re.match(regexp)
if m:
return lambda func: func(m)
return lambda func: None
These have the drawback of being a little dense, and the functions
can't rebind v
501 - 600 of 1709 matches
Mail list logo