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
..), 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
://medium.com/quick-code/3d-graphics-using-the-python-standard-library-99914447760c
--
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
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 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
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 "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
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
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
-
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
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
eir names?
Worst of all, will episodes of Doctor Who featuring the
Master be banned?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
and g represent?
--
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
definition. Python's definition
is somewhat unusual, and so would not be appropriate.
--
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
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
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
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
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
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
--
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
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
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
he shadowing would be detected at compile
time, so you would only be warned once.
--
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
t; int = 42
>>> int
42
>>> __builtins__.int
>>>
--
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
me message.
Reading comp.lang.python with Thunderbird.
--
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
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
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
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
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
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
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
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
ch it.
--
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
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
(3x), tgoto(3x),
tputs(3x) - direct curses interface to the terminfo capability database
--
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
urpose of stdio buffering.
--
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
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
o interact badly with Python
stdio.
Can something be done about this? Maybe Python stdio objects
should flush all the C stdio streams before writing anything?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ge.
So get and set methods are unnecessary and actively discouraged
in Python.
(C#, if I understand correctly, gets this sort of half-right.
You can turn an attribute into a property, and the calling *source*
doesn't change, but it all has to be recompiled -- which kind of
defeats the purpose.)
ng as sqrt, but the sqrt function probably uses a more
efficient algorithm.
Also, exponentiation assumes you're okay with getting a
complex result:
>>> (-27)**0.5
(3.181725716174721e-16+5.196152422706632j)
So it's not quite the same thing as math.sqrt().
--
Greg
--
https:/
;t see any harm in
allowing the app to *request* (not force) a certain position for
a window.
The app can of course abuse that privilege, but that's the fault
of the app, not the feature.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 14/01/21 11:09 am, Grant Edwards wrote:
Perhaps I need to recalibrate my adjectives, but with
256KB+ of flash and 32KB+ of RAM, I wouldn't call them "small"
It's small by today's standards, when you consider that
multiple GB of RAM is commonplace now in most &
On 13/01/21 7:57 pm, Christian Gollwitzer wrote:
What do you mean, "until" ?
https://medium.com/@yon.goldschmidt/running-python-in-the-linux-kernel-7cbcbd44503c
He's using Micropython. That's cheating! :-)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 13/01/21 4:18 am, Grant Edwards wrote:
AFAIK, Python can't be used to write device drivers for any popular OS
At least not until some crazy person embeds Python in the
Linux kernel...
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ment following -r
containing a value.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ard python distribution, gives low-level access to C library
functions).
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
look right to
you, it may be the fault of whatever you're using to read
the group.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
"credits" or "license" for more information.
>>> s = 'Hello World'
>>> s
'Hello World'
>>> b = s.encode('ascii')
>>> b
b'Hello World'
>>> s2 = b.decode('ascii')
>>> s2
'Hello World'
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 9/01/21 12:10 pm, pascal z wrote:
any way to attach a file because I loose indentation?
Indentation usually makes it through here if you indent with
spaces rather than tabs.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 9/01/21 11:17 am, Martin Schöön wrote:
"regardless of what you have been told, recreational use of
mathematics is harmless"
I hope that is true for recreational programming as well :-)
Mostly harmless, but it can be addictive!
--
Greg
--
https://mail.python.org/mailman/listi
x27;b', 'c'], 3, [], words)
print(words)
For this particular problem it's less efficient than the
technique used by itertools.product, because it generates
sub-combinations multiple times. However, it's a useful
technique to keep in mind whenever you have a "variable
number o
On 3/01/21 12:30 am, Alan Bawden wrote:
So as long as the OP's commands are no longer than 512 bytes, and as
long as they are careful to send commands in a single call to write(),
Also note that's one write() system call, which may or may not
correspond to one Python write() call
g
but functions.
This is mainly of theoretical interest; it's not usually a
practical way to go about things. But it's a good exercise
in thinking about functions as objects to be manipulated.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
macros effectively let you do something similar.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
the limit is
about 1000. So if you have a large graph with a path more than
1000 steps long, you can hit the recursion limit.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
nterpreter?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ntics with respect to particular
types -- that's left to the type checkers.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
gives you another view of the underlying data.
This is a trap you need to watch out for, since it's
different from the way sequences normally behave in
Python.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ery different things...
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
of the
standard offerings from Microsoft such as WinForms rather than
rolling your own.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
en changes occur.
On the other hand, if the toolkit wraps the platform's native widgets,
it gets all the correct appearance and behaviour, and automatically
tracks changes.
For these reasons I regard "uses native widgets" as a mark of quality
for a toolkit.
--
Greg
--
https://mail.py
ed=True does *not*
make your result biased -- quite the contrary!)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
actually do any harm if someone instantiated your
base class? If not, then it's probably not worth going out
of your way to prevent it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ve you tried using a different name, such as "my_types.py"?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
had this way
of using "pass" in mind. More likely they're just trying to be helpful
and save you from having to manually unindent in a few rare situations.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
so
rarely needed. Although it probably wouldn't be as fast as an
LC could potentially be, due to the need to call a user-supplied
function for every item.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
chine it seems to be about 17 times slower than using
a trailing comma:
>>> timeit.repeat("tuple(['first'])")
[0.1774688908953, 0.1768788059062, 0.1768771102082,
0.176763284033, 0.17684489200001963]
>>> timeit.repeat("('first',)")
[0.0117392889055, 0.01156933400708, 0.01158800017473,
0.01156976132486, 0.01157938358281]
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
empty __init__.py in
Python 3.8 and there was no problem:
% ls -l empty
total 0
-rw-r--r-- 1 greg staff 0 20 Sep 12:00 __init__.py
% python3
Python 3.8.2 (default, Mar 23 2020, 11:36:18)
[Clang 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits"
normal brackets, but
there are a few interesting ones, such as LEFT/RIGHT WHITE/BLACK
LENTICULAR BRACKET and LEFT/RIGHT TORTOISE SHELL BRACKET.
〖 〗【 】〔 〕
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ue
>>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino
True
What happens if you go one level deeper? I.e. is
os.lstat('test1/spam/eggs/../..').st_ino == os.lstat('test1').st_ino
and
os.lstat('test2/spam/eggs/../..').st_ino == os.lstat('test2').st_ino
?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 23/07/20 12:23 pm, dn wrote:
You be sure to have a nice day, now!
How do you feel about you be sure to have a nice day, now?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
nding mode for
floats.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
so that you keep whatever indentation the line had before.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
't specify a metaclass.
I find it peculiar that you can give a function as metaclass.
Yes, it just calls whatever object you give it, which allows
for various fun things. You'd be risking a lynching if you took
advantage of it for anything important, though.:-)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
7;, '__init__', '__new__',
'__thisclass__', '__self__', '__self_class__', '__doc__']
from which it's clear that the super object overrides __getattribute__
but not __getattr__.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
*should* be
eliminated, before thinking about how to achieve it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 22/03/20 10:20 pm, Greg Ewing wrote:
I'm going to try again with XCode 8, which purportedly comes
with a 10.12 SDK, and see if that fixes it.
It does.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
version) but I think
I'm being bitten by the same underlying issue.
I'm going to try again with XCode 8, which purportedly comes
with a 10.12 SDK, and see if that fixes it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
bort trap: 6
Am I out of luck? Is Python 3.8 only intended work on very recent
versions of MacOSX?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
the
tp_getattro type slot, which corresponds to __getattribute__.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
call a coroutine, so switching a
function between coroutine and non-coroutine would still have
just as much of a ripple effect on the rest of your code.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ion, while ensuring that there really
is only one instance, and making this fact clear to anyone
reading the code.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
blems need to be addressed by appropriate use of locks,
etc.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
e point of asyncio is to make tasks very lightweight, so you
can use as many of them as is convenient without worries. One task
per client sounds like the right thing to do here.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 3/02/20 3:38 am, Stefan Ram wrote:
void( ( print( 2 ), print( 3 )))
If the functions you're calling all return None, you can
do this:
>>> print(2); print(3)
2
3
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 29/01/20 6:27 pm, Peng Yu wrote:
Suppose that I use this to read from stdin. But `line` contains
decoded data in python 3. In python 2, it contains the original data.
What is the best way to get the original data in python 3?
Read from stdin.buffer, which is a stream of bytes.
--
Greg
ree assignment statements.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
_']['__imp'+'ort__']",
{"__builtins__":{}})
You can probably find a way to block that particular loophole.
But then there will be another one, and another, and another...
You'll never be sure that you've found all of them.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
port from being opened.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
201 - 300 of 1192 matches
Mail list logo