port' statements get compiled into a call to
__import__.
It also provides a way of importing something specifed by a
string at runtime, so it can be useful.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 16/01/21 3:37 pm, Chris Angelico wrote:
Surely it should be the other way around? If you use the C stdio
streams, flush them after use.
1. You might not know that you're (implicitly) using C stdio.
2. There doesn't seem to be an easy way to flush C stdio from
Python any more
urpose of stdio buffering.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
em in this particular case stems
from trying to use parts of curses without initialising it
properly. I expect that initialising curses would put stdout
into some kind of unbuffered mode, and the rest of it assumes
that this has been done.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
(3x), tgoto(3x),
tputs(3x) - direct curses interface to the terminfo capability database
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
me it would be useful to have something that returns
what tputs() would have output, as a string, so you can send it
where you want.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
_user("Couldn't connect to %s: %s" % (address, e))
2. If it's anything else, I assume it's a bug and let it
propagate.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ch it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 12/02/21 11:33 am, Mr Flibble wrote:
neos isn't a Python package so that isn't a problem.
It might be a bit confusing if it ever becomes part of the
wider Python ecosystem, though.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
time to a subclass of Port having the required
features. That would be a lot easier and more efficient than
adding individual methods to every Port instance, and super()
should work normally.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ts __len__ should return the number of
items you would get if you iterated over it. Anything else
is confusing and can lead to trouble, as you found here.
But is there a cleaner way to do this?
Yes. Give up on using __len__ to get the length in bytes,
and provide another way to do that.
--
Greg
On 3/03/21 12:24 pm, Chris Angelico wrote:
if PRODUCTION:
def assert(*a, **kw): pass
would work if it were a function :)
But would cost you a useless function call for every assert
in production mode.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
table or not makes no difference.
You can see this if you do the equivalent thing with lists:
>>> a = ["alice", "bob", "carol"]
>>> b = a
>>> b
['alice', 'bob', 'carol']
>>> b = ['dave', 'edward', 'felicity']
>>> a
['alice', 'bob', 'carol']
>>> b
['dave', 'edward', 'felicity']
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ves deep enough, making it
quite tricky to break off a row cleanly.
I'd upload a patch for that, but it doesn't seem to be
open source. At least I can't find it on chochub.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
12 RETURN_VALUE
Here the tuple creation is being done at compile time,
so there's still an unpacking operation. It might not be
much different speed-wise from loading the values separately,
though.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
reachable or not.
It would also break existing code. An unreachable "yield" is
sometimes used as a way to get a generator that doesn't yield
anything.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
me message.
Reading comp.lang.python with Thunderbird.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
My opinion on all this: The volume in this newsgroup is nowhere
near high enough to be worth changing anything.
This thread itself now contains more messages than the recent
neopython trollage that prompted it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
t; int = 42
>>> int
42
>>> __builtins__.int
>>>
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
es? Why should they be treated
differently to built-in types? Or are you suggesting there
should be a special syntax for declaring type names?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
he shadowing would be detected at compile
time, so you would only be warned once.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 26/05/21 3:33 am, Dennis Lee Bieber wrote:
the OBJECTS have a type and can not change type.
Well... built-in types can't, but...
>>> class A:
... pass
...
>>> class B:
... pass
...
>>> a = A()
>>> type(a)
>>> a.__class__ = B
>>
st giving you access to a
namespace.
But if you prefer, you can get the same result without
needing an import using
raise SystemExit(1)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
er. Almost every object in Python has
an interpretation as true or false, and can be used wherever a
boolean value is needed.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
en contains the thing you found.
It also has the benefit of being simple and consistent with
the way scoping and assignments work in the rest of the language.
There are other ways to code a search, of course, but it's been
the way it is from the beginning, and changing it now would be
massively
On 27/05/21 4:17 am, Chris Angelico wrote:
Worst case, it
is technically available as the ._fullcircle member, but I would
advise against using that if you can help it!
If you're worried about that, you could create your own
turle subclass that tracks the state how you want.
--
Greg
--
electronics in sight. Even the little dot-matrix printer that
wrote human-readable characters along the top of the card was
all mechanical!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
So a Python-specific definition is necessarily going
to be very different from a generic one.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ction.
That's not a definition of a property -- it's talking about a
mechanism that provides one way of creating a property, using
decorators. DON'T quote that as a definition!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
at in most cases the method is implemented
in C and it looks up a value in the object's dict.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
attribute?
(I'm assuming that by "data attribute" you mean a piece of
data that's stored directly in the object. If you mean
something else, we might be talking at cross purposes.)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
definition. Python's definition
is somewhat unusual, and so would not be appropriate.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
#x27;s not generally useful to get an arbitrary
value from a dict without its corresponding key. Hence the existence
of popitem().
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
and g represent?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
eir names?
Worst of all, will episodes of Doctor Who featuring the
Master be banned?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
I think I still need more information about the underlying problem
before I can help you much.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
2]
b = [1, 2]
c = [1, 2]
d = [1, 2]
s = (a, b)
t = (c, d)
then you are guaranteed to get four different list objects and
two diffferent tuple objects.
Does that help to ease your fears?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
objects.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
in all of
this. If the ultimate goal is to find a better mixture,
you need some kind of figure of merit for an individual
mixture. But you don't have that, you only have this
thing g that somehow depends on all of your mixtures
at once.
I'm still not seeing the big picture.
--
Greg
-
3. If you
use int division instead, they all get merged:
>>> NoDup = [(5, 2), (6-1, 6//3), (12%7, 1//1 + 1//1)]
>>> [id(x) for x in NoDup]
[4387030272, 4387030272, 4387030272]
So you need to be tricker than that to fool it!
The bottom line is, don't write code that depends on the identities
of immutable objects.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
on "haydn" triggered in my brain was a
local company that I have professional dealings with. Only when I
read a bit further did I realise it was referring to the composer!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 16/06/21 10:51 pm, Elena wrote:
sorry I wrote it wrongly, my bad, I will use f just to predict yi from new
coming Xi.
Then what do you do with the new yi?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 23/06/21 3:03 am, Kais Ayadi wrote:
for n in range(1, 7):
print (n)
for x in range(0, n):
print(" ", x)
can this code be more optimised?
Optimised for what? Readability? Execution speed? Code size?
Memory usage?
--
Greg
--
https://mail.python.org/mailma
However, that won't work very well if the message doesn't
consist of mostly text in an ASCII-compatible encoding.
If you want something better, Python comes with some standard
library code for dealing with mail messages. Check out the
'email' module.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 11/07/21 2:24 am, Dennis Lee Bieber wrote:
Off-hand, that looks like a BASH command, so stuff it in your .bashrc
or .profile and see what happens.
Or make yourself a little shell script that starts flask with
the appopriate settings.
--
Greg
--
https://mail.python.org/mailman
://medium.com/quick-code/3d-graphics-using-the-python-standard-library-99914447760c
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
..), then I subtract 1 from
1, getting 0 (that's J, ...), so I got "kcaJ" but my counter is 0 not
-13, which was my stopping point.
You need to first replace any negative or missing indices with
equivalent indices measured from the start of the string.
When you do that in this example, y
hat may not be doing what you think it's doing. Consider also
>>> if0: print('yes!')
yes!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
))
"Module(body=[AnnAssign(target=Name(id='if0', ctx=Store()),
annotation=Call(func=Name(id='print', ctx=Load()),
args=[Constant(value='yes!', kind=None)], keywords=[]), value=None,
simple=1)], type_ignores=[])"
"An annotated assignment without th
, it was
often the entire contents of the file. Applications had all the
code in there, for example -- the data fork of an application
was usually empty.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
what the module itself does, but
what other modules do with it. If any other module has imported
it, that module will still contain references to the old
module; if there are instances of a class defined in it still
existing, they will still be instances of the old version of
the class; etc.
On 18/08/21 4:43 pm, Steve wrote:
"The HAL (hardware abstraction layer) function HalMakeBeep()"
Is the beep that opens the pod bay doors?
def HalMakeBeepUsingPCSpeaker():
raise IOError("I'm sorry, I can't do that, Dave.")
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
27;ll have to tell us what you do want.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
lobals
dict:
g = {}
exec(code(), g)
g['p']()
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
the course anyway!)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ause NaNs never
compare equal. You still get a NaN either way, so for all practical
purposes it's commutative.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
minator is a power of 10, reduce that to lowest
terms, and compare with the result of as_integer_ratio().
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 7/09/21 11:38 am, Avi Gross wrote:
#define INDEFINITELY_LOOP while (true)
So, how to do something like that in python, is a challenge left to the user 😉
def hell_frozen_over():
return False
while not hell_frozen_over():
--
Greg
--
https://mail.python.org/mailman/listinfo
that sort of thing if you're a
Really Smart Person.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
execute completely at least once, and
aren't bugs waiting to be triggered by an edge case such as
empty input.
I seem to remember someone - maybe Wirth? - long ago expressing
the opinion that repeat-until loops often tended to be error
prone, but I can't provide a reference, sorry.
--
Greg
On 10/09/21 6:11 pm, Roland Mueller wrote:
When I call print(s) it even shows ABCD and D is underscored. But copying
the output to mail looses the underscore ...
If the terminal understands unicode, Combining Low Line: U+0332
might help
--
Greg
--
https://mail.python.org/mailman/listinfo
s* something in the stdlib called an array, but
it's rarely used or needed.)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
nd of object it is, rather than a generic name such
as "obj".
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
look up the name, if
it's global, which it usually is, and the machinery of the
call itself.
* Creating objects is expensive. Creating instances of
user-defined objects is more expensive than built-in ones.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
y
scan the trail looking for dead weakref objects and remove the
corresponding [*] node from the list.
You can also attach callbacks to weakref objects that are triggered
when the referenced object dies. You might be able to make use of
that to remove items from the trail instead of the per
aid to use them when it makes sense to do so.
I'm not sure what you mean by "some code annotations",
so I don't know how to answer that question. I suspect
that the way exceptions are implemented in the JVM is
similar to the way CPython does it, but I don't kno
peek:
...
But if get() in Python is implemented under the hood with
exception handling. ... then Python get() will probably be quite slow.
No, it doesn't use exceptions as far as I know. It should
be fairly fast.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
skip over dead ones
during backtracking.
Seems to me you would be doing about the same amount of
work either way, just doing it at different times.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
.g.
class Foo():
x : set
def __init__(self, s):
self.x = set()
if s:
self.x.add(s)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
make it possible, but
that would be turning them into special cases that break the rules.
It would be better to provide separate functions, as was done with
sum().
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
's bizarre. It's as though there were a large community of
professional builders who insisted on using hammers to drive
scews, and extolled the advantages of doing so.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ating point and writing them out again with exponents...
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
at in a different way.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 25/09/21 11:00 am, Chris Angelico wrote:
On Sat, Sep 25, 2021 at 8:53 AM dn via Python-list
wrote:
and YAML?
Invented because there weren't enough markup languages, so we needed another?
There were *too many* markup languages, so we invented another!
--
Greg
--
https://mail.pytho
On 29/09/21 4:37 am, Michael F. Stemper wrote:
I'm talking about something made
from tons of iron and copper that is oil-filled and rotates at 1800 rpm.
To avoid confusion, we should rename them "electricity comprehensions".
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 29/09/21 12:21 pm, Chris Angelico wrote:
to the extent that you automatically read 65 and 0x41 as the same
number.
Am I too geeky for reading both of them as 'A'?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
more than a byte at
a time. The second was a 6800, which is big-endian. That's definitely
more convenient when you're hand-assembling code! I can see the
advantages of little-endian when you're implementing a CPU, though.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 30/09/21 7:28 am, dn wrote:
Oh yes! The D2 kit - I kept those books for years...
https://www.electronixandmore.com/adam/temp/6800trainer/mek6800d2.html
My 6800 system was nowhere near as fancy as that! It was the
result of replacing the CPU in my homebrew Miniscamp.
--
Greg
--
https
On 23/10/21 8:49 am, dn wrote:
Whereas, creating a list (or tuple...) is legal because the structure's
name is an "identifier"!
No, the restriction only applies to the LHS. The list construction
is on the RHS.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
engineer sighs "not again".
Orders NaN beers and
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
have to give us more
details.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
at it was. You'll have to capture it earlier in the process
somehow and pass it to where it's needed.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
very common for handheld calculators to work in decimal.
Most of HP's classic calculators used a CPU that was specifically
designed for doing BCD arithmetic, and many versions of it didn't
even have a way of doing arithmetic in binary!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
bit words (14 BCD digits), and the instructions
had options for operating on various fields of a floating-point
number (mantissa, exponent, sign, etc.)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
]
>>> def f(x): return l[:-x or None]
...
>>> f(3)
['a', 'b']
>>> f(2)
['a', 'b', 'c']
>>> f(1)
['a', 'b', 'c', 'd']
>>> f(0)
['a', 'b', 'c', 'd', 'e']
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 14/12/21 7:07 am, MRAB wrote:
It's difficult to say what the problem is when you haven't given us the
code!
Note: Attachments do not make it to this list.
You will need to insert the code into the message as text.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ng it with sufficient privileges to put them in the
shared area?
Are you sure that your users are running the same Python that
you installed?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
!
But at least they'll be free of charge!
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
double the double-quote.
Another quirk is that Excel allows newlines in a quoted field,
which causes problems for naive parsers that split the input
into lines first and then analyse it into fields. (A particular
non-Python one I use professionally is guilty of this...)
--
Greg
--
https://mail.
tance, Py_RETURN_NONE will incref None and then
> return it.
>
The OP understands that this is not a normal thing to do. He's
trying to deliberately leak a reference for the purpose of diagnosing
a problem.
It would be interesting to see what the actual refcount is after
calling this fu
turn convention.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
er your OS provides (e.g. the
"time" shell command in unices).
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
loyed.
Or the internet acquires a new protocol that's designed
for very-long-latency connections.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
nd
to *any* name. The thing you're proposing wouldn't be
anonymous -- it would have a name, that name being the empty
string.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
skip waiting altogether and
immediately return None.
* Also if the first call to get_data() times out it will
return None (although maybe that's acceptable if the caller
is expecting it).
* The caller of get_data() is getting an object that could
be changed under it by a future update.
--
On 26/02/22 11:22 am, Chris Angelico wrote:
What's the best language for swearing in? Ah, that one I can't help
you with, although I've heard good things about French. :)
Russian seems to be quite good for it too, judging by
certain dashcam footage channels.
--
Greg
--
https://
ned to use JSON if the data is something that can
be easily represented that way.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
it's up to
the program to split it up how it wants. Different programs do that in
different ways, hence the inconsistencies in how quoting and whitespace
is handled.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
expect the kind of problem they're having. It could be argued that
it's their responsibility to ensure that all the needed code is loaded
into the subprocess.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
Canterbury recently started using a Microsoft thing
for all its email, and it thinks a large proportion of messages in
the Python mailing lists are Very Dangerous Phishing Emails and
helpfully quarantines them for me behind a clunky web interface. :-(
--
Greg
--
https://mail.python.org/mailman
501 - 600 of 1198 matches
Mail list logo