Xavier Morel added the comment:
PS: "platform.system()" also documents `Java` as a value which doesn't seem to
make that much sense, however it's an open set so probably less of an issue /
source of confusion.
--
___
Python track
New submission from Xavier Morel :
os.name is defined as:
> The following names have currently been registered: 'posix', 'nt', 'java'.
In my understanding, the value `'java'` is for the benefit of jython, which is
rather poorly. Other third-party implementations which may or may not h
Xavier Morel added the comment:
> True is a boolean so ~True should return False according to me.
That's be a BC break for no reason: if you want to invert a boolean you can
just `not` it.
> True is not the same as 1
For historical reasons, in Python it is:
>>> bool.mro()
New submission from Xavier Morel :
concurrent.futures.Future currently has the note:
> Future instances are created by Executor.submit() and should not be created
> directly except for testing.
That seems like a shame as futures are useful concurrency construct and having
to rebuil
Xavier Morel added the comment:
> If working Python 3 program suddenly became emitting BytesWarning it will
> confuse users.
Oh yeah no I meant making it a normal warning, without needing the `-b` flag,
not enabling it by default.
Because controlling / configuring warnings can b
Xavier Morel added the comment:
And though I did not check, I expect the `-b` flag exists mostly because of the
performance impact of the warning any time bytes are checked for equality, but
surely that impact would be limited and probably not very relevant for the
stringification of bytes
Xavier Morel added the comment:
> I am not against documenting the behavior of -b and BytesWarning clearly. I
> don't think that anyone would be against. Just somebody have to provide a PR.
Right but what about the ability to enable warning on stringification without
enabling the w
Xavier Morel added the comment:
Serhiy an other question (because I've encountered it *again*), do you think
it'd be possible to split out the specific warning of stringifying (but *not*
explicitely repr-ing) a bytes instance from everything else?
There are use-cases for it, but I think
New submission from Xavier Morel :
Python code uses a fair amount of globals, and sometimes there's no good choice
but to do dodgy things and temporarily update global state for one reason or
another e.g. redirect a standard fd or stream (cf redirect_stdout),
monkey-patch a builtin
Xavier Morel added the comment:
> But if we allow for ellipsis, then would we not also have to start allowing
> characters like ≥ and ≤ in Python?
No, they're not defined as canonically equivalent to >= and <= by the Unicode
specification:
>>> unicod
New submission from Xavier Morel :
In 3.4 (resp. 3.5), `redirect_stdout` and `redirect_stderr` were added to
provide easy and reentrant stream redirection. Although that is documented, it
seems like a waste that they only redirect the high-level `sys.std*` streams:
those are already pretty
Xavier Morel added the comment:
> In normal circumstances you should never deal with BytesWarning. The -b
> option is only used for testing your program for some possible bugs caused by
> migration from Python 2. If your program always worked only with Python 3,
> the -b optio
New submission from Xavier Morel :
When triggering warnings, it's possible to pass in a `stacklevel` in order to
point to a more informative cause than the `warnings.warn` call.
For instance `stacklevel=2` is a common one for DeprecationWarning in order to
mark the call itself as deprecated
Xavier Morel added the comment:
Addendum: is there a way to force `-b` from within the running Python program?
--
___
Python tracker
<https://bugs.python.org/issue43
New submission from Xavier Morel :
When setting `BytesWarning` programmatically (via the warnings API), though the
`warnings.filters` value matches what's obtained via `python -b` and an
explicit `warnings.warn` trigger will trigger, "native" triggers of the warning
fail to trigge
Change by Xavier Morel :
--
title: TOS-behaviour documentation is -> TOS-behaviour documentation is
inconsistent
___
Python tracker
<https://bugs.python.org/issu
New submission from Xavier Morel :
I was looking at the disassembly of a fairly straightforward listcomp:
[e for e in s if e[0]]
1 0 BUILD_LIST 0
2 LOAD_FAST0 (.0)
>>4 FOR_ITER16 (to 22)
Xavier Morel added the comment:
Oh I now see you've created a PR to do essentially that, nm.
--
___
Python tracker
<https://bugs.python.org/issue42644>
___
___
Xavier Morel added the comment:
> I think that patching logging.disable to raise a type error immediately would
> be welcome
FWIW `logging` has a built-in checker / converter[0] which is already used in a
bunch of places (e.g. the aforementioned setLevel), it could just be added
Xavier Morel added the comment:
The problem seems to be in the user code? As you were told by "Carreau",
loggin.disable takes a logging level (an integer), since you're giving it a
string which it dutifully stores, it blows up at the next logging call which
happens to be
Xavier Morel added the comment:
> What exactly do you do with a path argument?
Because they mention "convert[ing] the string to a path", I would expect an
output of `pathlib.Path`, optionally checked for existence / non-existence and
/ or kind (file, directory, symlink, ...
Xavier Morel added the comment:
Tried patterning the PR after the one which originally added the warning.
Wasn't too sure how the news item was supposed to be generated, and grepping
the repository didn't reveal any clear script doing that, so I made up a date
and copied an existing random
Change by Xavier Morel :
--
pull_requests: +22532
pull_request: https://github.com/python/cpython/pull/23665
___
Python tracker
<https://bugs.python.org/issue42
Xavier Morel added the comment:
I was preparing to open the PR but now I'm doubting: should I open the PR
against master and miss islington will backport it, or should I open the PR
against 3.9?
--
___
Python tracker
<https://bugs.python.
Xavier Morel added the comment:
> Do you want to submit a PR for this?
Sure. Do you think the code I proposed would be suitable?
> * The current logic matches the logic before the warning was added.
> * The proposed logic matches what the code will do after the
> deprec
New submission from Xavier Morel :
In 3.9, using `random.sample` on sets triggers
DeprecationWarning: Sampling from a set deprecated
since Python 3.9 and will be removed in a subsequent version.
*However* it also triggers on types which implement *both* Sequence and Set,
despite Sequence
Xavier Morel added the comment:
Apparently it's at least a possibility on DDG's side
(https://duckduckgo.com/search_box), don't know how easy it'd be to integrate
in sphinx, or whether a hard dependency on an external search engine is
acceptable / desirable
New submission from Xavier Morel :
I expect it simply uses sphinx and I don't know if sphinx's search is easily
customisable but the experience is really terrible when looking for the doc of
a specific thing, *especially* when that thing is or is related to a builtin,
which I'd expect
Xavier Morel added the comment:
The 3.9 changelog mentions WITH_EXCEPT_FINISH but that seems to have ultimately
been called WITH_EXCEPT_START, maybe it shoudl be updated also?
--
nosy: +xmorel
___
Python tracker
<https://bugs.python.
Xavier Morel added the comment:
Should I close this since I believe 2.7 is not supported anymore?
--
___
Python tracker
<https://bugs.python.org/issue24
Xavier Morel added the comment:
@rhettinger checking software against 3.9 there's a little issue with the way
the check is done: if passed something which is *both* a sequence and a set
(e.g. an ordered set), `random.sample` will trigger a warning, which I don't
think is correct.
Should I
Xavier Morel added the comment:
I have not noticed anything, I was just looking at the bytecode changes and
stumbled upon this oddity. Though I would expect a small slowdown as every
fn(**kw) would now incur an extra dict copy, unless there’s something in
call_function_ex which copies
New submission from Xavier Morel :
Following bpo-39320 the highly specialised bytecode for vararg calls were
replaced by simpler ones, but there seems to be at least one area where the
generated bytecode regressed for possibly no reason?
In Python 3.8, foo(**var) compiles to:
0 LOAD_GLOBAL
New submission from Xavier Morel :
Warning actions allow deduplicating warning triggers based on category
("once"), category + file ("module") and category + exact location ("default").
One thing which is missing is support for a single location generating
Xavier Morel added the comment:
Maybe something along the lines of "names other than arguments and function
locals", or "names of the symbols used in the code object, other than arguments
and function locals"? This is still slightly confusing because in the case of
Xavier Morel added the comment:
> Fair enough. So we can just add a sentence informing readers that
`meta_path`, by default, holds entries to handle the standard kinds of
modules (.py files, extension modules…).
Yeah that's basically what I meant, talking about a "warning" in pytho
Xavier Morel added the comment:
> A warning is probably too strong. Also, it's easy to check sys.meta_path at
> the interpreter prompt, so I'm not sure it's worth mentioning at all.
It's easy if you think of it and did not miss a small bit of the Python 3.3
release note indi
Xavier Morel added the comment:
> I'm fine with adding a note to the Python 2 docs, but putting it in Python 3
> seems to be going in the wrong direction as having sys.meta_path not be empty
> is how Python will be going forward.
I don't think putting a note is any hint that the
Xavier Morel added the comment:
Should I close this since the PR was merged?
--
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
Xavier Morel added the comment:
And it turns out the change was noted in the Python 3.3 release notes[0] though
not all the consequences were spelled out (and the meta_path and path_hooks
documentations were not changed)
[0] https://docs.python.org/3/whatsnew/3.3.html#visible-changes
Xavier Morel added the comment:
Addendum: the warning was present (in the documentation) until Python 3.5, even
though Python 3.3 is apparently where the "default finders" were moved to
meta_path:
> python3.2 -c 'import sys;print(sys.meta_path)'
[]
> python3.3 -c '
New submission from Xavier Morel:
Encountered this issue porting Python 2 code manipulating meta_path to Python 3.
In Python 2, meta_path is empty by default and its documentation specifically
notes that:
> sys.meta_path is searched before any implicit default finders or sys.p
Changes by Xavier Morel <xavier.mo...@masklinn.net>:
--
pull_requests: -747
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python
Xavier Morel added the comment:
PR targetted to master rather than 2.7
--
pull_requests: +748
___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/i
New submission from Xavier Morel:
Currently, cgitb documents the hook (enable) and somewhat unclearly the ability
to dump the HTML traceback to stdout, but despite that being technically
available it does not document the ability to dump the traceback to a string as
either text or html
New submission from Xavier Morel:
It looks to be fixed in 3.3 and up, but in Python 2.7
import ast
m = ast.Module(body=[
ast.Expr(value=ast.Name(id='foo', ctx=ast.Store()))
])
ast.fix_missing_locations(m)
code = compile(m, '', mode='exec')
eval(code
Changes by Xavier Morel xavier.mo...@masklinn.net:
--
nosy: +xmorel
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13405
___
___
Python-bugs-list
Changes by Xavier Morel xavier.mo...@masklinn.net:
--
nosy: +xmorel
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14776
___
___
Python-bugs-list
Changes by Xavier Morel xavier.mo...@masklinn.net:
--
nosy: +xmorel
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21590
___
___
Python-bugs-list
Xavier Morel added the comment:
Correction: csv also seems to raise csv.Error if the file contains NUL bytes:
Error: line contains NULL byte
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15639
New submission from Xavier Morel:
In both Python 2.7 and Python 3.x, csv.Error is documented as:
Raised by any of the functions when an error is detected.
As far as I can tell from using the module and looking at the code, this is
completely incorrect. There is actually a single instance
Xavier Morel xavier.mo...@masklinn.net added the comment:
Had some time to play with this today, here's a draft matrix of actions and
add_argument parameters which is pretty readable, but:
* It's incredibly not helpful for people who don't know argparse
* I tried adding effects descriptions
Xavier Morel xavier.mo...@masklinn.net added the comment:
completion for list item 4:
although it would definitely make the raw text (in-rst) much harder to read
compared to the current table (which can be used from the rst source without
compiling
Xavier Morel xavier.mo...@masklinn.net added the comment:
Creating the tables should not be too hard, especially using e.g. org-mode, but:
1. Where should those tables live? The argparse documentation is pretty big and
there's no completely obvious place. I would guess table 1. could just
Xavier Morel xavier.mo...@masklinn.net added the comment:
My specific suggestion is to have a dedicated Quick Reference section
before the first example.
OK, that looks like a good plan.
--
___
Python tracker rep...@bugs.python.org
http
Xavier Morel xavier.mo...@masklinn.net added the comment:
The Parameters column would span multiple lines, with one parameter and a
brief description of the parameter on each line.
I started looking into that, and it turns out that's more annoying than
expected: a bunch of parameters
New submission from Xavier Morel xavier.mo...@masklinn.net:
In Python 3, ... became useable as a normal expression, and translates into
an ellipsis instance.
Unicode defines an ellipsis character … (U+2026 HORIZONTAL ELLIPSIS) which is
canonically equivalent to a 3-sequence of FULL STOP [U
New submission from Xavier Morel xavier.mo...@masklinn.net:
First patch fixes a typo (the reads a reply - then reads a reply) and — I
believe — improves the wording of a pair of sentences.
Second patch makes use of Sphinx's ``:abbr:`` role, and removes some period
which I think are redundant
Changes by Xavier Morel xavier.mo...@masklinn.net:
Added file: http://bugs.python.org/file21854/sphinx-features
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11979
Xavier Morel xavier.mo...@masklinn.net added the comment:
Do tests currently exist for smtpd run as a script?
I have to confess I didn't think to check.
If not, our experience with converting compileall to argparse indicates a
thorough test suite is needed (and even so we missed some
Xavier Morel xavier.mo...@masklinn.net added the comment:
any of the undocumented command-line interfaces are intentionally
undocumented -- they were there for the convenience of the developer for
exercising the module as it was being developed and are not part of the
official API.
I can
Xavier Morel xavier.mo...@masklinn.net added the comment:
One more note I forgot previously: the conversion of as much scripts as
possible to argparse would be for three reasons:
* Make behavior consistent across the board (e.g. -h/--help)
* Make CLI documentation format consistent across
Xavier Morel xavier.mo...@masklinn.net added the comment:
Barry, do I correctly understand your comment to mean I should write end-to-end
tests of the CLI (until reaching the already tested meat of smtpd), not just
the CLI options parsing
Xavier Morel xavier.mo...@masklinn.net added the comment:
Only document and formalize the parts that are well thought out.
I don't believe I have the knowledge, right or ability to make that call for
any module or package but a pair of extremely obvious ones (http.server seems a
pretty good
New submission from Xavier Morel xavier.mo...@masklinn.net:
argparse has been merged to the standard library in 3.2, and (tell me if I'm
wrong) would therefore be the best-practices way to parse command-line
arguments.
Numerous stdlib modules can be used as scripts, but they tend to have ad
Xavier Morel xavier.mo...@masklinn.net added the comment:
Second patch: documenting smtpd-as-a-script in the module's rst
--
Added file: http://bugs.python.org/file20813/smtpd-as-script-doc.diff
___
Python tracker rep...@bugs.python.org
http
Konrad Mühler wrote:
Hi,
are there predefinded chances to use hashtables in python? How can I use
Hashtable in python? Or do I have to implement this on my own?
Thanks
A Java Hashtable/Hashmap is equivalent to a Python dictionary, which is
a builtin objects (and not a second-class
KraftDiner wrote:
I had a structure that looked like this
((0,1), (2, 3), (4, 5), (6,7)
I changed my code slightly and now I do this:
odd = (1,3,5,7)
even = (0,2,4,6)
all = zip(even, odd)
however the zip produces:
[(0, 1), (2, 3), (4, 5), (6, 7)]
Which is a list of tuples.. I wanted
[EMAIL PROTECTED] wrote:
I am a python newbie. I have writen some 500 lines of code. There are 4
classes and in all 5 files.
Now, I am trying to run the program. I am getting wrong values for the
simulation results.
Is there any debugging facilities in python which would let me go step
by
Bil Kleb wrote:
Xavier Morel wrote:
2) Ruby does not have true first-class functions living in the same
namespace as other variables while Python does :
In Ruby you need extra syntax that ruins the first-class-ness :
The extra syntax is a side-effect of the parensless call of method
Torsten Bronger wrote:
Yes, however, this is also true for Python in my opinion.
Ruby's ability to generate DSLs is an order of magnitude better than
Python's at least.
I only know of the Lisp dialects that get better at DSLs.
Check Rails' validation methods (in the models), or if you don't
John Salerno wrote:
So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.
Under
trixie wrote:
Using WinXP and Python24 on generic desktop.
Being used to linux and command line operations I cannot make Windows accept
the 'python myprog.py' command.
Any help appreciated.
Bob
I think you could've given us the error message that this command yields.
Issue is probably
I'll just play the devil's advocate here
Francois wrote:
1) In Ruby there is a risk of Variable/Method Ambiguity when calling
a method with no parameters without using () :
Yes, but that's in my opinion a programmer error, not necessarily a
language error.
2) Ruby does not have true
[EMAIL PROTECTED] wrote:
Let's say I have two dictionaries:
dict1 is 1:23, 2:76, 4:56
dict2 is 23:A, 76:B, 56:C
How do I get a dictionary that is
1:A, 2:B, 4:C
dict1 = {1:23,2:76,4:56}
dict2 = {23:'A',76:'B',56:'C'}
dict((k, dict2[v]) for k, v in dict1.items())
{1: 'A', 2: 'B',
Ross Ridge wrote:
Xavier Morel wrote:
Not if you're still within Unicode / Universal Character Set code space.
Akihiro Kayama in his original post made it clear that he wanted to use
a character set larger than entire Unicode code space.
Ross Ridge
Akihiro KAYAMA wrote:
Sorry for my terrible English. I am living in Japan, and we have a
large number of characters called Kanji. UTF-16(U+...U+10) is
enough for practical use in this country also, but for academic
purpose, I need a large codespace over 20-bits. I wish I could use
Ross Ridge wrote:
Steve Holden wrote:
Wider than UTF-16 doesn't make sense.
It makes perfect sense.
Ross
Ridge
Not if you're still within Unicode / Universal Character Set code space.
While UCS-4 technically goes beyond any
nuttydevil wrote:
Hey everyone! I'm hoping someone will be able to help me, cause I
haven't had success searching on the web so far... I have large chunks
of text ( all in a long string) that are currently all in separate
notebook files. I want to use python to read these strings of text,
Fredrik Lundh wrote:
did you read the string chapter in the tutorial ?
http://docs.python.org/tut/node5.html#SECTION00512
around the middle of that chapter, there's a section on slicing:
substrings can be specified with the slice notation: two indices
separated
Rene Pijlman wrote:
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Yes. By implementing a compiler or an interpreter
Rene Pijlman wrote:
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Yes. By implementing a compiler or an interpreter
Tempo wrote:
Larry I do see your point. There does seem to be a lot more support for
PHP and MySQL together than there is Python and ASP. But I want to
first try to accomplish my goal by using Python first before I give up
and revert back to PHP. So if I was going to parse HTML forms and place
Alex Martelli wrote:
Carl Banks [EMAIL PROTECTED] wrote:
...
class better_list (list):
tail = property(None, list.append)
This is an impressive, spiffy little class.
Yes, nice use of property.
Alex
I don't know, I usually see people considering that properties are
cool
Diez B. Roggisch wrote:
py wrote:
I have two lists which I want to use to create a dictionary. List x
would be the keys, and list y is the values.
x = [1,2,3,4,5]
y = ['a','b','c','d','e']
Any suggestions? looking for an efficent simple way to do this...maybe
i am just having a brain
Mark Harrison wrote:
I thought I saw a package that would create a DOM from html, with
allowances that it would do a best effort job to parse
non-perfectly formed html.
Now I can't seem to find this... does anybody have a recommendation
as to a good package to look at?
Many TIA!
Mark
Dylan Moreland wrote:
I'm trying to implement a bunch of class methods in an ORM object in
order to provide functionality similar to Rails' ActiveRecord. This
means that if I have an SQL table mapped to the class Person with
columns name, city, and email, I can have class methods such as:
Oh, and I wondered too: is your goal to build an ORM, or do you just
need an ORM?
Cause if it's the latter then Python does already have some fairly good
ORMs such as SQLAlchemy or PyDO2, you don't *need* to create yours.
--
http://mail.python.org/mailman/listinfo/python-list
Ben Wilson wrote:
I read somewhere else that Python was getting a ternary operator (e.g.
x = (true/false) ? y : z). I read the PEP about it and that the PEP had
been approved this past Fall. Has this been released into the wild yet?
IIRC, the operator is like:
x = y if C : else z
PEP
malv wrote:
Of course, multiprocessing has been used for many years but this always
involved a much higher level of sophistication on the part of the
designers. This point seems to be largely hidden from the public,
ignorant and semi-ignorant, by the chip manufacturers.
Will new languages see
malv wrote:
Maybe this is too simplistic, but given two programs, one in Python the
other in Java or C#. Would this mean that running the latter on a dual
core processor would significantly increase execution speed, whereas
the Python program would be running in one processor only without any
Ernesto wrote:
I'm not sure if I should use RE's or some other mechanism. Thanks
I think a line-based state machine parser could be a better idea. Much
simpler to build and debug if not faster to execute.
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
Generally I use urllib.read() to get
the whole html page as a string, then process it from there. I just
look for the substrings I'm interested in, making no attempt to
actually parse the html into a DOM or anything like that.
BeautifulSoup works *really* well when you
Ernesto wrote:
Xavier Morel wrote:
Ernesto wrote:
I'm not sure if I should use RE's or some other mechanism. Thanks
I think a line-based state machine parser could be a better idea. Much
simpler to build and debug if not faster to execute.
What is a line-based state machine ?
Parse
Terry Reedy wrote:
John Pote [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I would wish to secure this data gathering against crashes of the OS,
I have read about people running *nix servers a year or more without
stopping.
He'd probably want to check the various
anon wrote:
Would somebody please drop me a hint, please?
Yeah, the definition of JAR is Java ARchive, why the hell would a
Python script be able to read a JAR in the first place (truth is it is,
a JAR file is nothing but a renamed ZIP, therefore the zipfile module
allows you to read it's
Byte wrote:
x = input(raw_input(Please enter your name: ))
if x==myself: print 'OK'
It kinda works - I can get to the please enter your name bit but then
it simply reprints your input as output. Someone please HELP!
--
C:\python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit
Byte wrote:
p.s. Xavier Morel, you seem to be using Windows, not Linux
I don't see how this may even remotely be relevant, Python is cross
platform and (mostly) works the same regardless of the OS
I got
the idea of stacking input on a raw_input from the official Python
Tutorial
Byte wrote:
http://docs.python.org/tut/node6.html#SECTION00610
--
x = int(raw_input(Please enter an integer: ))
--
Unless my eyes fail me, it's written int, not input, the goal of
this line is to convert the return value of raw_input (a string) into an
integer.
--
Byte wrote:
Assumption. Im also new to programing, so could do something stupid
like think a Windows path is a command/input/etc. (really, ive done
things like that before.)
Don't assume anything when you have no reason to, and especially don't
assume that a cross-platform programming
1 - 100 of 165 matches
Mail list logo