Terry Reedy wrote:
It seems to me that generators are already 'channels' that connect the
calling code to the __next__ method, a semi-coroutine based on the body
of the generator function. At present, the next method waits until an
object is requested. Then it goes into action, yields an objec
John Nagle wrote:
In the beginning, strings, tuples, and numbers were immutable, and
everything else was mutable. That was simple enough. But over time,
Python has acquired more immutable types - immutable sets and immutable
byte arrays. Each of these is a special case.
Immutabil
Jean-Claude Neveu wrote:
Hello,
I was wondering if someone could tell me where I'm going wrong with my
regular expression. I'm trying to write a regexp that identifies whether
a string contains a correctly-formatted currency amount. I want to
support dollars, UK pounds and Euros, but the exam
mattia wrote:
I'm using urlopen in order to download some web pages. I've always to
replace some characters that are in the url, so I've come up with:
url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace
(":", "%3A")
There isn't a better way of doing this?
Yeah, shame there's
Johannes Bauer wrote:
Hello group,
I'm looking for a Python function but have forgotten it's name.
Essentially what I want is:
class Foo():
def bar(self):
pass
x = Foo()
y = x.MAGIC("bar")
print(y)
>
So the question is: How is the magic function called which returns me
George Sakkis wrote:
If you push this logic too far, you should del every name immediately
after the last statement it is used in the scope. I would generally
find less readable some code spread with del every few lines, micro-
managing the effective scope of each name. YMMV.
Yes, but ... how
On Apr 19, 3:16 am, Joseph Turian <[EMAIL PROTECTED]> wrote:
> Basically, we're planning on releasing it as open-source, and don't
> want to alienate a large percentage of potential users.
How about Java users? Jython was recently at 2.2 (still is for all I
know). I'm pleased they've got that fa
On Apr 11, 6:14 pm, bdsatish <[EMAIL PROTECTED]> wrote:
> The built-in function round( ) will always "round up", that is 1.5 is
> rounded to 2.0 and 2.5 is rounded to 3.0.
>
> If I want to round to the nearest even, that is
>
> my_round(1.5) = 2# As expected
> my_round(2.5) = 2# Not
Dennis Lee Bieber wote:
> But if these "macros" are supposed to allow one to sort of extend
> Python syntax, are you really going to code things like
>
> macrolib1.keyword
>
> everywhere?
I don't see why that *shouldn't* work. Or "from macrolib1 import
keyword as foo". And to be tru
Douglas Alan wote:
> Graham Breed <[EMAIL PROTECTED]> writes:
>
> > Another way is to decorate functions with their local variables:
>
> >>>> from strict import my
> >>>> @my("item")
> > ... def f(x=1, y=2.5, z=[1,2,4]):
> >
Steven D'Aprano wote:
> But if you really want declarations, you can have them.
>
> >>> import variables
> >>> variables.declare(x=1, y=2.5, z=[1, 2, 4])
> >>> variables.x = None
> >>> variables.w = 0
> Traceback (most recent call last):
> File "", line 1, in
> File "variables.py", line 15, i
Duncan Booth wote:
> If you must insist on using backslash escapes (which introduces the
> question of how you get backslashes into the output: do they have to be
> escaped as well?) then use string.Template with a custom pattern.
If anybody wants this, I worked out the following regular expressi
f he really does want to reject single letter variable names,
or names beginning with a backslash, he'll still need to subclass
Template and supply a regular expression, but a simpler one.
> ... and in another message Graham Breed wrote:
> > def get_variable(varname):
> >
Samuel wote:
> Thanks, however, turns out my specification of the problem was
> incomplete: In addition, the variable names are not known at compilation
> time.
> I just did it that way, this looks fairly easy already:
>
> ---
> import re
>
> def variable_sub_cb(match):
>
Jim Lewis \/\/|20+3:
> I'm not planning to write C functions. My understanding is that by
> using cdefs in the python code one can gain substantial speed. I'm
> trying to find a description of how to modify python code in more
> detail so it runs fast under pyrex.
I've used pyrex to speed up my co
15 matches
Mail list logo