r...@zedat.fu-berlin.de (Stefan Ram) writes:
> "Michael F. Stemper" wrote or quoted:
>
> path = r'C:\Windows\example' + '\\'
>
You could even omit the '+'. Then the concatenation is done at parsing time
instead of run time.
--
Pieter van
unit.
>
That is a famous Unix task : (Sorry, no Python)
grep -o '\w*' JoyceUlysses.txt | sort | uniq -c | sort -n
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
ly:
print("something_to_be_done_at_the_end_of_this_function()")
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
cigar.
(%i10) bfloat(2.718281828459045b0) - bfloat(%e);
(%o10) - 2.35360287471352802147785151603b-16
Fricas:
(1) -> 2.718281828459045^0.8618974796837966
(1) 2.367648_98319
(2) -> exp(0.8618974796837966)
(2) 2.367649_00086
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP
Pieter van Oostrum writes:
> My Python development environment is Emacs. I used to use 'jupyter
> console --simple-prompt' (driven by Emacs comint) to do interactive
> work, but it has the disadvantage that it doesn't work properly with
> multiline input, inclu
--simple-prompt' in Emacs does work with
multiline statements. No idea why jupyter console doesn't.
Is there any advantage in using jupyter console over ipython?
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
rc/lxml/parser.pxi", line 615, in
lxml.etree._ParserContext._handleParseResultDoc
File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
File "", line 1
XMLSyntaxError: Premature end of data in tag hr line 1, line 1, column 13
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
est, or is the only
> alternative to use if...then...else to cater for y = 0?
If you put it in a function with x and y as parameters, then both x and y are
just a simple identifier inside the function.
And then you can then even eliminate the if with
for item in x[:len(x)-y]:
--
Pieter van O
ast writes:
>> li = []
>> li.append(li)
>> li
> [[...]]
>
>>li[0][0][0][0]
> [[...]]
>
> That's funny
>
You made a list whose only element is itself.
In [1]: li = []
In [3]: li.append(li)
In [4]: li[0] is li
Out[4]: True
--
Pieter van Oost
ottom of your posts.
> White space aids readability and readability counts. :)
The separator line should be '-- ' (without quotes), i.e. with a trailing space.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
However, due to a bug this won't work unless you patch the nbconvert export
code.
This is a simple one-line patch.
See
https://github.com/jupyter/nbconvert/pull/1496/commits/a61a2241a87912005720d3412ccd7ef7b5fce6dd
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
Martin Schöön writes:
> Hello all,
>
> Some years ago I asked about exporting notebooks to pdf in
> A4 rather than US Letter. I got help, rather detailed
> instructions from you in general and Piet von Oostrum in
Who now calls himself Pieter van Oostrum, just like hi
;head"
("Injection-Info: news.bbs.nz" -1002 nil s))
i.e. each message that contains "news.bbs.nz" in the "Injection-Info"
header will be made invisible.
This solved the problem for me.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
list [","] | comprehension] ")"
comprehension ::= expression comp_for
The last part is the inner part (i.e. without the parentheses) of
generator_expression.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
2 + 11 + 1 == 64.
> Yep, floating point is fun.
>
> That assumed top 1 bit is always there, except when it isn't. Because
> denormal numbers are a thing. They don't have that implied 1 bit.
Yes, for subnormal numbers the implicit bit *is* stored. They are characterized
by
the 0.4 followed by 6 more digits.
> Anything further is, in effect, up for grabs.
>
Most Python implementations use 64-bit doubles (53 bits of precision). See
https://docs.python.org/3.8/tutorial/floatingpoint.html
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
L page describing the first steps to start
using Python. It could mention the command line (py) to be used with a
text editor (some recommendations) and IDLE. And how not to double click
.py files :)
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
rably something that is displayed
immediately after installation of in some other way is prominently
displayed. I am not on Windows myself, so I am afraid I will not be of
much help in this respect.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
Pieter van Oostrum writes:
> Your Pardon is not a class, it is a function. Class A is created by
> type(cls, *args), so 'type' is the metaclass of A, and therefore also of
> B.
> Creation of B does not call Pardon.
With a class it *does* work:
In [74]: class Pardon(t
t you can give a function as metaclass. But that seems to
be part of the specification. The function result is what the 'class' becomes.
You can even have it return something else. Then the 'class' wouldn't really be
a class.
In [65]: def meta(cls, *args): return 1
In [66]: class A(metaclass=meta): pass
In [67]: A
Out[67]: 1
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
break
if is_prime:
print(a)
a = a + 2
Further optimizations are possible, for example use range(2,a/2) or even range
(2, sqrt(a)).
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
Pieter van Oostrum writes:
>
> The first import creates a file __pycache__ in the directory p1.
That should be 'a directory __pycache__'
> To remove it use rmtree(path.join(P1,'__pycache__'))
> Then the second import will succeed.
> --
> Pieter van Oostr
file __pycache__ in the directory p1.
To remove it use rmtree(path.join(P1,'__pycache__'))
Then the second import will succeed.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
rror appears.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
... 'last_name': 'Allen',
... 'email': 'fal...@ibm.com'
... })
In [37]: d
Out[37]: {'first_name': 'Frances', 'last_name': 'Allen', 'email':
'fal...@ibm.com'}
In [3
this so?
'From first' is the result of the class definition. 'from second' is the result
of first.second().
And first() doesn't produce any output.
Your problem is probably that you think that the call first() executes all the
statements in the class definition. It doesn
x27;t print anything,
because the print statement is not part of the class __init__ code.
In [28]: first.second()
>From second
That's expected.
In [29]: first.second()
>From second
Again.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
Pieter van Oostrum writes:
> Joseph Nail writes:
>
>> Hello,
>> I have one problem. Somehow in my function when I wrote y=x, they are the
>> same variable and then it also changes age or height (which were x) in the
>> main program. See more in attached file.
you write y = x, then they are not the same variable, but they point to (the
proper Python language is they are bound to) the same object.
Now if you say x.age = 20, then y.age will also be 20 (it's the same object).
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142
not something you
provide yourself. Your arguments are bez, ge, ins.
class PKW(Fahrzeug):
def __init__(self, bez, ge, ins):
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
econd way can be used in Python 3.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
'
else:
yield from reclist(item)
else:
yield item
for i in reclist(aList):
print(i, end=',')
This gives you an extra comma at the end, unfortunately. But it is the pattern
for other types of processing.
Or use it like this:
print (','.join(str(i) for i in reclist(aList)))
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
'
else:
yield from reclist(item)
else:
yield item
for i in reclist(aList):
print(i, end=',')
This gives you an extra comma at the end, unfortunately. But it is the pattern
for other types of processing.
Or use it like this:
print (','.join(str(i) for i in reclist(aList)))
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
t;Is there something about the output that puzzles you?
>> No
>>
>>>Did you have a question?
>> No, only a comment
>>
>> This buggy language is very amusing.
>
> What's the bug, or source of amusement?
The bug is in the mental world of the OP.
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
'Ä¿'.encode('utf-16-le')
>>> > b'\xff\x00'
>>> >>>> 'Ä¿'.encode('utf-32-le')
>>> > b'\xff\x00\x00\x00'
>>
>>> That all looks as expected.
>> Yes
>>
>>>Is there some
'
else:
yield from reclist(item)
else:
yield item
for i in reclist(aList):
print(i, end=',')
This gives you an extra comma at the end, unfortunately. But it is the pattern
for other types of processing.
Or use it like this:
print (','.join(str(i) for i in reclist(aList)))
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
'
else:
yield from reclist(item)
else:
yield item
for i in reclist(aList):
print(i, end=',')
This gives you an extra comma at the end, unfortunately.
But it is the pattern for other types of processing.
Or use it like this:
print (','.join(str(i) for i in reclist(aList)))
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
t; 'ÿ'.encode('utf-16-le')
>>> > b'\xff\x00'
>>> >>>> 'ÿ'.encode('utf-32-le')
>>> > b'\xff\x00\x00\x00'
>>
>>> That all looks as expected.
>> Yes
>>
>>>Is there somet
er file name
with open(secretfile, 'rb') as fd:
secret = fd.read()
key = 'goldQ3T8-1QRD-5QBI-9F22'
bkey = key.encode('ascii')
h = hmac.new(secret, bkey, hashlib.sha256)
print('hd (hex): ', h.hexdigest())
--
Pieter van Oostrum
www: http://piet
kiran chawan writes:
> Whenever Iam trying to run this 'New latest version python software 3.8.4
> python ' but it doesn't show any install option and it say ' modify set up
> ' So tell what to do sir plz help me out.
There is no Python 3.8.4
n the database. Of course this
only works if that stored hash has been calculated in the same way from the
same key.
On Python 2 (which you shouldn't use) you can leave out the "key = bytes(key,
'ascii')" part.
You can of course make it more sophisticated, for example by
the import system.
Are you running python 3.6?
I tried this on python 3.7 and it worked, but the file is called
_rtmidi.cpython-37m-darwin.so there (37 for python3.7, and the d is missing, I
don't know what that indicates).
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
anyone have any suggestions?
>
> chris
https://github.com/eea/odfpy
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
alon.naj...@gmail.com writes:
> hi
> looking for git with a solution - merge many pdfs to 1 pdf (no matter what
> language)
There is a clone of pdftk on github: https://github.com/ericmason/pdftk
Another possibility is mupdf: http://git.ghostscript.com/?p=mupdf.git
--
Pieter van Oo
he name sys is used in the imported module, that module has to import sys.
Importing it in the calling code doesn't help.
So I would say this is a bug in the module.
You should report the bug to its author. In the meantime you can correct your
own copy at
~/opt/miniconda3/envs/py3/
character, Unicode 0xF3,
LATIN SMALL LETTER O WITH ACUTE.
In (a) it is composed of the letter o and the accent "́" (Unicode 0x301).
So you would have to do Unicode normalisation before comparing.
For example:
In [16]: from unicodedata import normalize
In [17]: a == b
Out[17]: False
>
> user@USERnoMacBook-Air LibraBrowser %
Could it be that your pip3 belongs to a different Python than the one above
(for example a Python 3.8 or 3.6)? What is the output of 'pip3 --version'
(without quotes)?
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8D
p.family)```
Please next time, supply a properly indented Python source, with only normal
ASCII spaces, not no-break spaces, i.e. exactly like in your Python source code.
>
> The Username class also needs to call super(). In general, super() is
> intended to be used with all classes that
#x27;], shell=True)
>
> I get
>
> Test.py: 1: Test.py: ./: Permission denied
>
Why would you do that, splitting './Test.py' in two parts? That doesn't work.
> Is there a simple way to use subprocess in this usecase?
>
subprocess.call(['./Test.py'])
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
; testfunc()
>>> globvar
Traceback (most recent call last):
File "", line 1, in
NameError: name 'globvar' is not defined
>>> def testfunc():
... global globvar
... globvar = 1
...
>>> globvar
Traceback (most recent call last):
File
Hongyi Zhao writes:
> On Sun, 17 Nov 2019 20:28:55 +0100, Pieter van Oostrum wrote:
>
>> To be honest, I myself would use Emacs, with rgrep and wgrep to do this.
>
> Are these tools superior to grep?
They are based on grep. But rgrep does a grep through a whole directory tre
Pieter van Oostrum writes:
> It isn't that difficult with sed, only you have to chose a different
> character than / in the substitute command, one that is not present in
> both texts, e.g instead of s/a/b/ use s=a=b=.
>
> And then the special characters " ' () [
al characters " ' () [ and $ must be escaped for the shell,
and [ and $ also for the regexp.
Then it comes down to
sed -e s=\"\(\\[^/]+\)\\$\"=\'\(\[^/]+\)\$\'= file
--
Pieter van Oostrum
WWW: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
t is called from Func2, it uses MyVar from Func2?
If that is what you mean, that would be dynamic scope.
--
Pieter van Oostrum
WWW: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
fication (:...). {i=} is not a correct
expression. When you remove the »f«, it becomes a normal string, where
the {} don't have a special meaning.
--
Pieter van Oostrum
WWW: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list
In [8]: class MA(type):
...: def __instancecheck__(cls, inst):
...: print ("MA", cls, inst)
...:
...: class AM(list, metaclass = MA): pass
...: class AM2(AM): pass
...:
...: am = AM2()
In [9]: isinstance(am, AM)
MA []
Out[9]: False
--
Pieter van Oostrum
WW
56 matches
Mail list logo