Le 28/03/2024 à 18:07, Stefan Ram a écrit :
ast wrote or quoted:
s1 = "AZERTY"
s2 = "QSDFGH"
s3 = "WXCVBN"
and I need an itertor who delivers
A Q W Z S C E D C ...
I didn't found anything in itertools to do the job.
So I came up with this solution:
l
Le 28/03/2024 à 17:45, ast a écrit :
A Q W Z S C E D C ...
sorry
A Q W Z S X E D C
--
https://mail.python.org/mailman/listinfo/python-list
Hello
Suppose I have these 3 strings:
s1 = "AZERTY"
s2 = "QSDFGH"
s3 = "WXCVBN"
and I need an itertor who delivers
A Q W Z S C E D C ...
I didn't found anything in itertools to do the job.
So I came up with this solution:
list(chain.from_iterable(zip("AZERTY", "QSDFGH", "WXCVBN")))
['A',
Python 3.9.9
Hello
I have some troubles with groupby from itertools
from itertools import groupby
for k, grp in groupby("aahfffddnnb"):
print(k, list(grp))
print(k, list(grp))
a ['a', 'a']
a []
h ['h']
h []
f ['f', 'f', 'f']
f []
d ['d', 'd']
d []
s ['s', 's', 's', 's']
s []
n ['n
Le 19/11/2021 à 21:17, Chris Angelico a écrit :
On Sat, Nov 20, 2021 at 5:08 AM ast wrote:
Le 19/11/2021 à 03:51, MRAB a écrit :
On 2021-11-19 02:40, 2qdxy4rzwzuui...@potatochowder.com wrote:
On 2021-11-18 at 23:16:32 -0300,
René Silva Valdés wrote:
>>> 0.3 + 0.3 + 0.3 ==
Le 22/11/2021 à 16:02, Jon Ribbens a écrit :
On 2021-11-22, ast wrote:
For immutable types, copy(foo) just returns foo.
ok, thx
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
>>> a = 6
>>> b = 6
>>> a is b
True
ok, we all know that Python creates a sole instance
with small integers, but:
>>> import copy
>>> b = copy.copy(a)
>>> a is b
True
I was expecting False
--
https://mail.python.org/mailman/listinfo/python-list
Le 19/11/2021 à 12:43, ast a écrit :
Le 19/11/2021 à 03:51, MRAB a écrit :
On 2021-11-19 02:40, 2qdxy4rzwzuui...@potatochowder.com wrote:
On 2021-11-18 at 23:16:32 -0300,
René Silva Valdés wrote:
Hello, I would like to report the following issue:
Working with floats i noticed that:
int
Le 19/11/2021 à 03:51, MRAB a écrit :
On 2021-11-19 02:40, 2qdxy4rzwzuui...@potatochowder.com wrote:
On 2021-11-18 at 23:16:32 -0300,
René Silva Valdés wrote:
Hello, I would like to report the following issue:
Working with floats i noticed that:
int(23.99/12) returns 1, and
int(
Le 17/11/2021 à 13:10, Python a écrit :
ast wrote:
Hello,
It seems that symbolic links on Windows are not
well reconized by modules os or pathlib.
I have a file named json.txt on my destop. With a
drag and drop right click on it I create a link
automatically named: json.txt - Raccourci.lnk
Hello,
It seems that symbolic links on Windows are not
well reconized by modules os or pathlib.
I have a file named json.txt on my destop. With a
drag and drop right click on it I create a link
automatically named: json.txt - Raccourci.lnk
Then:
>>> from pathlib import Path
>>> p2 = Path('C:/
A curiosity:
q = lambda x: x and q([i for i in x[1:] if i < x[0]]) + [x[0]] + q([i
for i in x[1:] if i >= x[0]])
>>> q([7, 5, 9, 0])
[0, 5, 7, 9]
--
https://mail.python.org/mailman/listinfo/python-list
Le 04/11/2021 à 16:41, Stefan Ram a écrit :
ast writes:
(scale * i for i in srcpages.xobj_box[2:]) is a generator, a single
object, it should not be possible to unpack it into 2 variables.
But the value of the right-hand side /always/ is a single object!
A syntax of an assignment
Hello
In this function
def get4(srcpages):
scale = 0.5
srcpages = PageMerge() + srcpages
x_increment, y_increment = (scale * i for i in srcpages.xobj_box[2:])
for i, page in enumerate(srcpages):
page.scale(scale)
page.x = x_increment if i & 1 else 0
page.y
> li = []
> li.append(li)
> li
[[...]]
>li[0][0][0][0]
[[...]]
That's funny
--
https://mail.python.org/mailman/listinfo/python-list
Hello
class NewStr(str):
def __init__(self, s):
self.l = len(s)
Normaly str is an immutable type so it can't be modified
after creation with __new__
But the previous code is working well
obj = NewStr("qwerty")
obj.l
6
I don't understand why it's working ?
(python 3.9)
--
https:/
Le 06/08/2021 à 02:57, Jach Feng a écrit :
ast 在 2021年8月5日 星期四下午11:29:15 [UTC+8] 的信中寫道:
Le 05/08/2021 à 17:11, ast a écrit :
Le 05/08/2021 à 11:40, Jach Feng a écrit :
import regex
# regex is more powerful that re
text = 'ch 1. is\nch 23. is\nch 4 is\nch 56 is\n'
regex.finda
Le 05/08/2021 à 17:11, ast a écrit :
Le 05/08/2021 à 11:40, Jach Feng a écrit :
I want to distinguish between numbers with/without a dot attached:
text = 'ch 1. is\nch 23. is\nch 4 is\nch 56 is\n'
re.compile(r'ch \d{1,}[.]').findall(text)
['ch 1.', &
Le 05/08/2021 à 17:11, ast a écrit :
Le 05/08/2021 à 11:40, Jach Feng a écrit :
I want to distinguish between numbers with/without a dot attached:
text = 'ch 1. is\nch 23. is\nch 4 is\nch 56 is\n'
re.compile(r'ch \d{1,}[.]').findall(text)
['ch 1.', &
Le 05/08/2021 à 11:40, Jach Feng a écrit :
I want to distinguish between numbers with/without a dot attached:
text = 'ch 1. is\nch 23. is\nch 4 is\nch 56 is\n'
re.compile(r'ch \d{1,}[.]').findall(text)
['ch 1.', 'ch 23.']
re.compile(r'ch \d{1,}[^.]').findall(text)
['ch 23', 'ch 4 ', 'ch 56 '
Hello
Reading PEP572 about Python 3.9 assignment expressions,
I discovered a subtle difference between any(a list)
and any(a generator)
see:
>>> lines = ["azerty", "#qsdfgh", "wxcvbn"]
>>> any((comment := line).startswith('#') for line in lines)
True
>>> comment
"#qsdfgh"
>>> any([(comment :=
Le 20/12/2020 à 21:00, danilob a écrit :
b = ((x[0] for x in a))
There is a useless pair of parenthesis
b = (x[0] for x in a)
b is a GENERATOR expression
first list(b) calls next method on b repetedly until b is empty.
So it provides the "content" of b
second list(b) provides nothing si
Le 12/12/2020 à 09:18, Cameron Simpson a écrit :
On 12Dec2020 07:39, ast wrote:
In case a function recursively calls itself many times,
is there a way to return a data immediately without
unstacking all functions ?
Not really. Do you have an example where this is inconvenient?
There are
Le 12/12/2020 à 17:10, Oscar a écrit :
In article <5fd465b5$0$8956$426a7...@news.free.fr>, ast wrote:
Hello
In case a function recursively calls itself many times,
is there a way to return a data immediately without
unstacking all functions ?
If you are referring to your "
Hello
In case a function recursively calls itself many times,
is there a way to return a data immediately without
unstacking all functions ?
--
https://mail.python.org/mailman/listinfo/python-list
Le 26/06/2020 à 15:12, Peter Otten a écrit :
Unknown wrote:
The getter/setter of the property builtin return a new property
p = property()
q = p.getter(None)
p is q
False
where you
def getter(self, fget):
self.fget = fget
return self
modify the existing one.
Le 26/06/2020 à 10:16, R.Wieser a écrit :
ast,
I have absolutily /no idea/ about how that "fahrenheit = property()" comes
into play though.
It just creates an empty property object.
You can then fill this object with the read/write/delete functions
with the methods gett
Hello,
I am wondering why this code is OK:
class Temperature:
def __init__(self):
self.celsius = 0
fahrenheit = property()
@fahrenheit.getter
def fahrenheit(self):
return 9/5*self.celsius +32
@fahrenheit.setter
def fahrenheit(self, value
Hello
Suppose we want that:
print("abcdef"); print("ghi")
produces:
ghidef
The 2nd print overwrites the first one.
Is it feasible ?
It should since the progress bar tdqh seems to do that
try:
from tkdm import tkdm
for i in tqdm(range(100_000_000)):
pass
It produces a progress bar li
Hello
doctest of the sample function funct() doesn't works
because flag used by funct() is the one defined in
first line "flag = True" and not the one in the
doctest code ">>> flag = False".
Any work around known ?
flag = True # <- funct() always use this one
def funct():
"""
Le 12/04/2020 à 23:40, Paul Rubin a écrit :
You might have heard by now that John Horton Conway died yesterday at
age 82, of complications from the SARS-Cov2 aka Corona virus. Among his
many cool accomplishments was inventing the Game of Life, which was one
of my first exercises as a beginning p
Le 07/05/2019 à 05:31, Paul Rubin a écrit :
#!/usr/bin/python3
from itertools import chain
def adjacents(cell):# generate coordinates of cell neighbors
x, y = cell # a cell is just an x,y coordinate pair
return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1]
Le 28/04/2020 à 09:52, ast a écrit :
Le 28/04/2020 à 09:39, Antoon Pardon a écrit :
Op 27/04/20 om 18:39 schreef Bob van der Poel:
Thanks Chris!
At least my code isn't (quite!) as bad as the xkcd example :)
Guess my "concern" is using the initialized array in the function:
Le 28/04/2020 à 09:39, Antoon Pardon a écrit :
Op 27/04/20 om 18:39 schreef Bob van der Poel:
Thanks Chris!
At least my code isn't (quite!) as bad as the xkcd example :)
Guess my "concern" is using the initialized array in the function:
def myfunct(a, b, c=array[0,1,2,3] )
always feels
Le 28/04/2020 à 09:13, Chris Angelico a écrit :
On Tue, Apr 28, 2020 at 4:56 PM ast wrote:
Le 27/04/2020 à 04:46, Bob van der Poel a écrit :
"Best"? Not sure about that. Functions are first-class objects in
Python, so a function *is* a callable object. You don't have to
Le 28/04/2020 à 08:51, ast a écrit :
Le 27/04/2020 à 04:46, Bob van der Poel a écrit :
Does this make as much sense as anything else? I need to track calls to a
function to make sure it doesn't get called to too great a depth. I had a
global which I inc/dec and then check in the function.
Le 27/04/2020 à 04:46, Bob van der Poel a écrit :
Does this make as much sense as anything else? I need to track calls to a
function to make sure it doesn't get called to too great a depth. I had a
global which I inc/dec and then check in the function. Works fine, but I do
need to keep a global a
Hello
It's not clear to me what the differences between
Axes and AxesSubplot classes are
AxesSubplot is a sub class of Axes
It is possible to draw in objects of both type with
plot, scatter ...
Axes object seems to be able to be inserted in AxesSubplot object
(It is strange because AxesSubplot
Le 21/04/2020 à 18:32, Dieter Maurer a écrit :
ast wrote at 2020-4-21 14:27 +0200:
I recently read the Python (3.9a5) documentation - and there
I found clearly expressed this behaviour (I no longer can
tell you exactly where I read this).
The reason comes from the implementation: when the
Hello
From python version 3.6, there is a useful new method
__set_name__ which could be implemented in descriptors.
This method is called after a descriptor is instantiated
in a class. Parameter "name" is filled with the name
of the attribute refering to the descriptor in the class
Here is an e
Le 19/04/2020 à 17:06, ast a écrit :
I understood where the problem is.
Once __get__ is defined, it is used to read self._name in method
__set_name__ and it is not défined yet. That's why I have
an error "'NoneType' object is not callable"
Thats a nice bug.
I need
Hello
This code is working well: (I am using python 3.6.3)
class my_property:
def __init__(self, fget=None, fset=None, fdel=None):
self.fget = fget
self.fset = fset
self.fdel = fdel
def __set_nam
Le 18/04/2020 à 15:07, Souvik Dutta a écrit :
I have one question here. On using print(f"{c:.32f}") where c= 2/5 instead
of getting 32 zeroes I got some random numbers. The exact thing is
0.40002220446049250313
Why do I get this and not 32 zeroes?
2/5 = 0.0110011001100110011001..
Le 17/04/2020 à 13:40, Aakash Jana a écrit :
I am running python 3.8 only but my issue is I need more zeroes after my
result.
I want 2/5 = 0.40
But I am only getting 0.4
f"{2/5:.6f}"
'0.40'
--
https://mail.python.org/mailman/listinfo/python-list
Hello
I wrote a decorator to add a cache to functions.
I realized that cache dictionnary could be defined
as an object attribute or as a local variable in
method __call__.
Both seems to work properly.
Can you see any differences between the two variants ?
from collection import OrderedDict
clas
Hi
An operation like x+=1 on a global variable x is not thread safe because
there can be a thread switch between reading and writing to x.
The correct way is to use a lock
lock = threading.Lock
with lock:
x+=1
I tried to write a program without the lock which should fail.
Here it is:
im
Le 02/10/2019 à 12:22, Richard Damon a écrit :
On 10/2/19 1:12 AM, ast wrote:
Le 01/10/2019 à 20:56, Timur Tabi a écrit :
Could you please fix your email software so that it shows a legitimate
email address in the From: line? Your emails all show this:
From: ast
All of your emails
Le 01/10/2019 à 20:56, Timur Tabi a écrit :
Could you please fix your email software so that it shows a legitimate
email address in the From: line? Your emails all show this:
From: ast
All of your emails are being caught in my spam filter because of this
address. I would email you
Le 01/10/2019 à 13:18, Rhodri James a écrit :
On 01/10/2019 08:37, ast wrote:
The problem is that "factorial" in line
"return n * factorial(self, n - 1)" should not have been found
because there is no factorial function defined in the current
scope.
Not so. "fa
Hello
I am trying to understand a program which use
a method named scanner on a re compiled object.
This program is named "Simple compiler" here:
https://www.pythonsheets.com/notes/python-generator.html
But unfortunately it is not documented
nor here:
https://docs.python.org/3.7/library/re.htm
Le 30/09/2019 à 13:11, Anders Märak Leffler a écrit :
What do you mean by transformed? This is probably your understanding
already, but a further consequence of when arguments are evaluated
plus what you said about data attributes is that the fib(self, n - 1)
call will follow the standard LEGB-lo
Le 27/09/2019 à 14:26, Jan van den Broek a écrit :
On 2019-09-27, ast wrote:
Is it feasible to define a recursive method in a class ?
(I don't need it, it's just a trial)
Here are failing codes:
class Test:
def fib(self, n):
if n < 2: return n
return
Hello
Is it feasible to define a recursive method in a class ?
(I don't need it, it's just a trial)
Here are failing codes:
class Test:
def fib(self, n):
if n < 2: return n
return fib(self, n-2) + fib(self, n-1)
t = Test()
t.fib(6)
-
Traceback (most r
Le 26/09/2019 à 15:17, Peter Otten a écrit :
ast wrote:
__init__ is called only if __new__ returns an instance of ClassB:
I was ignoring that. thank you
--
https://mail.python.org/mailman/listinfo/python-list
Le 26/09/2019 à 14:20, ast a écrit :
Hello
In the following code found here:
https://www.pythonsheets.com/notes/python-object.html
__init__ is not invoked when we create an object
with "o = ClassB("Hello")". I don't understand why.
I know the correct way to define __
Hello
In the following code found here:
https://www.pythonsheets.com/notes/python-object.html
__init__ is not invoked when we create an object
with "o = ClassB("Hello")". I don't understand why.
I know the correct way to define __new__ is to write
"return object.__new__(cls, arg)" and not "retur
Hello
A line of code which produce itself when executed
>>> s='s=%r;print(s%%s)';print(s%s)
s='s=%r;print(s%%s)';print(s%s)
Thats funny !
--
https://mail.python.org/mailman/listinfo/python-list
Le 24/09/2019 à 15:51, אורי a écrit :
https://stackoverflow.com/a/24752607/1412564
thank you for link. it's clear now
--
https://mail.python.org/mailman/listinfo/python-list
Hi
It is not clear to me why the following code
generates 2 exceptions, ZeroDivisionError and
ArithmeticError. Since ZeroDivisionError is
catched, it shoud not bubble out.
Found here:
https://www.pythonsheets.com/notes/python-new-py3.html
>>> def func():
... try:
... 1 / 0
... e
Hello
Following syntax doesn't generate any errors:
>>> foo=0
>>> Class Foo:
foo
But class Foo seems empty
Is it equivalent to ?
>>> class Foo:
pass
--
https://mail.python.org/mailman/listinfo/python-list
Le 14/09/2019 à 03:40, Random832 a écrit :
On Fri, Sep 13, 2019, at 21:22, Hongyi Zhao wrote:
what's the differences: None and null?
null isn't really a concept that exists in Python... while None fills many of
the same roles that null does in some other languages, it is a proper object,
wit
Le 14/09/2019 à 04:26, Oscar Benjamin a écrit :
I've been staring at this for a little while:
from itertools import product
class Naturals:
def __iter__(self):
i = 1
while True:
yield i
i += 1
N = Naturals()
print(iter(N))
print(product(N)) # <
Le 11/09/2019 à 12:11, Sayth Renshaw a écrit :
Hi
I want to allow as many lists as needed to be passed into a function.
But how can I determine how many lists have been passed in?
I expected this to return 3 but it only returned 1.
matrix1 = [[1, -2], [-3, 4],]
matrix2 = [[2, -1], [0, -1]]
mat
Hello
I read in a course that class UserList from module
collections can be used to create our own custom list
Example
>>> from collections import UserList
>>> class MyList(UserList):
... def head(self):
... return self.data[0]
... def queue(self):
... return self.data[1
Hello
List sys.path contains all paths where python shall
look for libraries.
Eg on my system, here is the content of sys.path:
>>> import sys
>>> sys.path
['',
'C:\\Users\\jean-marc\\Desktop\\python',
'C:\\Program Files\\Python36-32\\python36.zip',
'C:\\Program Files\\Python36-32\\DLLs',
'C:\\
Hello
In the following snippet, a file is opened but
without any variable referring to it.
So the file can't be closed.
[line.split(":")[0]
for line in open('/etc/passwd')
if line.strip() and not line.startswith("#")]
What do you think about this practice ?
--
https://mail.python.org/mailm
Hello
I just uploaded a package on pypi, whose name is "arith_lib"
The strange thing is that on pypi the package is renamed "arith-lib"
The underscore is substitued with a dash
If we search for this package:
pip search arith
arith-lib (2.0.0) - A set of functions for miscellaneous arithmetic
Hello
I noticed a quirk difference between classes and functions
>>> x=0
>>>
>>> class Test:
x = x+1
print(x)
x = x+1
print(x)
1
2
>>> print(x)
0
Previous code doesn't generate any errors.
x at the right of = in first "x = x+1" line is
the global one (x=0), then
Le 24/02/2019 à 05:21, Himanshu Yadav a écrit :
fibs={0:0,1:1}
def rfib(n):
global fibs
if not fibs.get(n):
fibs[n]=rfib(n-2)+rfib(n-1)
return fibs[n]
Why it is gives error??
Nothing to do with the malfunction, but you dont need
to define fibs as globa
Hello
Is it normal to have 151 entries in dictionary sys.modules
just after starting IDLE or something goes wrong ?
>>> import sys
>>> len(sys.modules)
151
Most of common modules seems to be already there,
os, itertools, random
I thought that sys.modules was containing loaded modules
with
Le 13/02/2019 à 14:21, ast a écrit :
Hello
>>> float('Nan') == float('Nan')
False
Why ?
Regards
Thank you for answers.
If you wonder how I was trapped with it, here
is the failing program.
r = float('Nan')
while r==float('Nan'):
i
Hello
>>> float('Nan') == float('Nan')
False
Why ?
Regards
--
https://mail.python.org/mailman/listinfo/python-list
Le 18/09/2018 à 17:01, ast a écrit :
error: permut instead of S
yield from permut(li2, prefix+[elt])
--
https://mail.python.org/mailman/listinfo/python-list
Hello
I found a smart and very concise code to
generate all permutations of a list.
I put it here if someone is interested to
figure out how it works
def permut(li, prefix=[]):
if len(li)==1:
yield prefix + li
else:
for elt in li:
li2 = li.copy()
Le 19/06/2018 à 11:47, Peter Otten a écrit :
ast wrote:
Le 19/06/2018 à 10:57, Peter Otten a écrit :
ast wrote:
No, with dt = 100 it should last
200 * 100ms = 20.000ms = 20s
with dt = 0.1 it should last
200 * 0.1ms = 20ms = 0.02s
but your computer is probably not fast enough for
Le 19/06/2018 à 10:57, Peter Otten a écrit :
ast wrote:
I noticed that the speed of animations made
with module matplotlib.animation always seems
wrong.
dt = 0.1 # 100 ms
interval : number, optional
Delay between frames in milliseconds. Defaults to 200.
What's wrong ?
Hello
I noticed that the speed of animations made
with module matplotlib.animation always seems
wrong.
Here is a small example for demonstration purpose:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
ax = fig.add_subplot(111)
tx
Hi
round is supposed to provide an integer when
called without any precision argument.
here is the doc:
>>> help(round)
round(number[, ndigits]) -> number
Round a number to a given precision in decimal digits (default 0 digits).
This returns an int when called with one argument, otherwise the
Le 25/03/2018 à 03:47, Steven D'Aprano a écrit :
On Sun, 25 Mar 2018 00:05:56 +0100, Peter J. Holzer wrote:
The Original Poster (OP) is concerned about saving, what, a tenth of a
microsecond in total? Hardly seems worth the effort, especially if you're
going to end up with something even sl
Le 23/03/2018 à 14:16, Antoon Pardon a écrit :
On 23-03-18 14:01, ast wrote:
Le 23/03/2018 à 13:43, Rustom Mody a écrit :
On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote:
What meaningful information from number can you easily retrieve from
representing the number in some kind
Le 23/03/2018 à 13:55, Wolfgang Maier a écrit :
On 03/23/2018 01:30 PM, Wolfgang Maier wrote:
On 03/23/2018 01:16 PM, ast wrote:
n = int(
''.join("""
37107287533902102798797998220837590246510135740250
4637693767749000971264812
Le 23/03/2018 à 13:30, Wolfgang Maier a écrit :
On 03/23/2018 01:16 PM, ast wrote:
A very simple improvement would be to use a single
triple-quoted string. Assuming you are copy/pasting
the number from somewhere that will save a lot of your
time.
no, it seems that sone \n are inserted
Le 23/03/2018 à 13:43, Rustom Mody a écrit :
On Friday, March 23, 2018 at 5:46:56 PM UTC+5:30, ast wrote:
Hi
I found this way to put a large number in
a variable.
What stops you from entering the number on one single (v long) line?
It is not beautiful and not very readable. It is better
Hi
I found this way to put a large number in
a variable.
C = int(
"28871482380507712126714295971303939919776094592797"
"22700926516024197432303799152733116328983144639225"
"94197780311092934965557841894944174093380561511397"
"4215424169339729054237110027510420801349667317"
"55152859226962916
Le 22/02/2018 à 19:53, Chris Angelico a écrit :
On Fri, Feb 23, 2018 at 2:15 AM, ast wrote:
Le 22/02/2018 à 13:03, bartc a écrit :
On 22/02/2018 10:59, Steven D'Aprano wrote:
for count in 1, 10, 100, 1000:
print(count, timeit("cache(maxsize=None)(fib)(20)", setu
Le 22/02/2018 à 13:03, bartc a écrit :
On 22/02/2018 10:59, Steven D'Aprano wrote:
https://www.ibm.com/developerworks/community/blogs/jfp/entry/Python_Meets_Julia_Micro_Performance?lang=en
While an interesting article on speed-up techniques, that seems to miss
the point of benchmarks.
On t
Hello
I share a very valuable table I found on
StackOverflow about file opening modes
If like me you always forget the details of
file opening mode, the following table provides
a good summary
| r r+ w w+ a a+
--|--
read
Le 21/02/2018 à 18:23, bartc a écrit :
On 21/02/2018 15:54, ast wrote:
Le 21/02/2018 à 15:02, bartc a écrit :
On 21/02/2018 13:27, ast wrote:
Time efficient or space efficient?
space efficient
If the latter, how many floats are we talking about?
10^9
Although it might be better
Le 21/02/2018 à 14:27, ast a écrit :
struct.pack() as advised works fine.
Exemple:
>>> import struct
>>> struct.pack(">d", -0.0)
b'\x80\x00\x00\x00\x00\x00\x00\x00'
before I read your answers I found a way
with pickle
>>> import pickle
>&
Le 21/02/2018 à 15:02, bartc a écrit :
On 21/02/2018 13:27, ast wrote:
Time efficient or space efficient?
space efficient
If the latter, how many floats are we talking about?
10^9
--
https://mail.python.org/mailman/listinfo/python-list
Hello
I would like to write a huge file of double precision
floats, 8 bytes each, using IEEE754 standard. Since
the file is big, it has to be done in an efficient
way.
I tried pickle module but unfortunately it writes
12 bytes per float instead of just 8.
Example:
import pickle
f = open("data
Le 14/02/2018 à 13:46, ast a écrit :
Hello
It seems that caracter % can't be escaped
>>>"test %d %" % 7
ValueError: incomplete format
>>>"test %d \%" % 7
ValueError: incomplete format
>>>"test %d" % 7 + "%"
'
Hello
It seems that caracter % can't be escaped
>>>"test %d %" % 7
ValueError: incomplete format
>>>"test %d \%" % 7
ValueError: incomplete format
>>>"test %d" % 7 + "%"
'test 7%' # OK
But is there a way to escape a % ?
thx
--
https://mail.python.org/mailman/listinfo/python-list
"Steve D'Aprano" a écrit dans le message de
news:5a33d0fc$0$2087$b1db1813$d948b...@news.astraweb.com...
On Sat, 16 Dec 2017 12:25 am, ast wrote:
"Thomas Jollans" a écrit dans le message de
news:mailman.74.1513341235.14074.python-l...@python.org...
On 20
"ast" a écrit dans le message de
news:5a33a5aa$0$10195$426a7...@news.free.fr...
Ty Peter and Steve, I would never have found that
explanation myself
--
https://mail.python.org/mailman/listinfo/python-list
"Thomas Jollans" a écrit dans le message de
news:mailman.74.1513341235.14074.python-l...@python.org...
On 2017-12-15 11:36, ast wrote:
No, this is right. The calculation takes practically no time; on my
system, it takes some 10 ns. The uncertainty of the timeit result is at
l
Hi
Time measurment with module timeit seems to work with some
statements but not with some other statements on my computer.
Python version 3.6.3
from timeit import Timer
Timer("'-'.join([str(i) for i in range(10)])").timeit(1)
0.179271876732912
Timer("'-'.join([str(i) for i in range(1
"ast" a écrit dans le message de
news:5a2a568c$0$3699$426a7...@news.free.fr...
I made some experiment.
It seems that the iterator shall provide None values, an other value
raises an exception: "RuntimeError: Task got bad yield: 1"
and in instruction "res
Hello,
According to:
https://www.python.org/dev/peps/pep-0492/#await-expression
an awaitable object is:
- A native coroutine object returned from a native coroutine function
- A generator-based coroutine object returned from a function decorated
with types.coroutine()
- An object with an __a
Hello
Python's doc says about loop.call_soon(callback, *arg):
Arrange for a callback to be called as soon as possible. The callback is called
after call_soon() returns, when control returns to the event loop.
But it doesn't seem to be true; see this program:
import asyncio
async def task_fu
1 - 100 of 255 matches
Mail list logo